diff --git a/lib/VMCore/PassManagerT.h b/lib/VMCore/PassManagerT.h index 07bf738fcdc..70f2cde66ea 100644 --- a/lib/VMCore/PassManagerT.h +++ b/lib/VMCore/PassManagerT.h @@ -150,7 +150,7 @@ public: for (std::vector::iterator I = Required.begin(), E = Required.end(); I != E; ++I) { if (getAnalysisOrNullDown(*I) == 0) - add(I->createPass()); + add((PassClass*)I->createPass()); } // Tell the pass to add itself to this PassManager... the way it does so @@ -282,14 +282,19 @@ template<> struct PassManagerTraits : public BasicBlockPass { // ParentClass - The type of the parent PassManager... typedef PassManagerT ParentClass; + // PMType - The type of the passmanager that subclasses this class + typedef PassManagerT PMType; + // runPass - Specify how the pass should be run on the UnitType static bool runPass(PassClass *P, BasicBlock *M) { // todo, init and finalize return P->runOnBasicBlock(M); } - // run - Implement the Pass interface... + // Implement the BasicBlockPass interface... + virtual bool doInitialization(Module *M); virtual bool runOnBasicBlock(BasicBlock *BB); + virtual bool doFinalization(Module *M); }; @@ -364,8 +369,22 @@ template<> struct PassManagerTraits : public Pass { // PassManagerTraits Implementations // +inline bool PassManagerTraits::doInitialization(Module *M) { + bool Changed = false; + for (unsigned i = 0, e = ((PMType*)this)->Passes.size(); i != e; ++i) + ((PMType*)this)->Passes[i]->doInitialization(M); + return Changed; +} + inline bool PassManagerTraits::runOnBasicBlock(BasicBlock *BB) { - return ((PassManagerT*)this)->runOnUnit(BB); + return ((PMType*)this)->runOnUnit(BB); +} + +inline bool PassManagerTraits::doFinalization(Module *M) { + bool Changed = false; + for (unsigned i = 0, e = ((PMType*)this)->Passes.size(); i != e; ++i) + ((PMType*)this)->Passes[i]->doFinalization(M); + return Changed; } @@ -382,9 +401,6 @@ inline bool PassManagerTraits::runOnMethod(Method *M) { return ((PMType*)this)->runOnUnit(M); } - -// PassManagerTraits Implementations -// inline bool PassManagerTraits::doFinalization(Module *M) { bool Changed = false; for (unsigned i = 0, e = ((PMType*)this)->Passes.size(); i != e; ++i)