aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore/PassManager.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2006-11-11 01:24:55 +0000
committerDevang Patel <dpatel@apple.com>2006-11-11 01:24:55 +0000
commit14d6581a7374bdb4a66ef6c30250efdc324f6dde (patch)
tree4b7fca514a01111dd53192919bbdb92e59be6605 /lib/VMCore/PassManager.cpp
parentb8526162551a3fbcf787e01d82ef44b69f879e01 (diff)
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
Diffstat (limited to 'lib/VMCore/PassManager.cpp')
-rw-r--r--lib/VMCore/PassManager.cpp31
1 files changed, 28 insertions, 3 deletions
diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp
index 157a9aa56e..19154fe06e 100644
--- a/lib/VMCore/PassManager.cpp
+++ b/lib/VMCore/PassManager.cpp
@@ -171,7 +171,8 @@ void CommonPassManagerImpl::noteDownRequiredAnalysis(Pass *P) {
const std::vector<AnalysisID> &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<AnalysisID> &PreservedSet = AnUsage.getPreservedSet();
+
+ for (std::set<AnalysisID>::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<AnalysisID>::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;
}