From: Devang Patel Date: Sat, 11 Nov 2006 01:24:55 +0000 (+0000) Subject: Remove analysis that is not preserved by the pass from AvailableAnalysis. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=14d6581a7374bdb4a66ef6c30250efdc324f6dde;p=oota-llvm.git Remove analysis that is not preserved by the pass from AvailableAnalysis. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31665 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp index 157a9aa56e6..19154fe06e9 100644 --- a/lib/VMCore/PassManager.cpp +++ b/lib/VMCore/PassManager.cpp @@ -171,7 +171,8 @@ void CommonPassManagerImpl::noteDownRequiredAnalysis(Pass *P) { const std::vector &RequiredSet = AnUsage.getRequiredSet(); // FIXME: What about duplicates ? - RequiredAnalysis.insert(RequiredAnalysis.end(), RequiredSet.begin(), RequiredSet.end()); + RequiredAnalysis.insert(RequiredAnalysis.end(), RequiredSet.begin(), + RequiredSet.end()); } /// Augement AvailableAnalysis by adding analysis made available by pass P. @@ -197,8 +198,20 @@ void CommonPassManagerImpl::removeAnalysis(AnalysisID AID) { /// Remove Analyss not preserved by Pass P void CommonPassManagerImpl::removeNotPreservedAnalysis(Pass *P) { - - // TODO + AnalysisUsage AnUsage; + P->getAnalysisUsage(AnUsage); + const std::vector &PreservedSet = AnUsage.getPreservedSet(); + + for (std::set::iterator I = AvailableAnalysis.begin(), + E = AvailableAnalysis.end(); I != E; ++I ) { + AnalysisID AID = *I; + if (std::find(PreservedSet.begin(), PreservedSet.end(), *I) == + PreservedSet.end()) { + // Remove this analysis + std::set::iterator J = I++; + AvailableAnalysis.erase(J); + } + } } /// BasicBlockPassManager implementation @@ -223,6 +236,10 @@ BasicBlockPassManager_New::addPass(Pass *P) { // Add pass PassVector.push_back(BP); + + // Remove the analysis not preserved by this pass + removeNotPreservedAnalysis(P); + return true; } @@ -306,6 +323,10 @@ FunctionPassManagerImpl_New::addPass(Pass *P) { noteDownAvailableAnalysis(P); PassVector.push_back(FP); + + // Remove the analysis not preserved by this pass + removeNotPreservedAnalysis(P); + activeBBPassManager = NULL; return true; } @@ -367,6 +388,10 @@ ModulePassManager_New::addPass(Pass *P) { noteDownAvailableAnalysis(P); PassVector.push_back(MP); + + // Remove the analysis not preserved by this pass + removeNotPreservedAnalysis(P); + activeFunctionPassManager = NULL; return true; }