Changes in directory llvm/lib/VMCore:
PassManager.cpp updated: 1.56 -> 1.57 --- Log message: set Last User. --- Diffs of the changes: (+49 -5) PassManager.cpp | 54 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 49 insertions(+), 5 deletions(-) Index: llvm/lib/VMCore/PassManager.cpp diff -u llvm/lib/VMCore/PassManager.cpp:1.56 llvm/lib/VMCore/PassManager.cpp:1.57 --- llvm/lib/VMCore/PassManager.cpp:1.56 Thu Dec 7 17:24:58 2006 +++ llvm/lib/VMCore/PassManager.cpp Thu Dec 7 17:55:10 2006 @@ -243,6 +243,7 @@ /// Initialize available analysis information. void initializeAnalysisInfo() { + ForcedLastUses.clear(); AvailableAnalysis.clear(); // Include immutable passes into AvailableAnalysis vector. @@ -277,6 +278,17 @@ unsigned getDepth() { return Depth; } +protected: + + // Collection of pass whose last user asked this manager to claim + // last use. If a FunctionPass F is the last user of ModulePass info M + // then the F's manager, not F, records itself as a last user of M. + std::vector<Pass *> ForcedLastUses; + + // Top level manager. + // TODO : Make it a reference. + PMTopLevelManager *TPM; + private: // Set of available Analysis. This information is used while scheduling // pass. If a pass requires an analysis which is not not available then @@ -287,10 +299,6 @@ // Collection of pass that are managed by this manager std::vector<Pass *> PassVector; - // Top level manager. - // TODO : Make it a reference. - PMTopLevelManager *TPM; - unsigned Depth; }; @@ -384,7 +392,8 @@ /// ModulePassManager_New manages ModulePasses and function pass managers. /// It batches all Module passes passes and function pass managers together and /// sequence them to process one module. -class ModulePassManager_New : public PMDataManager { +class ModulePassManager_New : public Pass, + public PMDataManager { public: ModulePassManager_New(int D) : PMDataManager(D) { @@ -522,6 +531,33 @@ bool ProcessAnalysis) { if (ProcessAnalysis) { + + // At the moment, this pass is the last user of all required passes. + std::vector<Pass *> LastUses; + std::vector<Pass *> RequiredPasses; + unsigned PDepth = this->getDepth(); + + collectRequiredAnalysisPasses(RequiredPasses, P); + for (std::vector<Pass *>::iterator I = RequiredPasses.begin(), + E = RequiredPasses.end(); I != E; ++I) { + Pass *PRequired = *I; + unsigned RDepth = 0; + //FIXME: RDepth = PRequired->getResolver()->getDepth(); + if (PDepth == RDepth) + LastUses.push_back(PRequired); + else if (PDepth > RDepth) { + // Let the parent claim responsibility of last use + ForcedLastUses.push_back(PRequired); + } else { + // Note : This feature is not yet implemented + assert (0 && + "Unable to handle Pass that requires lower level Analysis pass"); + } + } + + if (!LastUses.empty()) + TPM->setLastUser(LastUses, P); + // Take a note of analysis required and made available by this pass. // Remove the analysis not preserved by this pass initializeAnalysisImpl(P); @@ -696,6 +732,10 @@ if (!activeBBPassManager->addPass(BP)) assert(0 && "Unable to add Pass"); } + + if (!ForcedLastUses.empty()) + TPM->setLastUser(ForcedLastUses, this); + return true; } @@ -836,6 +876,10 @@ if (!activeFunctionPassManager->addPass(FP)) assert(0 && "Unable to add pass"); } + + if (!ForcedLastUses.empty()) + TPM->setLastUser(ForcedLastUses, this); + return true; } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits