Clean up pass manager cache after each run.
authorDevang Patel <dpatel@apple.com>
Wed, 1 Apr 2009 22:34:41 +0000 (22:34 +0000)
committerDevang Patel <dpatel@apple.com>
Wed, 1 Apr 2009 22:34:41 +0000 (22:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68254 91177308-0d34-0410-b5e6-96231b3b80d8

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

index f0343b3911b7fbac2db943e1322ee4d580cb217d..de37862b62983932c931245c7f5973debfd92950 100644 (file)
@@ -143,6 +143,12 @@ public:
     AnalysisImpls.push_back(pir);
   }
 
+  /// clearAnalysisImpls - Clear cache that is used to connect a pass to the
+  /// the analysis (PassInfo).
+  void clearAnalysisImpls() {
+    AnalysisImpls.clear();
+  }
+
   // getAnalysisIfAvailable - Return analysis result or null if it doesn't exist
   Pass *getAnalysisIfAvailable(AnalysisID ID, bool Direction) const;
 
index 0716ce53721b9dfa23af0b4ce4db3e2af7d87173..1aa0d3a6fa427cc64114ea9d4db5ac428d06cff8 100644 (file)
@@ -414,6 +414,9 @@ public:
   /// whether any of the passes modifies the module, and if so, return true.
   bool runOnFunction(Function &F);
   bool runOnModule(Module &M);
+  
+  /// cleanup - After running all passes, clean up pass manager cache.
+  void cleanup();
 
   /// doInitialization - Run all of the initializers for the function passes.
   ///
index dd035487be57a98059b4bdce2604ae7435dc134b..2e9fa53d0affc64a93dc1a3e4175acc449d5ad55 100644 (file)
@@ -1267,6 +1267,16 @@ bool FunctionPassManagerImpl::doFinalization(Module &M) {
   return Changed;
 }
 
+/// cleanup - After running all passes, clean up pass manager cache.
+void FPPassManager::cleanup() {
+ for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
+    FunctionPass *FP = getContainedPass(Index);
+    AnalysisResolver *AR = FP->getResolver();
+    assert(AR && "Analysis Resolver is not set");
+    AR->clearAnalysisImpls();
+ }
+}
+
 // Execute all the passes managed by this top level manager.
 // Return true if any function is modified by a pass.
 bool FunctionPassManagerImpl::run(Function &F) {
@@ -1279,6 +1289,10 @@ bool FunctionPassManagerImpl::run(Function &F) {
   initializeAllAnalysisInfo();
   for (unsigned Index = 0; Index < getNumContainedManagers(); ++Index)
     Changed |= getContainedManager(Index)->runOnFunction(F);
+
+  for (unsigned Index = 0; Index < getNumContainedManagers(); ++Index)
+    getContainedManager(Index)->cleanup();
+
   return Changed;
 }