Keep track of analysis required by the passes. Force use of new pass

manager if a pass does not preserve analysis that is used by other
passes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31659 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2006-11-11 00:42:16 +00:00
parent 448f219fed
commit a363a0bdef
2 changed files with 20 additions and 7 deletions

View File

@ -119,8 +119,8 @@ public:
void removeDeadPasses() { /* TODO : Implement */ }
private:
// Required set of analysis for the passes managed by this manager
std::vector<AnalysisID> RequiredSet;
// Analysis required by the passes managed by this manager
std::vector<AnalysisID> RequiredAnalysis;
};
/// PassManager_New manages ModulePassManagers

View File

@ -142,9 +142,18 @@ bool CommonPassManagerImpl::manageablePass(Pass *P) {
AnalysisUsage AnUsage;
P->getAnalysisUsage(AnUsage);
// If this pass is not preserving information that is required by the other passes
// managed by this manager then use new manager
// TODO
// If this pass is not preserving information that is required by the other
// passes managed by this manager then use new manager
if (!AnUsage.getPreservesAll()) {
const std::vector<AnalysisID> &PreservedSet = AnUsage.getPreservedSet();
for (std::vector<AnalysisID>::iterator I = RequiredAnalysis.begin(),
E = RequiredAnalysis.end(); I != E; ++I) {
if (std::find(PreservedSet.begin(), PreservedSet.end(), *I) ==
PreservedSet.end())
// This analysis is not preserved. Need new manager.
return false;
}
}
return true;
}
@ -157,8 +166,12 @@ bool CommonPassManagerImpl::analysisCurrentlyAvailable(AnalysisID AID) {
/// Augment RequiredSet by adding analysis required by pass P.
void CommonPassManagerImpl::noteDownRequiredAnalysis(Pass *P) {
AnalysisUsage AnUsage;
P->getAnalysisUsage(AnUsage);
const std::vector<AnalysisID> &RequiredSet = AnUsage.getRequiredSet();
// TODO
// FIXME: What about duplicates ?
RequiredAnalysis.insert(RequiredAnalysis.end(), RequiredSet.begin(), RequiredSet.end());
}
/// Remove AnalysisID from the RequiredSet
@ -375,7 +388,7 @@ PassManagerImpl_New::add(Pass *P) {
bool
PassManagerImpl_New::addPass(Pass *P) {
if (!activeManager) {
if (!activeManager || !activeManager->addPass(P)) {
activeManager = new ModulePassManager_New();
PassManagers.push_back(activeManager);
}