diff options
author | Dan Gohman <gohman@apple.com> | 2009-09-27 23:38:27 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-09-27 23:38:27 +0000 |
commit | 27a8fb8a546ec5d39b057bfe2ee5c36a8e454f09 (patch) | |
tree | 4080b462e953636f5be51d3a1abeca7a2da5c887 /lib/VMCore/PassManager.cpp | |
parent | c261df9fab0c95e2362b518d071ac2ec37d0a9df (diff) | |
download | external_llvm-27a8fb8a546ec5d39b057bfe2ee5c36a8e454f09.zip external_llvm-27a8fb8a546ec5d39b057bfe2ee5c36a8e454f09.tar.gz external_llvm-27a8fb8a546ec5d39b057bfe2ee5c36a8e454f09.tar.bz2 |
Extract the code for releasing a pass into a separate function, and
tidy it up a little.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82944 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/PassManager.cpp')
-rw-r--r-- | lib/VMCore/PassManager.cpp | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp index f2c9ea3..79c30aa 100644 --- a/lib/VMCore/PassManager.cpp +++ b/lib/VMCore/PassManager.cpp @@ -815,34 +815,35 @@ void PMDataManager::removeDeadPasses(Pass *P, const StringRef &Msg, } for (SmallVector<Pass *, 12>::iterator I = DeadPasses.begin(), - E = DeadPasses.end(); I != E; ++I) { + E = DeadPasses.end(); I != E; ++I) + freePass(*I, Msg, DBG_STR); +} - dumpPassInfo(*I, FREEING_MSG, DBG_STR, Msg); +void PMDataManager::freePass(Pass *P, const StringRef &Msg, + enum PassDebuggingString DBG_STR) { + dumpPassInfo(P, FREEING_MSG, DBG_STR, Msg); - { - // If the pass crashes releasing memory, remember this. - PassManagerPrettyStackEntry X(*I); - - if (TheTimeInfo) TheTimeInfo->passStarted(*I); - (*I)->releaseMemory(); - if (TheTimeInfo) TheTimeInfo->passEnded(*I); - } - if (const PassInfo *PI = (*I)->getPassInfo()) { - std::map<AnalysisID, Pass*>::iterator Pos = - AvailableAnalysis.find(PI); + { + // If the pass crashes releasing memory, remember this. + PassManagerPrettyStackEntry X(P); + + if (TheTimeInfo) TheTimeInfo->passStarted(P); + P->releaseMemory(); + if (TheTimeInfo) TheTimeInfo->passEnded(P); + } - // It is possible that pass is already removed from the AvailableAnalysis - if (Pos != AvailableAnalysis.end()) - AvailableAnalysis.erase(Pos); + if (const PassInfo *PI = P->getPassInfo()) { + // Remove the pass itself (if it is not already removed). + AvailableAnalysis.erase(PI); - // Remove all interfaces this pass implements, for which it is also - // listed as the available implementation. - const std::vector<const PassInfo*> &II = PI->getInterfacesImplemented(); - for (unsigned i = 0, e = II.size(); i != e; ++i) { - Pos = AvailableAnalysis.find(II[i]); - if (Pos != AvailableAnalysis.end() && Pos->second == *I) - AvailableAnalysis.erase(Pos); - } + // Remove all interfaces this pass implements, for which it is also + // listed as the available implementation. + const std::vector<const PassInfo*> &II = PI->getInterfacesImplemented(); + for (unsigned i = 0, e = II.size(); i != e; ++i) { + std::map<AnalysisID, Pass*>::iterator Pos = + AvailableAnalysis.find(II[i]); + if (Pos != AvailableAnalysis.end() && Pos->second == P) + AvailableAnalysis.erase(Pos); } } } |