From 1209f416cf2f2ec0f335d91a7c115e3b0a37d603 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Thu, 7 Dec 2006 21:10:57 +0000 Subject: [PATCH] Reimplement schedulePass interface. Move it into PMTopLevelManager. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32324 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/PassManager.cpp | 79 ++++++++++++++------------------------ 1 file changed, 28 insertions(+), 51 deletions(-) diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp index 3ab01854c42..c0aeaa20468 100644 --- a/lib/VMCore/PassManager.cpp +++ b/lib/VMCore/PassManager.cpp @@ -173,6 +173,33 @@ void PMTopLevelManager::collectLastUses(std::vector &LastUses, LastUses.push_back(LUI->first); } +/// Schedule pass P for execution. Make sure that passes required by +/// P are run before P is run. Update analysis info maintained by +/// the manager. Remove dead passes. This is a recursive function. +void PMTopLevelManager::schedulePass(Pass *P, Pass *PM) { + + // TODO : Allocate function manager for this pass, other wise required set + // may be inserted into previous function manager + + AnalysisUsage AnUsage; + P->getAnalysisUsage(AnUsage); + const std::vector &RequiredSet = AnUsage.getRequiredSet(); + for (std::vector::const_iterator I = RequiredSet.begin(), + E = RequiredSet.end(); I != E; ++I) { + + Pass *AnalysisPass = NULL; // FIXME PM->getAnalysisPass(*I, true); + if (!AnalysisPass) { + // Schedule this analysis run first. + AnalysisPass = (*I)->createPass(); + schedulePass(AnalysisPass, PM); + } + } + + // Now all required passes are available. + addTopLevelPass(P); +} + + //===----------------------------------------------------------------------===// // PMDataManager @@ -399,18 +426,9 @@ public: private: - /// Add a pass into a passmanager queue. This is used by schedulePasses + /// Add a pass into a passmanager queue. bool addPass(Pass *p); - /// Schedule pass P for execution. Make sure that passes required by - /// P are run before P is run. Update analysis info maintained by - /// the manager. Remove dead passes. This is a recursive function. - void schedulePass(Pass *P); - - /// Schedule all passes collected in pass queue using add(). Add all the - /// schedule passes into various manager's queue using addPass(). - void schedulePasses(); - // Collection of pass managers std::vector PassManagers; @@ -842,46 +860,6 @@ Pass *PassManagerImpl_New::getAnalysisPassFromManager(AnalysisID AID) { return P; } -/// Schedule pass P for execution. Make sure that passes required by -/// P are run before P is run. Update analysis info maintained by -/// the manager. Remove dead passes. This is a recursive function. -void PassManagerImpl_New::schedulePass(Pass *P) { - - AnalysisUsage AnUsage; - P->getAnalysisUsage(AnUsage); - const std::vector &RequiredSet = AnUsage.getRequiredSet(); - for (std::vector::const_iterator I = RequiredSet.begin(), - E = RequiredSet.end(); I != E; ++I) { - - Pass *AnalysisPass = getAnalysisPassFromManager(*I); - if (!AnalysisPass) { - // Schedule this analysis run first. - AnalysisPass = (*I)->createPass(); - schedulePass(AnalysisPass); - } - setLastUser (AnalysisPass, P); - - // Prolong live range of analyses that are needed after an analysis pass - // is destroyed, for querying by subsequent passes - const std::vector &IDs = AnUsage.getRequiredTransitiveSet(); - for (std::vector::const_iterator I = IDs.begin(), - E = IDs.end(); I != E; ++I) { - Pass *AP = getAnalysisPassFromManager(*I); - assert (AP && "Analysis pass is not available"); - setLastUser(AP, P); - } - } - addPass(P); -} - -/// Schedule all passes from the queue by adding them in their -/// respective manager's queue. -void PassManagerImpl_New::schedulePasses() { - for (std::vector::iterator I = passVectorBegin(), - E = passVectorEnd(); I != E; ++I) - schedulePass (*I); -} - /// Add pass P to the queue of passes to run. void PassManagerImpl_New::add(Pass *P) { // Do not process Analysis now. Analysis is process while scheduling @@ -906,7 +884,6 @@ bool PassManagerImpl_New::addPass(Pass *P) { /// whether any of the passes modifies the module, and if so, return true. bool PassManagerImpl_New::run(Module &M) { - schedulePasses(); bool Changed = false; for (std::vector::iterator itr = PassManagers.begin(), e = PassManagers.end(); itr != e; ++itr) {