[llvm-commits] CVS: llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h

Chris Lattner lattner at cs.uiuc.edu
Sat May 13 19:01:34 PDT 2006



Changes in directory llvm/include/llvm/Transforms/Utils:

BasicBlockUtils.h updated: 1.12 -> 1.13
---
Log message:

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.


---
Diffs of the changes:  (+11 -3)

 BasicBlockUtils.h |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)


Index: llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
diff -u llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h:1.12 llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h:1.13
--- llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h:1.12	Sat May 13 13:11:32 2006
+++ llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h	Sat May 13 21:01:22 2006
@@ -74,7 +74,8 @@
 /// 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 @@
   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
 






More information about the llvm-commits mailing list