mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
Add a new BasicBlockPass::doInitialization/Finalization(Function &) pair of
methods that may be useful for BasicBlockPasses. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3688 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
287d4436c5
commit
e0a54f88a0
@ -341,18 +341,20 @@ void FunctionPass::addToPassManager(PassManagerT<Function> *PM,
|
||||
// function.
|
||||
//
|
||||
bool BasicBlockPass::runOnFunction(Function &F) {
|
||||
bool Changed = false;
|
||||
bool Changed = doInitialization(F);
|
||||
for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I)
|
||||
Changed |= runOnBasicBlock(*I);
|
||||
return Changed;
|
||||
return Changed | doFinalization(F);
|
||||
}
|
||||
|
||||
// To run directly on the basic block, we initialize, runOnBasicBlock, then
|
||||
// finalize.
|
||||
//
|
||||
bool BasicBlockPass::run(BasicBlock &BB) {
|
||||
Module &M = *BB.getParent()->getParent();
|
||||
return doInitialization(M) | runOnBasicBlock(BB) | doFinalization(M);
|
||||
Function &F = *BB.getParent();
|
||||
Module &M = *F.getParent();
|
||||
return doInitialization(M) | doInitialization(F) | runOnBasicBlock(BB) |
|
||||
doFinalization(F) | doFinalization(M);
|
||||
}
|
||||
|
||||
void BasicBlockPass::addToPassManager(PassManagerT<Function> *PM,
|
||||
|
@ -525,7 +525,9 @@ template<> struct PassManagerTraits<BasicBlock> : public BasicBlockPass {
|
||||
|
||||
// Implement the BasicBlockPass interface...
|
||||
virtual bool doInitialization(Module &M);
|
||||
virtual bool doInitialization(Function &F);
|
||||
virtual bool runOnBasicBlock(BasicBlock &BB);
|
||||
virtual bool doFinalization(Function &F);
|
||||
virtual bool doFinalization(Module &M);
|
||||
|
||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
@ -657,10 +659,24 @@ inline bool PassManagerTraits<BasicBlock>::doInitialization(Module &M) {
|
||||
return Changed;
|
||||
}
|
||||
|
||||
inline bool PassManagerTraits<BasicBlock>::doInitialization(Function &F) {
|
||||
bool Changed = false;
|
||||
for (unsigned i = 0, e = ((PMType*)this)->Passes.size(); i != e; ++i)
|
||||
((PMType*)this)->Passes[i]->doInitialization(F);
|
||||
return Changed;
|
||||
}
|
||||
|
||||
inline bool PassManagerTraits<BasicBlock>::runOnBasicBlock(BasicBlock &BB) {
|
||||
return ((PMType*)this)->runOnUnit(&BB);
|
||||
}
|
||||
|
||||
inline bool PassManagerTraits<BasicBlock>::doFinalization(Function &F) {
|
||||
bool Changed = false;
|
||||
for (unsigned i = 0, e = ((PMType*)this)->Passes.size(); i != e; ++i)
|
||||
((PMType*)this)->Passes[i]->doFinalization(F);
|
||||
return Changed;
|
||||
}
|
||||
|
||||
inline bool PassManagerTraits<BasicBlock>::doFinalization(Module &M) {
|
||||
bool Changed = false;
|
||||
for (unsigned i = 0, e = ((PMType*)this)->Passes.size(); i != e; ++i)
|
||||
|
Loading…
x
Reference in New Issue
Block a user