diff options
author | Chris Lattner <sabre@nondot.org> | 2002-10-08 19:12:08 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-10-08 19:12:08 +0000 |
commit | 7ca266fe1f211afaec0bdb3b8d8e8a98d2c78fbc (patch) | |
tree | 3c798ef902c7ef845227b88b70a6af769c9fe11e | |
parent | de013f53a797400104444416b980ea2e586611e4 (diff) |
Expose new "recalculate" method from dominatorset
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4074 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Analysis/Dominators.h | 5 | ||||
-rw-r--r-- | lib/VMCore/Dominators.cpp | 12 |
2 files changed, 13 insertions, 4 deletions
diff --git a/include/llvm/Analysis/Dominators.h b/include/llvm/Analysis/Dominators.h index 81f0eaf76d..815be7dfaf 100644 --- a/include/llvm/Analysis/Dominators.h +++ b/include/llvm/Analysis/Dominators.h @@ -128,6 +128,11 @@ struct DominatorSet : public DominatorSetBase { virtual bool runOnFunction(Function &F); + /// recalculate - This method may be called by external passes that modify the + /// CFG and then need dominator information recalculated. This method is + /// obviously really slow, so it should be avoided if at all possible. + void recalculate(); + // getAnalysisUsage - This simply provides a dominator set virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp index 37e7d48c28..a9479aa635 100644 --- a/lib/VMCore/Dominators.cpp +++ b/lib/VMCore/Dominators.cpp @@ -92,10 +92,15 @@ void DominatorSet::calculateDominatorsFromBlock(BasicBlock *RootBB) { // specified function. // bool DominatorSet::runOnFunction(Function &F) { - Doms.clear(); // Reset from the last time we were run... Root = &F.getEntryNode(); assert(pred_begin(Root) == pred_end(Root) && "Root node has predecessors in function!"); + recalculate(); + return false; +} + +void DominatorSet::recalculate() { + Doms.clear(); // Reset from the last time we were run... // Calculate dominator sets for the reachable basic blocks... calculateDominatorsFromBlock(Root); @@ -106,11 +111,10 @@ bool DominatorSet::runOnFunction(Function &F) { // extra pass over the function, calculating dominator information for // unreachable blocks. // - for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) + Function *F = Root->getParent(); + for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) if (Doms[I].count(I) == 0) calculateDominatorsFromBlock(I); - - return false; } |