/// Remove dead passes
void removeDeadPasses() { /* TODO : Implement */ }
+ /// Add pass P into the PassVector. Update RequiredAnalysis and
+ /// AvailableAnalysis appropriately
+ void addPassToManager (Pass *P);
+
+ inline std::vector<Pass *>::iterator passVectorBegin() {
+ return PassVector.begin();
+ }
+
+ inline std::vector<Pass *>::iterator passVectorEnd() {
+ return PassVector.end();
+ }
+
private:
// Analysis required by the passes managed by this manager
std::vector<AnalysisID> RequiredAnalysis;
// set of available Analysis
std::set<AnalysisID> AvailableAnalysis;
+
+ // Collection of pass that are managed by this manager
+ std::vector<Pass *> PassVector;
};
/// BasicBlockPassManager_New manages BasicBlockPass. It batches all the
bool runOnFunction(Function &F);
private:
- // Collection of pass that are managed by this manager
- std::vector<Pass *> PassVector;
};
/// FunctionPassManagerImpl_New manages FunctionPasses and BasicBlockPassManagers.
bool runOnModule(Module &M);
private:
- // Collection of pass that are manged by this manager
- std::vector<Pass *> PassVector;
-
// Active Pass Managers
BasicBlockPassManager_New *activeBBPassManager;
};
bool runOnModule(Module &M);
private:
- // Collection of pass that are managed by this manager
- std::vector<Pass *> PassVector;
-
// Active Pass Manager
FunctionPassManagerImpl_New *activeFunctionPassManager;
};
// Collection of pass managers
std::vector<ModulePassManager_New *> PassManagers;
- // Collection of pass that are not yet scheduled
- std::vector<Pass *> PassVector;
-
// Active Pass Manager
ModulePassManager_New *activeManager;
};
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
}
}
+/// Add pass P into the PassVector. Update RequiredAnalysis and
+/// AvailableAnalysis appropriately
+void CommonPassManagerImpl::addPassToManager (Pass *P) {
+
+ // Take a note of analysis required and made available by this pass
+ noteDownRequiredAnalysis(P);
+ noteDownAvailableAnalysis(P);
+
+ // Add pass
+ PassVector.push_back(P);
+
+ // Remove the analysis not preserved by this pass
+ removeNotPreservedAnalysis(P);
+}
+
/// BasicBlockPassManager implementation
/// Add pass P into PassVector and return true. If this pass is not
if (!manageablePass(P))
return false;
- // Take a note of analysis required and made available by this pass
- noteDownRequiredAnalysis(P);
- noteDownAvailableAnalysis(P);
-
- // Add pass
- PassVector.push_back(BP);
-
- // Remove the analysis not preserved by this pass
- removeNotPreservedAnalysis(P);
+ addPassToManager (BP);
return true;
}
bool Changed = false;
for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I)
- for (std::vector<Pass *>::iterator itr = PassVector.begin(),
- e = PassVector.end(); itr != e; ++itr) {
+ for (std::vector<Pass *>::iterator itr = passVectorBegin(),
+ e = passVectorEnd(); itr != e; ++itr) {
Pass *P = *itr;
BasicBlockPass *BP = dynamic_cast<BasicBlockPass*>(P);
Changed |= BP->runOnBasicBlock(*I);
|| !activeBBPassManager->addPass(BP)) {
activeBBPassManager = new BasicBlockPassManager_New();
-
- PassVector.push_back(activeBBPassManager);
+ addPassToManager(activeBBPassManager);
if (!activeBBPassManager->addPass(BP))
assert(0 && "Unable to add Pass");
}
if (!manageablePass(P))
return false;
- // Take a note of analysis required and made available by this pass
- noteDownRequiredAnalysis(P);
- noteDownAvailableAnalysis(P);
-
- PassVector.push_back(FP);
-
- // Remove the analysis not preserved by this pass
- removeNotPreservedAnalysis(P);
-
+ addPassToManager (FP);
activeBBPassManager = NULL;
return true;
}
bool Changed = false;
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
- for (std::vector<Pass *>::iterator itr = PassVector.begin(),
- e = PassVector.end(); itr != e; ++itr) {
+ for (std::vector<Pass *>::iterator itr = passVectorBegin(),
+ e = passVectorEnd(); itr != e; ++itr) {
Pass *P = *itr;
FunctionPass *FP = dynamic_cast<FunctionPass*>(P);
Changed |= FP->runOnFunction(*I);
|| !activeFunctionPassManager->addPass(P)) {
activeFunctionPassManager = new FunctionPassManagerImpl_New();
-
- PassVector.push_back(activeFunctionPassManager);
+ addPassToManager(activeFunctionPassManager);
if (!activeFunctionPassManager->addPass(FP))
assert(0 && "Unable to add pass");
}
if (!manageablePass(P))
return false;
- // Take a note of analysis required and made available by this pass
- noteDownRequiredAnalysis(P);
- noteDownAvailableAnalysis(P);
-
- PassVector.push_back(MP);
-
- // Remove the analysis not preserved by this pass
- removeNotPreservedAnalysis(P);
-
+ addPassToManager(MP);
activeFunctionPassManager = NULL;
return true;
}
bool
ModulePassManager_New::runOnModule(Module &M) {
bool Changed = false;
- for (std::vector<Pass *>::iterator itr = PassVector.begin(),
- e = PassVector.end(); itr != e; ++itr) {
+ for (std::vector<Pass *>::iterator itr = passVectorBegin(),
+ e = passVectorEnd(); itr != e; ++itr) {
Pass *P = *itr;
ModulePass *MP = dynamic_cast<ModulePass*>(P);
Changed |= MP->runOnModule(M);