forked from OSchip/llvm-project
				
			Clean up pass manager cache after each run.
llvm-svn: 68254
This commit is contained in:
		
							parent
							
								
									d2eb0a63a1
								
							
						
					
					
						commit
						ec9c58f7e5
					
				| 
						 | 
					@ -143,6 +143,12 @@ public:
 | 
				
			||||||
    AnalysisImpls.push_back(pir);
 | 
					    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
 | 
					  // getAnalysisIfAvailable - Return analysis result or null if it doesn't exist
 | 
				
			||||||
  Pass *getAnalysisIfAvailable(AnalysisID ID, bool Direction) const;
 | 
					  Pass *getAnalysisIfAvailable(AnalysisID ID, bool Direction) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -414,6 +414,9 @@ public:
 | 
				
			||||||
  /// whether any of the passes modifies the module, and if so, return true.
 | 
					  /// whether any of the passes modifies the module, and if so, return true.
 | 
				
			||||||
  bool runOnFunction(Function &F);
 | 
					  bool runOnFunction(Function &F);
 | 
				
			||||||
  bool runOnModule(Module &M);
 | 
					  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.
 | 
					  /// doInitialization - Run all of the initializers for the function passes.
 | 
				
			||||||
  ///
 | 
					  ///
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1267,6 +1267,16 @@ bool FunctionPassManagerImpl::doFinalization(Module &M) {
 | 
				
			||||||
  return Changed;
 | 
					  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.
 | 
					// Execute all the passes managed by this top level manager.
 | 
				
			||||||
// Return true if any function is modified by a pass.
 | 
					// Return true if any function is modified by a pass.
 | 
				
			||||||
bool FunctionPassManagerImpl::run(Function &F) {
 | 
					bool FunctionPassManagerImpl::run(Function &F) {
 | 
				
			||||||
| 
						 | 
					@ -1279,6 +1289,10 @@ bool FunctionPassManagerImpl::run(Function &F) {
 | 
				
			||||||
  initializeAllAnalysisInfo();
 | 
					  initializeAllAnalysisInfo();
 | 
				
			||||||
  for (unsigned Index = 0; Index < getNumContainedManagers(); ++Index)
 | 
					  for (unsigned Index = 0; Index < getNumContainedManagers(); ++Index)
 | 
				
			||||||
    Changed |= getContainedManager(Index)->runOnFunction(F);
 | 
					    Changed |= getContainedManager(Index)->runOnFunction(F);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for (unsigned Index = 0; Index < getNumContainedManagers(); ++Index)
 | 
				
			||||||
 | 
					    getContainedManager(Index)->cleanup();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return Changed;
 | 
					  return Changed;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue