[llvm-commits] [llvm] r90708 - in /llvm/trunk: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/crash.ll
Chris Lattner
sabre at nondot.org
Sun Dec 6 09:17:23 PST 2009
Author: lattner
Date: Sun Dec 6 11:17:23 2009
New Revision: 90708
URL: http://llvm.org/viewvc/llvm-project?rev=90708&view=rev
Log:
fix PR5698
Modified:
llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
llvm/trunk/test/Transforms/JumpThreading/crash.ll
Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=90708&r1=90707&r2=90708&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Sun Dec 6 11:17:23 2009
@@ -718,6 +718,11 @@
if (PredSI->getSuccessor(PredCase) != DestBB &&
DestSI->getSuccessor(i) != DestBB)
continue;
+
+ // Do not forward this if it already goes to this destination, this would
+ // be an infinite loop.
+ if (PredSI->getSuccessor(PredCase) == DestSucc)
+ continue;
// Otherwise, we're safe to make the change. Make sure that the edge from
// DestSI to DestSucc is not critical and has no PHI nodes.
Modified: llvm/trunk/test/Transforms/JumpThreading/crash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/crash.ll?rev=90708&r1=90707&r2=90708&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/JumpThreading/crash.ll (original)
+++ llvm/trunk/test/Transforms/JumpThreading/crash.ll Sun Dec 6 11:17:23 2009
@@ -212,3 +212,25 @@
bb61:
ret void
}
+
+
+; PR5698
+define void @test7(i32 %x) {
+tailrecurse:
+ switch i32 %x, label %return [
+ i32 2, label %bb2
+ i32 3, label %bb
+ ]
+
+bb:
+ switch i32 %x, label %return [
+ i32 2, label %bb2
+ i32 3, label %tailrecurse
+ ]
+
+bb2:
+ ret void
+
+return:
+ ret void
+}
More information about the llvm-commits
mailing list