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:[a-zA-Z0-9_$"\\.-]+]] = global i32 0
14 ; CHECK: @[[CONSTANT_MEM:[a-zA-Z0-9_$"\\.-]+]] = 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 ; CHECK: declare void @llvm.masked.scatter
133 declare void @llvm.masked.scatter.v4i32.v4p0(<4 x i32>%val, <4 x ptr>, i32, <4 x i1>)
135 ; CHECK-NOT: readnone
136 ; CHECK-NOT: readonly
137 define void @test9(<4 x ptr> %ptrs, <4 x i32>%val) {
138 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
139 ; TUNIT-LABEL: define {{[^@]+}}@test9
140 ; TUNIT-SAME: (<4 x ptr> [[PTRS:%.*]], <4 x i32> [[VAL:%.*]]) #[[ATTR0]] {
141 ; 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]+]]
142 ; TUNIT-NEXT: ret void
144 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
145 ; CGSCC-LABEL: define {{[^@]+}}@test9
146 ; CGSCC-SAME: (<4 x ptr> [[PTRS:%.*]], <4 x i32> [[VAL:%.*]]) #[[ATTR0]] {
147 ; 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]+]]
148 ; CGSCC-NEXT: ret void
150 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>)
154 ; CHECK: declare <4 x i32> @llvm.masked.gather
155 declare <4 x i32> @llvm.masked.gather.v4i32.v4p0(<4 x ptr>, i32, <4 x i1>, <4 x i32>)
156 define <4 x i32> @test10(<4 x ptr> %ptrs) {
157 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read)
158 ; TUNIT-LABEL: define {{[^@]+}}@test10
159 ; TUNIT-SAME: (<4 x ptr> [[PTRS:%.*]]) #[[ATTR7:[0-9]+]] {
160 ; 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]+]]
161 ; TUNIT-NEXT: ret <4 x i32> [[RES]]
163 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read)
164 ; CGSCC-LABEL: define {{[^@]+}}@test10
165 ; CGSCC-SAME: (<4 x ptr> [[PTRS:%.*]]) #[[ATTR8:[0-9]+]] {
166 ; 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]+]]
167 ; CGSCC-NEXT: ret <4 x i32> [[RES]]
169 %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)
173 ; CHECK: declare <4 x i32> @test11_1
174 declare <4 x i32> @test11_1(<4 x ptr>) argmemonly nounwind readonly
175 define <4 x i32> @test11_2(<4 x ptr> %ptrs) {
176 ; TUNIT: Function Attrs: nosync nounwind memory(argmem: read)
177 ; TUNIT-LABEL: define {{[^@]+}}@test11_2
178 ; TUNIT-SAME: (<4 x ptr> [[PTRS:%.*]]) #[[ATTR9:[0-9]+]] {
179 ; TUNIT-NEXT: [[RES:%.*]] = call <4 x i32> @test11_1(<4 x ptr> [[PTRS]]) #[[ATTR15:[0-9]+]]
180 ; TUNIT-NEXT: ret <4 x i32> [[RES]]
182 ; CGSCC: Function Attrs: nosync nounwind memory(argmem: read)
183 ; CGSCC-LABEL: define {{[^@]+}}@test11_2
184 ; CGSCC-SAME: (<4 x ptr> [[PTRS:%.*]]) #[[ATTR10:[0-9]+]] {
185 ; CGSCC-NEXT: [[RES:%.*]] = call <4 x i32> @test11_1(<4 x ptr> [[PTRS]]) #[[ATTR16:[0-9]+]]
186 ; CGSCC-NEXT: ret <4 x i32> [[RES]]
188 %res = call <4 x i32> @test11_1(<4 x ptr> %ptrs)
192 declare <4 x i32> @test12_1(<4 x ptr>) argmemonly nounwind
193 ; CHECK-NOT: readnone
194 define <4 x i32> @test12_2(<4 x ptr> %ptrs) {
195 ; TUNIT: Function Attrs: nounwind memory(argmem: readwrite)
196 ; TUNIT-LABEL: define {{[^@]+}}@test12_2
197 ; TUNIT-SAME: (<4 x ptr> [[PTRS:%.*]]) #[[ATTR10:[0-9]+]] {
198 ; TUNIT-NEXT: [[RES:%.*]] = call <4 x i32> @test12_1(<4 x ptr> [[PTRS]]) #[[ATTR18:[0-9]+]]
199 ; TUNIT-NEXT: ret <4 x i32> [[RES]]
201 ; CGSCC: Function Attrs: nounwind memory(argmem: readwrite)
202 ; CGSCC-LABEL: define {{[^@]+}}@test12_2
203 ; CGSCC-SAME: (<4 x ptr> [[PTRS:%.*]]) #[[ATTR11:[0-9]+]] {
204 ; CGSCC-NEXT: [[RES:%.*]] = call <4 x i32> @test12_1(<4 x ptr> [[PTRS]]) #[[ATTR20:[0-9]+]]
205 ; CGSCC-NEXT: ret <4 x i32> [[RES]]
207 %res = call <4 x i32> @test12_1(<4 x ptr> %ptrs)
211 define i32 @volatile_load(ptr %p) {
212 ; TUNIT: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite)
213 ; TUNIT-LABEL: define {{[^@]+}}@volatile_load
214 ; TUNIT-SAME: (ptr nofree noundef align 4 [[P:%.*]]) #[[ATTR11:[0-9]+]] {
215 ; TUNIT-NEXT: [[LOAD:%.*]] = load volatile i32, ptr [[P]], align 4
216 ; TUNIT-NEXT: ret i32 [[LOAD]]
218 ; CGSCC: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite)
219 ; CGSCC-LABEL: define {{[^@]+}}@volatile_load
220 ; CGSCC-SAME: (ptr nofree noundef align 4 [[P:%.*]]) #[[ATTR12:[0-9]+]] {
221 ; CGSCC-NEXT: [[LOAD:%.*]] = load volatile i32, ptr [[P]], align 4
222 ; CGSCC-NEXT: ret i32 [[LOAD]]
224 %load = load volatile i32, ptr %p
228 declare void @escape_readnone_ptr(ptr %addr, ptr readnone %ptr)
229 declare void @escape_readonly_ptr(ptr %addr, ptr readonly %ptr)
231 ; The argument pointer %escaped_then_written cannot be marked readnone/only even
232 ; though the only direct use, in @escape_readnone_ptr/@escape_readonly_ptr,
233 ; is marked as readnone/only. However, the functions can write the pointer into
234 ; %addr, causing the store to write to %escaped_then_written.
236 define void @unsound_readnone(ptr %ignored, ptr %escaped_then_written) {
237 ; CHECK-LABEL: define {{[^@]+}}@unsound_readnone
238 ; CHECK-SAME: (ptr nocapture nofree readnone [[IGNORED:%.*]], ptr nofree [[ESCAPED_THEN_WRITTEN:%.*]]) {
239 ; CHECK-NEXT: [[ADDR:%.*]] = alloca ptr, align 8
240 ; CHECK-NEXT: call void @escape_readnone_ptr(ptr noundef nonnull align 8 dereferenceable(8) [[ADDR]], ptr noalias nofree readnone [[ESCAPED_THEN_WRITTEN]])
241 ; CHECK-NEXT: [[ADDR_LD:%.*]] = load ptr, ptr [[ADDR]], align 8
242 ; CHECK-NEXT: store i8 0, ptr [[ADDR_LD]], align 1
243 ; CHECK-NEXT: ret void
246 call void @escape_readnone_ptr(ptr %addr, ptr %escaped_then_written)
247 %addr.ld = load ptr, ptr %addr
248 store i8 0, ptr %addr.ld
252 define void @unsound_readonly(ptr %ignored, ptr %escaped_then_written) {
253 ; CHECK-LABEL: define {{[^@]+}}@unsound_readonly
254 ; CHECK-SAME: (ptr nocapture nofree readnone [[IGNORED:%.*]], ptr nofree [[ESCAPED_THEN_WRITTEN:%.*]]) {
255 ; CHECK-NEXT: [[ADDR:%.*]] = alloca ptr, align 8
256 ; CHECK-NEXT: call void @escape_readonly_ptr(ptr noundef nonnull align 8 dereferenceable(8) [[ADDR]], ptr nofree readonly [[ESCAPED_THEN_WRITTEN]])
257 ; CHECK-NEXT: [[ADDR_LD:%.*]] = load ptr, ptr [[ADDR]], align 8
258 ; CHECK-NEXT: store i8 0, ptr [[ADDR_LD]], align 1
259 ; CHECK-NEXT: ret void
262 call void @escape_readonly_ptr(ptr %addr, ptr %escaped_then_written)
263 %addr.ld = load ptr, ptr %addr
264 store i8 0, ptr %addr.ld
268 ; Byval but not readonly/none tests
271 declare void @escape_i8(ptr %ptr)
273 define void @byval_not_readonly_1(ptr byval(i8) %written) readonly {
274 ; CHECK: Function Attrs: nosync memory(read)
275 ; CHECK-LABEL: define {{[^@]+}}@byval_not_readonly_1
276 ; CHECK-SAME: (ptr noalias nonnull byval(i8) dereferenceable(1) [[WRITTEN:%.*]]) #[[ATTR3]] {
277 ; CHECK-NEXT: call void @escape_i8(ptr nonnull dereferenceable(1) [[WRITTEN]])
278 ; CHECK-NEXT: ret void
280 call void @escape_i8(ptr %written)
284 define void @byval_not_readonly_2(ptr byval(i8) %written) readonly {
285 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
286 ; CHECK-LABEL: define {{[^@]+}}@byval_not_readonly_2
287 ; CHECK-SAME: (ptr noalias nocapture nofree noundef nonnull writeonly byval(i8) dereferenceable(1) [[WRITTEN:%.*]]) #[[ATTR1]] {
288 ; CHECK-NEXT: store i8 0, ptr [[WRITTEN]], align 1
289 ; CHECK-NEXT: ret void
291 store i8 0, ptr %written
295 define void @byval_not_readnone_1(ptr byval(i8) %written) readnone {
296 ; TUNIT: Function Attrs: nosync memory(none)
297 ; TUNIT-LABEL: define {{[^@]+}}@byval_not_readnone_1
298 ; TUNIT-SAME: (ptr noalias nonnull byval(i8) dereferenceable(1) [[WRITTEN:%.*]]) #[[ATTR12:[0-9]+]] {
299 ; TUNIT-NEXT: call void @escape_i8(ptr nonnull dereferenceable(1) [[WRITTEN]])
300 ; TUNIT-NEXT: ret void
302 ; CGSCC: Function Attrs: nosync memory(none)
303 ; CGSCC-LABEL: define {{[^@]+}}@byval_not_readnone_1
304 ; CGSCC-SAME: (ptr noalias nonnull byval(i8) dereferenceable(1) [[WRITTEN:%.*]]) #[[ATTR13:[0-9]+]] {
305 ; CGSCC-NEXT: call void @escape_i8(ptr nonnull dereferenceable(1) [[WRITTEN]])
306 ; CGSCC-NEXT: ret void
308 call void @escape_i8(ptr %written)
312 define void @byval_not_readnone_2(ptr byval(i8) %written) readnone {
313 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
314 ; CHECK-LABEL: define {{[^@]+}}@byval_not_readnone_2
315 ; CHECK-SAME: (ptr noalias nocapture nofree noundef nonnull writeonly byval(i8) dereferenceable(1) [[WRITTEN:%.*]]) #[[ATTR1]] {
316 ; CHECK-NEXT: store i8 0, ptr [[WRITTEN]], align 1
317 ; CHECK-NEXT: ret void
319 store i8 0, ptr %written
323 define void @byval_no_fnarg(ptr byval(i8) %written) {
324 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
325 ; CHECK-LABEL: define {{[^@]+}}@byval_no_fnarg
326 ; CHECK-SAME: (ptr noalias nocapture nofree noundef nonnull writeonly byval(i8) dereferenceable(1) [[WRITTEN:%.*]]) #[[ATTR4]] {
327 ; CHECK-NEXT: store i8 0, ptr [[WRITTEN]], align 1
328 ; CHECK-NEXT: ret void
330 store i8 0, ptr %written
334 define void @testbyval(ptr %read_only) {
335 ; TUNIT: Function Attrs: nosync
336 ; TUNIT-LABEL: define {{[^@]+}}@testbyval
337 ; TUNIT-SAME: (ptr nocapture nonnull readonly [[READ_ONLY:%.*]]) #[[ATTR13:[0-9]+]] {
338 ; TUNIT-NEXT: call void @byval_not_readonly_1(ptr noalias nocapture nonnull readonly byval(i8) [[READ_ONLY]]) #[[ATTR3]]
339 ; TUNIT-NEXT: call void @byval_not_readnone_1(ptr noalias nocapture nonnull readnone byval(i8) [[READ_ONLY]]) #[[ATTR13]]
340 ; TUNIT-NEXT: call void @byval_no_fnarg(ptr noalias nocapture nofree noundef nonnull readonly byval(i8) [[READ_ONLY]]) #[[ATTR19:[0-9]+]]
341 ; TUNIT-NEXT: ret void
343 ; CGSCC: Function Attrs: nosync
344 ; CGSCC-LABEL: define {{[^@]+}}@testbyval
345 ; CGSCC-SAME: (ptr nocapture noundef nonnull readonly dereferenceable(1) [[READ_ONLY:%.*]]) #[[ATTR14:[0-9]+]] {
346 ; CGSCC-NEXT: call void @byval_not_readonly_1(ptr noalias nocapture noundef nonnull readonly byval(i8) dereferenceable(1) [[READ_ONLY]]) #[[ATTR2:[0-9]+]]
347 ; CGSCC-NEXT: call void @byval_not_readnone_1(ptr noalias nocapture noundef nonnull readnone byval(i8) dereferenceable(1) [[READ_ONLY]]) #[[ATTR14]]
348 ; CGSCC-NEXT: call void @byval_no_fnarg(ptr noalias nocapture nofree noundef nonnull readnone byval(i8) dereferenceable(1) [[READ_ONLY]]) #[[ATTR21:[0-9]+]]
349 ; CGSCC-NEXT: ret void
351 call void @byval_not_readonly_1(ptr byval(i8) %read_only)
352 call void @byval_not_readonly_2(ptr byval(i8) %read_only)
353 call void @byval_not_readnone_1(ptr byval(i8) %read_only)
354 call void @byval_not_readnone_2(ptr byval(i8) %read_only)
355 call void @byval_no_fnarg(ptr byval(i8) %read_only)
360 declare ptr @maybe_returned_ptr(ptr readonly %ptr) readonly nounwind
361 declare i8 @maybe_returned_val(ptr %ptr) readonly nounwind
362 declare void @val_use(i8 %ptr) readonly nounwind
364 define void @ptr_uses(ptr %ptr) {
365 ; TUNIT: Function Attrs: nosync nounwind memory(read)
366 ; TUNIT-LABEL: define {{[^@]+}}@ptr_uses
367 ; TUNIT-SAME: (ptr nocapture nofree readonly [[PTR:%.*]]) #[[ATTR15]] {
368 ; TUNIT-NEXT: [[CALL_PTR:%.*]] = call ptr @maybe_returned_ptr(ptr nofree readonly [[PTR]]) #[[ATTR15]]
369 ; TUNIT-NEXT: [[CALL_VAL:%.*]] = call i8 @maybe_returned_val(ptr readonly [[CALL_PTR]]) #[[ATTR15]]
370 ; TUNIT-NEXT: ret void
372 ; CGSCC: Function Attrs: nosync nounwind memory(read)
373 ; CGSCC-LABEL: define {{[^@]+}}@ptr_uses
374 ; CGSCC-SAME: (ptr nocapture nofree readonly [[PTR:%.*]]) #[[ATTR16]] {
375 ; CGSCC-NEXT: [[CALL_PTR:%.*]] = call ptr @maybe_returned_ptr(ptr nofree readonly [[PTR]]) #[[ATTR16]]
376 ; CGSCC-NEXT: [[CALL_VAL:%.*]] = call i8 @maybe_returned_val(ptr readonly [[CALL_PTR]]) #[[ATTR16]]
377 ; CGSCC-NEXT: ret void
379 %call_ptr = call ptr @maybe_returned_ptr(ptr %ptr)
380 %call_val = call i8 @maybe_returned_val(ptr %call_ptr)
381 call void @val_use(i8 %call_val)
385 define void @ptr_use_chain(ptr %ptr) {
386 ; CHECK-LABEL: define {{[^@]+}}@ptr_use_chain
387 ; CHECK-SAME: (ptr [[PTR:%.*]]) {
388 ; CHECK-NEXT: call void @escape_i8(ptr [[PTR]])
389 ; CHECK-NEXT: ret void
391 call void @escape_i8(ptr %ptr)
395 @constant_mem = external dso_local constant i32, align 4
396 define i32 @read_only_constant_mem() {
397 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
398 ; CHECK-LABEL: define {{[^@]+}}@read_only_constant_mem
399 ; CHECK-SAME: () #[[ATTR1]] {
400 ; CHECK-NEXT: [[L:%.*]] = load i32, ptr @constant_mem, align 4
401 ; CHECK-NEXT: ret i32 [[L]]
403 %l = load i32, ptr @constant_mem
407 ; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(write) }
408 ; TUNIT: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
409 ; TUNIT: attributes #[[ATTR2:[0-9]+]] = { memory(read) }
410 ; TUNIT: attributes #[[ATTR3]] = { nosync memory(read) }
411 ; TUNIT: attributes #[[ATTR4]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) }
412 ; TUNIT: attributes #[[ATTR5:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(write) }
413 ; TUNIT: attributes #[[ATTR6:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(read) }
414 ; TUNIT: attributes #[[ATTR7]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(read) }
415 ; TUNIT: attributes #[[ATTR8:[0-9]+]] = { nounwind memory(argmem: read) }
416 ; TUNIT: attributes #[[ATTR9]] = { nosync nounwind memory(argmem: read) }
417 ; TUNIT: attributes #[[ATTR10]] = { nounwind memory(argmem: readwrite) }
418 ; TUNIT: attributes #[[ATTR11]] = { mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite) }
419 ; TUNIT: attributes #[[ATTR12]] = { nosync memory(none) }
420 ; TUNIT: attributes #[[ATTR13]] = { nosync }
421 ; TUNIT: attributes #[[ATTR14:[0-9]+]] = { nounwind memory(read) }
422 ; TUNIT: attributes #[[ATTR15]] = { nosync nounwind memory(read) }
423 ; TUNIT: attributes #[[ATTR16]] = { nofree willreturn memory(write) }
424 ; TUNIT: attributes #[[ATTR17]] = { nofree willreturn memory(read) }
425 ; TUNIT: attributes #[[ATTR18]] = { nounwind }
426 ; TUNIT: attributes #[[ATTR19]] = { nosync nounwind memory(write) }
428 ; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(write) }
429 ; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
430 ; CGSCC: attributes #[[ATTR2]] = { memory(read) }
431 ; CGSCC: attributes #[[ATTR3]] = { nosync memory(read) }
432 ; CGSCC: attributes #[[ATTR4]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) }
433 ; CGSCC: attributes #[[ATTR5]] = { mustprogress nofree nosync nounwind willreturn memory(argmem: write) }
434 ; CGSCC: attributes #[[ATTR6:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(write) }
435 ; CGSCC: attributes #[[ATTR7:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(read) }
436 ; CGSCC: attributes #[[ATTR8]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(read) }
437 ; CGSCC: attributes #[[ATTR9:[0-9]+]] = { nounwind memory(argmem: read) }
438 ; CGSCC: attributes #[[ATTR10]] = { nosync nounwind memory(argmem: read) }
439 ; CGSCC: attributes #[[ATTR11]] = { nounwind memory(argmem: readwrite) }
440 ; CGSCC: attributes #[[ATTR12]] = { mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite) }
441 ; CGSCC: attributes #[[ATTR13]] = { nosync memory(none) }
442 ; CGSCC: attributes #[[ATTR14]] = { nosync }
443 ; CGSCC: attributes #[[ATTR15:[0-9]+]] = { nounwind memory(read) }
444 ; CGSCC: attributes #[[ATTR16]] = { nosync nounwind memory(read) }
445 ; CGSCC: attributes #[[ATTR17]] = { nofree nosync willreturn }
446 ; CGSCC: attributes #[[ATTR18]] = { nofree willreturn memory(write) }
447 ; CGSCC: attributes #[[ATTR19]] = { nofree willreturn memory(read) }
448 ; CGSCC: attributes #[[ATTR20]] = { nounwind }
449 ; CGSCC: attributes #[[ATTR21]] = { nounwind memory(write) }