[llvm-commits] CVS: llvm/lib/VMCore/Pass.cpp PassManagerT.h
Chris Lattner
lattner at cs.uiuc.edu
Thu Sep 12 12:08:07 PDT 2002
Changes in directory llvm/lib/VMCore:
Pass.cpp updated: 1.35 -> 1.36
PassManagerT.h updated: 1.26 -> 1.27
---
Log message:
Add a new BasicBlockPass::doInitialization/Finalization(Function &) pair of
methods that may be useful for BasicBlockPasses.
---
Diffs of the changes:
Index: llvm/lib/VMCore/Pass.cpp
diff -u llvm/lib/VMCore/Pass.cpp:1.35 llvm/lib/VMCore/Pass.cpp:1.36
--- llvm/lib/VMCore/Pass.cpp:1.35 Fri Aug 30 15:23:45 2002
+++ llvm/lib/VMCore/Pass.cpp Thu Sep 12 12:06:40 2002
@@ -341,18 +341,20 @@
// 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,
Index: llvm/lib/VMCore/PassManagerT.h
diff -u llvm/lib/VMCore/PassManagerT.h:1.26 llvm/lib/VMCore/PassManagerT.h:1.27
--- llvm/lib/VMCore/PassManagerT.h:1.26 Sun Sep 8 14:00:07 2002
+++ llvm/lib/VMCore/PassManagerT.h Thu Sep 12 12:06:40 2002
@@ -525,7 +525,9 @@
// 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,8 +659,22 @@
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) {
More information about the llvm-commits
mailing list