mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 02:33:33 +00:00
Add #ifdef switch toggle between old and new pass manager. However,
continue to use old pass manager at the moment. To use new manager remove #define USE_OLD_PASSMANAGER 1 from Pass.h git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32525 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
21c362d324
commit
3162691f69
@ -36,6 +36,8 @@
|
||||
#include <typeinfo>
|
||||
#include <cassert>
|
||||
|
||||
#define USE_OLD_PASSMANAGER 1
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class Value;
|
||||
@ -203,7 +205,9 @@ public:
|
||||
virtual bool runPass(Module &M) { return runOnModule(M); }
|
||||
virtual bool runPass(BasicBlock&) { return false; }
|
||||
|
||||
#ifdef USE_OLD_PASSMANAGER
|
||||
virtual void addToPassManager(ModulePassManager *PM, AnalysisUsage &AU);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@ -226,10 +230,12 @@ public:
|
||||
///
|
||||
virtual bool runOnModule(Module &M) { return false; }
|
||||
|
||||
#ifdef USE_OLD_PASSMANAGER
|
||||
private:
|
||||
template<typename Trait> friend class PassManagerT;
|
||||
friend class ModulePassManager;
|
||||
virtual void addToPassManager(ModulePassManager *PM, AnalysisUsage &AU);
|
||||
#endif
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -269,6 +275,7 @@ public:
|
||||
///
|
||||
bool run(Function &F);
|
||||
|
||||
#ifdef USE_OLD_PASSMANAGER
|
||||
protected:
|
||||
template<typename Trait> friend class PassManagerT;
|
||||
friend class ModulePassManager;
|
||||
@ -276,6 +283,7 @@ protected:
|
||||
friend class BasicBlockPassManager;
|
||||
virtual void addToPassManager(ModulePassManager *PM, AnalysisUsage &AU);
|
||||
virtual void addToPassManager(FunctionPassManagerT *PM, AnalysisUsage &AU);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@ -329,6 +337,7 @@ public:
|
||||
virtual bool runPass(Module &M) { return false; }
|
||||
virtual bool runPass(BasicBlock &BB);
|
||||
|
||||
#ifdef USE_OLD_PASSMANAGER
|
||||
private:
|
||||
template<typename Trait> friend class PassManagerT;
|
||||
friend class FunctionPassManagerT;
|
||||
@ -338,6 +347,7 @@ private:
|
||||
}
|
||||
virtual void addToPassManager(FunctionPassManagerT *PM, AnalysisUsage &AU);
|
||||
virtual void addToPassManager(BasicBlockPassManager *PM,AnalysisUsage &AU);
|
||||
#endif
|
||||
};
|
||||
|
||||
/// If the user specifies the -time-passes argument on an LLVM tool command line
|
||||
|
@ -189,10 +189,19 @@ protected:
|
||||
///
|
||||
template<typename AnalysisType>
|
||||
AnalysisType *Pass::getAnalysisToUpdate() const {
|
||||
#ifdef USE_OLD_PASSMANAGER
|
||||
assert(Resolver && "Pass not resident in a PassManager object!");
|
||||
#else
|
||||
assert(Resolver_New && "Pass not resident in a PassManager object!");
|
||||
#endif
|
||||
const PassInfo *PI = getClassPassInfo<AnalysisType>();
|
||||
if (PI == 0) return 0;
|
||||
#ifdef USE_OLD_PASSMANAGER
|
||||
return dynamic_cast<AnalysisType*>(Resolver->getAnalysisToUpdate(PI));
|
||||
#else
|
||||
return dynamic_cast<AnalysisType*>
|
||||
(Resolver_New->getAnalysisToUpdate(PI, true));
|
||||
#endif
|
||||
}
|
||||
|
||||
/// getAnalysis<AnalysisType>() - This function is used by subclasses to get
|
||||
@ -201,15 +210,20 @@ AnalysisType *Pass::getAnalysisToUpdate() const {
|
||||
///
|
||||
template<typename AnalysisType>
|
||||
AnalysisType &Pass::getAnalysis() const {
|
||||
#ifdef USE_OLD_PASSMANAGER
|
||||
assert(Resolver && "Pass has not been inserted into a PassManager object!");
|
||||
#else
|
||||
assert(Resolver_New && "Pass has not been inserted into a PassManager object!");
|
||||
#endif
|
||||
const PassInfo *PI = getClassPassInfo<AnalysisType>();
|
||||
return getAnalysisID<AnalysisType>(PI);
|
||||
}
|
||||
|
||||
template<typename AnalysisType>
|
||||
AnalysisType &Pass::getAnalysisID(const PassInfo *PI) const {
|
||||
assert(Resolver && "Pass has not been inserted into a PassManager object!");
|
||||
assert(PI && "getAnalysis for unregistered pass!");
|
||||
#ifdef USE_OLD_PASSMANAGER
|
||||
assert(Resolver && "Pass has not been inserted into a PassManager object!");
|
||||
|
||||
// PI *must* appear in AnalysisImpls. Because the number of passes used
|
||||
// should be a small number, we just do a linear search over a (dense)
|
||||
@ -224,7 +238,17 @@ AnalysisType &Pass::getAnalysisID(const PassInfo *PI) const {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
assert(Resolver_New && "Pass has not been inserted into a PassManager object!");
|
||||
// PI *must* appear in AnalysisImpls. Because the number of passes used
|
||||
// should be a small number, we just do a linear search over a (dense)
|
||||
// vector.
|
||||
Pass *ResultPass = Resolver_New->findImplPass(PI);
|
||||
assert (ResultPass &&
|
||||
"getAnalysis*() called on an analysis that was not "
|
||||
"'required' by pass!");
|
||||
|
||||
#endif
|
||||
// Because the AnalysisType may not be a subclass of pass (for
|
||||
// AnalysisGroups), we must use dynamic_cast here to potentially adjust the
|
||||
// return pointer (because the class may multiply inherit, once from pass,
|
||||
|
@ -25,6 +25,9 @@ class Pass;
|
||||
class ModulePass;
|
||||
class Module;
|
||||
class ModuleProvider;
|
||||
|
||||
#ifdef USE_OLD_PASSMANAGER
|
||||
|
||||
class ModulePassManager;
|
||||
class FunctionPassManagerT;
|
||||
class BasicBlockPassManager;
|
||||
@ -87,17 +90,19 @@ public:
|
||||
bool doFinalization();
|
||||
};
|
||||
|
||||
class ModulePassManager_New;
|
||||
#else
|
||||
|
||||
class ModulePassManager;
|
||||
class PassManagerImpl_New;
|
||||
class FunctionPassManagerImpl_New;
|
||||
|
||||
/// PassManager_New manages ModulePassManagers
|
||||
class PassManager_New {
|
||||
/// PassManager manages ModulePassManagers
|
||||
class PassManager {
|
||||
|
||||
public:
|
||||
|
||||
PassManager_New();
|
||||
~PassManager_New();
|
||||
PassManager();
|
||||
~PassManager();
|
||||
|
||||
/// add - Add a pass to the queue of passes to run. This passes ownership of
|
||||
/// the Pass to the PassManager. When the PassManager is destroyed, the pass
|
||||
@ -111,18 +116,18 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
/// PassManagerImpl_New is the actual class. PassManager_New is just the
|
||||
/// PassManagerImpl_New is the actual class. PassManager is just the
|
||||
/// wraper to publish simple pass manager interface
|
||||
PassManagerImpl_New *PM;
|
||||
|
||||
};
|
||||
|
||||
/// FunctionPassManager_New manages FunctionPasses and BasicBlockPassManagers.
|
||||
class FunctionPassManager_New {
|
||||
/// FunctionPassManager manages FunctionPasses and BasicBlockPassManagers.
|
||||
class FunctionPassManager {
|
||||
public:
|
||||
FunctionPassManager_New(ModuleProvider *P);
|
||||
FunctionPassManager_New();
|
||||
~FunctionPassManager_New();
|
||||
FunctionPassManager(ModuleProvider *P);
|
||||
FunctionPassManager();
|
||||
~FunctionPassManager();
|
||||
|
||||
/// add - Add a pass to the queue of passes to run. This passes
|
||||
/// ownership of the Pass to the PassManager. When the
|
||||
@ -150,6 +155,7 @@ private:
|
||||
ModuleProvider *MP;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
|
@ -14,7 +14,9 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/PassManager.h"
|
||||
#ifdef USE_OLD_PASSMANAGER
|
||||
#include "PassManagerT.h" // PassManagerT implementation
|
||||
#endif
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/ModuleProvider.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
@ -34,6 +36,7 @@ void AnalysisResolver::setAnalysisResolver(Pass *P, AnalysisResolver *AR) {
|
||||
P->Resolver = AR;
|
||||
}
|
||||
|
||||
#ifdef USE_OLD_PASSMANAGER
|
||||
//===----------------------------------------------------------------------===//
|
||||
// PassManager implementation - The PassManager class is a simple Pimpl class
|
||||
// that wraps the PassManagerT template.
|
||||
@ -158,17 +161,24 @@ void PMDebug::PrintAnalysisSetInfo(unsigned Depth, const char *Msg,
|
||||
cerr << "\n";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Pass Implementation
|
||||
//
|
||||
|
||||
#ifdef USE_OLD_PASSMANAGER
|
||||
void ModulePass::addToPassManager(ModulePassManager *PM, AnalysisUsage &AU) {
|
||||
PM->addPass(this, AU);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool Pass::mustPreserveAnalysisID(const PassInfo *AnalysisID) const {
|
||||
#ifdef USE_OLD_PASSMANAGER
|
||||
return Resolver->getAnalysisToUpdate(AnalysisID) != 0;
|
||||
#else
|
||||
return Resolver_New->getAnalysisToUpdate(AnalysisID, true) != 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// dumpPassStructure - Implement the -debug-passes=Structure option
|
||||
@ -200,11 +210,12 @@ void Pass::dump() const {
|
||||
//===----------------------------------------------------------------------===//
|
||||
// ImmutablePass Implementation
|
||||
//
|
||||
#ifdef USE_OLD_PASSMANAGER
|
||||
void ImmutablePass::addToPassManager(ModulePassManager *PM,
|
||||
AnalysisUsage &AU) {
|
||||
PM->addPass(this, AU);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// FunctionPass Implementation
|
||||
@ -233,6 +244,7 @@ bool FunctionPass::run(Function &F) {
|
||||
return Changed | doFinalization(*F.getParent());
|
||||
}
|
||||
|
||||
#ifdef USE_OLD_PASSMANAGER
|
||||
void FunctionPass::addToPassManager(ModulePassManager *PM,
|
||||
AnalysisUsage &AU) {
|
||||
PM->addPass(this, AU);
|
||||
@ -242,6 +254,7 @@ void FunctionPass::addToPassManager(FunctionPassManagerT *PM,
|
||||
AnalysisUsage &AU) {
|
||||
PM->addPass(this, AU);
|
||||
}
|
||||
#endif
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// BasicBlockPass Implementation
|
||||
@ -271,6 +284,7 @@ bool BasicBlockPass::runPass(BasicBlock &BB) {
|
||||
return Changed;
|
||||
}
|
||||
|
||||
#ifdef USE_OLD_PASSMANAGER
|
||||
void BasicBlockPass::addToPassManager(FunctionPassManagerT *PM,
|
||||
AnalysisUsage &AU) {
|
||||
PM->addPass(this, AU);
|
||||
@ -280,7 +294,7 @@ void BasicBlockPass::addToPassManager(BasicBlockPassManager *PM,
|
||||
AnalysisUsage &AU) {
|
||||
PM->addPass(this, AU);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Pass Registration mechanism
|
||||
|
@ -84,6 +84,7 @@ using namespace llvm;
|
||||
// ModulePassManagers.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef USE_OLD_PASSMANAGER
|
||||
namespace llvm {
|
||||
|
||||
class PMDataManager;
|
||||
@ -125,6 +126,10 @@ public:
|
||||
/// then return NULL.
|
||||
Pass *findAnalysisPass(AnalysisID AID);
|
||||
|
||||
inline void clearManagers() {
|
||||
PassManagers.clear();
|
||||
}
|
||||
|
||||
virtual ~PMTopLevelManager() {
|
||||
|
||||
for (std::vector<Pass *>::iterator I = PassManagers.begin(),
|
||||
@ -291,16 +296,16 @@ private:
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// BasicBlockPassManager_New
|
||||
// BasicBlockPassManager
|
||||
//
|
||||
/// BasicBlockPassManager_New manages BasicBlockPass. It batches all the
|
||||
/// BasicBlockPassManager manages BasicBlockPass. It batches all the
|
||||
/// pass together and sequence them to process one basic block before
|
||||
/// processing next basic block.
|
||||
class BasicBlockPassManager_New : public PMDataManager,
|
||||
class BasicBlockPassManager : public PMDataManager,
|
||||
public FunctionPass {
|
||||
|
||||
public:
|
||||
BasicBlockPassManager_New(int D) : PMDataManager(D) { }
|
||||
BasicBlockPassManager(int D) : PMDataManager(D) { }
|
||||
|
||||
/// Add a pass into a passmanager queue.
|
||||
bool addPass(Pass *p);
|
||||
@ -407,20 +412,20 @@ public:
|
||||
|
||||
private:
|
||||
// Active Pass Managers
|
||||
BasicBlockPassManager_New *activeBBPassManager;
|
||||
BasicBlockPassManager *activeBBPassManager;
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// ModulePassManager_New
|
||||
// ModulePassManager
|
||||
//
|
||||
/// ModulePassManager_New manages ModulePasses and function pass managers.
|
||||
/// ModulePassManager 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 Pass,
|
||||
class ModulePassManager : public Pass,
|
||||
public PMDataManager {
|
||||
|
||||
public:
|
||||
ModulePassManager_New(int D) : PMDataManager(D) {
|
||||
ModulePassManager(int D) : PMDataManager(D) {
|
||||
activeFunctionPassManager = NULL;
|
||||
}
|
||||
|
||||
@ -504,7 +509,7 @@ private:
|
||||
bool addPass(Pass *p);
|
||||
|
||||
// Active Pass Manager
|
||||
ModulePassManager_New *activeManager;
|
||||
ModulePassManager *activeManager;
|
||||
};
|
||||
|
||||
} // End of llvm namespace
|
||||
@ -814,12 +819,12 @@ Pass *AnalysisResolver_New::getAnalysisToUpdate(AnalysisID ID, bool dir) const {
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// BasicBlockPassManager_New implementation
|
||||
// BasicBlockPassManager implementation
|
||||
|
||||
/// Add pass P into PassVector and return true. If this pass is not
|
||||
/// manageable by this manager then return false.
|
||||
bool
|
||||
BasicBlockPassManager_New::addPass(Pass *P) {
|
||||
BasicBlockPassManager::addPass(Pass *P) {
|
||||
|
||||
BasicBlockPass *BP = dynamic_cast<BasicBlockPass*>(P);
|
||||
if (!BP)
|
||||
@ -839,7 +844,7 @@ BasicBlockPassManager_New::addPass(Pass *P) {
|
||||
/// runOnBasicBlock method. Keep track of whether any of the passes modifies
|
||||
/// the function, and if so, return true.
|
||||
bool
|
||||
BasicBlockPassManager_New::runOnFunction(Function &F) {
|
||||
BasicBlockPassManager::runOnFunction(Function &F) {
|
||||
|
||||
if (F.isExternal())
|
||||
return false;
|
||||
@ -862,7 +867,7 @@ BasicBlockPassManager_New::runOnFunction(Function &F) {
|
||||
}
|
||||
|
||||
// Implement doInitialization and doFinalization
|
||||
inline bool BasicBlockPassManager_New::doInitialization(Module &M) {
|
||||
inline bool BasicBlockPassManager::doInitialization(Module &M) {
|
||||
bool Changed = false;
|
||||
|
||||
for (std::vector<Pass *>::iterator itr = passVectorBegin(),
|
||||
@ -875,7 +880,7 @@ inline bool BasicBlockPassManager_New::doInitialization(Module &M) {
|
||||
return Changed;
|
||||
}
|
||||
|
||||
inline bool BasicBlockPassManager_New::doFinalization(Module &M) {
|
||||
inline bool BasicBlockPassManager::doFinalization(Module &M) {
|
||||
bool Changed = false;
|
||||
|
||||
for (std::vector<Pass *>::iterator itr = passVectorBegin(),
|
||||
@ -888,7 +893,7 @@ inline bool BasicBlockPassManager_New::doFinalization(Module &M) {
|
||||
return Changed;
|
||||
}
|
||||
|
||||
inline bool BasicBlockPassManager_New::doInitialization(Function &F) {
|
||||
inline bool BasicBlockPassManager::doInitialization(Function &F) {
|
||||
bool Changed = false;
|
||||
|
||||
for (std::vector<Pass *>::iterator itr = passVectorBegin(),
|
||||
@ -901,7 +906,7 @@ inline bool BasicBlockPassManager_New::doInitialization(Function &F) {
|
||||
return Changed;
|
||||
}
|
||||
|
||||
inline bool BasicBlockPassManager_New::doFinalization(Function &F) {
|
||||
inline bool BasicBlockPassManager::doFinalization(Function &F) {
|
||||
bool Changed = false;
|
||||
|
||||
for (std::vector<Pass *>::iterator itr = passVectorBegin(),
|
||||
@ -916,10 +921,10 @@ inline bool BasicBlockPassManager_New::doFinalization(Function &F) {
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// FunctionPassManager_New implementation
|
||||
// FunctionPassManager implementation
|
||||
|
||||
/// Create new Function pass manager
|
||||
FunctionPassManager_New::FunctionPassManager_New(ModuleProvider *P) {
|
||||
FunctionPassManager::FunctionPassManager(ModuleProvider *P) {
|
||||
FPM = new FunctionPassManagerImpl_New(0);
|
||||
// FPM is the top level manager.
|
||||
FPM->setTopLevelManager(FPM);
|
||||
@ -932,7 +937,14 @@ FunctionPassManager_New::FunctionPassManager_New(ModuleProvider *P) {
|
||||
MP = P;
|
||||
}
|
||||
|
||||
FunctionPassManager_New::~FunctionPassManager_New() {
|
||||
FunctionPassManager::~FunctionPassManager() {
|
||||
// Note : FPM maintains one entry in PassManagers vector.
|
||||
// This one entry is FPM itself. This is not ideal. One
|
||||
// alternative is have one additional layer between
|
||||
// FunctionPassManager and FunctionPassManagerImpl.
|
||||
// Meanwhile, to avoid going into infinte loop, first
|
||||
// remove FPM from its PassMangers vector.
|
||||
FPM->clearManagers();
|
||||
delete FPM;
|
||||
}
|
||||
|
||||
@ -941,7 +953,7 @@ FunctionPassManager_New::~FunctionPassManager_New() {
|
||||
/// PassManager_X is destroyed, the pass will be destroyed as well, so
|
||||
/// there is no need to delete the pass. (TODO delete passes.)
|
||||
/// This implies that all passes MUST be allocated with 'new'.
|
||||
void FunctionPassManager_New::add(Pass *P) {
|
||||
void FunctionPassManager::add(Pass *P) {
|
||||
FPM->add(P);
|
||||
}
|
||||
|
||||
@ -949,7 +961,7 @@ void FunctionPassManager_New::add(Pass *P) {
|
||||
/// track of whether any of the passes modifies the function, and if
|
||||
/// so, return true.
|
||||
///
|
||||
bool FunctionPassManager_New::run(Function &F) {
|
||||
bool FunctionPassManager::run(Function &F) {
|
||||
std::string errstr;
|
||||
if (MP->materializeFunction(&F, &errstr)) {
|
||||
cerr << "Error reading bytecode file: " << errstr << "\n";
|
||||
@ -961,13 +973,13 @@ bool FunctionPassManager_New::run(Function &F) {
|
||||
|
||||
/// doInitialization - Run all of the initializers for the function passes.
|
||||
///
|
||||
bool FunctionPassManager_New::doInitialization() {
|
||||
bool FunctionPassManager::doInitialization() {
|
||||
return FPM->doInitialization(*MP->getModule());
|
||||
}
|
||||
|
||||
/// doFinalization - Run all of the initializers for the function passes.
|
||||
///
|
||||
bool FunctionPassManager_New::doFinalization() {
|
||||
bool FunctionPassManager::doFinalization() {
|
||||
return FPM->doFinalization(*MP->getModule());
|
||||
}
|
||||
|
||||
@ -980,7 +992,7 @@ bool FunctionPassManager_New::doFinalization() {
|
||||
bool
|
||||
FunctionPassManagerImpl_New::addPass(Pass *P) {
|
||||
|
||||
// If P is a BasicBlockPass then use BasicBlockPassManager_New.
|
||||
// If P is a BasicBlockPass then use BasicBlockPassManager.
|
||||
if (BasicBlockPass *BP = dynamic_cast<BasicBlockPass*>(P)) {
|
||||
|
||||
if (!activeBBPassManager || !activeBBPassManager->addPass(BP)) {
|
||||
@ -991,7 +1003,7 @@ FunctionPassManagerImpl_New::addPass(Pass *P) {
|
||||
|
||||
// Create and add new manager
|
||||
activeBBPassManager =
|
||||
new BasicBlockPassManager_New(getDepth() + 1);
|
||||
new BasicBlockPassManager(getDepth() + 1);
|
||||
// Inherit top level manager
|
||||
activeBBPassManager->setTopLevelManager(this->getTopLevelManager());
|
||||
|
||||
@ -1109,7 +1121,8 @@ bool FunctionPassManagerImpl_New::run(Function &F) {
|
||||
bool Changed = false;
|
||||
for (std::vector<Pass *>::iterator I = passManagersBegin(),
|
||||
E = passManagersEnd(); I != E; ++I) {
|
||||
FunctionPass *FP = dynamic_cast<FunctionPass *>(*I);
|
||||
FunctionPassManagerImpl_New *FP =
|
||||
dynamic_cast<FunctionPassManagerImpl_New *>(*I);
|
||||
Changed |= FP->runOnFunction(F);
|
||||
}
|
||||
return Changed;
|
||||
@ -1122,7 +1135,7 @@ bool FunctionPassManagerImpl_New::run(Function &F) {
|
||||
/// then use FunctionPassManagerImpl_New to manage it. Return false if P
|
||||
/// is not manageable by this manager.
|
||||
bool
|
||||
ModulePassManager_New::addPass(Pass *P) {
|
||||
ModulePassManager::addPass(Pass *P) {
|
||||
|
||||
// If P is FunctionPass then use function pass maanager.
|
||||
if (FunctionPass *FP = dynamic_cast<FunctionPass*>(P)) {
|
||||
@ -1183,7 +1196,7 @@ ModulePassManager_New::addPass(Pass *P) {
|
||||
/// runOnModule method. Keep track of whether any of the passes modifies
|
||||
/// the module, and if so, return true.
|
||||
bool
|
||||
ModulePassManager_New::runOnModule(Module &M) {
|
||||
ModulePassManager::runOnModule(Module &M) {
|
||||
bool Changed = false;
|
||||
initializeAnalysisInfo();
|
||||
|
||||
@ -1208,7 +1221,7 @@ ModulePassManager_New::runOnModule(Module &M) {
|
||||
bool PassManagerImpl_New::addPass(Pass *P) {
|
||||
|
||||
if (!activeManager || !activeManager->addPass(P)) {
|
||||
activeManager = new ModulePassManager_New(getDepth() + 1);
|
||||
activeManager = new ModulePassManager(getDepth() + 1);
|
||||
// Inherit top level manager
|
||||
activeManager->setTopLevelManager(this->getTopLevelManager());
|
||||
|
||||
@ -1230,7 +1243,7 @@ bool PassManagerImpl_New::run(Module &M) {
|
||||
bool Changed = false;
|
||||
for (std::vector<Pass *>::iterator I = passManagersBegin(),
|
||||
E = passManagersEnd(); I != E; ++I) {
|
||||
ModulePassManager_New *MP = dynamic_cast<ModulePassManager_New *>(*I);
|
||||
ModulePassManager *MP = dynamic_cast<ModulePassManager *>(*I);
|
||||
Changed |= MP->runOnModule(M);
|
||||
}
|
||||
return Changed;
|
||||
@ -1240,13 +1253,13 @@ bool PassManagerImpl_New::run(Module &M) {
|
||||
// PassManager implementation
|
||||
|
||||
/// Create new pass manager
|
||||
PassManager_New::PassManager_New() {
|
||||
PassManager::PassManager() {
|
||||
PM = new PassManagerImpl_New(0);
|
||||
// PM is the top level manager
|
||||
PM->setTopLevelManager(PM);
|
||||
}
|
||||
|
||||
PassManager_New::~PassManager_New() {
|
||||
PassManager::~PassManager() {
|
||||
delete PM;
|
||||
}
|
||||
|
||||
@ -1255,14 +1268,15 @@ PassManager_New::~PassManager_New() {
|
||||
/// will be destroyed as well, so there is no need to delete the pass. This
|
||||
/// implies that all passes MUST be allocated with 'new'.
|
||||
void
|
||||
PassManager_New::add(Pass *P) {
|
||||
PassManager::add(Pass *P) {
|
||||
PM->add(P);
|
||||
}
|
||||
|
||||
/// run - Execute all of the passes scheduled for execution. Keep track of
|
||||
/// whether any of the passes modifies the module, and if so, return true.
|
||||
bool
|
||||
PassManager_New::run(Module &M) {
|
||||
PassManager::run(Module &M) {
|
||||
return PM->run(M);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user