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