[llvm-commits] [llvm] r91147 - in /llvm/trunk: include/llvm/Analysis/LoopInfo.h lib/Analysis/LoopInfo.cpp test/Transforms/IndVarSimplify/indirectbr.ll

Dan Gohman gohman at apple.com
Fri Dec 11 12:05:23 PST 2009


Author: djg
Date: Fri Dec 11 14:05:23 2009
New Revision: 91147

URL: http://llvm.org/viewvc/llvm-project?rev=91147&view=rev
Log:
Make getUniqueExitBlocks's precondition assert more precise, to
avoid spurious failures. This fixes PR5758.

Added:
    llvm/trunk/test/Transforms/IndVarSimplify/indirectbr.ll
Modified:
    llvm/trunk/include/llvm/Analysis/LoopInfo.h
    llvm/trunk/lib/Analysis/LoopInfo.cpp

Modified: llvm/trunk/include/llvm/Analysis/LoopInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopInfo.h?rev=91147&r1=91146&r2=91147&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Analysis/LoopInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/LoopInfo.h Fri Dec 11 14:05:23 2009
@@ -568,7 +568,7 @@
 
   /// getUniqueExitBlocks - Return all unique successor blocks of this loop. 
   /// These are the blocks _outside of the current loop_ which are branched to.
-  /// This assumes that loop is in canonical form.
+  /// This assumes that loop exits are in canonical form.
   ///
   void getUniqueExitBlocks(SmallVectorImpl<BasicBlock *> &ExitBlocks) const;
 

Modified: llvm/trunk/lib/Analysis/LoopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopInfo.cpp?rev=91147&r1=91146&r2=91147&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/LoopInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/LoopInfo.cpp Fri Dec 11 14:05:23 2009
@@ -316,12 +316,12 @@
 
 /// getUniqueExitBlocks - Return all unique successor blocks of this loop.
 /// These are the blocks _outside of the current loop_ which are branched to.
-/// This assumes that loop is in canonical form.
+/// This assumes that loop exits are in canonical form.
 ///
 void
 Loop::getUniqueExitBlocks(SmallVectorImpl<BasicBlock *> &ExitBlocks) const {
-  assert(isLoopSimplifyForm() &&
-         "getUniqueExitBlocks assumes the loop is in canonical form!");
+  assert(hasDedicatedExits() &&
+         "getUniqueExitBlocks assumes the loop has canonical form exits!");
 
   // Sort the blocks vector so that we can use binary search to do quick
   // lookups.

Added: llvm/trunk/test/Transforms/IndVarSimplify/indirectbr.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/indirectbr.ll?rev=91147&view=auto

==============================================================================
--- llvm/trunk/test/Transforms/IndVarSimplify/indirectbr.ll (added)
+++ llvm/trunk/test/Transforms/IndVarSimplify/indirectbr.ll Fri Dec 11 14:05:23 2009
@@ -0,0 +1,22 @@
+; RUN: opt < %s -indvars -S -disable-output
+; PR5758
+
+define zeroext i1 @foo() nounwind {
+entry:
+  indirectbr i8* undef, [label %"202", label %"133"]
+
+"132":                                            ; preds = %"133"
+  %0 = add i32 %1, 1                              ; <i32> [#uses=1]
+  br label %"133"
+
+"133":                                            ; preds = %"132", %entry
+  %1 = phi i32 [ %0, %"132" ], [ 0, %entry ]      ; <i32> [#uses=2]
+  %2 = icmp eq i32 %1, 4                          ; <i1> [#uses=1]
+  br i1 %2, label %"134", label %"132"
+
+"134":                                            ; preds = %"133"
+  ret i1 true
+
+"202":                                            ; preds = %entry
+  ret i1 false
+}





More information about the llvm-commits mailing list