[llvm-commits] [llvm] r92679 - in /llvm/trunk: lib/Transforms/Scalar/Reassociate.cpp test/Transforms/Reassociate/crash.ll

Chris Lattner sabre at nondot.org
Mon Jan 4 20:55:40 PST 2010


Author: lattner
Date: Mon Jan  4 22:55:35 2010
New Revision: 92679

URL: http://llvm.org/viewvc/llvm-project?rev=92679&view=rev
Log:
fix an infinite loop in reassociate building emacs.

Added:
    llvm/trunk/test/Transforms/Reassociate/crash.ll
Modified:
    llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp?rev=92679&r1=92678&r2=92679&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Mon Jan  4 22:55:35 2010
@@ -932,6 +932,10 @@
     if (BI->getOpcode() == Instruction::Sub) {
       if (ShouldBreakUpSubtract(BI)) {
         BI = BreakUpSubtract(BI, ValueRankMap);
+        // Reset the BBI iterator in case BreakUpSubtract changed the
+        // instruction it points to.
+        BBI = BI;
+        ++BBI;
         MadeChange = true;
       } else if (BinaryOperator::isNeg(BI)) {
         // Otherwise, this is a negation.  See if the operand is a multiply tree

Added: llvm/trunk/test/Transforms/Reassociate/crash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Reassociate/crash.ll?rev=92679&view=auto

==============================================================================
--- llvm/trunk/test/Transforms/Reassociate/crash.ll (added)
+++ llvm/trunk/test/Transforms/Reassociate/crash.ll Mon Jan  4 22:55:35 2010
@@ -0,0 +1,15 @@
+; RUN: opt -reassociate -disable-output %s
+
+
+; rdar://7507855
+define fastcc i32 @test() nounwind {
+entry:
+  %cond = select i1 undef, i32 1, i32 -1          ; <i32> [#uses=2]
+  br label %for.cond
+
+for.cond:                                         ; preds = %for.body, %entry
+  %sub889 = sub i32 undef, undef                  ; <i32> [#uses=1]
+  %sub891 = sub i32 %sub889, %cond                ; <i32> [#uses=0]
+  %add896 = sub i32 0, %cond                      ; <i32> [#uses=0]
+  ret i32 undef
+}





More information about the llvm-commits mailing list