]> granicus.if.org Git - clang/commitdiff
Teach Clang's -cc1 option -print-stats to print LLVM statistics.
authorDouglas Gregor <dgregor@apple.com>
Tue, 30 Mar 2010 17:33:59 +0000 (17:33 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 30 Mar 2010 17:33:59 +0000 (17:33 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99894 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/CompilerInstance.cpp
tools/driver/cc1_main.cpp

index 7b4932d787a1d78df733acd73b56befb2359d429..879e9f681de98791f4cbb6d506c92cf4f7255cc8 100644 (file)
@@ -29,6 +29,7 @@
 #include "llvm/LLVMContext.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/ADT/Statistic.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/System/Host.h"
 #include "llvm/System/Path.h"
@@ -479,6 +480,9 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) {
   if (getFrontendOpts().ShowTimers)
     createFrontendTimer();
 
+  if (getFrontendOpts().ShowStats)
+    llvm::EnableStatistics();
+    
   for (unsigned i = 0, e = getFrontendOpts().Inputs.size(); i != e; ++i) {
     const std::string &InFile = getFrontendOpts().Inputs[i].second;
 
index 5770a1a11509ccd81cdfb2e235dcab9e2a5defee..35854bea057e0345a17e99be85cfb918ff349704 100644 (file)
@@ -29,6 +29,7 @@
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "llvm/LLVMContext.h"
 #include "llvm/ADT/OwningPtr.h"
+#include "llvm/ADT/Statistic.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Timer.h"
@@ -279,6 +280,8 @@ int cc1_main(const char **ArgBegin, const char **ArgEnd,
   
   // When running with -disable-free, don't do any destruction or shutdown.
   if (Clang->getFrontendOpts().DisableFree) {
+    if (Clang->getFrontendOpts().ShowStats)
+      llvm::PrintStatistics();
     Clang.take();
     return !Success;
   }