From b05ef6a8eb4e06a4c3addb74d7d30eb2150049ea Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Mon, 29 Jan 2007 20:06:26 +0000 Subject: [PATCH] Move TimingInfo into PassManagers.h so that other libs can use it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33626 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/PassManagers.h | 49 +++++++++++++++++++++++++++++++ lib/VMCore/PassManager.cpp | 58 ++++--------------------------------- 2 files changed, 54 insertions(+), 53 deletions(-) diff --git a/include/llvm/PassManagers.h b/include/llvm/PassManagers.h index c4b3eed7f8a..e4ae30a15cb 100644 --- a/include/llvm/PassManagers.h +++ b/include/llvm/PassManagers.h @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "llvm/PassManager.h" +#include "llvm/Support/Timer.h" using namespace llvm; class llvm::PMDataManager; @@ -323,5 +324,53 @@ 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 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(P)) + return; + + std::map::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(P)) + return; + + std::map::iterator I = TimingData.find(P); + assert (I != TimingData.end() && "passStarted/passEnded not nested right!"); + I->second.stopTimer(); + } +}; + +extern TimingInfo *getTheTimeInfo(); } diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp index 5d391444caa..28bd4b5439b 100644 --- a/lib/VMCore/PassManager.cpp +++ b/lib/VMCore/PassManager.cpp @@ -14,7 +14,6 @@ #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" @@ -259,60 +258,13 @@ public: }; -} // End of llvm namespace - -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 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(P)) - return; - - std::map::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(P)) - return; - - std::map::iterator I = TimingData.find(P); - assert (I != TimingData.end() && "passStarted/passEnded not nested right!"); - I->second.stopTimer(); - } -}; - static TimingInfo *TheTimeInfo; -} // End of anon namespace +TimingInfo *getTheTimeInfo() { + return TheTimeInfo; +} + +} // End of llvm namespace //===----------------------------------------------------------------------===// // PMTopLevelManager implementation