diff options
author | Chris Lattner <sabre@nondot.org> | 2003-11-10 04:42:13 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-11-10 04:42:13 +0000 |
commit | aeef8c70f07d14f811baf5838a2d4b2f04ee95c1 (patch) | |
tree | 8f5befef26cc6e3cbe42521231372092b26bd053 /include/llvm | |
parent | 33e0a7575dd1b200ad75d6216f135389e2b0575a (diff) | |
download | external_llvm-aeef8c70f07d14f811baf5838a2d4b2f04ee95c1.zip external_llvm-aeef8c70f07d14f811baf5838a2d4b2f04ee95c1.tar.gz external_llvm-aeef8c70f07d14f811baf5838a2d4b2f04ee95c1.tar.bz2 |
Include forms of SplitCriticalEdge which work correctly with pred/succ iterators
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9856 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/Transforms/Utils/BasicBlockUtils.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/llvm/Transforms/Utils/BasicBlockUtils.h b/include/llvm/Transforms/Utils/BasicBlockUtils.h index 78e5592..4630d53 100644 --- a/include/llvm/Transforms/Utils/BasicBlockUtils.h +++ b/include/llvm/Transforms/Utils/BasicBlockUtils.h @@ -18,6 +18,7 @@ // FIXME: Move to this file: BasicBlock::removePredecessor, BB::splitBasicBlock #include "llvm/BasicBlock.h" +#include "llvm/Support/CFG.h" class Instruction; class Pass; @@ -64,4 +65,22 @@ bool isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum); /// bool SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P = 0); +inline bool SplitCriticalEdge(BasicBlock *BB, succ_iterator SI, Pass *P = 0) { + return SplitCriticalEdge(BB->getTerminator(), SI.getSuccessorIndex(), P); +} + +/// SplitCriticalEdge - If the edge from *PI to BB is not critical, return +/// false. Otherwise, split all edges between the two blocks and return true. +/// This updates all of the same analyses as the other SplitCriticalEdge +/// function. +inline bool SplitCriticalEdge(BasicBlock *Succ, pred_iterator PI, Pass *P = 0) { + BasicBlock *Pred = *PI; + bool MadeChange = false; + for (succ_iterator SI = succ_begin(Pred), E = succ_end(Pred); SI != E; ++SI) + if (*SI == Succ) + MadeChange |= SplitCriticalEdge(Pred, SI, P); + return MadeChange; +} + + #endif |