diff options
author | Dan Gohman <gohman@apple.com> | 2010-10-11 23:19:01 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-10-11 23:19:01 +0000 |
commit | 7c34730fb96808d7116d83b8831164042a98a4b1 (patch) | |
tree | 9c7a289346fd02ae286923a349e6c40b014f0acd /lib/VMCore/PassManager.cpp | |
parent | 42fac8ee3bc02e18a5887800e812af762b45b9eb (diff) |
Fix the pass manager's search order for immutable passes, and make it
stop searching when it has found a match.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116262 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/PassManager.cpp')
-rw-r--r-- | lib/VMCore/PassManager.cpp | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp index ab4d4e55c7..57d6b8c0de 100644 --- a/lib/VMCore/PassManager.cpp +++ b/lib/VMCore/PassManager.cpp @@ -612,41 +612,40 @@ void PMTopLevelManager::schedulePass(Pass *P) { /// then return NULL. Pass *PMTopLevelManager::findAnalysisPass(AnalysisID AID) { - Pass *P = NULL; // Check pass managers for (SmallVector<PMDataManager *, 8>::iterator I = PassManagers.begin(), - E = PassManagers.end(); P == NULL && I != E; ++I) { - PMDataManager *PMD = *I; - P = PMD->findAnalysisPass(AID, false); - } + E = PassManagers.end(); I != E; ++I) + if (Pass *P = (*I)->findAnalysisPass(AID, false)) + return P; // Check other pass managers for (SmallVector<PMDataManager *, 8>::iterator I = IndirectPassManagers.begin(), - E = IndirectPassManagers.end(); P == NULL && I != E; ++I) - P = (*I)->findAnalysisPass(AID, false); - - for (SmallVector<ImmutablePass *, 8>::iterator I = ImmutablePasses.begin(), - E = ImmutablePasses.end(); P == NULL && I != E; ++I) { + E = IndirectPassManagers.end(); I != E; ++I) + if (Pass *P = (*I)->findAnalysisPass(AID, false)) + return P; + + // Check the immutable passes. Iterate in reverse order so that we find + // the most recently registered passes first. + for (SmallVector<ImmutablePass *, 8>::reverse_iterator I = + ImmutablePasses.rbegin(), E = ImmutablePasses.rend(); I != E; ++I) { AnalysisID PI = (*I)->getPassID(); if (PI == AID) - P = *I; + return *I; // If Pass not found then check the interfaces implemented by Immutable Pass - if (!P) { - const PassInfo *PassInf = - PassRegistry::getPassRegistry()->getPassInfo(PI); - const std::vector<const PassInfo*> &ImmPI = - PassInf->getInterfacesImplemented(); - for (std::vector<const PassInfo*>::const_iterator II = ImmPI.begin(), - EE = ImmPI.end(); II != EE; ++II) { - if ((*II)->getTypeInfo() == AID) - P = *I; - } + const PassInfo *PassInf = + PassRegistry::getPassRegistry()->getPassInfo(PI); + const std::vector<const PassInfo*> &ImmPI = + PassInf->getInterfacesImplemented(); + for (std::vector<const PassInfo*>::const_iterator II = ImmPI.begin(), + EE = ImmPI.end(); II != EE; ++II) { + if ((*II)->getTypeInfo() == AID) + return *I; } } - return P; + return 0; } // Print passes managed by this top level manager. |