llvm.org GIT mirror llvm / 6052eef
Fix a pretty scary bug I introduced into the always inliner with a single missing character. Somehow, this had gone untested. I've added tests for returns-twice logic specifically with the always-inliner that would have caught this, and fixed the bug. Thanks to Matt for the careful review and spotting this!!! =D git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153832 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 8 years ago
2 changed file(s) with 39 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
8282
8383 // Disallow calls which expose returns-twice to a function not previously
8484 // attributed as such.
85 if (ReturnsTwice && CS.isCall() &&
85 if (!ReturnsTwice && CS.isCall() &&
8686 cast(CS.getInstruction())->canReturnTwice())
8787 return false;
8888 }
3939 call void @inner2( i32 %N )
4040 ret void
4141 }
42
43 declare i32 @a() returns_twice
44 declare i32 @b() returns_twice
45
46 define i32 @inner3() alwaysinline {
47 entry:
48 %call = call i32 @a() returns_twice
49 %add = add nsw i32 1, %call
50 ret i32 %add
51 }
52 define i32 @outer3() {
53 entry:
54 ; CHECK: @outer3
55 ; CHECK-NOT: call i32 @a
56 ; CHECK: ret
57
58 %call = call i32 @inner3()
59 %add = add nsw i32 1, %call
60 ret i32 %add
61 }
62
63 define i32 @inner4() alwaysinline returns_twice {
64 entry:
65 %call = call i32 @b() returns_twice
66 %add = add nsw i32 1, %call
67 ret i32 %add
68 }
69
70 define i32 @outer4() {
71 entry:
72 ; CHECK: @outer4
73 ; CHECK: call i32 @b()
74 ; CHECK: ret
75
76 %call = call i32 @inner4() returns_twice
77 %add = add nsw i32 1, %call
78 ret i32 %add
79 }