aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/VMCore/PassManager.cpp51
1 files changed, 23 insertions, 28 deletions
diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp
index d71192689a..c2351eda1e 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() {