diff options
author | Devang Patel <dpatel@apple.com> | 2009-04-01 22:34:41 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2009-04-01 22:34:41 +0000 |
commit | 9dfa1671fc5ba478530ba88877dd508dac20bac4 (patch) | |
tree | 0185e6d3a1dce50ad0dbff76db0474b340eabdcf | |
parent | 5867de1243c7e43d7bbd5e90287106e3feb7e9e6 (diff) | |
download | llvm-9dfa1671fc5ba478530ba88877dd508dac20bac4.tar.gz llvm-9dfa1671fc5ba478530ba88877dd508dac20bac4.tar.bz2 llvm-9dfa1671fc5ba478530ba88877dd508dac20bac4.tar.xz |
Clean up pass manager cache after each run.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68254 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/PassAnalysisSupport.h | 6 | ||||
-rw-r--r-- | include/llvm/PassManagers.h | 3 | ||||
-rw-r--r-- | lib/VMCore/PassManager.cpp | 14 |
3 files changed, 23 insertions, 0 deletions
diff --git a/include/llvm/PassAnalysisSupport.h b/include/llvm/PassAnalysisSupport.h index f0343b3911..de37862b62 100644 --- a/include/llvm/PassAnalysisSupport.h +++ b/include/llvm/PassAnalysisSupport.h @@ -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; diff --git a/include/llvm/PassManagers.h b/include/llvm/PassManagers.h index 0716ce5372..1aa0d3a6fa 100644 --- a/include/llvm/PassManagers.h +++ b/include/llvm/PassManagers.h @@ -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. /// diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp index dd035487be..2e9fa53d0a 100644 --- a/lib/VMCore/PassManager.cpp +++ b/lib/VMCore/PassManager.cpp @@ -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; } |