1 ; RUN: opt -mtriple=i386-pc-linux-gnu -aa-pipeline=basic-aa -passes=inferattrs,aa-eval -print-all-alias-modref-info -disable-output 2>&1 %s | FileCheck %s
3 ; CHECK-LABEL: Function: test_memcmp_const_size
4 ; CHECK: Just Ref: Ptr: i8* %a <-> %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 4)
5 ; CHECK-NEXT: Just Ref: Ptr: i8* %b <-> %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 4)
6 ; CHECK-NEXT: Just Ref: Ptr: i8* %a.gep.1 <-> %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 4)
7 ; CHECK-NEXT: NoModRef: Ptr: i8* %a.gep.5 <-> %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 4)
8 ; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.1 <-> %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 4)
9 ; CHECK-NEXT: NoModRef: Ptr: i8* %b.gep.5 <-> %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 4)
10 define i32 @test_memcmp_const_size(i8* noalias %a, i8* noalias %b) {
14 %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 4)
15 %a.gep.1 = getelementptr i8, i8* %a, i32 1
16 store i8 0, i8* %a.gep.1
17 %a.gep.5 = getelementptr i8, i8* %a, i32 5
18 store i8 1, i8* %a.gep.5
19 %b.gep.1 = getelementptr i8, i8* %b, i32 1
20 store i8 2, i8* %b.gep.1
21 %b.gep.5 = getelementptr i8, i8* %b, i32 5
22 store i8 3, i8* %b.gep.5
26 ; CHECK-LABEL: Function: test_memcmp_variable_size
27 ; CHECK: Just Ref: Ptr: i8* %a <-> %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 %n)
28 ; CHECK-NEXT: Just Ref: Ptr: i8* %b <-> %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 %n)
29 ; CHECK-NEXT: Just Ref: Ptr: i8* %a.gep.1 <-> %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 %n)
30 ; CHECK-NEXT: Just Ref: Ptr: i8* %a.gep.5 <-> %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 %n)
31 ; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.1 <-> %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 %n)
32 ; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.5 <-> %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 %n)
33 define i32 @test_memcmp_variable_size(i8* noalias %a, i8* noalias %b, i64 %n) {
37 %res = tail call i32 @memcmp(i8* %a, i8* %b, i64 %n)
38 %a.gep.1 = getelementptr i8, i8* %a, i32 1
39 store i8 0, i8* %a.gep.1
40 %a.gep.5 = getelementptr i8, i8* %a, i32 5
41 store i8 1, i8* %a.gep.5
42 %b.gep.1 = getelementptr i8, i8* %b, i32 1
43 store i8 2, i8* %b.gep.1
44 %b.gep.5 = getelementptr i8, i8* %b, i32 5
45 store i8 3, i8* %b.gep.5
49 declare i32 @memcmp(i8*, i8*, i64)
50 declare i32 @bcmp(i8*, i8*, i64)
52 ; CHECK-LABEL: Function: test_bcmp_const_size
53 ; CHECK: Just Ref: Ptr: i8* %a <-> %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 4)
54 ; CHECK-NEXT: Just Ref: Ptr: i8* %b <-> %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 4)
55 ; CHECK-NEXT: Just Ref: Ptr: i8* %a.gep.1 <-> %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 4)
56 ; CHECK-NEXT: NoModRef: Ptr: i8* %a.gep.5 <-> %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 4)
57 ; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.1 <-> %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 4)
58 ; CHECK-NEXT: NoModRef: Ptr: i8* %b.gep.5 <-> %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 4)
59 define i32 @test_bcmp_const_size(i8* noalias %a, i8* noalias %b) {
63 %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 4)
64 %a.gep.1 = getelementptr i8, i8* %a, i32 1
65 store i8 0, i8* %a.gep.1
66 %a.gep.5 = getelementptr i8, i8* %a, i32 5
67 store i8 1, i8* %a.gep.5
68 %b.gep.1 = getelementptr i8, i8* %b, i32 1
69 store i8 2, i8* %b.gep.1
70 %b.gep.5 = getelementptr i8, i8* %b, i32 5
71 store i8 3, i8* %b.gep.5
75 ; CHECK-LABEL: Function: test_bcmp_variable_size
76 ; CHECK: Just Ref: Ptr: i8* %a <-> %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 %n)
77 ; CHECK-NEXT: Just Ref: Ptr: i8* %b <-> %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 %n)
78 ; CHECK-NEXT: Just Ref: Ptr: i8* %a.gep.1 <-> %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 %n)
79 ; CHECK-NEXT: Just Ref: Ptr: i8* %a.gep.5 <-> %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 %n)
80 ; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.1 <-> %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 %n)
81 ; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.5 <-> %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 %n)
82 define i32 @test_bcmp_variable_size(i8* noalias %a, i8* noalias %b, i64 %n) {
86 %res = tail call i32 @bcmp(i8* %a, i8* %b, i64 %n)
87 %a.gep.1 = getelementptr i8, i8* %a, i32 1
88 store i8 0, i8* %a.gep.1
89 %a.gep.5 = getelementptr i8, i8* %a, i32 5
90 store i8 1, i8* %a.gep.5
91 %b.gep.1 = getelementptr i8, i8* %b, i32 1
92 store i8 2, i8* %b.gep.1
93 %b.gep.5 = getelementptr i8, i8* %b, i32 5
94 store i8 3, i8* %b.gep.5
98 declare i8* @memchr(i8*, i32, i64)
100 ; CHECK-LABEL: Function: test_memchr_const_size
101 ; CHECK: Just Ref: Ptr: i8* %res <-> %res = call i8* @memchr(i8* %a, i32 42, i64 4)
102 ; CHECK-NEXT: Just Ref: Ptr: i8* %a.gep.1 <-> %res = call i8* @memchr(i8* %a, i32 42, i64 4)
103 ; CHECK-NEXT: NoModRef: Ptr: i8* %a.gep.5 <-> %res = call i8* @memchr(i8* %a, i32 42, i64 4)
104 define i8* @test_memchr_const_size(i8* noalias %a) {
106 %res = call i8* @memchr(i8* %a, i32 42, i64 4)
108 %a.gep.1 = getelementptr i8, i8* %a, i32 1
109 store i8 0, i8* %a.gep.1
110 %a.gep.5 = getelementptr i8, i8* %a, i32 5
111 store i8 1, i8* %a.gep.5
115 declare i8* @memccpy(i8*, i8*, i32, i64)
117 ; CHECK-LABEL: Function: test_memccpy_const_size
118 ; CHECK: Just Mod: Ptr: i8* %a <-> %res = call i8* @memccpy(i8* %a, i8* %b, i32 42, i64 4)
119 ; CHECK-NEXT: Just Ref: Ptr: i8* %b <-> %res = call i8* @memccpy(i8* %a, i8* %b, i32 42, i64 4)
120 ; CHECK-NEXT: Just Mod: Ptr: i8* %res <-> %res = call i8* @memccpy(i8* %a, i8* %b, i32 42, i64 4)
121 ; CHECK-NEXT: Just Mod: Ptr: i8* %a.gep.1 <-> %res = call i8* @memccpy(i8* %a, i8* %b, i32 42, i64 4)
122 ; CHECK-NEXT: NoModRef: Ptr: i8* %a.gep.5 <-> %res = call i8* @memccpy(i8* %a, i8* %b, i32 42, i64 4)
123 ; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.1 <-> %res = call i8* @memccpy(i8* %a, i8* %b, i32 42, i64 4)
124 ; CHECK-NEXT: NoModRef: Ptr: i8* %b.gep.5 <-> %res = call i8* @memccpy(i8* %a, i8* %b, i32 42, i64 4)
126 define i8* @test_memccpy_const_size(i8* noalias %a, i8* noalias %b) {
130 %res = call i8* @memccpy(i8* %a, i8* %b, i32 42, i64 4)
132 %a.gep.1 = getelementptr i8, i8* %a, i32 1
133 store i8 0, i8* %a.gep.1
134 %a.gep.5 = getelementptr i8, i8* %a, i32 5
135 store i8 1, i8* %a.gep.5
136 %b.gep.1 = getelementptr i8, i8* %b, i32 1
137 store i8 2, i8* %b.gep.1
138 %b.gep.5 = getelementptr i8, i8* %b, i32 5
139 store i8 3, i8* %b.gep.5
143 declare i8* @strcat(i8*, i8*)
145 define i8* @test_strcat_read_write_after(i8* noalias %a, i8* noalias %b) {
146 ; CHECK-LABEL: Function: test_strcat_read_write_after
147 ; CHECK: NoModRef: Ptr: i8* %a <-> %res = tail call i8* @strcat(i8* %a.gep.1, i8* %b.gep.1)
148 ; CHECK-NEXT: NoModRef: Ptr: i8* %b <-> %res = tail call i8* @strcat(i8* %a.gep.1, i8* %b.gep.1)
149 ; CHECK-NEXT: Both ModRef: Ptr: i8* %a.gep.1 <-> %res = tail call i8* @strcat(i8* %a.gep.1, i8* %b.gep.1)
150 ; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.1 <-> %res = tail call i8* @strcat(i8* %a.gep.1, i8* %b.gep.1)
151 ; CHECK-NEXT: Both ModRef: Ptr: i8* %res <-> %res = tail call i8* @strcat(i8* %a.gep.1, i8* %b.gep.1)
152 ; CHECK-NEXT: Both ModRef: Ptr: i8* %a.gep.5 <-> %res = tail call i8* @strcat(i8* %a.gep.1, i8* %b.gep.1)
153 ; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.5 <-> %res = tail call i8* @strcat(i8* %a.gep.1, i8* %b.gep.1)
158 %a.gep.1 = getelementptr i8, i8* %a, i32 1
159 load i8, i8* %a.gep.1
160 %b.gep.1 = getelementptr i8, i8* %b, i32 1
161 load i8, i8* %b.gep.1
162 %res = tail call i8* @strcat(i8* %a.gep.1, i8* %b.gep.1)
164 %a.gep.5 = getelementptr i8, i8* %a, i32 5
165 store i8 1, i8* %a.gep.5
166 %b.gep.5 = getelementptr i8, i8* %b, i32 5
167 store i8 3, i8* %b.gep.5
171 declare i8* @strncat(i8*, i8*, i64)
173 define i8* @test_strncat_read_write_after(i8* noalias %a, i8* noalias %b, i64 %n) {
174 ; CHECK-LABEL: Function: test_strncat_read_write_after
175 ; CHECK: NoModRef: Ptr: i8* %a <-> %res = tail call i8* @strncat(i8* %a.gep.1, i8* %b.gep.1, i64 %n)
176 ; CHECK-NEXT: NoModRef: Ptr: i8* %b <-> %res = tail call i8* @strncat(i8* %a.gep.1, i8* %b.gep.1, i64 %n)
177 ; CHECK-NEXT: Both ModRef: Ptr: i8* %a.gep.1 <-> %res = tail call i8* @strncat(i8* %a.gep.1, i8* %b.gep.1, i64 %n)
178 ; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.1 <-> %res = tail call i8* @strncat(i8* %a.gep.1, i8* %b.gep.1, i64 %n)
179 ; CHECK-NEXT: Both ModRef: Ptr: i8* %res <-> %res = tail call i8* @strncat(i8* %a.gep.1, i8* %b.gep.1, i64 %n)
180 ; CHECK-NEXT: Both ModRef: Ptr: i8* %a.gep.5 <-> %res = tail call i8* @strncat(i8* %a.gep.1, i8* %b.gep.1, i64 %n)
181 ; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.5 <-> %res = tail call i8* @strncat(i8* %a.gep.1, i8* %b.gep.1, i64 %n)
186 %a.gep.1 = getelementptr i8, i8* %a, i32 1
187 load i8, i8* %a.gep.1
188 %b.gep.1 = getelementptr i8, i8* %b, i32 1
189 load i8, i8* %b.gep.1
190 %res = tail call i8* @strncat(i8* %a.gep.1, i8* %b.gep.1, i64 %n)
192 %a.gep.5 = getelementptr i8, i8* %a, i32 5
193 store i8 1, i8* %a.gep.5
194 %b.gep.5 = getelementptr i8, i8* %b, i32 5
195 store i8 3, i8* %b.gep.5
199 declare i8* @strcpy(i8*, i8*)
201 define i8* @test_strcpy_read_write_after(i8* noalias %a, i8* noalias %b) {
202 ; CHECK-LABEL: Function: test_strcpy_read_write_after
203 ; CHECK: NoModRef: Ptr: i8* %a <-> %res = tail call i8* @strcpy(i8* %a.gep.1, i8* %b.gep.1)
204 ; CHECK-NEXT: NoModRef: Ptr: i8* %b <-> %res = tail call i8* @strcpy(i8* %a.gep.1, i8* %b.gep.1)
205 ; CHECK-NEXT: Just Mod: Ptr: i8* %a.gep.1 <-> %res = tail call i8* @strcpy(i8* %a.gep.1, i8* %b.gep.1)
206 ; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.1 <-> %res = tail call i8* @strcpy(i8* %a.gep.1, i8* %b.gep.1)
207 ; CHECK-NEXT: Just Mod: Ptr: i8* %res <-> %res = tail call i8* @strcpy(i8* %a.gep.1, i8* %b.gep.1)
208 ; CHECK-NEXT: Just Mod: Ptr: i8* %a.gep.5 <-> %res = tail call i8* @strcpy(i8* %a.gep.1, i8* %b.gep.1)
209 ; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.5 <-> %res = tail call i8* @strcpy(i8* %a.gep.1, i8* %b.gep.1)
214 %a.gep.1 = getelementptr i8, i8* %a, i32 1
215 load i8, i8* %a.gep.1
216 %b.gep.1 = getelementptr i8, i8* %b, i32 1
217 load i8, i8* %b.gep.1
218 %res = tail call i8* @strcpy(i8* %a.gep.1, i8* %b.gep.1)
220 %a.gep.5 = getelementptr i8, i8* %a, i32 5
221 store i8 1, i8* %a.gep.5
222 %b.gep.5 = getelementptr i8, i8* %b, i32 5
223 store i8 3, i8* %b.gep.5
227 declare i8* @strncpy(i8*, i8*, i64)
229 define i8* @test_strncpy_const_size(i8* noalias %a, i8* noalias %b) {
230 ; CHECK-LABEL: Function: test_strncpy_const_size
231 ; CHECK: Just Mod: Ptr: i8* %a <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 4)
232 ; CHECK-NEXT: Just Ref: Ptr: i8* %b <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 4)
233 ; CHECK-NEXT: Just Mod: Ptr: i8* %res <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 4)
234 ; CHECK-NEXT: Just Mod: Ptr: i8* %a.gep.1 <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 4)
235 ; CHECK-NEXT: NoModRef: Ptr: i8* %a.gep.5 <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 4)
236 ; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.1 <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 4)
237 ; CHECK-NEXT: NoModRef: Ptr: i8* %b.gep.5 <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 4)
242 %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 4)
244 %a.gep.1 = getelementptr i8, i8* %a, i32 1
245 store i8 0, i8* %a.gep.1
246 %a.gep.5 = getelementptr i8, i8* %a, i32 5
247 store i8 1, i8* %a.gep.5
248 %b.gep.1 = getelementptr i8, i8* %b, i32 1
249 store i8 2, i8* %b.gep.1
250 %b.gep.5 = getelementptr i8, i8* %b, i32 5
251 store i8 3, i8* %b.gep.5
255 define i8* @test_strncpy_variable_size(i8* noalias %a, i8* noalias %b, i64 %n) {
256 ; CHECK-LABEL: Function: test_strncpy_variable_size
257 ; CHECK: Just Mod: Ptr: i8* %a <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 %n)
258 ; CHECK-NEXT: Just Ref: Ptr: i8* %b <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 %n)
259 ; CHECK-NEXT: Just Mod: Ptr: i8* %res <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 %n)
260 ; CHECK-NEXT: Just Mod: Ptr: i8* %a.gep.1 <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 %n)
261 ; CHECK-NEXT: Just Mod: Ptr: i8* %a.gep.5 <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 %n)
262 ; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.1 <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 %n)
263 ; CHECK-NEXT: Just Ref: Ptr: i8* %b.gep.5 <-> %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 %n)
268 %res = tail call i8* @strncpy(i8* %a, i8* %b, i64 %n)
270 %a.gep.1 = getelementptr i8, i8* %a, i32 1
271 store i8 0, i8* %a.gep.1
272 %a.gep.5 = getelementptr i8, i8* %a, i32 5
273 store i8 1, i8* %a.gep.5
274 %b.gep.1 = getelementptr i8, i8* %b, i32 1
275 store i8 2, i8* %b.gep.1
276 %b.gep.5 = getelementptr i8, i8* %b, i32 5
277 store i8 3, i8* %b.gep.5
281 declare i8* @__memset_chk(i8* writeonly, i32, i64, i64)
283 ; CHECK-LABEL: Function: test_memset_chk_const_size
284 define i8* @test_memset_chk_const_size(i8* noalias %a, i64 %n) {
285 ; CHECK: Just Mod: Ptr: i8* %a <-> %res = tail call i8* @__memset_chk(i8* %a, i32 0, i64 4, i64 %n)
286 ; CHECK-NEXT: Just Mod: Ptr: i8* %res <-> %res = tail call i8* @__memset_chk(i8* %a, i32 0, i64 4, i64 %n)
287 ; CHECK-NEXT: Just Mod: Ptr: i8* %a.gep.1 <-> %res = tail call i8* @__memset_chk(i8* %a, i32 0, i64 4, i64 %n)
288 ; CHECK-NEXT: NoModRef: Ptr: i8* %a.gep.5 <-> %res = tail call i8* @__memset_chk(i8* %a, i32 0, i64 4, i64 %n)
292 %res = tail call i8* @__memset_chk(i8* %a, i32 0, i64 4, i64 %n)
294 %a.gep.1 = getelementptr i8, i8* %a, i32 1
295 store i8 0, i8* %a.gep.1
296 %a.gep.5 = getelementptr i8, i8* %a, i32 5
297 store i8 1, i8* %a.gep.5
301 define i8* @test_memset_chk_variable_size(i8* noalias %a, i64 %n.1, i64 %n.2) {
302 ; CHECK-LABEL: Function: test_memset_chk_variable_size
303 ; CHECK: Just Mod: Ptr: i8* %a <-> %res = tail call i8* @__memset_chk(i8* %a, i32 0, i64 %n.1, i64 %n.2)
304 ; CHECK-NEXT: Just Mod: Ptr: i8* %res <-> %res = tail call i8* @__memset_chk(i8* %a, i32 0, i64 %n.1, i64 %n.2)
305 ; CHECK-NEXT: Just Mod: Ptr: i8* %a.gep.1 <-> %res = tail call i8* @__memset_chk(i8* %a, i32 0, i64 %n.1, i64 %n.2)
306 ; CHECK-NEXT: Just Mod: Ptr: i8* %a.gep.5 <-> %res = tail call i8* @__memset_chk(i8* %a, i32 0, i64 %n.1, i64 %n.2)
310 %res = tail call i8* @__memset_chk(i8* %a, i32 0, i64 %n.1, i64 %n.2)
312 %a.gep.1 = getelementptr i8, i8* %a, i32 1
313 store i8 0, i8* %a.gep.1
314 %a.gep.5 = getelementptr i8, i8* %a, i32 5
315 store i8 1, i8* %a.gep.5