summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-12-06 17:17:23 +0000
committerChris Lattner <sabre@nondot.org>2009-12-06 17:17:23 +0000
commit6d6f10fe919eaf8391bae3df6ff8278158f11c4c (patch)
tree771a9f56c485b599ee3f39e46a8c2952c4f1cd8a
parent7a141b3d887c185599169cb28ce284358c110c09 (diff)
downloadbcm5719-llvm-6d6f10fe919eaf8391bae3df6ff8278158f11c4c.tar.gz
bcm5719-llvm-6d6f10fe919eaf8391bae3df6ff8278158f11c4c.zip
fix PR5698
llvm-svn: 90708
-rw-r--r--llvm/lib/Transforms/Scalar/JumpThreading.cpp5
-rw-r--r--llvm/test/Transforms/JumpThreading/crash.ll22
2 files changed, 27 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
index 1b93f3441e4..d58b9c9de01 100644
--- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -718,6 +718,11 @@ bool JumpThreading::ProcessSwitchOnDuplicateCond(BasicBlock *PredBB,
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.
diff --git a/llvm/test/Transforms/JumpThreading/crash.ll b/llvm/test/Transforms/JumpThreading/crash.ll
index b2b9d69e16d..361ec6cfb5a 100644
--- a/llvm/test/Transforms/JumpThreading/crash.ll
+++ b/llvm/test/Transforms/JumpThreading/crash.ll
@@ -212,3 +212,25 @@ bb13:
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
+}
OpenPOWER on IntegriCloud