[llvm-commits] [llvm] r82944 - in /llvm/trunk: include/llvm/PassManagers.h lib/VMCore/PassManager.cpp
Dan Gohman
gohman at apple.com
Sun Sep 27 16:38:27 PDT 2009
Author: djg
Date: Sun Sep 27 18:38:27 2009
New Revision: 82944
URL: http://llvm.org/viewvc/llvm-project?rev=82944&view=rev
Log:
Extract the code for releasing a pass into a separate function, and
tidy it up a little.
Modified:
llvm/trunk/include/llvm/PassManagers.h
llvm/trunk/lib/VMCore/PassManager.cpp
Modified: llvm/trunk/include/llvm/PassManagers.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/PassManagers.h?rev=82944&r1=82943&r2=82944&view=diff
==============================================================================
--- llvm/trunk/include/llvm/PassManagers.h (original)
+++ llvm/trunk/include/llvm/PassManagers.h Sun Sep 27 18:38:27 2009
@@ -285,10 +285,14 @@
/// Remove Analysis that is not preserved by the pass
void removeNotPreservedAnalysis(Pass *P);
- /// Remove dead passes
+ /// Remove dead passes used by P.
void removeDeadPasses(Pass *P, const StringRef &Msg,
enum PassDebuggingString);
+ /// Remove P.
+ void freePass(Pass *P, const StringRef &Msg,
+ enum PassDebuggingString);
+
/// Add pass P into the PassVector. Update
/// AvailableAnalysis appropriately if ProcessAnalysis is true.
void add(Pass *P, bool ProcessAnalysis = true);
Modified: llvm/trunk/lib/VMCore/PassManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=82944&r1=82943&r2=82944&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/PassManager.cpp (original)
+++ llvm/trunk/lib/VMCore/PassManager.cpp Sun Sep 27 18:38:27 2009
@@ -815,34 +815,35 @@
}
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())
+ 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) {
+ std::map<AnalysisID, Pass*>::iterator Pos =
+ AvailableAnalysis.find(II[i]);
+ if (Pos != AvailableAnalysis.end() && Pos->second == P)
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) {
- Pos = AvailableAnalysis.find(II[i]);
- if (Pos != AvailableAnalysis.end() && Pos->second == *I)
- AvailableAnalysis.erase(Pos);
- }
}
}
}
More information about the llvm-commits
mailing list