summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/PassManager.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-09-28 00:07:05 +0000
committerDan Gohman <gohman@apple.com>2009-09-28 00:07:05 +0000
commit277e7675789274337827840724b54d1643e597ae (patch)
treef3f76c8c9bf3adb04fb15866fb91e3de99e080df /llvm/lib/VMCore/PassManager.cpp
parent7c2b1e71c13e88e0788c5e26e6a366fecea06238 (diff)
downloadbcm5719-llvm-277e7675789274337827840724b54d1643e597ae.tar.gz
bcm5719-llvm-277e7675789274337827840724b54d1643e597ae.zip
Extend the StartPassTimer and StopPassTimer functions so that the
code that stops the timer doesn't have to search to find the timer object before it stops the timer. This avoids a lock acquisition and a few other things done with the timer running. llvm-svn: 82949
Diffstat (limited to 'llvm/lib/VMCore/PassManager.cpp')
-rw-r--r--llvm/lib/VMCore/PassManager.cpp46
1 files changed, 20 insertions, 26 deletions
diff --git a/llvm/lib/VMCore/PassManager.cpp b/llvm/lib/VMCore/PassManager.cpp
index 79c30aa480c..a3496ed9b4f 100644
--- a/llvm/lib/VMCore/PassManager.cpp
+++ b/llvm/lib/VMCore/PassManager.cpp
@@ -397,25 +397,19 @@ public:
// null. It may be called multiple times.
static void createTheTimeInfo();
- void passStarted(Pass *P) {
+ /// passStarted - This method creates a timer for the given pass if it doesn't
+ /// already have one, and starts the timer.
+ Timer *passStarted(Pass *P) {
if (dynamic_cast<PMDataManager *>(P))
- return;
+ return 0;
sys::SmartScopedLock<true> Lock(*TimingInfoMutex);
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;
-
- sys::SmartScopedLock<true> Lock(*TimingInfoMutex);
- std::map<Pass*, Timer>::iterator I = TimingData.find(P);
- assert(I != TimingData.end() && "passStarted/passEnded not nested right!");
- I->second.stopTimer();
+ Timer *T = &I->second;
+ T->startTimer();
+ return T;
}
};
@@ -827,9 +821,9 @@ void PMDataManager::freePass(Pass *P, const StringRef &Msg,
// If the pass crashes releasing memory, remember this.
PassManagerPrettyStackEntry X(P);
- if (TheTimeInfo) TheTimeInfo->passStarted(P);
+ Timer *T = StartPassTimer(P);
P->releaseMemory();
- if (TheTimeInfo) TheTimeInfo->passEnded(P);
+ StopPassTimer(P, T);
}
if (const PassInfo *PI = P->getPassInfo()) {
@@ -1162,9 +1156,9 @@ bool BBPassManager::runOnFunction(Function &F) {
// If the pass crashes, remember this.
PassManagerPrettyStackEntry X(BP, *I);
- if (TheTimeInfo) TheTimeInfo->passStarted(BP);
+ Timer *T = StartPassTimer(BP);
Changed |= BP->runOnBasicBlock(*I);
- if (TheTimeInfo) TheTimeInfo->passEnded(BP);
+ StopPassTimer(BP, T);
}
if (Changed)
@@ -1377,9 +1371,9 @@ bool FPPassManager::runOnFunction(Function &F) {
{
PassManagerPrettyStackEntry X(FP, F);
- if (TheTimeInfo) TheTimeInfo->passStarted(FP);
+ Timer *T = StartPassTimer(FP);
Changed |= FP->runOnFunction(F);
- if (TheTimeInfo) TheTimeInfo->passEnded(FP);
+ StopPassTimer(FP, T);
}
if (Changed)
@@ -1453,9 +1447,9 @@ MPPassManager::runOnModule(Module &M) {
{
PassManagerPrettyStackEntry X(MP, M);
- if (TheTimeInfo) TheTimeInfo->passStarted(MP);
+ Timer *T = StartPassTimer(MP);
Changed |= MP->runOnModule(M);
- if (TheTimeInfo) TheTimeInfo->passEnded(MP);
+ StopPassTimer(MP, T);
}
if (Changed)
@@ -1591,15 +1585,15 @@ void TimingInfo::createTheTimeInfo() {
}
/// If TimingInfo is enabled then start pass timer.
-void llvm::StartPassTimer(Pass *P) {
+Timer *llvm::StartPassTimer(Pass *P) {
if (TheTimeInfo)
- TheTimeInfo->passStarted(P);
+ return TheTimeInfo->passStarted(P);
+ return 0;
}
/// If TimingInfo is enabled then stop pass timer.
-void llvm::StopPassTimer(Pass *P) {
- if (TheTimeInfo)
- TheTimeInfo->passEnded(P);
+void llvm::StopPassTimer(Pass *P, Timer *T) {
+ if (T) T->stopTimer();
}
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud