- Undo previous check-in (i.e. Do not export TimingInfo class through
authorDevang Patel <dpatel@apple.com>
Mon, 29 Jan 2007 23:10:37 +0000 (23:10 +0000)
committerDevang Patel <dpatel@apple.com>
Mon, 29 Jan 2007 23:10:37 +0000 (23:10 +0000)
PassManagers.h).

- Add StopPassTimer() and StartPassTimer() to expose TimingInfo to
CallGraphPassManager

- Use these two APIs in CalLgraphPassManager to measure timings.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33638 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/PassManagers.h
lib/VMCore/PassManager.cpp

index e4ae30a15cb005778a1152b304629a552f8b89ff..920707c89cc1ec9d148151aad3a1c0023ff525e1 100644 (file)
@@ -12,7 +12,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/PassManager.h"
-#include "llvm/Support/Timer.h"
 
 using namespace llvm;
 class llvm::PMDataManager;
@@ -324,53 +323,7 @@ public:
   }
 };
 
-//===----------------------------------------------------------------------===//
-// TimingInfo Class - This class is used to calculate information about the
-// amount of time each pass takes to execute.  This only happens when
-// -time-passes is enabled on the command line.
-//
-
-class TimingInfo {
-  std::map<Pass*, Timer> TimingData;
-  TimerGroup TG;
-
-public:
-  // Use 'create' member to get this.
-  TimingInfo() : TG("... Pass execution timing report ...") {}
-  
-  // TimingDtor - Print out information about timing information
-  ~TimingInfo() {
-    // Delete all of the timers...
-    TimingData.clear();
-    // TimerGroup is deleted next, printing the report.
-  }
-
-  // createTheTimeInfo - This method either initializes the TheTimeInfo pointer
-  // to a non null value (if the -time-passes option is enabled) or it leaves it
-  // null.  It may be called multiple times.
-  static void createTheTimeInfo();
-
-  void passStarted(Pass *P) {
-
-    if (dynamic_cast<PMDataManager *>(P)) 
-      return;
-
-    std::map<Pass*, Timer>::iterator I = TimingData.find(P);
-    if (I == TimingData.end())
-      I=TimingData.insert(std::make_pair(P, Timer(P->getPassName(), TG))).first;
-    I->second.startTimer();
-  }
-  void passEnded(Pass *P) {
-
-    if (dynamic_cast<PMDataManager *>(P)) 
-      return;
-
-    std::map<Pass*, Timer>::iterator I = TimingData.find(P);
-    assert (I != TimingData.end() && "passStarted/passEnded not nested right!");
-    I->second.stopTimer();
-  }
-};
-
-extern TimingInfo *getTheTimeInfo();
 }
 
+extern void StartPassTimer(Pass *);
+extern void StopPassTimer(Pass *);
index 28bd4b5439b3dbd835f675bc3dc7a84f4dd78d3f..d72f8caa145b4356941fbbd6a38cb355e46c76b0 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "llvm/PassManagers.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Timer.h"
 #include "llvm/Module.h"
 #include "llvm/ModuleProvider.h"
 #include "llvm/Support/Streams.h"
@@ -258,13 +259,60 @@ public:
 
 };
 
-static TimingInfo *TheTimeInfo;
+} // End of llvm namespace
 
-TimingInfo *getTheTimeInfo() {
-  return TheTimeInfo;
-}
+namespace {
 
-} // End of llvm namespace
+//===----------------------------------------------------------------------===//
+// TimingInfo Class - This class is used to calculate information about the
+// amount of time each pass takes to execute.  This only happens when
+// -time-passes is enabled on the command line.
+//
+
+class VISIBILITY_HIDDEN TimingInfo {
+  std::map<Pass*, Timer> TimingData;
+  TimerGroup TG;
+
+public:
+  // Use 'create' member to get this.
+  TimingInfo() : TG("... Pass execution timing report ...") {}
+  
+  // TimingDtor - Print out information about timing information
+  ~TimingInfo() {
+    // Delete all of the timers...
+    TimingData.clear();
+    // TimerGroup is deleted next, printing the report.
+  }
+
+  // createTheTimeInfo - This method either initializes the TheTimeInfo pointer
+  // to a non null value (if the -time-passes option is enabled) or it leaves it
+  // null.  It may be called multiple times.
+  static void createTheTimeInfo();
+
+  void passStarted(Pass *P) {
+
+    if (dynamic_cast<PMDataManager *>(P)) 
+      return;
+
+    std::map<Pass*, Timer>::iterator I = TimingData.find(P);
+    if (I == TimingData.end())
+      I=TimingData.insert(std::make_pair(P, Timer(P->getPassName(), TG))).first;
+    I->second.startTimer();
+  }
+  void passEnded(Pass *P) {
+
+    if (dynamic_cast<PMDataManager *>(P)) 
+      return;
+
+    std::map<Pass*, Timer>::iterator I = TimingData.find(P);
+    assert (I != TimingData.end() && "passStarted/passEnded not nested right!");
+    I->second.stopTimer();
+  }
+};
+
+static TimingInfo *TheTimeInfo;
+
+} // End of anon namespace
 
 //===----------------------------------------------------------------------===//
 // PMTopLevelManager implementation
@@ -1084,6 +1132,18 @@ void TimingInfo::createTheTimeInfo() {
   TheTimeInfo = &*TTI;
 }
 
+/// If TimingInfo is enabled then start pass timer.
+void StartPassTimer(Pass *P) {
+  if (TheTimeInfo) 
+    TheTimeInfo->passStarted(P);
+}
+
+/// If TimingInfo is enabled then stop pass timer.
+void StopPassTimer(Pass *P) {
+  if (TheTimeInfo) 
+    TheTimeInfo->passEnded(P);
+}
+
 //===----------------------------------------------------------------------===//
 // PMStack implementation
 //