[llvm-commits] CVS: llvm/lib/VMCore/PassManager.cpp
Devang Patel
dpatel at apple.com
Mon Apr 16 13:27:26 PDT 2007
Changes in directory llvm/lib/VMCore:
PassManager.cpp updated: 1.148 -> 1.149
---
Log message:
Update module pass manager to support module passes that require
function passes.
---
Diffs of the changes: (+44 -11)
PassManager.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 44 insertions(+), 11 deletions(-)
Index: llvm/lib/VMCore/PassManager.cpp
diff -u llvm/lib/VMCore/PassManager.cpp:1.148 llvm/lib/VMCore/PassManager.cpp:1.149
--- llvm/lib/VMCore/PassManager.cpp:1.148 Mon Apr 16 15:12:57 2007
+++ llvm/lib/VMCore/PassManager.cpp Mon Apr 16 15:27:05 2007
@@ -195,6 +195,11 @@
/// through getAnalysis interface.
virtual void addLowerLevelRequiredPass(Pass *P, Pass *RequiredPass);
+ /// Return function pass corresponding to PassInfo PI, that is
+ /// required by module pass MP. Instantiate analysis pass, by using
+ /// its runOnFunction() for function F.
+ virtual Pass* getOnTheFlyPass(Pass *MP, const PassInfo *PI, Function &F);
+
virtual const char *getPassName() const {
return "Module Pass Manager";
}
@@ -218,6 +223,11 @@
virtual PassManagerType getPassManagerType() const {
return PMT_ModulePassManager;
}
+
+ private:
+ /// Collection of on the fly FPPassManagers. These managers manage
+ /// function passes that are required by module passes.
+ std::map<Pass *, FPPassManager *> OnTheFlyManagers;
};
//===----------------------------------------------------------------------===//
@@ -614,6 +624,10 @@
enum PassDebuggingString DBG_STR) {
std::vector<Pass *> DeadPasses;
+
+ if (!TPM)
+ return;
+
TPM->collectLastUses(DeadPasses, P);
for (std::vector<Pass *>::iterator I = DeadPasses.begin(),
@@ -678,14 +692,6 @@
assert (0 && "Unable to accomodate Required Pass");
}
- // Now, take care of required analysises that are not available.
- for (SmallVector<AnalysisID, 8>::iterator
- I = ReqAnalysisNotAvailable.begin(),
- E = ReqAnalysisNotAvailable.end() ;I != E; ++I) {
- Pass *AnalysisPass = (*I)->createPass();
- this->addLowerLevelRequiredPass(P, AnalysisPass);
- }
-
// Set P as P's last user until someone starts using P.
// However, if P is a Pass Manager then it does not need
// to record its last user.
@@ -699,6 +705,14 @@
TransferLastUses.clear();
}
+ // Now, take care of required analysises that are not available.
+ for (SmallVector<AnalysisID, 8>::iterator
+ I = ReqAnalysisNotAvailable.begin(),
+ E = ReqAnalysisNotAvailable.end() ;I != E; ++I) {
+ Pass *AnalysisPass = (*I)->createPass();
+ this->addLowerLevelRequiredPass(P, AnalysisPass);
+ }
+
// Take a note of analysis required and made available by this pass.
// Remove the analysis not preserved by this pass
removeNotPreservedAnalysis(P);
@@ -1190,10 +1204,29 @@
RequiredPass->getPotentialPassManagerType())
&& "Unable to handle Pass that requires lower level Analysis pass");
- assert (0 &&
- "Unable to handle Pass that requires lower level Analysis pass");
+ FPPassManager *FPP = OnTheFlyManagers[P];
+ if (!FPP) {
+ FPP = new FPPassManager(getDepth() + 1);
+ OnTheFlyManagers[P] = FPP;
+ }
+
+ FPP->add(RequiredPass, false);
}
-
+
+/// Return function pass corresponding to PassInfo PI, that is
+/// required by module pass MP. Instantiate analysis pass, by using
+/// its runOnFunction() for function F.
+Pass* MPPassManager::getOnTheFlyPass(Pass *MP, const PassInfo *PI,
+ Function &F) {
+ AnalysisID AID = PI;
+ FPPassManager *FPP =OnTheFlyManagers[MP];
+ assert (FPP && "Unable to find on the fly pass");
+
+ FPP->runOnFunction(F);
+ return FPP->findAnalysisPass(AID, false);
+}
+
+
//===----------------------------------------------------------------------===//
// PassManagerImpl implementation
//
More information about the llvm-commits
mailing list