Skip to content
Snippets Groups Projects
Commit 6f34e317 authored by Chris Lattner's avatar Chris Lattner
Browse files

Fix PR3353, infinitely jump threading an infinite loop make from switches.

llvm-svn: 62529
parent 740e9870
No related branches found
No related tags found
No related merge requests found
......@@ -419,6 +419,11 @@ bool JumpThreading::ProcessBranchOnDuplicateCond(BasicBlock *PredBB,
/// switches out of repeated 'if' conditions.
bool JumpThreading::ProcessSwitchOnDuplicateCond(BasicBlock *PredBB,
BasicBlock *DestBB) {
// Can't thread edge to self.
if (PredBB == DestBB)
return false;
SwitchInst *PredSI = cast<SwitchInst>(PredBB->getTerminator());
SwitchInst *DestSI = cast<SwitchInst>(DestBB->getTerminator());
......
; RUN: llvm-as < %s | opt -jump-threading | llvm-dis
; PR3353
define i32 @test(i8 %X) {
entry:
%Y = add i8 %X, 1
%Z = add i8 %Y, 1
br label %bb33.i
bb33.i: ; preds = %bb33.i, %bb32.i
switch i8 %Y, label %bb32.i [
i8 39, label %bb35.split.i
i8 13, label %bb33.i
]
bb35.split.i:
ret i32 5
bb32.i:
ret i32 1
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment