• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -correlated-propagation -S | FileCheck %s
2
3define void @test1(i8* %ptr) {
4; CHECK: test1
5  %A = load i8, i8* %ptr
6  br label %bb
7bb:
8  icmp ne i8* %ptr, null
9; CHECK-NOT: icmp
10  ret void
11}
12
13define void @test2(i8* %ptr) {
14; CHECK: test2
15  store i8 0, i8* %ptr
16  br label %bb
17bb:
18  icmp ne i8* %ptr, null
19; CHECK-NOT: icmp
20  ret void
21}
22
23define void @test3() {
24; CHECK: test3
25  %ptr = alloca i8
26  br label %bb
27bb:
28  icmp ne i8* %ptr, null
29; CHECK-NOT: icmp
30  ret void
31}
32
33declare void @llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1)
34define void @test4(i8* %dest, i8* %src) {
35; CHECK: test4
36  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 1, i32 1, i1 false)
37  br label %bb
38bb:
39  icmp ne i8* %dest, null
40  icmp ne i8* %src, null
41; CHECK-NOT: icmp
42  ret void
43}
44
45declare void @llvm.memmove.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1)
46define void @test5(i8* %dest, i8* %src) {
47; CHECK: test5
48  call void @llvm.memmove.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 1, i32 1, i1 false)
49  br label %bb
50bb:
51  icmp ne i8* %dest, null
52  icmp ne i8* %src, null
53; CHECK-NOT: icmp
54  ret void
55}
56
57declare void @llvm.memset.p0i8.i32(i8*, i8, i32, i32, i1)
58define void @test6(i8* %dest) {
59; CHECK: test6
60  call void @llvm.memset.p0i8.i32(i8* %dest, i8 255, i32 1, i32 1, i1 false)
61  br label %bb
62bb:
63  icmp ne i8* %dest, null
64; CHECK-NOT: icmp
65  ret void
66}
67
68define void @test7(i8* %dest, i8* %src, i32 %len) {
69; CHECK: test7
70  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 %len, i32 1, i1 false)
71  br label %bb
72bb:
73  %KEEP1 = icmp ne i8* %dest, null
74; CHECK: KEEP1
75  %KEEP2 = icmp ne i8* %src, null
76; CHECK: KEEP2
77  ret void
78}
79
80declare void @llvm.memcpy.p1i8.p1i8.i32(i8 addrspace(1) *, i8 addrspace(1) *, i32, i32, i1)
81define void @test8(i8 addrspace(1) * %dest, i8 addrspace(1) * %src) {
82; CHECK: test8
83  call void @llvm.memcpy.p1i8.p1i8.i32(i8 addrspace(1) * %dest, i8 addrspace(1) * %src, i32 1, i32 1, i1 false)
84  br label %bb
85bb:
86  %KEEP1 = icmp ne i8 addrspace(1) * %dest, null
87; CHECK: KEEP1
88  %KEEP2 = icmp ne i8 addrspace(1) * %src, null
89; CHECK: KEEP2
90  ret void
91}
92
93define void @test9(i8* %dest, i8* %src) {
94; CHECK: test9
95  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 1, i32 1, i1 true)
96  br label %bb
97bb:
98  %KEEP1 = icmp ne i8* %dest, null
99; CHECK: KEEP1
100  %KEEP2 = icmp ne i8* %src, null
101; CHECK: KEEP2
102  ret void
103}
104
105declare void @test10_helper(i8* %arg1, i8* %arg2, i32 %non-pointer-arg)
106define void @test10(i8* %arg1, i8* %arg2, i32 %non-pointer-arg) {
107; CHECK-LABEL: @test10
108entry:
109  %is_null = icmp eq i8* %arg1, null
110  br i1 %is_null, label %null, label %non_null
111
112non_null:
113  call void @test10_helper(i8* %arg1, i8* %arg2, i32 %non-pointer-arg)
114  ; CHECK: call void @test10_helper(i8* nonnull %arg1, i8* %arg2, i32 %non-pointer-arg)
115  br label %null
116
117null:
118  call void @test10_helper(i8* %arg1, i8* %arg2, i32 %non-pointer-arg)
119  ; CHECK: call void @test10_helper(i8* %arg1, i8* %arg2, i32 %non-pointer-arg)
120  ret void
121}
122
123declare void @test11_helper(i8* %arg)
124define void @test11(i8* %arg1, i8** %arg2) {
125; CHECK-LABEL: @test11
126entry:
127  %is_null = icmp eq i8* %arg1, null
128  br i1 %is_null, label %null, label %non_null
129
130non_null:
131  br label %merge
132
133null:
134  %another_arg = alloca i8
135  br label %merge
136
137merge:
138  %merged_arg = phi i8* [%another_arg, %null], [%arg1, %non_null]
139  call void @test11_helper(i8* %merged_arg)
140  ; CHECK: call void @test11_helper(i8* nonnull %merged_arg)
141  ret void
142}
143
144declare void @test12_helper(i8* %arg)
145define void @test12(i8* %arg1, i8** %arg2) {
146; CHECK-LABEL: @test12
147entry:
148  %is_null = icmp eq i8* %arg1, null
149  br i1 %is_null, label %null, label %non_null
150
151non_null:
152  br label %merge
153
154null:
155  %another_arg = load i8*, i8** %arg2, !nonnull !{}
156  br label %merge
157
158merge:
159  %merged_arg = phi i8* [%another_arg, %null], [%arg1, %non_null]
160  call void @test12_helper(i8* %merged_arg)
161  ; CHECK: call void @test12_helper(i8* nonnull %merged_arg)
162  ret void
163}
164