aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2007-04-16 20:12:57 +0000
committerDevang Patel <dpatel@apple.com>2007-04-16 20:12:57 +0000
commit569a6fd9d59d67bc79f63f69ef14f91b0fda6c4a (patch)
tree24f8eaf9a3cc455dcada78f2f97161d30d6e46c7
parentb71ccac03a46b70c92ecd07369aa1bcaa99f48b1 (diff)
downloadexternal_llvm-569a6fd9d59d67bc79f63f69ef14f91b0fda6c4a.zip
external_llvm-569a6fd9d59d67bc79f63f69ef14f91b0fda6c4a.tar.gz
external_llvm-569a6fd9d59d67bc79f63f69ef14f91b0fda6c4a.tar.bz2
Give each pass manager chance to manage lower level analysis pass, which is
pass required by one of pass managed by the manager. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36153 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/PassManagers.h25
-rw-r--r--lib/VMCore/PassManager.cpp80
2 files changed, 80 insertions, 25 deletions
diff --git a/include/llvm/PassManagers.h b/include/llvm/PassManagers.h
index c94a098..29912b1 100644
--- a/include/llvm/PassManagers.h
+++ b/include/llvm/PassManagers.h
@@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/PassManager.h"
-
+#include "llvm/ADT/SmallVector.h"
using namespace llvm;
class llvm::PMDataManager;
class llvm::PMStack;
@@ -221,6 +221,19 @@ public:
/// AvailableAnalysis appropriately if ProcessAnalysis is true.
void add(Pass *P, bool ProcessAnalysis = true);
+ /// Add RequiredPass into list of lower level passes required by pass P.
+ /// RequiredPass is run on the fly by Pass Manager when P requests it
+ /// through getAnalysis interface.
+ virtual void addLowerLevelRequiredPass(Pass *P, Pass *RequiredPass) {
+ assert (0 &&
+ "Unable to handle Pass that requires lower level Analysis pass");
+ }
+
+ virtual Pass * getOnTheFlyPass(Pass *P, const PassInfo *PI, Function &F) {
+ assert (0 && "Unable to find on the fly pass");
+ return NULL;
+ }
+
/// Initialize available analysis information.
void initializeAnalysisInfo() {
AvailableAnalysis.clear();
@@ -233,10 +246,12 @@ public:
bool preserveHigherLevelAnalysis(Pass *P);
- /// Populate RequiredPasses with the analysis pass that are required by
- /// pass P.
- void collectRequiredAnalysisPasses(std::vector<Pass *> &RequiredPasses,
- Pass *P);
+ /// Populate RequiredPasses with analysis pass that are required by
+ /// pass P and are available. Populate ReqPassNotAvailable with analysis
+ /// pass that are required by pass P but are not available.
+ void collectRequiredAnalysis(SmallVector<Pass *, 8> &RequiredPasses,
+ SmallVector<AnalysisID, 8> &ReqPassNotAvailable,
+ Pass *P);
/// All Required analyses should be available to the pass as it runs! Here
/// we fill in the AnalysisImpls member of the pass so that it can
diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp
index 37b8a5f..02a27c2 100644
--- a/lib/VMCore/PassManager.cpp
+++ b/lib/VMCore/PassManager.cpp
@@ -190,6 +190,11 @@ public:
Info.setPreservesAll();
}
+ /// Add RequiredPass into list of lower level passes required by pass P.
+ /// RequiredPass is run on the fly by Pass Manager when P requests it
+ /// through getAnalysis interface.
+ virtual void addLowerLevelRequiredPass(Pass *P, Pass *RequiredPass);
+
virtual const char *getPassName() const {
return "Module Pass Manager";
}
@@ -400,9 +405,14 @@ void PMTopLevelManager::schedulePass(Pass *P) {
Pass *AnalysisPass = findAnalysisPass(*I);
if (!AnalysisPass) {
- // Schedule this analysis run first.
AnalysisPass = (*I)->createPass();
- schedulePass(AnalysisPass);
+ // Schedule this analysis run first only if it is not a lower level
+ // analysis pass. Lower level analsyis passes are run on the fly.
+ if (P->getPotentialPassManagerType () >=
+ AnalysisPass->getPotentialPassManagerType())
+ schedulePass(AnalysisPass);
+ else
+ delete AnalysisPass;
}
}
@@ -642,11 +652,14 @@ void PMDataManager::add(Pass *P,
// At the moment, this pass is the last user of all required passes.
std::vector<Pass *> LastUses;
- std::vector<Pass *> RequiredPasses;
+ SmallVector<Pass *, 8> RequiredPasses;
+ SmallVector<AnalysisID, 8> ReqAnalysisNotAvailable;
+
unsigned PDepth = this->getDepth();
- collectRequiredAnalysisPasses(RequiredPasses, P);
- for (std::vector<Pass *>::iterator I = RequiredPasses.begin(),
+ collectRequiredAnalysis(RequiredPasses,
+ ReqAnalysisNotAvailable, P);
+ for (SmallVector<Pass *, 8>::iterator I = RequiredPasses.begin(),
E = RequiredPasses.end(); I != E; ++I) {
Pass *PRequired = *I;
unsigned RDepth = 0;
@@ -661,11 +674,16 @@ void PMDataManager::add(Pass *P,
TransferLastUses.push_back(PRequired);
// Keep track of higher level analysis used by this manager.
HigherLevelAnalysis.push_back(PRequired);
- } else {
- // Note : This feature is not yet implemented
- assert (0 &&
- "Unable to handle Pass that requires lower level Analysis pass");
- }
+ } else
+ 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.
@@ -691,27 +709,34 @@ void PMDataManager::add(Pass *P,
PassVector.push_back(P);
}
-/// Populate RequiredPasses with the analysis pass that are required by
-/// pass P.
-void PMDataManager::collectRequiredAnalysisPasses(std::vector<Pass *> &RP,
- Pass *P) {
+
+/// Populate RP with analysis pass that are required by
+/// pass P and are available. Populate RP_NotAvail with analysis
+/// pass that are required by pass P but are not available.
+void PMDataManager::collectRequiredAnalysis(SmallVector<Pass *, 8>&RP,
+ SmallVector<AnalysisID, 8> &RP_NotAvail,
+ Pass *P) {
AnalysisUsage AnUsage;
P->getAnalysisUsage(AnUsage);
const std::vector<AnalysisID> &RequiredSet = AnUsage.getRequiredSet();
for (std::vector<AnalysisID>::const_iterator
I = RequiredSet.begin(), E = RequiredSet.end();
I != E; ++I) {
- Pass *AnalysisPass = findAnalysisPass(*I, true);
- assert (AnalysisPass && "Analysis pass is not available");
- RP.push_back(AnalysisPass);
+ AnalysisID AID = *I;
+ if (Pass *AnalysisPass = findAnalysisPass(*I, true))
+ RP.push_back(AnalysisPass);
+ else
+ RP_NotAvail.push_back(AID);
}
const std::vector<AnalysisID> &IDs = AnUsage.getRequiredTransitiveSet();
for (std::vector<AnalysisID>::const_iterator I = IDs.begin(),
E = IDs.end(); I != E; ++I) {
- Pass *AnalysisPass = findAnalysisPass(*I, true);
- assert (AnalysisPass && "Analysis pass is not available");
- RP.push_back(AnalysisPass);
+ AnalysisID AID = *I;
+ if (Pass *AnalysisPass = findAnalysisPass(*I, true))
+ RP.push_back(AnalysisPass);
+ else
+ RP_NotAvail.push_back(AID);
}
}
@@ -1154,6 +1179,21 @@ MPPassManager::runOnModule(Module &M) {
return Changed;
}
+/// Add RequiredPass into list of lower level passes required by pass P.
+/// RequiredPass is run on the fly by Pass Manager when P requests it
+/// through getAnalysis interface.
+void MPPassManager::addLowerLevelRequiredPass(Pass *P, Pass *RequiredPass) {
+
+ assert (P->getPotentialPassManagerType() == PMT_ModulePassManager
+ && "Unable to handle Pass that requires lower level Analysis pass");
+ assert ((P->getPotentialPassManagerType() <
+ RequiredPass->getPotentialPassManagerType())
+ && "Unable to handle Pass that requires lower level Analysis pass");
+
+ assert (0 &&
+ "Unable to handle Pass that requires lower level Analysis pass");
+}
+
//===----------------------------------------------------------------------===//
// PassManagerImpl implementation
//