[llvm-commits] [llvm] r129203 - in /llvm/trunk: lib/Transforms/Scalar/LoopRotation.cpp test/Transforms/LoopRotate/crash.ll

Chris Lattner sabre at nondot.org
Sat Apr 9 00:25:58 PDT 2011


Author: lattner
Date: Sat Apr  9 02:25:58 2011
New Revision: 129203

URL: http://llvm.org/viewvc/llvm-project?rev=129203&view=rev
Log:
fix PR9523, a crash in looprotate on a non-canonical loop made out of indirectbr.

Modified:
    llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp
    llvm/trunk/test/Transforms/LoopRotate/crash.ll

Modified: llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp?rev=129203&r1=129202&r2=129203&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp Sat Apr  9 02:25:58 2011
@@ -184,7 +184,11 @@
   // Now, this loop is suitable for rotation.
   BasicBlock *OrigPreheader = L->getLoopPreheader();
   BasicBlock *OrigLatch = L->getLoopLatch();
-  assert(OrigPreheader && OrigLatch && "Loop not in canonical form?");
+  
+  // If the loop could not be converted to canonical form, it must have an
+  // indirectbr in it, just give up.
+  if (OrigPreheader == 0 || OrigLatch == 0)
+    return false;
 
   // Anything ScalarEvolution may know about this loop or the PHI nodes
   // in its header will soon be invalidated.

Modified: llvm/trunk/test/Transforms/LoopRotate/crash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopRotate/crash.ll?rev=129203&r1=129202&r2=129203&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LoopRotate/crash.ll (original)
+++ llvm/trunk/test/Transforms/LoopRotate/crash.ll Sat Apr  9 02:25:58 2011
@@ -137,3 +137,19 @@
 }
 
 
+
+
+; PR9523 - Non-canonical loop.
+define void @test7(i8* %P) nounwind {
+entry:
+  indirectbr i8* %P, [label %"3", label %"5"]
+
+"3":                                              ; preds = %"4", %entry
+  br i1 undef, label %"5", label %"4"
+
+"4":                                              ; preds = %"3"
+  br label %"3"
+
+"5":                                              ; preds = %"3", %entry
+  ret void
+}





More information about the llvm-commits mailing list