aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Transforms/Utils/BasicBlockUtils.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-05-14 02:01:22 +0000
committerChris Lattner <sabre@nondot.org>2006-05-14 02:01:22 +0000
commitfd50080fe2b8608075cee0a77af0bb61c2edf9b2 (patch)
treee4a23f3fb82e8b97e65ca69fce895531f7cfb9b4 /include/llvm/Transforms/Utils/BasicBlockUtils.h
parentca960c9946094deab036101b755c5bbed1cd9f86 (diff)
This is a proper fix for the compiler warning. A termination condition is
not needed, as it can never be reached: an edge must exist. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28282 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Transforms/Utils/BasicBlockUtils.h')
-rw-r--r--include/llvm/Transforms/Utils/BasicBlockUtils.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/include/llvm/Transforms/Utils/BasicBlockUtils.h b/include/llvm/Transforms/Utils/BasicBlockUtils.h
index 4c12c704d2..3853901b30 100644
--- a/include/llvm/Transforms/Utils/BasicBlockUtils.h
+++ b/include/llvm/Transforms/Utils/BasicBlockUtils.h
@@ -74,7 +74,8 @@ inline bool SplitCriticalEdge(BasicBlock *BB, succ_iterator SI, Pass *P = 0) {
/// 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.
+/// function. If P is specified, it updates the analyses
+/// described above.
inline bool SplitCriticalEdge(BasicBlock *Succ, pred_iterator PI, Pass *P = 0) {
bool MadeChange = false;
TerminatorInst *TI = (*PI)->getTerminator();
@@ -84,12 +85,19 @@ inline bool SplitCriticalEdge(BasicBlock *Succ, pred_iterator PI, Pass *P = 0) {
return MadeChange;
}
+/// SplitCriticalEdge - If an edge from Src to Dst is critical, split the edge
+/// and return true, otherwise return false. This method requires that there be
+/// an edge between the two blocks. If P is specified, it updates the analyses
+/// described above.
inline bool SplitCriticalEdge(BasicBlock *Src, BasicBlock *Dst, Pass *P = 0) {
TerminatorInst *TI = Src->getTerminator();
- for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i)
+ unsigned i = 0;
+ while (1) {
+ assert(i != TI->getNumSuccessors() && "Edge doesn't exist!");
if (TI->getSuccessor(i) == Dst)
return SplitCriticalEdge(TI, i, P);
- return false;
+ ++i;
+ }
}
} // End llvm namespace