Skip to content

Commit b67ea33

Browse files
committed
Add missing test file from r329855
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_60@329857 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 7ce61db commit b67ea33

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
; RUN: opt < %s -ipsccp -S | FileCheck %s
2+
; PR36485
3+
; musttail call result can\'t be replaced with a constant, unless the call
4+
; can be removed
5+
6+
declare i32 @external()
7+
8+
define i8* @start(i8 %v) {
9+
%c1 = icmp eq i8 %v, 0
10+
br i1 %c1, label %true, label %false
11+
true:
12+
; CHECK: %ca = musttail call i8* @side_effects(i8 %v)
13+
; CHECK: ret i8* %ca
14+
%ca = musttail call i8* @side_effects(i8 %v)
15+
ret i8* %ca
16+
false:
17+
%c2 = icmp eq i8 %v, 1
18+
br i1 %c2, label %c2_true, label %c2_false
19+
c2_true:
20+
; CHECK: %ca1 = musttail call i8* @no_side_effects(i8 %v)
21+
; CHECK: ret i8* %ca1
22+
%ca1 = musttail call i8* @no_side_effects(i8 %v)
23+
ret i8* %ca1
24+
c2_false:
25+
; CHECK: %ca2 = musttail call i8* @dont_zap_me(i8 %v)
26+
; CHECK: ret i8* %ca2
27+
%ca2 = musttail call i8* @dont_zap_me(i8 %v)
28+
ret i8* %ca2
29+
}
30+
31+
define internal i8* @side_effects(i8 %v) {
32+
%i1 = call i32 @external()
33+
34+
; since this goes back to `start` the SCPP should be see that the return value
35+
; is always `null`.
36+
; The call can't be removed due to `external` call above, though.
37+
38+
; CHECK: %ca = musttail call i8* @start(i8 %v)
39+
%ca = musttail call i8* @start(i8 %v)
40+
41+
; Thus the result must be returned anyway
42+
; CHECK: ret i8* %ca
43+
ret i8* %ca
44+
}
45+
46+
define internal i8* @no_side_effects(i8 %v) readonly nounwind {
47+
; CHECK: ret i8* null
48+
ret i8* null
49+
}
50+
51+
define internal i8* @dont_zap_me(i8 %v) {
52+
%i1 = call i32 @external()
53+
54+
; The call to this function cannot be removed due to side effects. Thus the
55+
; return value should stay as it is, and should not be zapped.
56+
; CHECK: ret i8* null
57+
ret i8* null
58+
}

0 commit comments

Comments
 (0)