[cfe-commits] r64875 - /cfe/trunk/Driver/clang.cpp

Chris Lattner sabre at nondot.org
Tue Feb 17 17:51:22 PST 2009


Author: lattner
Date: Tue Feb 17 19:51:21 2009
New Revision: 64875

URL: http://llvm.org/viewvc/llvm-project?rev=64875&view=rev
Log:
add a bunch of timers for -E and other modes.  This requires
llvm r64874 or later.

Modified:
    cfe/trunk/Driver/clang.cpp

Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=64875&r1=64874&r2=64875&view=diff

==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Tue Feb 17 19:51:21 2009
@@ -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 @@
 // 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 @@
     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 @@
     break;
   }
   case DumpTokens: {                 // Token dump mode.
+    llvm::TimeRegion Timer(ClangFrontendTimer);
     Token Tok;
     // Start preprocessing the specified input file.
     PP.EnterMainSourceFile();
@@ -1361,6 +1369,7 @@
     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 @@
   }
       
   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 @@
   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 @@
   // 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.





More information about the cfe-commits mailing list