Fix issues (infinite loop and/or crash) with self-referential instructions, for

example degenerate phi nodes and binops that use themselves in unreachable code.
Thanks to Charles Davis for the testcase that uncovered this can of worms.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158508 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan Sands
2012-06-15 08:37:50 +00:00
parent 8e58b3e9b8
commit cd117f736c
2 changed files with 39 additions and 6 deletions

View File

@@ -83,3 +83,28 @@ define i128 @foo() {
%mul = mul i128 0, 0
ret i128 %mul
}
define void @infinite_loop() {
entry:
br label %loop
loop:
%x = phi i32 [undef, %entry], [%x, %loop]
%dead = add i32 %x, 0
br label %loop
unreachable1:
%y1 = add i32 %y1, 0
%z1 = add i32 %y1, 0
ret void
unreachable2:
%y2 = add i32 %y2, 0
%z2 = add i32 %y2, %y2
ret void
unreachable3:
%y3 = add i32 %y3, %y3
%z3 = add i32 %y3, 0
ret void
unreachable4:
%y4 = add i32 %y4, %y4
%z4 = add i32 %y4, %y4
ret void
}