[llvm-commits] CVS: llvm/lib/VMCore/PassManager.cpp
Devang Patel
dpatel at apple.com
Fri Nov 10 17:51:16 PST 2006
Changes in directory llvm/lib/VMCore:
PassManager.cpp updated: 1.15 -> 1.16
---
Log message:
Code refactoring. Move common code into CommonPassManagerImpl :)
---
Diffs of the changes: (+41 -49)
PassManager.cpp | 90 +++++++++++++++++++++++++-------------------------------
1 files changed, 41 insertions(+), 49 deletions(-)
Index: llvm/lib/VMCore/PassManager.cpp
diff -u llvm/lib/VMCore/PassManager.cpp:1.15 llvm/lib/VMCore/PassManager.cpp:1.16
--- llvm/lib/VMCore/PassManager.cpp:1.15 Fri Nov 10 19:31:05 2006
+++ llvm/lib/VMCore/PassManager.cpp Fri Nov 10 19:51:02 2006
@@ -50,12 +50,27 @@
/// 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
@@ -74,8 +89,6 @@
bool runOnFunction(Function &F);
private:
- // Collection of pass that are managed by this manager
- std::vector<Pass *> PassVector;
};
/// FunctionPassManagerImpl_New manages FunctionPasses and BasicBlockPassManagers.
@@ -106,9 +119,6 @@
bool runOnModule(Module &M);
private:
- // Collection of pass that are manged by this manager
- std::vector<Pass *> PassVector;
-
// Active Pass Managers
BasicBlockPassManager_New *activeBBPassManager;
};
@@ -129,9 +139,6 @@
bool runOnModule(Module &M);
private:
- // Collection of pass that are managed by this manager
- std::vector<Pass *> PassVector;
-
// Active Pass Manager
FunctionPassManagerImpl_New *activeFunctionPassManager;
};
@@ -163,9 +170,6 @@
// 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;
};
@@ -243,7 +247,6 @@
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
@@ -253,6 +256,21 @@
}
}
+/// 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
@@ -269,15 +287,7 @@
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;
}
@@ -290,8 +300,8 @@
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);
@@ -340,8 +350,7 @@
|| !activeBBPassManager->addPass(BP)) {
activeBBPassManager = new BasicBlockPassManager_New();
-
- PassVector.push_back(activeBBPassManager);
+ addPassToManager(activeBBPassManager);
if (!activeBBPassManager->addPass(BP))
assert(0 && "Unable to add Pass");
}
@@ -357,15 +366,7 @@
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;
}
@@ -378,8 +379,8 @@
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);
@@ -405,8 +406,7 @@
|| !activeFunctionPassManager->addPass(P)) {
activeFunctionPassManager = new FunctionPassManagerImpl_New();
-
- PassVector.push_back(activeFunctionPassManager);
+ addPassToManager(activeFunctionPassManager);
if (!activeFunctionPassManager->addPass(FP))
assert(0 && "Unable to add pass");
}
@@ -422,15 +422,7 @@
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;
}
@@ -442,8 +434,8 @@
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);
More information about the llvm-commits
mailing list