aboutsummaryrefslogtreecommitdiff
path: root/Driver/clang.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-02-18 01:51:21 +0000
committerChris Lattner <sabre@nondot.org>2009-02-18 01:51:21 +0000
commit47099742e22c84a4dc905a01ad4180a3fd4fa99f (patch)
treebb56d02bee86143a8628c3ad5218d9023445531b /Driver/clang.cpp
parent6f114eb1d67d9800e2b007a90ff6ad4ba41fd19d (diff)
add a bunch of timers for -E and other modes. This requires
llvm r64874 or later. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64875 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/clang.cpp')
-rw-r--r--Driver/clang.cpp37
1 files changed, 31 insertions, 6 deletions
diff --git a/Driver/clang.cpp b/Driver/clang.cpp
index d188f37c5a..a818c8d1a4 100644
--- a/Driver/clang.cpp
+++ b/Driver/clang.cpp
@@ -50,6 +50,7 @@
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/PluginLoader.h"
+#include "llvm/Support/Timer.h"
#include "llvm/System/Host.h"
#include "llvm/System/Path.h"
#include "llvm/System/Signals.h"
@@ -59,6 +60,11 @@ using namespace clang;
// Global options.
//===----------------------------------------------------------------------===//
+/// ClangFrontendTimer - The front-end activities should charge time to it with
+/// TimeRegion. The -ftime-report option controls whether this will do
+/// anything.
+llvm::Timer *ClangFrontendTimer = 0;
+
static bool HadErrors = false;
static llvm::cl::opt<bool>
@@ -1333,6 +1339,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
break;
case DumpRawTokens: {
+ llvm::TimeRegion Timer(ClangFrontendTimer);
SourceManager &SM = PP.getSourceManager();
// Start lexing the specified input file.
Lexer RawLex(SM.getMainFileID(), SM, PP.getLangOptions());
@@ -1349,6 +1356,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
break;
}
case DumpTokens: { // Token dump mode.
+ llvm::TimeRegion Timer(ClangFrontendTimer);
Token Tok;
// Start preprocessing the specified input file.
PP.EnterMainSourceFile();
@@ -1361,6 +1369,7 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
break;
}
case RunPreprocessorOnly: { // Just lex as fast as we can, no output.
+ llvm::TimeRegion Timer(ClangFrontendTimer);
Token Tok;
// Start parsing the specified input file.
PP.EnterMainSourceFile();
@@ -1372,40 +1381,50 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
}
case GeneratePCH: {
+ llvm::TimeRegion Timer(ClangFrontendTimer);
CacheTokens(PP, OutputFile);
ClearSourceMgr = true;
break;
}
- case PrintPreprocessedInput: // -E mode.
+ case PrintPreprocessedInput: { // -E mode.
+ llvm::TimeRegion Timer(ClangFrontendTimer);
DoPrintPreprocessedInput(PP, OutputFile);
ClearSourceMgr = true;
break;
+ }
- case ParseNoop: // -parse-noop
+ case ParseNoop: { // -parse-noop
+ llvm::TimeRegion Timer(ClangFrontendTimer);
ParseFile(PP, new MinimalAction(PP));
ClearSourceMgr = true;
break;
+ }
- case ParsePrintCallbacks:
+ case ParsePrintCallbacks: {
+ llvm::TimeRegion Timer(ClangFrontendTimer);
ParseFile(PP, CreatePrintParserActionsAction(PP));
ClearSourceMgr = true;
break;
-
- case ParseSyntaxOnly: // -fsyntax-only
+ }
+
+ case ParseSyntaxOnly: { // -fsyntax-only
+ llvm::TimeRegion Timer(ClangFrontendTimer);
Consumer.reset(new ASTConsumer());
break;
+ }
case RewriteMacros:
RewriteMacrosInInput(PP, InFile, OutputFile);
ClearSourceMgr = true;
break;
- case RewriteTest:
+ case RewriteTest: {
DoRewriteTest(PP, InFile, OutputFile);
ClearSourceMgr = true;
break;
}
+ }
if (Consumer) {
TranslationUnit *TU = 0;
@@ -1506,6 +1525,10 @@ int main(int argc, char **argv) {
llvm::cl::ParseCommandLineOptions(argc, argv, " llvm clang cfe\n");
llvm::sys::PrintStackTraceOnErrorSignal();
+ if (TimeReport)
+ ClangFrontendTimer = new llvm::Timer("Clang front-end time");
+
+
// If no input was specified, read from stdin.
if (InputFilenames.empty())
InputFilenames.push_back("-");
@@ -1636,6 +1659,8 @@ int main(int argc, char **argv) {
// If verifying diagnostics and we reached here, all is well.
if (VerifyDiagnostics)
return 0;
+
+ delete ClangFrontendTimer;
// Managed static deconstruction. Useful for making things like
// -time-passes usable.