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
This commit is contained in:
Devang Patel 2007-01-11 22:15:30 +00:00
parent 6cb4c1ad7f
commit 36bcb82c3f

View File

@ -24,6 +24,7 @@
using namespace llvm; using namespace llvm;
class llvm::PMDataManager; class llvm::PMDataManager;
class llvm::PMStack;
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Overview: // Overview:
@ -190,6 +191,9 @@ public:
void initializeAllAnalysisInfo(); void initializeAllAnalysisInfo();
// Active Pass Managers
PMStack activeStack;
protected: protected:
/// Collection of pass managers /// Collection of pass managers
@ -434,9 +438,8 @@ private:
// //
/// FunctionPassManagerImpl manages FPPassManagers /// FunctionPassManagerImpl manages FPPassManagers
class FunctionPassManagerImpl : public Pass, class FunctionPassManagerImpl : public Pass,
public PMDataManager, public PMDataManager,
public PMTopLevelManager { public PMTopLevelManager {
public: public:
FunctionPassManagerImpl(int Depth) : PMDataManager(Depth) { FunctionPassManagerImpl(int Depth) : PMDataManager(Depth) {
@ -551,8 +554,8 @@ private:
// //
/// PassManagerImpl manages MPPassManagers /// PassManagerImpl manages MPPassManagers
class PassManagerImpl : public Pass, class PassManagerImpl : public Pass,
public PMDataManager, public PMDataManager,
public PMTopLevelManager { public PMTopLevelManager {
public: public:
@ -1218,19 +1221,15 @@ bool FunctionPassManager::doFinalization() {
/// manage it. /// manage it.
bool FunctionPassManagerImpl::addPass(Pass *P) { bool FunctionPassManagerImpl::addPass(Pass *P) {
if (!activeManager || !activeManager->addPass(P)) { if (activeStack.empty()) {
activeManager = new FPPassManager(getDepth() + 1); FPPassManager *FPP = new FPPassManager(getDepth() + 1);
// Inherit top level manager FPP->setTopLevelManager(this->getTopLevelManager());
activeManager->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);
addPassManager(activeManager);
return activeManager->addPass(P);
} }
P->assignPassManager(activeStack);
return true; return true;
} }
@ -1525,21 +1524,16 @@ MPPassManager::runOnModule(Module &M) {
/// manage it. /// manage it.
bool PassManagerImpl::addPass(Pass *P) { bool PassManagerImpl::addPass(Pass *P) {
if (!activeManager || !activeManager->addPass(P)) {
activeManager = new MPPassManager(getDepth() + 1); if (activeStack.empty()) {
MPPassManager *MPP = new MPPassManager(getDepth() + 1);
// Inherit top level manager MPP->setTopLevelManager(this->getTopLevelManager());
activeManager->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);
addPassManager(activeManager);
return activeManager->addPass(P);
} }
P->assignPassManager(activeStack);
return true; return true;
} }
@ -1618,6 +1612,7 @@ void TimingInfo::createTheTimeInfo() {
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// PMStack implementation // PMStack implementation
// //
// Pop Pass Manager from the stack and clear its analysis info. // Pop Pass Manager from the stack and clear its analysis info.
void PMStack::pop() { void PMStack::pop() {