xref: /llvm-project/llvm/test/Analysis/BasicAA/libfuncs.ll (revision e39f6c1844fab59c638d8059a6cf139adb42279a)
1; RUN: opt -mtriple=x86_64-pc-linux-gnu -aa-pipeline=basic-aa -passes=inferattrs,aa-eval -print-all-alias-modref-info -disable-output 2>&1 %s | FileCheck %s
2
3; CHECK-LABEL: Function: test_memcmp_const_size
4; CHECK:      Just Ref:  Ptr: i8* %a	<->  %res = tail call i32 @memcmp(ptr %a, ptr %b, i64 4)
5; CHECK-NEXT: Just Ref:  Ptr: i8* %b	<->  %res = tail call i32 @memcmp(ptr %a, ptr %b, i64 4)
6; CHECK-NEXT: Just Ref:  Ptr: i8* %a.gep.1	<->  %res = tail call i32 @memcmp(ptr %a, ptr %b, i64 4)
7; CHECK-NEXT: NoModRef:  Ptr: i8* %a.gep.5	<->  %res = tail call i32 @memcmp(ptr %a, ptr %b, i64 4)
8; CHECK-NEXT: Just Ref:  Ptr: i8* %b.gep.1	<->  %res = tail call i32 @memcmp(ptr %a, ptr %b, i64 4)
9; CHECK-NEXT: NoModRef:  Ptr: i8* %b.gep.5	<->  %res = tail call i32 @memcmp(ptr %a, ptr %b, i64 4)
10define i32 @test_memcmp_const_size(ptr noalias %a, ptr noalias %b) {
11entry:
12  load i8, ptr %a
13  load i8, ptr %b
14  %res = tail call i32 @memcmp(ptr %a, ptr %b, i64 4)
15  %a.gep.1 = getelementptr i8, ptr %a, i32 1
16  store i8 0, ptr %a.gep.1
17  %a.gep.5 = getelementptr i8, ptr %a, i32 5
18  store i8 1, ptr %a.gep.5
19  %b.gep.1 = getelementptr i8, ptr %b, i32 1
20  store i8 2, ptr %b.gep.1
21  %b.gep.5 = getelementptr i8, ptr %b, i32 5
22  store i8 3, ptr %b.gep.5
23  ret i32 %res
24}
25
26; CHECK-LABEL: Function: test_memcmp_variable_size
27; CHECK:      Just Ref:  Ptr: i8* %a	<->  %res = tail call i32 @memcmp(ptr %a, ptr %b, i64 %n)
28; CHECK-NEXT: Just Ref:  Ptr: i8* %b	<->  %res = tail call i32 @memcmp(ptr %a, ptr %b, i64 %n)
29; CHECK-NEXT: Just Ref:  Ptr: i8* %a.gep.1	<->  %res = tail call i32 @memcmp(ptr %a, ptr %b, i64 %n)
30; CHECK-NEXT: Just Ref:  Ptr: i8* %a.gep.5	<->  %res = tail call i32 @memcmp(ptr %a, ptr %b, i64 %n)
31; CHECK-NEXT: Just Ref:  Ptr: i8* %b.gep.1	<->  %res = tail call i32 @memcmp(ptr %a, ptr %b, i64 %n)
32; CHECK-NEXT: Just Ref:  Ptr: i8* %b.gep.5	<->  %res = tail call i32 @memcmp(ptr %a, ptr %b, i64 %n)
33define i32 @test_memcmp_variable_size(ptr noalias %a, ptr noalias %b, i64 %n) {
34entry:
35  load i8, ptr %a
36  load i8, ptr %b
37  %res = tail call i32 @memcmp(ptr %a, ptr %b, i64 %n)
38  %a.gep.1 = getelementptr i8, ptr %a, i32 1
39  store i8 0, ptr %a.gep.1
40  %a.gep.5 = getelementptr i8, ptr %a, i32 5
41  store i8 1, ptr %a.gep.5
42  %b.gep.1 = getelementptr i8, ptr %b, i32 1
43  store i8 2, ptr %b.gep.1
44  %b.gep.5 = getelementptr i8, ptr %b, i32 5
45  store i8 3, ptr %b.gep.5
46  ret i32 %res
47}
48
49declare i32 @memcmp(ptr, ptr, i64)
50declare i32 @bcmp(ptr, ptr, i64)
51
52; CHECK-LABEL: Function: test_bcmp_const_size
53; CHECK:      Just Ref:  Ptr: i8* %a	<->  %res = tail call i32 @bcmp(ptr %a, ptr %b, i64 4)
54; CHECK-NEXT: Just Ref:  Ptr: i8* %b	<->  %res = tail call i32 @bcmp(ptr %a, ptr %b, i64 4)
55; CHECK-NEXT: Just Ref:  Ptr: i8* %a.gep.1	<->  %res = tail call i32 @bcmp(ptr %a, ptr %b, i64 4)
56; CHECK-NEXT: NoModRef:  Ptr: i8* %a.gep.5	<->  %res = tail call i32 @bcmp(ptr %a, ptr %b, i64 4)
57; CHECK-NEXT: Just Ref:  Ptr: i8* %b.gep.1	<->  %res = tail call i32 @bcmp(ptr %a, ptr %b, i64 4)
58; CHECK-NEXT: NoModRef:  Ptr: i8* %b.gep.5	<->  %res = tail call i32 @bcmp(ptr %a, ptr %b, i64 4)
59define i32 @test_bcmp_const_size(ptr noalias %a, ptr noalias %b) {
60entry:
61  load i8, ptr %a
62  load i8, ptr %b
63  %res = tail call i32 @bcmp(ptr %a, ptr %b, i64 4)
64  %a.gep.1 = getelementptr i8, ptr %a, i32 1
65  store i8 0, ptr %a.gep.1
66  %a.gep.5 = getelementptr i8, ptr %a, i32 5
67  store i8 1, ptr %a.gep.5
68  %b.gep.1 = getelementptr i8, ptr %b, i32 1
69  store i8 2, ptr %b.gep.1
70  %b.gep.5 = getelementptr i8, ptr %b, i32 5
71  store i8 3, ptr %b.gep.5
72  ret i32 %res
73}
74
75; CHECK-LABEL: Function: test_bcmp_variable_size
76; CHECK:      Just Ref:  Ptr: i8* %a	<->  %res = tail call i32 @bcmp(ptr %a, ptr %b, i64 %n)
77; CHECK-NEXT: Just Ref:  Ptr: i8* %b	<->  %res = tail call i32 @bcmp(ptr %a, ptr %b, i64 %n)
78; CHECK-NEXT: Just Ref:  Ptr: i8* %a.gep.1	<->  %res = tail call i32 @bcmp(ptr %a, ptr %b, i64 %n)
79; CHECK-NEXT: Just Ref:  Ptr: i8* %a.gep.5	<->  %res = tail call i32 @bcmp(ptr %a, ptr %b, i64 %n)
80; CHECK-NEXT: Just Ref:  Ptr: i8* %b.gep.1	<->  %res = tail call i32 @bcmp(ptr %a, ptr %b, i64 %n)
81; CHECK-NEXT: Just Ref:  Ptr: i8* %b.gep.5	<->  %res = tail call i32 @bcmp(ptr %a, ptr %b, i64 %n)
82define i32 @test_bcmp_variable_size(ptr noalias %a, ptr noalias %b, i64 %n) {
83entry:
84  load i8, ptr %a
85  load i8, ptr %b
86  %res = tail call i32 @bcmp(ptr %a, ptr %b, i64 %n)
87  %a.gep.1 = getelementptr i8, ptr %a, i32 1
88  store i8 0, ptr %a.gep.1
89  %a.gep.5 = getelementptr i8, ptr %a, i32 5
90  store i8 1, ptr %a.gep.5
91  %b.gep.1 = getelementptr i8, ptr %b, i32 1
92  store i8 2, ptr %b.gep.1
93  %b.gep.5 = getelementptr i8, ptr %b, i32 5
94  store i8 3, ptr %b.gep.5
95  ret i32 %res
96}
97
98declare ptr @memchr(ptr, i32, i64)
99
100; CHECK-LABEL: Function: test_memchr_const_size
101; CHECK: Just Ref:  Ptr: i8* %res      <->  %res = call ptr @memchr(ptr %a, i32 42, i64 4)
102; CHECK-NEXT: Just Ref:  Ptr: i8* %a.gep.1  <->  %res = call ptr @memchr(ptr %a, i32 42, i64 4)
103; CHECK-NEXT: NoModRef:  Ptr: i8* %a.gep.5  <->  %res = call ptr @memchr(ptr %a, i32 42, i64 4)
104define ptr @test_memchr_const_size(ptr noalias %a) {
105entry:
106  %res = call ptr @memchr(ptr %a, i32 42, i64 4)
107  load i8, ptr %res
108  %a.gep.1 = getelementptr i8, ptr %a, i32 1
109  store i8 0, ptr %a.gep.1
110  %a.gep.5 = getelementptr i8, ptr %a, i32 5
111  store i8 1, ptr %a.gep.5
112  ret ptr %res
113}
114
115declare ptr @memccpy(ptr, ptr, i32, i64)
116
117; CHECK-LABEL: Function: test_memccpy_const_size
118; CHECK:      Just Mod:  Ptr: i8* %a        <->  %res = call ptr @memccpy(ptr %a, ptr %b, i32 42, i64 4)
119; CHECK-NEXT: Just Ref:  Ptr: i8* %b        <->  %res = call ptr @memccpy(ptr %a, ptr %b, i32 42, i64 4)
120; CHECK-NEXT: Just Mod:  Ptr: i8* %res      <->  %res = call ptr @memccpy(ptr %a, ptr %b, i32 42, i64 4)
121; CHECK-NEXT: Just Mod:  Ptr: i8* %a.gep.1  <->  %res = call ptr @memccpy(ptr %a, ptr %b, i32 42, i64 4)
122; CHECK-NEXT: NoModRef:  Ptr: i8* %a.gep.5  <->  %res = call ptr @memccpy(ptr %a, ptr %b, i32 42, i64 4)
123; CHECK-NEXT: Just Ref:  Ptr: i8* %b.gep.1  <->  %res = call ptr @memccpy(ptr %a, ptr %b, i32 42, i64 4)
124; CHECK-NEXT: NoModRef:  Ptr: i8* %b.gep.5  <->  %res = call ptr @memccpy(ptr %a, ptr %b, i32 42, i64 4)
125
126define ptr @test_memccpy_const_size(ptr noalias %a, ptr noalias %b) {
127entry:
128  load i8, ptr %a
129  load i8, ptr %b
130  %res = call ptr @memccpy(ptr %a, ptr %b, i32 42, i64 4)
131  load i8, ptr %res
132  %a.gep.1 = getelementptr i8, ptr %a, i32 1
133  store i8 0, ptr %a.gep.1
134  %a.gep.5 = getelementptr i8, ptr %a, i32 5
135  store i8 1, ptr %a.gep.5
136  %b.gep.1 = getelementptr i8, ptr %b, i32 1
137  store i8 2, ptr %b.gep.1
138  %b.gep.5 = getelementptr i8, ptr %b, i32 5
139  store i8 3, ptr %b.gep.5
140  ret ptr %res
141}
142
143declare ptr @strcat(ptr, ptr)
144
145define ptr @test_strcat_read_write_after(ptr noalias %a, ptr noalias %b) {
146; CHECK-LABEL: Function: test_strcat_read_write_after
147; CHECK:       NoModRef:  Ptr: i8* %a	<->  %res = tail call ptr @strcat(ptr %a.gep.1, ptr %b.gep.1)
148; CHECK-NEXT:  NoModRef:  Ptr: i8* %b	<->  %res = tail call ptr @strcat(ptr %a.gep.1, ptr %b.gep.1)
149; CHECK-NEXT:  Both ModRef:  Ptr: i8* %a.gep.1	<->  %res = tail call ptr @strcat(ptr %a.gep.1, ptr %b.gep.1)
150; CHECK-NEXT:  Just Ref:  Ptr: i8* %b.gep.1	<->  %res = tail call ptr @strcat(ptr %a.gep.1, ptr %b.gep.1)
151; CHECK-NEXT:  Both ModRef:  Ptr: i8* %res	<->  %res = tail call ptr @strcat(ptr %a.gep.1, ptr %b.gep.1)
152; CHECK-NEXT:  Both ModRef:  Ptr: i8* %a.gep.5	<->  %res = tail call ptr @strcat(ptr %a.gep.1, ptr %b.gep.1)
153; CHECK-NEXT:  Just Ref:  Ptr: i8* %b.gep.5	<->  %res = tail call ptr @strcat(ptr %a.gep.1, ptr %b.gep.1)
154;
155entry:
156  store i8 0, ptr %a
157  store i8 2, ptr %b
158  %a.gep.1 = getelementptr i8, ptr %a, i32 1
159  load i8, ptr %a.gep.1
160  %b.gep.1 = getelementptr i8, ptr %b, i32 1
161  load i8, ptr %b.gep.1
162  %res = tail call ptr @strcat(ptr %a.gep.1, ptr %b.gep.1)
163  load i8, ptr %res
164  %a.gep.5 = getelementptr i8, ptr %a, i32 5
165  store i8 1, ptr %a.gep.5
166  %b.gep.5 = getelementptr i8, ptr %b, i32 5
167  store i8 3, ptr %b.gep.5
168  ret ptr %res
169}
170
171declare ptr @strncat(ptr, ptr, i64)
172
173define ptr @test_strncat_read_write_after(ptr noalias %a, ptr noalias %b, i64 %n) {
174; CHECK-LABEL: Function: test_strncat_read_write_after
175; CHECK:       NoModRef:  Ptr: i8* %a	<->  %res = tail call ptr @strncat(ptr %a.gep.1, ptr %b.gep.1, i64 %n)
176; CHECK-NEXT:  NoModRef:  Ptr: i8* %b	<->  %res = tail call ptr @strncat(ptr %a.gep.1, ptr %b.gep.1, i64 %n)
177; CHECK-NEXT:  Both ModRef:  Ptr: i8* %a.gep.1	<->  %res = tail call ptr @strncat(ptr %a.gep.1, ptr %b.gep.1, i64 %n)
178; CHECK-NEXT:  Just Ref:  Ptr: i8* %b.gep.1	<->  %res = tail call ptr @strncat(ptr %a.gep.1, ptr %b.gep.1, i64 %n)
179; CHECK-NEXT:  Both ModRef:  Ptr: i8* %res	<->  %res = tail call ptr @strncat(ptr %a.gep.1, ptr %b.gep.1, i64 %n)
180; CHECK-NEXT:  Both ModRef:  Ptr: i8* %a.gep.5	<->  %res = tail call ptr @strncat(ptr %a.gep.1, ptr %b.gep.1, i64 %n)
181; CHECK-NEXT:  Just Ref:  Ptr: i8* %b.gep.5	<->  %res = tail call ptr @strncat(ptr %a.gep.1, ptr %b.gep.1, i64 %n)
182;
183entry:
184  store i8 0, ptr %a
185  store i8 2, ptr %b
186  %a.gep.1 = getelementptr i8, ptr %a, i32 1
187  load i8, ptr %a.gep.1
188  %b.gep.1 = getelementptr i8, ptr %b, i32 1
189  load i8, ptr %b.gep.1
190  %res = tail call ptr @strncat(ptr %a.gep.1, ptr %b.gep.1, i64 %n)
191  load i8, ptr %res
192  %a.gep.5 = getelementptr i8, ptr %a, i32 5
193  store i8 1, ptr %a.gep.5
194  %b.gep.5 = getelementptr i8, ptr %b, i32 5
195  store i8 3, ptr %b.gep.5
196  ret ptr %res
197}
198
199declare ptr @strcpy(ptr, ptr)
200
201define ptr @test_strcpy_read_write_after(ptr noalias %a, ptr noalias %b) {
202; CHECK-LABEL: Function: test_strcpy_read_write_after
203; CHECK:       NoModRef:  Ptr: i8* %a	<->  %res = tail call ptr @strcpy(ptr %a.gep.1, ptr %b.gep.1)
204; CHECK-NEXT:  NoModRef:  Ptr: i8* %b	<->  %res = tail call ptr @strcpy(ptr %a.gep.1, ptr %b.gep.1)
205; CHECK-NEXT:  Just Mod:  Ptr: i8* %a.gep.1	<->  %res = tail call ptr @strcpy(ptr %a.gep.1, ptr %b.gep.1)
206; CHECK-NEXT:  Just Ref:  Ptr: i8* %b.gep.1	<->  %res = tail call ptr @strcpy(ptr %a.gep.1, ptr %b.gep.1)
207; CHECK-NEXT:  Just Mod:  Ptr: i8* %res	<->  %res = tail call ptr @strcpy(ptr %a.gep.1, ptr %b.gep.1)
208; CHECK-NEXT:  Just Mod:  Ptr: i8* %a.gep.5	<->  %res = tail call ptr @strcpy(ptr %a.gep.1, ptr %b.gep.1)
209; CHECK-NEXT:  Just Ref:  Ptr: i8* %b.gep.5	<->  %res = tail call ptr @strcpy(ptr %a.gep.1, ptr %b.gep.1)
210;
211entry:
212  store i8 0, ptr %a
213  store i8 2, ptr %b
214  %a.gep.1 = getelementptr i8, ptr %a, i32 1
215  load i8, ptr %a.gep.1
216  %b.gep.1 = getelementptr i8, ptr %b, i32 1
217  load i8, ptr %b.gep.1
218  %res = tail call ptr @strcpy(ptr %a.gep.1, ptr %b.gep.1)
219  load i8, ptr %res
220  %a.gep.5 = getelementptr i8, ptr %a, i32 5
221  store i8 1, ptr %a.gep.5
222  %b.gep.5 = getelementptr i8, ptr %b, i32 5
223  store i8 3, ptr %b.gep.5
224  ret ptr %res
225}
226
227declare ptr @strncpy(ptr, ptr, i64)
228
229define ptr @test_strncpy_const_size(ptr noalias %a, ptr noalias %b) {
230; CHECK-LABEL: Function: test_strncpy_const_size
231; CHECK:       Just Mod:  Ptr: i8* %a	<->  %res = tail call ptr @strncpy(ptr %a, ptr %b, i64 4)
232; CHECK-NEXT:  Just Ref:  Ptr: i8* %b	<->  %res = tail call ptr @strncpy(ptr %a, ptr %b, i64 4)
233; CHECK-NEXT:  Just Mod:  Ptr: i8* %res	<->  %res = tail call ptr @strncpy(ptr %a, ptr %b, i64 4)
234; CHECK-NEXT:  Just Mod:  Ptr: i8* %a.gep.1	<->  %res = tail call ptr @strncpy(ptr %a, ptr %b, i64 4)
235; CHECK-NEXT:  NoModRef:  Ptr: i8* %a.gep.5	<->  %res = tail call ptr @strncpy(ptr %a, ptr %b, i64 4)
236; CHECK-NEXT:  Just Ref:  Ptr: i8* %b.gep.1	<->  %res = tail call ptr @strncpy(ptr %a, ptr %b, i64 4)
237; CHECK-NEXT:  NoModRef:  Ptr: i8* %b.gep.5	<->  %res = tail call ptr @strncpy(ptr %a, ptr %b, i64 4)
238;
239entry:
240  load i8, ptr %a
241  load i8, ptr %b
242  %res = tail call ptr @strncpy(ptr %a, ptr %b, i64 4)
243  load i8, ptr %res
244  %a.gep.1 = getelementptr i8, ptr %a, i32 1
245  store i8 0, ptr %a.gep.1
246  %a.gep.5 = getelementptr i8, ptr %a, i32 5
247  store i8 1, ptr %a.gep.5
248  %b.gep.1 = getelementptr i8, ptr %b, i32 1
249  store i8 2, ptr %b.gep.1
250  %b.gep.5 = getelementptr i8, ptr %b, i32 5
251  store i8 3, ptr %b.gep.5
252  ret ptr %res
253}
254
255define ptr @test_strncpy_variable_size(ptr noalias %a, ptr noalias %b, i64 %n) {
256; CHECK-LABEL: Function: test_strncpy_variable_size
257; CHECK:       Just Mod:  Ptr: i8* %a	<->  %res = tail call ptr @strncpy(ptr %a, ptr %b, i64 %n)
258; CHECK-NEXT:  Just Ref:  Ptr: i8* %b	<->  %res = tail call ptr @strncpy(ptr %a, ptr %b, i64 %n)
259; CHECK-NEXT:  Just Mod:  Ptr: i8* %res	<->  %res = tail call ptr @strncpy(ptr %a, ptr %b, i64 %n)
260; CHECK-NEXT:  Just Mod:  Ptr: i8* %a.gep.1	<->  %res = tail call ptr @strncpy(ptr %a, ptr %b, i64 %n)
261; CHECK-NEXT:  Just Mod:  Ptr: i8* %a.gep.5	<->  %res = tail call ptr @strncpy(ptr %a, ptr %b, i64 %n)
262; CHECK-NEXT:  Just Ref:  Ptr: i8* %b.gep.1	<->  %res = tail call ptr @strncpy(ptr %a, ptr %b, i64 %n)
263; CHECK-NEXT:  Just Ref:  Ptr: i8* %b.gep.5	<->  %res = tail call ptr @strncpy(ptr %a, ptr %b, i64 %n)
264;
265entry:
266  load i8, ptr %a
267  load i8, ptr %b
268  %res = tail call ptr @strncpy(ptr %a, ptr %b, i64 %n)
269  load i8, ptr %res
270  %a.gep.1 = getelementptr i8, ptr %a, i32 1
271  store i8 0, ptr %a.gep.1
272  %a.gep.5 = getelementptr i8, ptr %a, i32 5
273  store i8 1, ptr %a.gep.5
274  %b.gep.1 = getelementptr i8, ptr %b, i32 1
275  store i8 2, ptr %b.gep.1
276  %b.gep.5 = getelementptr i8, ptr %b, i32 5
277  store i8 3, ptr %b.gep.5
278  ret ptr %res
279}
280
281declare ptr @__memset_chk(ptr writeonly, i32, i64, i64)
282
283; CHECK-LABEL: Function: test_memset_chk_const_size
284define ptr @test_memset_chk_const_size(ptr noalias %a, i64 %n) {
285; CHECK:       Just Mod:  Ptr: i8* %a	<->  %res = tail call ptr @__memset_chk(ptr %a, i32 0, i64 4, i64 %n)
286; CHECK-NEXT:  Just Mod:  Ptr: i8* %res	<->  %res = tail call ptr @__memset_chk(ptr %a, i32 0, i64 4, i64 %n)
287; CHECK-NEXT:  Just Mod:  Ptr: i8* %a.gep.1	<->  %res = tail call ptr @__memset_chk(ptr %a, i32 0, i64 4, i64 %n)
288; CHECK-NEXT:  NoModRef:  Ptr: i8* %a.gep.5	<->  %res = tail call ptr @__memset_chk(ptr %a, i32 0, i64 4, i64 %n)
289;
290entry:
291  load i8, ptr %a
292  %res = tail call ptr @__memset_chk(ptr %a, i32 0, i64 4, i64 %n)
293  load i8, ptr %res
294  %a.gep.1 = getelementptr i8, ptr %a, i32 1
295  store i8 0, ptr %a.gep.1
296  %a.gep.5 = getelementptr i8, ptr %a, i32 5
297  store i8 1, ptr %a.gep.5
298  ret ptr %res
299}
300
301define ptr @test_memset_chk_variable_size(ptr 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 ptr @__memset_chk(ptr %a, i32 0, i64 %n.1, i64 %n.2)
304; CHECK-NEXT:  Just Mod:  Ptr: i8* %res	<->  %res = tail call ptr @__memset_chk(ptr %a, i32 0, i64 %n.1, i64 %n.2)
305; CHECK-NEXT:  Just Mod:  Ptr: i8* %a.gep.1	<->  %res = tail call ptr @__memset_chk(ptr %a, i32 0, i64 %n.1, i64 %n.2)
306; CHECK-NEXT:  Just Mod:  Ptr: i8* %a.gep.5	<->  %res = tail call ptr @__memset_chk(ptr %a, i32 0, i64 %n.1, i64 %n.2)
307;
308entry:
309  load i8, ptr %a
310  %res = tail call ptr @__memset_chk(ptr %a, i32 0, i64 %n.1, i64 %n.2)
311  load i8, ptr %res
312  %a.gep.1 = getelementptr i8, ptr %a, i32 1
313  store i8 0, ptr %a.gep.1
314  %a.gep.5 = getelementptr i8, ptr %a, i32 5
315  store i8 1, ptr %a.gep.5
316  ret ptr %res
317}
318
319declare ptr @__memcpy_chk(ptr writeonly, ptr readonly, i64, i64)
320
321define ptr @test_memcpy_chk_const_size(ptr noalias %a, ptr noalias %b, i64 %n) {
322; CHECK-LABEL: Function: test_memcpy_chk_const_size
323; CHECK:       Just Mod:  Ptr: i8* %a	<->  %res = tail call ptr @__memcpy_chk(ptr %a, ptr %b, i64 4, i64 %n)
324; CHECK-NEXT:  Just Mod:  Ptr: i8* %res	<->  %res = tail call ptr @__memcpy_chk(ptr %a, ptr %b, i64 4, i64 %n)
325; CHECK-NEXT:  Just Mod:  Ptr: i8* %a.gep.1	<->  %res = tail call ptr @__memcpy_chk(ptr %a, ptr %b, i64 4, i64 %n)
326; CHECK-NEXT:  NoModRef:  Ptr: i8* %a.gep.5	<->  %res = tail call ptr @__memcpy_chk(ptr %a, ptr %b, i64 4, i64 %n)
327; CHECK-NEXT:  Just Ref:  Ptr: i8* %b.gep.1	<->  %res = tail call ptr @__memcpy_chk(ptr %a, ptr %b, i64 4, i64 %n)
328; CHECK-NEXT:  NoModRef:  Ptr: i8* %b.gep.5	<->  %res = tail call ptr @__memcpy_chk(ptr %a, ptr %b, i64 4, i64 %n)
329;
330entry:
331  load i8, ptr %a
332  %res = tail call ptr @__memcpy_chk(ptr %a, ptr %b, i64 4, i64 %n)
333  load i8, ptr %res
334  %a.gep.1 = getelementptr i8, ptr %a, i32 1
335  store i8 0, ptr %a.gep.1
336  %a.gep.5 = getelementptr i8, ptr %a, i32 5
337  store i8 1, ptr %a.gep.5
338  %b.gep.1 = getelementptr i8, ptr %b, i32 1
339  store i8 0, ptr %b.gep.1
340  %b.gep.5 = getelementptr i8, ptr %b, i32 5
341  store i8 1, ptr %b.gep.5
342  ret ptr %res
343}
344
345define ptr @test_memcpy_chk_variable_size(ptr noalias %a, ptr noalias %b, i64 %n.1, i64 %n.2) {
346; CHECK-LABEL: Function: test_memcpy_chk_variable_size
347; CHECK:       Just Mod:  Ptr: i8* %a	<->  %res = tail call ptr @__memcpy_chk(ptr %a, ptr %b, i64 %n.1, i64 %n.2)
348; CHECK-NEXT:  Just Mod:  Ptr: i8* %res	<->  %res = tail call ptr @__memcpy_chk(ptr %a, ptr %b, i64 %n.1, i64 %n.2)
349; CHECK-NEXT:  Just Mod:  Ptr: i8* %a.gep.1	<->  %res = tail call ptr @__memcpy_chk(ptr %a, ptr %b, i64 %n.1, i64 %n.2)
350; CHECK-NEXT:  Just Mod:  Ptr: i8* %a.gep.5	<->  %res = tail call ptr @__memcpy_chk(ptr %a, ptr %b, i64 %n.1, i64 %n.2)
351; CHECK-NEXT:  Just Ref:  Ptr: i8* %b.gep.1	<->  %res = tail call ptr @__memcpy_chk(ptr %a, ptr %b, i64 %n.1, i64 %n.2)
352; CHECK-NEXT:  Just Ref:  Ptr: i8* %b.gep.5	<->  %res = tail call ptr @__memcpy_chk(ptr %a, ptr %b, i64 %n.1, i64 %n.2)
353;
354entry:
355  load i8, ptr %a
356  %res = tail call ptr @__memcpy_chk(ptr %a, ptr %b, i64 %n.1, i64 %n.2)
357  load i8, ptr %res
358  %a.gep.1 = getelementptr i8, ptr %a, i32 1
359  store i8 0, ptr %a.gep.1
360  %a.gep.5 = getelementptr i8, ptr %a, i32 5
361  store i8 1, ptr %a.gep.5
362  %b.gep.1 = getelementptr i8, ptr %b, i32 1
363  store i8 0, ptr %b.gep.1
364  %b.gep.5 = getelementptr i8, ptr %b, i32 5
365  store i8 1, ptr %b.gep.5
366  ret ptr %res
367}
368