From 36bcb82c3f7acd7cc3a79f51102c5995db2fb723 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Thu, 11 Jan 2007 22:15:30 +0000 Subject: [PATCH] Start using PMStack. Now each pass is responsibe for assinging a pass manager for itself. There is some opportunity to remove some dead code from PassManager.cpp. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33087 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/PassManager.cpp | 51 +++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp index d71192689af..c2351eda1e0 100644 --- a/lib/VMCore/PassManager.cpp +++ b/lib/VMCore/PassManager.cpp @@ -24,6 +24,7 @@ using namespace llvm; class llvm::PMDataManager; +class llvm::PMStack; //===----------------------------------------------------------------------===// // Overview: @@ -190,6 +191,9 @@ public: void initializeAllAnalysisInfo(); + // Active Pass Managers + PMStack activeStack; + protected: /// Collection of pass managers @@ -434,9 +438,8 @@ private: // /// FunctionPassManagerImpl manages FPPassManagers class FunctionPassManagerImpl : public Pass, - public PMDataManager, - public PMTopLevelManager { - + public PMDataManager, + public PMTopLevelManager { public: FunctionPassManagerImpl(int Depth) : PMDataManager(Depth) { @@ -551,8 +554,8 @@ private: // /// PassManagerImpl manages MPPassManagers class PassManagerImpl : public Pass, - public PMDataManager, - public PMTopLevelManager { + public PMDataManager, + public PMTopLevelManager { public: @@ -1218,19 +1221,15 @@ bool FunctionPassManager::doFinalization() { /// manage it. bool FunctionPassManagerImpl::addPass(Pass *P) { - if (!activeManager || !activeManager->addPass(P)) { - activeManager = new FPPassManager(getDepth() + 1); - // Inherit top level manager - activeManager->setTopLevelManager(this->getTopLevelManager()); + if (activeStack.empty()) { + FPPassManager *FPP = new FPPassManager(getDepth() + 1); + FPP->setTopLevelManager(this->getTopLevelManager()); + addPassManager(FPP); + activeStack.push(FPP); + } - // This top level manager is going to manage activeManager. - // Set up analysis resolver to connect them. - AnalysisResolver *AR = new AnalysisResolver(*this); - activeManager->setResolver(AR); + P->assignPassManager(activeStack); - addPassManager(activeManager); - return activeManager->addPass(P); - } return true; } @@ -1525,21 +1524,16 @@ MPPassManager::runOnModule(Module &M) { /// manage it. bool PassManagerImpl::addPass(Pass *P) { - if (!activeManager || !activeManager->addPass(P)) { - activeManager = new MPPassManager(getDepth() + 1); - - // Inherit top level manager - activeManager->setTopLevelManager(this->getTopLevelManager()); + if (activeStack.empty()) { + MPPassManager *MPP = new MPPassManager(getDepth() + 1); + MPP->setTopLevelManager(this->getTopLevelManager()); + addPassManager(MPP); + activeStack.push(MPP); + } - // This top level manager is going to manage activeManager. - // Set up analysis resolver to connect them. - AnalysisResolver *AR = new AnalysisResolver(*this); - activeManager->setResolver(AR); + P->assignPassManager(activeStack); - addPassManager(activeManager); - return activeManager->addPass(P); - } return true; } @@ -1618,6 +1612,7 @@ void TimingInfo::createTheTimeInfo() { //===----------------------------------------------------------------------===// // PMStack implementation // + // Pop Pass Manager from the stack and clear its analysis info. void PMStack::pop() { -- 2.34.1