public:
static char ID;
explicit BBPassManager(int Depth)
- : PMDataManager(Depth), FunctionPass((intptr_t)&ID) {}
+ : PMDataManager(Depth), FunctionPass(&ID) {}
/// Execute all of the passes scheduled for execution. Keep track of
/// whether any of the passes modifies the function, and if so, return true.
public:
static char ID;
explicit FunctionPassManagerImpl(int Depth) :
- Pass((intptr_t)&ID), PMDataManager(Depth),
+ Pass(&ID), PMDataManager(Depth),
PMTopLevelManager(TLM_Function) { }
/// add - Add a pass to the queue of passes to run. This passes ownership of
public:
static char ID;
explicit MPPassManager(int Depth) :
- Pass((intptr_t)&ID), PMDataManager(Depth) { }
+ Pass(&ID), PMDataManager(Depth) { }
// Delete on the fly managers.
virtual ~MPPassManager() {
public:
static char ID;
explicit PassManagerImpl(int Depth) :
- Pass((intptr_t)&ID), PMDataManager(Depth),
- PMTopLevelManager(TLM_Pass) { }
+ Pass(&ID), PMDataManager(Depth), PMTopLevelManager(TLM_Pass) { }
/// add - Add a pass to the queue of passes to run. This passes ownership of
/// the Pass to the PassManager. When the PassManager is destroyed, the pass
AnalysisUsage *AnUsage = findAnalysisUsage(P);
- const AnalysisUsage::VectorType &RequiredSet = AnUsage->getRequiredSet();
- for (AnalysisUsage::VectorType::const_iterator I = RequiredSet.begin(),
- E = RequiredSet.end(); I != E; ++I) {
-
- Pass *AnalysisPass = findAnalysisPass(*I);
- if (!AnalysisPass) {
- AnalysisPass = (*I)->createPass();
- // 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;
+ bool checkAnalysis = true;
+ while (checkAnalysis) {
+ checkAnalysis = false;
+
+ const AnalysisUsage::VectorType &RequiredSet = AnUsage->getRequiredSet();
+ for (AnalysisUsage::VectorType::const_iterator I = RequiredSet.begin(),
+ E = RequiredSet.end(); I != E; ++I) {
+
+ Pass *AnalysisPass = findAnalysisPass(*I);
+ if (!AnalysisPass) {
+ AnalysisPass = (*I)->createPass();
+ if (P->getPotentialPassManagerType () ==
+ AnalysisPass->getPotentialPassManagerType())
+ // Schedule analysis pass that is managed by the same pass manager.
+ schedulePass(AnalysisPass);
+ else if (P->getPotentialPassManagerType () >
+ AnalysisPass->getPotentialPassManagerType()) {
+ // Schedule analysis pass that is managed by a new manager.
+ schedulePass(AnalysisPass);
+ // Recheck analysis passes to ensure that required analysises that
+ // are already checked are still available.
+ checkAnalysis = true;
+ }
+ else
+ // Do not schedule this analysis. Lower level analsyis
+ // passes are run on the fly.
+ delete AnalysisPass;
+ }
}
}
else
break;
}
-
+ assert(!PMS.empty() && "Unable to find appropriate Pass Manager");
PMS.top()->add(this);
}
void FunctionPass::assignPassManager(PMStack &PMS,
PassManagerType PreferredType) {
- // Find Module Pass Manager (TODO : Or Call Graph Pass Manager)
+ // Find Module Pass Manager
while(!PMS.empty()) {
if (PMS.top()->getPassManagerType() > PMT_FunctionPassManager)
PMS.pop();
// [3] Assign manager to manage this new manager. This may create
// and push new managers into PMS
-
- // If Call Graph Pass Manager is active then use it to manage
- // this new Function Pass manager.
- if (PMD->getPassManagerType() == PMT_CallGraphPassManager)
- FPP->assignPassManager(PMS, PMT_CallGraphPassManager);
- else
- FPP->assignPassManager(PMS);
+ FPP->assignPassManager(PMS, PMD->getPassManagerType());
// [4] Push new manager into PMS
PMS.push(FPP);