1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
2 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
3 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC
8 declare void @test1_1(ptr %x1_1, ptr readonly %y1_1, ...)
10 ; NOTE: readonly for %y1_2 would be OK here but not for the similar situation in test13.
13 ; CHECK: @x = global i32 0
14 ; CHECK: @constant_mem = external dso_local constant i32, align 4
16 define void @test1_2(ptr %x1_2, ptr %y1_2, ptr %z1_2) {
17 ; CHECK-LABEL: define {{[^@]+}}@test1_2
18 ; CHECK-SAME: (ptr [[X1_2:%.*]], ptr nofree [[Y1_2:%.*]], ptr [[Z1_2:%.*]]) {
19 ; CHECK-NEXT: call void (ptr, ptr, ...) @test1_1(ptr [[X1_2]], ptr nofree readonly [[Y1_2]], ptr [[Z1_2]])
20 ; CHECK-NEXT: store i32 0, ptr @x, align 4
21 ; CHECK-NEXT: ret void
23 call void (ptr, ptr, ...) @test1_1(ptr %x1_2, ptr %y1_2, ptr %z1_2)
28 define ptr @test2(ptr %p) {
29 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
30 ; CHECK-LABEL: define {{[^@]+}}@test2
31 ; CHECK-SAME: (ptr nofree readnone returned "no-capture-maybe-returned" [[P:%.*]]) #[[ATTR0:[0-9]+]] {
32 ; CHECK-NEXT: store i32 0, ptr @x, align 4
33 ; CHECK-NEXT: ret ptr [[P]]
39 define i1 @test3(ptr %p, ptr %q) {
40 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
41 ; CHECK-LABEL: define {{[^@]+}}@test3
42 ; CHECK-SAME: (ptr nofree readnone [[P:%.*]], ptr nofree readnone [[Q:%.*]]) #[[ATTR1:[0-9]+]] {
43 ; CHECK-NEXT: [[A:%.*]] = icmp ult ptr [[P]], [[Q]]
44 ; CHECK-NEXT: ret i1 [[A]]
46 %A = icmp ult ptr %p, %q
50 declare void @test4_1(ptr nocapture) readonly
52 define void @test4_2(ptr %p) {
53 ; CHECK: Function Attrs: nosync memory(read)
54 ; CHECK-LABEL: define {{[^@]+}}@test4_2
55 ; CHECK-SAME: (ptr nocapture readonly [[P:%.*]]) #[[ATTR3:[0-9]+]] {
56 ; CHECK-NEXT: call void @test4_1(ptr nocapture readonly [[P]]) #[[ATTR3]]
57 ; CHECK-NEXT: ret void
59 call void @test4_1(ptr %p)
63 ; Missed optz'n: we could make %q readnone, but don't break test6!
64 define void @test5(ptr %p, ptr %q) {
65 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
66 ; CHECK-LABEL: define {{[^@]+}}@test5
67 ; CHECK-SAME: (ptr nocapture nofree noundef nonnull writeonly align 8 dereferenceable(8) [[P:%.*]], ptr nofree writeonly [[Q:%.*]]) #[[ATTR4:[0-9]+]] {
68 ; CHECK-NEXT: store ptr [[Q]], ptr [[P]], align 8
69 ; CHECK-NEXT: ret void
75 declare void @test6_1()
76 ; This is not a missed optz'n.
77 define void @test6_2(ptr %p, ptr %q) {
78 ; CHECK-LABEL: define {{[^@]+}}@test6_2
79 ; CHECK-SAME: (ptr nocapture nofree noundef nonnull writeonly align 8 dereferenceable(8) [[P:%.*]], ptr nofree [[Q:%.*]]) {
80 ; CHECK-NEXT: store ptr [[Q]], ptr [[P]], align 8
81 ; CHECK-NEXT: call void @test6_1()
82 ; CHECK-NEXT: ret void
89 ; inalloca parameters are always considered written
90 define void @test7_1(ptr inalloca(i32) %a) {
91 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
92 ; CHECK-LABEL: define {{[^@]+}}@test7_1
93 ; CHECK-SAME: (ptr nocapture nofree nonnull writeonly inalloca(i32) dereferenceable(4) [[A:%.*]]) #[[ATTR1]] {
94 ; CHECK-NEXT: ret void
99 define ptr @test8_1(ptr %p) {
100 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
101 ; CHECK-LABEL: define {{[^@]+}}@test8_1
102 ; CHECK-SAME: (ptr nofree readnone returned "no-capture-maybe-returned" [[P:%.*]]) #[[ATTR1]] {
104 ; CHECK-NEXT: ret ptr [[P]]
110 define void @test8_2(ptr %p) {
111 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
112 ; TUNIT-LABEL: define {{[^@]+}}@test8_2
113 ; TUNIT-SAME: (ptr nocapture nofree writeonly [[P:%.*]]) #[[ATTR4]] {
115 ; TUNIT-NEXT: store i32 10, ptr [[P]], align 4
116 ; TUNIT-NEXT: ret void
118 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(argmem: write)
119 ; CGSCC-LABEL: define {{[^@]+}}@test8_2
120 ; CGSCC-SAME: (ptr nofree writeonly [[P:%.*]]) #[[ATTR5:[0-9]+]] {
122 ; CGSCC-NEXT: [[CALL:%.*]] = call align 4 ptr @test8_1(ptr noalias nofree readnone [[P]]) #[[ATTR17:[0-9]+]]
123 ; CGSCC-NEXT: store i32 10, ptr [[CALL]], align 4
124 ; CGSCC-NEXT: ret void
127 %call = call ptr @test8_1(ptr %p)
128 store i32 10, ptr %call, align 4
132 declare void @llvm.masked.scatter.v4i32.v4p0(<4 x i32>%val, <4 x ptr>, i32, <4 x i1>)
134 ; CHECK-NOT: readnone
135 ; CHECK-NOT: readonly
136 define void @test9(<4 x ptr> %ptrs, <4 x i32>%val) {
137 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
138 ; TUNIT-LABEL: define {{[^@]+}}@test9
139 ; TUNIT-SAME: (<4 x ptr> [[PTRS:%.*]], <4 x i32> [[VAL:%.*]]) #[[ATTR0]] {
140 ; TUNIT-NEXT: call void @llvm.masked.scatter.v4i32.v4p0(<4 x i32> [[VAL]], <4 x ptr> [[PTRS]], i32 noundef 4, <4 x i1> noundef <i1 true, i1 false, i1 true, i1 false>) #[[ATTR16:[0-9]+]]
141 ; TUNIT-NEXT: ret void
143 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
144 ; CGSCC-LABEL: define {{[^@]+}}@test9
145 ; CGSCC-SAME: (<4 x ptr> [[PTRS:%.*]], <4 x i32> [[VAL:%.*]]) #[[ATTR0]] {
146 ; CGSCC-NEXT: call void @llvm.masked.scatter.v4i32.v4p0(<4 x i32> [[VAL]], <4 x ptr> [[PTRS]], i32 noundef 4, <4 x i1> noundef <i1 true, i1 false, i1 true, i1 false>) #[[ATTR18:[0-9]+]]
147 ; CGSCC-NEXT: ret void
149 call void @llvm.masked.scatter.v4i32.v4p0(<4 x i32>%val, <4 x ptr> %ptrs, i32 4, <4 x i1><i1 true, i1 false, i1 true, i1 false>)
153 declare <4 x i32> @llvm.masked.gather.v4i32.v4p0(<4 x ptr>, i32, <4 x i1>, <4 x i32>)
154 define <4 x i32> @test10(<4 x ptr> %ptrs) {
155 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read)
156 ; TUNIT-LABEL: define {{[^@]+}}@test10
157 ; TUNIT-SAME: (<4 x ptr> [[PTRS:%.*]]) #[[ATTR7:[0-9]+]] {
158 ; TUNIT-NEXT: [[RES:%.*]] = call <4 x i32> @llvm.masked.gather.v4i32.v4p0(<4 x ptr> [[PTRS]], i32 noundef 4, <4 x i1> noundef <i1 true, i1 false, i1 true, i1 false>, <4 x i32> undef) #[[ATTR17:[0-9]+]]
159 ; TUNIT-NEXT: ret <4 x i32> [[RES]]
161 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read)
162 ; CGSCC-LABEL: define {{[^@]+}}@test10
163 ; CGSCC-SAME: (<4 x ptr> [[PTRS:%.*]]) #[[ATTR8:[0-9]+]] {
164 ; CGSCC-NEXT: [[RES:%.*]] = call <4 x i32> @llvm.masked.gather.v4i32.v4p0(<4 x ptr> [[PTRS]], i32 noundef 4, <4 x i1> noundef <i1 true, i1 false, i1 true, i1 false>, <4 x i32> undef) #[[ATTR19:[0-9]+]]
165 ; CGSCC-NEXT: ret <4 x i32> [[RES]]
167 %res = call <4 x i32> @llvm.masked.gather.v4i32.v4p0(<4 x ptr> %ptrs, i32 4, <4 x i1><i1 true, i1 false, i1 true, i1 false>, <4 x i32>undef)
171 declare <4 x i32> @test11_1(<4 x ptr>) argmemonly nounwind readonly
172 define <4 x i32> @test11_2(<4 x ptr> %ptrs) {
173 ; TUNIT: Function Attrs: nosync nounwind memory(argmem: read)
174 ; TUNIT-LABEL: define {{[^@]+}}@test11_2
175 ; TUNIT-SAME: (<4 x ptr> [[PTRS:%.*]]) #[[ATTR9:[0-9]+]] {
176 ; TUNIT-NEXT: [[RES:%.*]] = call <4 x i32> @test11_1(<4 x ptr> [[PTRS]]) #[[ATTR15:[0-9]+]]
177 ; TUNIT-NEXT: ret <4 x i32> [[RES]]
179 ; CGSCC: Function Attrs: nosync nounwind memory(argmem: read)
180 ; CGSCC-LABEL: define {{[^@]+}}@test11_2
181 ; CGSCC-SAME: (<4 x ptr> [[PTRS:%.*]]) #[[ATTR10:[0-9]+]] {
182 ; CGSCC-NEXT: [[RES:%.*]] = call <4 x i32> @test11_1(<4 x ptr> [[PTRS]]) #[[ATTR16:[0-9]+]]
183 ; CGSCC-NEXT: ret <4 x i32> [[RES]]
185 %res = call <4 x i32> @test11_1(<4 x ptr> %ptrs)
189 declare <4 x i32> @test12_1(<4 x ptr>) argmemonly nounwind
190 ; CHECK-NOT: readnone
191 define <4 x i32> @test12_2(<4 x ptr> %ptrs) {
192 ; TUNIT: Function Attrs: nounwind memory(argmem: readwrite)
193 ; TUNIT-LABEL: define {{[^@]+}}@test12_2
194 ; TUNIT-SAME: (<4 x ptr> [[PTRS:%.*]]) #[[ATTR10:[0-9]+]] {
195 ; TUNIT-NEXT: [[RES:%.*]] = call <4 x i32> @test12_1(<4 x ptr> [[PTRS]]) #[[ATTR18:[0-9]+]]
196 ; TUNIT-NEXT: ret <4 x i32> [[RES]]
198 ; CGSCC: Function Attrs: nounwind memory(argmem: readwrite)
199 ; CGSCC-LABEL: define {{[^@]+}}@test12_2
200 ; CGSCC-SAME: (<4 x ptr> [[PTRS:%.*]]) #[[ATTR11:[0-9]+]] {
201 ; CGSCC-NEXT: [[RES:%.*]] = call <4 x i32> @test12_1(<4 x ptr> [[PTRS]]) #[[ATTR20:[0-9]+]]
202 ; CGSCC-NEXT: ret <4 x i32> [[RES]]
204 %res = call <4 x i32> @test12_1(<4 x ptr> %ptrs)
208 define i32 @volatile_load(ptr %p) {
209 ; TUNIT: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite)
210 ; TUNIT-LABEL: define {{[^@]+}}@volatile_load
211 ; TUNIT-SAME: (ptr nofree noundef align 4 [[P:%.*]]) #[[ATTR11:[0-9]+]] {
212 ; TUNIT-NEXT: [[LOAD:%.*]] = load volatile i32, ptr [[P]], align 4
213 ; TUNIT-NEXT: ret i32 [[LOAD]]
215 ; CGSCC: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite)
216 ; CGSCC-LABEL: define {{[^@]+}}@volatile_load
217 ; CGSCC-SAME: (ptr nofree noundef align 4 [[P:%.*]]) #[[ATTR12:[0-9]+]] {
218 ; CGSCC-NEXT: [[LOAD:%.*]] = load volatile i32, ptr [[P]], align 4
219 ; CGSCC-NEXT: ret i32 [[LOAD]]
221 %load = load volatile i32, ptr %p
225 declare void @escape_readnone_ptr(ptr %addr, ptr readnone %ptr)
226 declare void @escape_readonly_ptr(ptr %addr, ptr readonly %ptr)
228 ; The argument pointer %escaped_then_written cannot be marked readnone/only even
229 ; though the only direct use, in @escape_readnone_ptr/@escape_readonly_ptr,
230 ; is marked as readnone/only. However, the functions can write the pointer into
231 ; %addr, causing the store to write to %escaped_then_written.
233 define void @unsound_readnone(ptr %ignored, ptr %escaped_then_written) {
234 ; CHECK-LABEL: define {{[^@]+}}@unsound_readnone
235 ; CHECK-SAME: (ptr nocapture nofree readnone [[IGNORED:%.*]], ptr nofree [[ESCAPED_THEN_WRITTEN:%.*]]) {
236 ; CHECK-NEXT: [[ADDR:%.*]] = alloca ptr, align 8
237 ; CHECK-NEXT: call void @escape_readnone_ptr(ptr noundef nonnull align 8 dereferenceable(8) [[ADDR]], ptr noalias nofree readnone [[ESCAPED_THEN_WRITTEN]])
238 ; CHECK-NEXT: [[ADDR_LD:%.*]] = load ptr, ptr [[ADDR]], align 8
239 ; CHECK-NEXT: store i8 0, ptr [[ADDR_LD]], align 1
240 ; CHECK-NEXT: ret void
243 call void @escape_readnone_ptr(ptr %addr, ptr %escaped_then_written)
244 %addr.ld = load ptr, ptr %addr
245 store i8 0, ptr %addr.ld
249 define void @unsound_readonly(ptr %ignored, ptr %escaped_then_written) {
250 ; CHECK-LABEL: define {{[^@]+}}@unsound_readonly
251 ; CHECK-SAME: (ptr nocapture nofree readnone [[IGNORED:%.*]], ptr nofree [[ESCAPED_THEN_WRITTEN:%.*]]) {
252 ; CHECK-NEXT: [[ADDR:%.*]] = alloca ptr, align 8
253 ; CHECK-NEXT: call void @escape_readonly_ptr(ptr noundef nonnull align 8 dereferenceable(8) [[ADDR]], ptr nofree readonly [[ESCAPED_THEN_WRITTEN]])
254 ; CHECK-NEXT: [[ADDR_LD:%.*]] = load ptr, ptr [[ADDR]], align 8
255 ; CHECK-NEXT: store i8 0, ptr [[ADDR_LD]], align 1
256 ; CHECK-NEXT: ret void
259 call void @escape_readonly_ptr(ptr %addr, ptr %escaped_then_written)
260 %addr.ld = load ptr, ptr %addr
261 store i8 0, ptr %addr.ld
265 ; Byval but not readonly/none tests
268 declare void @escape_i8(ptr %ptr)
270 define void @byval_not_readonly_1(ptr byval(i8) %written) readonly {
271 ; CHECK: Function Attrs: nosync memory(read)
272 ; CHECK-LABEL: define {{[^@]+}}@byval_not_readonly_1
273 ; CHECK-SAME: (ptr noalias nonnull byval(i8) dereferenceable(1) [[WRITTEN:%.*]]) #[[ATTR3]] {
274 ; CHECK-NEXT: call void @escape_i8(ptr nonnull dereferenceable(1) [[WRITTEN]])
275 ; CHECK-NEXT: ret void
277 call void @escape_i8(ptr %written)
281 define void @byval_not_readonly_2(ptr byval(i8) %written) readonly {
282 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
283 ; CHECK-LABEL: define {{[^@]+}}@byval_not_readonly_2
284 ; CHECK-SAME: (ptr noalias nocapture nofree noundef nonnull writeonly byval(i8) dereferenceable(1) [[WRITTEN:%.*]]) #[[ATTR1]] {
285 ; CHECK-NEXT: store i8 0, ptr [[WRITTEN]], align 1
286 ; CHECK-NEXT: ret void
288 store i8 0, ptr %written
292 define void @byval_not_readnone_1(ptr byval(i8) %written) readnone {
293 ; TUNIT: Function Attrs: nosync memory(none)
294 ; TUNIT-LABEL: define {{[^@]+}}@byval_not_readnone_1
295 ; TUNIT-SAME: (ptr noalias nonnull byval(i8) dereferenceable(1) [[WRITTEN:%.*]]) #[[ATTR12:[0-9]+]] {
296 ; TUNIT-NEXT: call void @escape_i8(ptr nonnull dereferenceable(1) [[WRITTEN]])
297 ; TUNIT-NEXT: ret void
299 ; CGSCC: Function Attrs: nosync memory(none)
300 ; CGSCC-LABEL: define {{[^@]+}}@byval_not_readnone_1
301 ; CGSCC-SAME: (ptr noalias nonnull byval(i8) dereferenceable(1) [[WRITTEN:%.*]]) #[[ATTR13:[0-9]+]] {
302 ; CGSCC-NEXT: call void @escape_i8(ptr nonnull dereferenceable(1) [[WRITTEN]])
303 ; CGSCC-NEXT: ret void
305 call void @escape_i8(ptr %written)
309 define void @byval_not_readnone_2(ptr byval(i8) %written) readnone {
310 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
311 ; CHECK-LABEL: define {{[^@]+}}@byval_not_readnone_2
312 ; CHECK-SAME: (ptr noalias nocapture nofree noundef nonnull writeonly byval(i8) dereferenceable(1) [[WRITTEN:%.*]]) #[[ATTR1]] {
313 ; CHECK-NEXT: store i8 0, ptr [[WRITTEN]], align 1
314 ; CHECK-NEXT: ret void
316 store i8 0, ptr %written
320 define void @byval_no_fnarg(ptr byval(i8) %written) {
321 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
322 ; CHECK-LABEL: define {{[^@]+}}@byval_no_fnarg
323 ; CHECK-SAME: (ptr noalias nocapture nofree noundef nonnull writeonly byval(i8) dereferenceable(1) [[WRITTEN:%.*]]) #[[ATTR4]] {
324 ; CHECK-NEXT: store i8 0, ptr [[WRITTEN]], align 1
325 ; CHECK-NEXT: ret void
327 store i8 0, ptr %written
331 define void @testbyval(ptr %read_only) {
332 ; TUNIT: Function Attrs: nosync
333 ; TUNIT-LABEL: define {{[^@]+}}@testbyval
334 ; TUNIT-SAME: (ptr nocapture nonnull readonly [[READ_ONLY:%.*]]) #[[ATTR13:[0-9]+]] {
335 ; TUNIT-NEXT: call void @byval_not_readonly_1(ptr noalias nocapture nonnull readonly byval(i8) [[READ_ONLY]]) #[[ATTR3]]
336 ; TUNIT-NEXT: call void @byval_not_readnone_1(ptr noalias nocapture nonnull readnone byval(i8) [[READ_ONLY]]) #[[ATTR13]]
337 ; TUNIT-NEXT: call void @byval_no_fnarg(ptr noalias nocapture nofree noundef nonnull readonly byval(i8) [[READ_ONLY]]) #[[ATTR19:[0-9]+]]
338 ; TUNIT-NEXT: ret void
340 ; CGSCC: Function Attrs: nosync
341 ; CGSCC-LABEL: define {{[^@]+}}@testbyval
342 ; CGSCC-SAME: (ptr nocapture noundef nonnull readonly dereferenceable(1) [[READ_ONLY:%.*]]) #[[ATTR14:[0-9]+]] {
343 ; CGSCC-NEXT: call void @byval_not_readonly_1(ptr noalias nocapture noundef nonnull readonly byval(i8) dereferenceable(1) [[READ_ONLY]]) #[[ATTR2:[0-9]+]]
344 ; CGSCC-NEXT: call void @byval_not_readnone_1(ptr noalias nocapture noundef nonnull readnone byval(i8) dereferenceable(1) [[READ_ONLY]]) #[[ATTR14]]
345 ; CGSCC-NEXT: call void @byval_no_fnarg(ptr noalias nocapture nofree noundef nonnull readnone byval(i8) dereferenceable(1) [[READ_ONLY]]) #[[ATTR21:[0-9]+]]
346 ; CGSCC-NEXT: ret void
348 call void @byval_not_readonly_1(ptr byval(i8) %read_only)
349 call void @byval_not_readonly_2(ptr byval(i8) %read_only)
350 call void @byval_not_readnone_1(ptr byval(i8) %read_only)
351 call void @byval_not_readnone_2(ptr byval(i8) %read_only)
352 call void @byval_no_fnarg(ptr byval(i8) %read_only)
357 declare ptr @maybe_returned_ptr(ptr readonly %ptr) readonly nounwind
358 declare i8 @maybe_returned_val(ptr %ptr) readonly nounwind
359 declare void @val_use(i8 %ptr) readonly nounwind
361 define void @ptr_uses(ptr %ptr) {
362 ; TUNIT: Function Attrs: nosync nounwind memory(read)
363 ; TUNIT-LABEL: define {{[^@]+}}@ptr_uses
364 ; TUNIT-SAME: (ptr nocapture nofree readonly [[PTR:%.*]]) #[[ATTR15]] {
365 ; TUNIT-NEXT: [[CALL_PTR:%.*]] = call ptr @maybe_returned_ptr(ptr nofree readonly [[PTR]]) #[[ATTR15]]
366 ; TUNIT-NEXT: [[CALL_VAL:%.*]] = call i8 @maybe_returned_val(ptr readonly [[CALL_PTR]]) #[[ATTR15]]
367 ; TUNIT-NEXT: ret void
369 ; CGSCC: Function Attrs: nosync nounwind memory(read)
370 ; CGSCC-LABEL: define {{[^@]+}}@ptr_uses
371 ; CGSCC-SAME: (ptr nocapture nofree readonly [[PTR:%.*]]) #[[ATTR16]] {
372 ; CGSCC-NEXT: [[CALL_PTR:%.*]] = call ptr @maybe_returned_ptr(ptr nofree readonly [[PTR]]) #[[ATTR16]]
373 ; CGSCC-NEXT: [[CALL_VAL:%.*]] = call i8 @maybe_returned_val(ptr readonly [[CALL_PTR]]) #[[ATTR16]]
374 ; CGSCC-NEXT: ret void
376 %call_ptr = call ptr @maybe_returned_ptr(ptr %ptr)
377 %call_val = call i8 @maybe_returned_val(ptr %call_ptr)
378 call void @val_use(i8 %call_val)
382 define void @ptr_use_chain(ptr %ptr) {
383 ; CHECK-LABEL: define {{[^@]+}}@ptr_use_chain
384 ; CHECK-SAME: (ptr [[PTR:%.*]]) {
385 ; CHECK-NEXT: call void @escape_i8(ptr [[PTR]])
386 ; CHECK-NEXT: ret void
388 call void @escape_i8(ptr %ptr)
392 @constant_mem = external dso_local constant i32, align 4
393 define i32 @read_only_constant_mem() {
394 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
395 ; CHECK-LABEL: define {{[^@]+}}@read_only_constant_mem
396 ; CHECK-SAME: () #[[ATTR1]] {
397 ; CHECK-NEXT: [[L:%.*]] = load i32, ptr @constant_mem, align 4
398 ; CHECK-NEXT: ret i32 [[L]]
400 %l = load i32, ptr @constant_mem
404 ; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(write) }
405 ; TUNIT: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
406 ; TUNIT: attributes #[[ATTR2:[0-9]+]] = { memory(read) }
407 ; TUNIT: attributes #[[ATTR3]] = { nosync memory(read) }
408 ; TUNIT: attributes #[[ATTR4]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) }
409 ; TUNIT: attributes #[[ATTR5:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(write) }
410 ; TUNIT: attributes #[[ATTR6:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(read) }
411 ; TUNIT: attributes #[[ATTR7]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(read) }
412 ; TUNIT: attributes #[[ATTR8:[0-9]+]] = { nounwind memory(argmem: read) }
413 ; TUNIT: attributes #[[ATTR9]] = { nosync nounwind memory(argmem: read) }
414 ; TUNIT: attributes #[[ATTR10]] = { nounwind memory(argmem: readwrite) }
415 ; TUNIT: attributes #[[ATTR11]] = { mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite) }
416 ; TUNIT: attributes #[[ATTR12]] = { nosync memory(none) }
417 ; TUNIT: attributes #[[ATTR13]] = { nosync }
418 ; TUNIT: attributes #[[ATTR14:[0-9]+]] = { nounwind memory(read) }
419 ; TUNIT: attributes #[[ATTR15]] = { nosync nounwind memory(read) }
420 ; TUNIT: attributes #[[ATTR16]] = { nofree willreturn memory(write) }
421 ; TUNIT: attributes #[[ATTR17]] = { nofree willreturn memory(read) }
422 ; TUNIT: attributes #[[ATTR18]] = { nounwind }
423 ; TUNIT: attributes #[[ATTR19]] = { nosync nounwind memory(write) }
425 ; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(write) }
426 ; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
427 ; CGSCC: attributes #[[ATTR2]] = { memory(read) }
428 ; CGSCC: attributes #[[ATTR3]] = { nosync memory(read) }
429 ; CGSCC: attributes #[[ATTR4]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) }
430 ; CGSCC: attributes #[[ATTR5]] = { mustprogress nofree nosync nounwind willreturn memory(argmem: write) }
431 ; CGSCC: attributes #[[ATTR6:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(write) }
432 ; CGSCC: attributes #[[ATTR7:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(read) }
433 ; CGSCC: attributes #[[ATTR8]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(read) }
434 ; CGSCC: attributes #[[ATTR9:[0-9]+]] = { nounwind memory(argmem: read) }
435 ; CGSCC: attributes #[[ATTR10]] = { nosync nounwind memory(argmem: read) }
436 ; CGSCC: attributes #[[ATTR11]] = { nounwind memory(argmem: readwrite) }
437 ; CGSCC: attributes #[[ATTR12]] = { mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite) }
438 ; CGSCC: attributes #[[ATTR13]] = { nosync memory(none) }
439 ; CGSCC: attributes #[[ATTR14]] = { nosync }
440 ; CGSCC: attributes #[[ATTR15:[0-9]+]] = { nounwind memory(read) }
441 ; CGSCC: attributes #[[ATTR16]] = { nosync nounwind memory(read) }
442 ; CGSCC: attributes #[[ATTR17]] = { nofree nosync willreturn }
443 ; CGSCC: attributes #[[ATTR18]] = { nofree willreturn memory(write) }
444 ; CGSCC: attributes #[[ATTR19]] = { nofree willreturn memory(read) }
445 ; CGSCC: attributes #[[ATTR20]] = { nounwind }
446 ; CGSCC: attributes #[[ATTR21]] = { nounwind memory(write) }