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
5 @g = global ptr null ; <ptr> [#uses=1]
8 ; CHECK: @g = global ptr null
9 ; CHECK: @lookup_table = global [2 x i1] [i1 false, i1 true]
10 ; CHECK: @g2 = global ptr null
11 ; CHECK: @g3 = global ptr null
13 define ptr @c1(ptr %q) {
14 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
15 ; CHECK-LABEL: define {{[^@]+}}@c1
16 ; CHECK-SAME: (ptr nofree readnone returned "no-capture-maybe-returned" [[Q:%.*]]) #[[ATTR0:[0-9]+]] {
17 ; CHECK-NEXT: ret ptr [[Q]]
22 ; It would also be acceptable to mark %q as readnone. Update @c3 too.
23 define void @c2(ptr %q) {
24 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
25 ; CHECK-LABEL: define {{[^@]+}}@c2
26 ; CHECK-SAME: (ptr nofree writeonly [[Q:%.*]]) #[[ATTR1:[0-9]+]] {
27 ; CHECK-NEXT: store ptr [[Q]], ptr @g, align 8
28 ; CHECK-NEXT: ret void
34 define void @c3(ptr %q) {
35 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
36 ; TUNIT-LABEL: define {{[^@]+}}@c3
37 ; TUNIT-SAME: (ptr nofree writeonly [[Q:%.*]]) #[[ATTR1]] {
38 ; TUNIT-NEXT: call void @c2(ptr nofree writeonly [[Q]]) #[[ATTR17:[0-9]+]]
39 ; TUNIT-NEXT: ret void
41 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(write)
42 ; CGSCC-LABEL: define {{[^@]+}}@c3
43 ; CGSCC-SAME: (ptr nofree writeonly [[Q:%.*]]) #[[ATTR2:[0-9]+]] {
44 ; CGSCC-NEXT: call void @c2(ptr nofree writeonly [[Q]]) #[[ATTR20:[0-9]+]]
45 ; CGSCC-NEXT: ret void
51 define i1 @c4(ptr %q, i32 %bitno) {
52 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
53 ; CHECK-LABEL: define {{[^@]+}}@c4
54 ; CHECK-SAME: (ptr nofree readnone [[Q:%.*]], i32 [[BITNO:%.*]]) #[[ATTR0]] {
55 ; CHECK-NEXT: [[TMP:%.*]] = ptrtoint ptr [[Q]] to i32
56 ; CHECK-NEXT: [[TMP2:%.*]] = lshr i32 [[TMP]], [[BITNO]]
57 ; CHECK-NEXT: [[BIT:%.*]] = trunc i32 [[TMP2]] to i1
58 ; CHECK-NEXT: br i1 [[BIT]], label [[L1:%.*]], label [[L0:%.*]]
60 ; CHECK-NEXT: ret i1 false
62 ; CHECK-NEXT: ret i1 true
64 %tmp = ptrtoint ptr %q to i32
65 %tmp2 = lshr i32 %tmp, %bitno
66 %bit = trunc i32 %tmp2 to i1
67 br i1 %bit, label %l1, label %l0
69 ret i1 0 ; escaping value not caught by def-use chaining.
71 ret i1 1 ; escaping value not caught by def-use chaining.
74 ; c4b is c4 but without the escaping part
75 define i1 @c4b(ptr %q, i32 %bitno) {
76 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
77 ; CHECK-LABEL: define {{[^@]+}}@c4b
78 ; CHECK-SAME: (ptr nocapture nofree readnone [[Q:%.*]], i32 [[BITNO:%.*]]) #[[ATTR0]] {
79 ; CHECK-NEXT: [[TMP:%.*]] = ptrtoint ptr [[Q]] to i32
80 ; CHECK-NEXT: [[TMP2:%.*]] = lshr i32 [[TMP]], [[BITNO]]
81 ; CHECK-NEXT: [[BIT:%.*]] = trunc i32 [[TMP2]] to i1
82 ; CHECK-NEXT: br i1 [[BIT]], label [[L1:%.*]], label [[L0:%.*]]
84 ; CHECK-NEXT: ret i1 false
86 ; CHECK-NEXT: ret i1 false
88 %tmp = ptrtoint ptr %q to i32
89 %tmp2 = lshr i32 %tmp, %bitno
90 %bit = trunc i32 %tmp2 to i1
91 br i1 %bit, label %l1, label %l0
93 ret i1 0 ; not escaping!
95 ret i1 0 ; not escaping!
98 @lookup_table = global [2 x i1] [ i1 0, i1 1 ]
100 define i1 @c5(ptr %q, i32 %bitno) {
101 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read)
102 ; TUNIT-LABEL: define {{[^@]+}}@c5
103 ; TUNIT-SAME: (ptr nofree readonly [[Q:%.*]], i32 [[BITNO:%.*]]) #[[ATTR2:[0-9]+]] {
104 ; TUNIT-NEXT: [[TMP:%.*]] = ptrtoint ptr [[Q]] to i32
105 ; TUNIT-NEXT: [[TMP2:%.*]] = lshr i32 [[TMP]], [[BITNO]]
106 ; TUNIT-NEXT: [[BIT:%.*]] = and i32 [[TMP2]], 1
107 ; TUNIT-NEXT: [[LOOKUP:%.*]] = getelementptr [2 x i1], ptr @lookup_table, i32 0, i32 [[BIT]]
108 ; TUNIT-NEXT: [[VAL:%.*]] = load i1, ptr [[LOOKUP]], align 1
109 ; TUNIT-NEXT: ret i1 [[VAL]]
111 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read)
112 ; CGSCC-LABEL: define {{[^@]+}}@c5
113 ; CGSCC-SAME: (ptr nofree readonly [[Q:%.*]], i32 [[BITNO:%.*]]) #[[ATTR3:[0-9]+]] {
114 ; CGSCC-NEXT: [[TMP:%.*]] = ptrtoint ptr [[Q]] to i32
115 ; CGSCC-NEXT: [[TMP2:%.*]] = lshr i32 [[TMP]], [[BITNO]]
116 ; CGSCC-NEXT: [[BIT:%.*]] = and i32 [[TMP2]], 1
117 ; CGSCC-NEXT: [[LOOKUP:%.*]] = getelementptr [2 x i1], ptr @lookup_table, i32 0, i32 [[BIT]]
118 ; CGSCC-NEXT: [[VAL:%.*]] = load i1, ptr [[LOOKUP]], align 1
119 ; CGSCC-NEXT: ret i1 [[VAL]]
121 %tmp = ptrtoint ptr %q to i32
122 %tmp2 = lshr i32 %tmp, %bitno
123 %bit = and i32 %tmp2, 1
124 ; subtle escape mechanism follows
125 %lookup = getelementptr [2 x i1], ptr @lookup_table, i32 0, i32 %bit
126 %val = load i1, ptr %lookup
130 declare void @throw_if_bit_set(ptr, i8) readonly
132 define i1 @c6(ptr %q, i8 %bit) personality ptr @__gxx_personality_v0 {
133 ; TUNIT: Function Attrs: nosync memory(read)
134 ; TUNIT-LABEL: define {{[^@]+}}@c6
135 ; TUNIT-SAME: (ptr readonly [[Q:%.*]], i8 [[BIT:%.*]]) #[[ATTR4:[0-9]+]] personality ptr @__gxx_personality_v0 {
136 ; TUNIT-NEXT: invoke void @throw_if_bit_set(ptr readonly [[Q]], i8 [[BIT]]) #[[ATTR4]]
137 ; TUNIT-NEXT: to label [[RET0:%.*]] unwind label [[RET1:%.*]]
139 ; TUNIT-NEXT: ret i1 false
141 ; TUNIT-NEXT: [[EXN:%.*]] = landingpad { ptr, i32 }
142 ; TUNIT-NEXT: cleanup
143 ; TUNIT-NEXT: ret i1 true
145 ; CGSCC: Function Attrs: nosync memory(read)
146 ; CGSCC-LABEL: define {{[^@]+}}@c6
147 ; CGSCC-SAME: (ptr readonly [[Q:%.*]], i8 [[BIT:%.*]]) #[[ATTR5:[0-9]+]] personality ptr @__gxx_personality_v0 {
148 ; CGSCC-NEXT: invoke void @throw_if_bit_set(ptr readonly [[Q]], i8 [[BIT]]) #[[ATTR5]]
149 ; CGSCC-NEXT: to label [[RET0:%.*]] unwind label [[RET1:%.*]]
151 ; CGSCC-NEXT: ret i1 false
153 ; CGSCC-NEXT: [[EXN:%.*]] = landingpad { ptr, i32 }
154 ; CGSCC-NEXT: cleanup
155 ; CGSCC-NEXT: ret i1 true
157 invoke void @throw_if_bit_set(ptr %q, i8 %bit)
158 to label %ret0 unwind label %ret1
162 %exn = landingpad {ptr, i32}
167 declare i32 @__gxx_personality_v0(...)
169 define ptr @lookup_bit(ptr %q, i32 %bitno) readnone nounwind {
170 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
171 ; CHECK-LABEL: define {{[^@]+}}@lookup_bit
172 ; CHECK-SAME: (ptr nofree readnone [[Q:%.*]], i32 [[BITNO:%.*]]) #[[ATTR0]] {
173 ; CHECK-NEXT: [[TMP:%.*]] = ptrtoint ptr [[Q]] to i32
174 ; CHECK-NEXT: [[TMP2:%.*]] = lshr i32 [[TMP]], [[BITNO]]
175 ; CHECK-NEXT: [[BIT:%.*]] = and i32 [[TMP2]], 1
176 ; CHECK-NEXT: [[LOOKUP:%.*]] = getelementptr [2 x i1], ptr @lookup_table, i32 0, i32 [[BIT]]
177 ; CHECK-NEXT: ret ptr [[LOOKUP]]
179 %tmp = ptrtoint ptr %q to i32
180 %tmp2 = lshr i32 %tmp, %bitno
181 %bit = and i32 %tmp2, 1
182 %lookup = getelementptr [2 x i1], ptr @lookup_table, i32 0, i32 %bit
186 define i1 @c7(ptr %q, i32 %bitno) {
187 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read)
188 ; TUNIT-LABEL: define {{[^@]+}}@c7
189 ; TUNIT-SAME: (ptr nofree readonly [[Q:%.*]], i32 [[BITNO:%.*]]) #[[ATTR2]] {
190 ; TUNIT-NEXT: [[PTR:%.*]] = call ptr @lookup_bit(ptr noalias nofree readnone [[Q]], i32 [[BITNO]]) #[[ATTR18:[0-9]+]]
191 ; TUNIT-NEXT: [[VAL:%.*]] = load i1, ptr [[PTR]], align 1
192 ; TUNIT-NEXT: ret i1 [[VAL]]
194 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(read)
195 ; CGSCC-LABEL: define {{[^@]+}}@c7
196 ; CGSCC-SAME: (ptr nofree readonly [[Q:%.*]], i32 [[BITNO:%.*]]) #[[ATTR6:[0-9]+]] {
197 ; CGSCC-NEXT: [[PTR:%.*]] = call ptr @lookup_bit(ptr noalias nofree readnone [[Q]], i32 [[BITNO]]) #[[ATTR21:[0-9]+]]
198 ; CGSCC-NEXT: [[VAL:%.*]] = load i1, ptr [[PTR]], align 1
199 ; CGSCC-NEXT: ret i1 [[VAL]]
201 %ptr = call ptr @lookup_bit(ptr %q, i32 %bitno)
202 %val = load i1, ptr %ptr
207 define i32 @nc1(ptr %q, ptr %p, i1 %b) {
208 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn
209 ; TUNIT-LABEL: define {{[^@]+}}@nc1
210 ; TUNIT-SAME: (ptr nofree [[Q:%.*]], ptr nocapture nofree [[P:%.*]], i1 [[B:%.*]]) #[[ATTR5:[0-9]+]] {
212 ; TUNIT-NEXT: br label [[L:%.*]]
214 ; TUNIT-NEXT: [[X:%.*]] = phi ptr [ [[P]], [[E:%.*]] ]
215 ; TUNIT-NEXT: [[Y:%.*]] = phi ptr [ [[Q]], [[E]] ]
216 ; TUNIT-NEXT: [[TMP2:%.*]] = select i1 [[B]], ptr [[P]], ptr [[Q]]
217 ; TUNIT-NEXT: [[VAL:%.*]] = load i32, ptr [[TMP2]], align 4
218 ; TUNIT-NEXT: store i32 0, ptr [[P]], align 4
219 ; TUNIT-NEXT: store ptr [[Q]], ptr @g, align 8
220 ; TUNIT-NEXT: ret i32 [[VAL]]
222 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn
223 ; CGSCC-LABEL: define {{[^@]+}}@nc1
224 ; CGSCC-SAME: (ptr nofree [[Q:%.*]], ptr nocapture nofree [[P:%.*]], i1 [[B:%.*]]) #[[ATTR7:[0-9]+]] {
226 ; CGSCC-NEXT: br label [[L:%.*]]
228 ; CGSCC-NEXT: [[X:%.*]] = phi ptr [ [[P]], [[E:%.*]] ]
229 ; CGSCC-NEXT: [[Y:%.*]] = phi ptr [ [[Q]], [[E]] ]
230 ; CGSCC-NEXT: [[TMP2:%.*]] = select i1 [[B]], ptr [[P]], ptr [[Q]]
231 ; CGSCC-NEXT: [[VAL:%.*]] = load i32, ptr [[TMP2]], align 4
232 ; CGSCC-NEXT: store i32 0, ptr [[P]], align 4
233 ; CGSCC-NEXT: store ptr [[Q]], ptr @g, align 8
234 ; CGSCC-NEXT: ret i32 [[VAL]]
239 %x = phi ptr [ %p, %e ]
240 %y = phi ptr [ %q, %e ]
241 %tmp2 = select i1 %b, ptr %x, ptr %y
242 %val = load i32, ptr %tmp2 ; <i32> [#uses=1]
248 define i32 @nc1_addrspace(ptr %q, ptr addrspace(1) %p, i1 %b) {
249 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn
250 ; TUNIT-LABEL: define {{[^@]+}}@nc1_addrspace
251 ; TUNIT-SAME: (ptr nofree [[Q:%.*]], ptr addrspace(1) nocapture nofree [[P:%.*]], i1 [[B:%.*]]) #[[ATTR5]] {
253 ; TUNIT-NEXT: br label [[L:%.*]]
255 ; TUNIT-NEXT: [[X:%.*]] = phi ptr addrspace(1) [ [[P]], [[E:%.*]] ]
256 ; TUNIT-NEXT: [[Y:%.*]] = phi ptr [ [[Q]], [[E]] ]
257 ; TUNIT-NEXT: [[TMP:%.*]] = addrspacecast ptr addrspace(1) [[P]] to ptr
258 ; TUNIT-NEXT: [[TMP2:%.*]] = select i1 [[B]], ptr [[TMP]], ptr [[Q]]
259 ; TUNIT-NEXT: [[VAL:%.*]] = load i32, ptr [[TMP2]], align 4
260 ; TUNIT-NEXT: store i32 0, ptr addrspace(1) [[P]], align 4
261 ; TUNIT-NEXT: store ptr [[Q]], ptr @g, align 8
262 ; TUNIT-NEXT: ret i32 [[VAL]]
264 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn
265 ; CGSCC-LABEL: define {{[^@]+}}@nc1_addrspace
266 ; CGSCC-SAME: (ptr nofree [[Q:%.*]], ptr addrspace(1) nocapture nofree [[P:%.*]], i1 [[B:%.*]]) #[[ATTR7]] {
268 ; CGSCC-NEXT: br label [[L:%.*]]
270 ; CGSCC-NEXT: [[X:%.*]] = phi ptr addrspace(1) [ [[P]], [[E:%.*]] ]
271 ; CGSCC-NEXT: [[Y:%.*]] = phi ptr [ [[Q]], [[E]] ]
272 ; CGSCC-NEXT: [[TMP:%.*]] = addrspacecast ptr addrspace(1) [[P]] to ptr
273 ; CGSCC-NEXT: [[TMP2:%.*]] = select i1 [[B]], ptr [[TMP]], ptr [[Q]]
274 ; CGSCC-NEXT: [[VAL:%.*]] = load i32, ptr [[TMP2]], align 4
275 ; CGSCC-NEXT: store i32 0, ptr addrspace(1) [[P]], align 4
276 ; CGSCC-NEXT: store ptr [[Q]], ptr @g, align 8
277 ; CGSCC-NEXT: ret i32 [[VAL]]
282 %x = phi ptr addrspace(1) [ %p, %e ]
283 %y = phi ptr [ %q, %e ]
284 %tmp = addrspacecast ptr addrspace(1) %x to ptr ; <ptr> [#uses=2]
285 %tmp2 = select i1 %b, ptr %tmp, ptr %y
286 %val = load i32, ptr %tmp2 ; <i32> [#uses=1]
287 store i32 0, ptr %tmp
292 define void @nc2(ptr %p, ptr %q) {
293 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn
294 ; TUNIT-LABEL: define {{[^@]+}}@nc2
295 ; TUNIT-SAME: (ptr nocapture nofree [[P:%.*]], ptr nofree [[Q:%.*]]) #[[ATTR5]] {
296 ; TUNIT-NEXT: [[TMP1:%.*]] = call i32 @nc1(ptr nofree [[Q]], ptr nocapture nofree [[P]], i1 noundef false) #[[ATTR19:[0-9]+]]
297 ; TUNIT-NEXT: ret void
299 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn
300 ; CGSCC-LABEL: define {{[^@]+}}@nc2
301 ; CGSCC-SAME: (ptr nocapture nofree align 4 [[P:%.*]], ptr nofree [[Q:%.*]]) #[[ATTR8:[0-9]+]] {
302 ; CGSCC-NEXT: [[TMP1:%.*]] = call i32 @nc1(ptr nofree [[Q]], ptr nocapture nofree align 4 [[P]], i1 noundef false) #[[ATTR22:[0-9]+]]
303 ; CGSCC-NEXT: ret void
305 %1 = call i32 @nc1(ptr %q, ptr %p, i1 0) ; <i32> [#uses=0]
310 define void @nc3(ptr %p) {
311 ; CHECK-LABEL: define {{[^@]+}}@nc3
312 ; CHECK-SAME: (ptr nocapture nofree noundef nonnull [[P:%.*]]) {
313 ; CHECK-NEXT: call void [[P]]()
314 ; CHECK-NEXT: ret void
320 ; The following test is tricky because improvements to AAIsDead can cause the call to be removed.
321 ; FIXME: readonly and nocapture missing on the pointer.
322 declare void @external(ptr readonly) nounwind argmemonly
323 define void @nc4(ptr %p) {
324 ; TUNIT: Function Attrs: nounwind memory(argmem: readwrite)
325 ; TUNIT-LABEL: define {{[^@]+}}@nc4
326 ; TUNIT-SAME: (ptr nofree [[P:%.*]]) #[[ATTR6:[0-9]+]] {
327 ; TUNIT-NEXT: call void @external(ptr nofree readonly [[P]]) #[[ATTR20:[0-9]+]]
328 ; TUNIT-NEXT: ret void
330 ; CGSCC: Function Attrs: nounwind memory(argmem: readwrite)
331 ; CGSCC-LABEL: define {{[^@]+}}@nc4
332 ; CGSCC-SAME: (ptr nofree [[P:%.*]]) #[[ATTR9:[0-9]+]] {
333 ; CGSCC-NEXT: call void @external(ptr nofree readonly [[P]]) #[[ATTR23:[0-9]+]]
334 ; CGSCC-NEXT: ret void
336 call void @external(ptr %p)
340 define void @nc5(ptr %f, ptr %p) {
341 ; CHECK-LABEL: define {{[^@]+}}@nc5
342 ; CHECK-SAME: (ptr nocapture nofree noundef nonnull [[F:%.*]], ptr nocapture [[P:%.*]]) {
343 ; CHECK-NEXT: call void [[F]](ptr nocapture [[P]])
344 ; CHECK-NEXT: ret void
346 call void %f(ptr %p) readonly nounwind
347 call void %f(ptr nocapture %p)
351 ; It would be acceptable to add readnone to %y1_1 and %y1_2.
352 define void @test1_1(ptr %x1_1, ptr %y1_1, i1 %c) {
353 ; TUNIT: Function Attrs: nofree nosync nounwind memory(write)
354 ; TUNIT-LABEL: define {{[^@]+}}@test1_1
355 ; TUNIT-SAME: (ptr nocapture nofree readnone [[X1_1:%.*]], ptr nocapture nofree readnone [[Y1_1:%.*]], i1 [[C:%.*]]) #[[ATTR7:[0-9]+]] {
356 ; TUNIT-NEXT: [[TMP1:%.*]] = call ptr @test1_2(ptr noalias nocapture nofree readnone undef, ptr noalias nofree readnone "no-capture-maybe-returned" [[Y1_1]], i1 noundef [[C]]) #[[ATTR7]]
357 ; TUNIT-NEXT: store ptr null, ptr @g, align 8
358 ; TUNIT-NEXT: ret void
360 ; CGSCC: Function Attrs: nofree nosync nounwind memory(write)
361 ; CGSCC-LABEL: define {{[^@]+}}@test1_1
362 ; CGSCC-SAME: (ptr nocapture nofree readnone [[X1_1:%.*]], ptr nocapture nofree readnone [[Y1_1:%.*]], i1 [[C:%.*]]) #[[ATTR10:[0-9]+]] {
363 ; CGSCC-NEXT: [[TMP1:%.*]] = call ptr @test1_2(ptr noalias nocapture nofree readnone undef, ptr noalias nofree readnone "no-capture-maybe-returned" [[Y1_1]], i1 noundef [[C]]) #[[ATTR10]]
364 ; CGSCC-NEXT: store ptr null, ptr @g, align 8
365 ; CGSCC-NEXT: ret void
367 call ptr @test1_2(ptr %x1_1, ptr %y1_1, i1 %c)
368 store ptr null, ptr @g
372 define ptr @test1_2(ptr %x1_2, ptr %y1_2, i1 %c) {
373 ; TUNIT: Function Attrs: nofree nosync nounwind memory(write)
374 ; TUNIT-LABEL: define {{[^@]+}}@test1_2
375 ; TUNIT-SAME: (ptr nocapture nofree readnone [[X1_2:%.*]], ptr nofree readnone returned "no-capture-maybe-returned" [[Y1_2:%.*]], i1 noundef [[C:%.*]]) #[[ATTR7]] {
376 ; TUNIT-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
378 ; TUNIT-NEXT: call void @test1_1(ptr noalias nocapture nofree readnone undef, ptr noalias nocapture nofree readnone [[Y1_2]], i1 noundef [[C]]) #[[ATTR7]]
379 ; TUNIT-NEXT: store ptr null, ptr @g, align 8
380 ; TUNIT-NEXT: br label [[F]]
382 ; TUNIT-NEXT: ret ptr [[Y1_2]]
384 ; CGSCC: Function Attrs: nofree nosync nounwind memory(write)
385 ; CGSCC-LABEL: define {{[^@]+}}@test1_2
386 ; CGSCC-SAME: (ptr nocapture nofree readnone [[X1_2:%.*]], ptr nofree readnone returned "no-capture-maybe-returned" [[Y1_2:%.*]], i1 noundef [[C:%.*]]) #[[ATTR10]] {
387 ; CGSCC-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
389 ; CGSCC-NEXT: call void @test1_1(ptr noalias nocapture nofree readnone undef, ptr noalias nocapture nofree readnone [[Y1_2]], i1 noundef [[C]]) #[[ATTR10]]
390 ; CGSCC-NEXT: store ptr null, ptr @g, align 8
391 ; CGSCC-NEXT: br label [[F]]
393 ; CGSCC-NEXT: ret ptr [[Y1_2]]
395 br i1 %c, label %t, label %f
397 call void @test1_1(ptr %x1_2, ptr %y1_2, i1 %c)
398 store ptr null, ptr @g
404 define void @test2(ptr %x2) {
405 ; TUNIT: Function Attrs: nofree nosync nounwind memory(write)
406 ; TUNIT-LABEL: define {{[^@]+}}@test2
407 ; TUNIT-SAME: (ptr nocapture nofree readnone [[X2:%.*]]) #[[ATTR7]] {
408 ; TUNIT-NEXT: call void @test2(ptr noalias nocapture nofree readnone undef) #[[ATTR7]]
409 ; TUNIT-NEXT: store ptr null, ptr @g, align 8
410 ; TUNIT-NEXT: ret void
412 ; CGSCC: Function Attrs: nofree nosync nounwind memory(write)
413 ; CGSCC-LABEL: define {{[^@]+}}@test2
414 ; CGSCC-SAME: (ptr nocapture nofree readnone [[X2:%.*]]) #[[ATTR10]] {
415 ; CGSCC-NEXT: call void @test2(ptr noalias nocapture nofree readnone undef) #[[ATTR10]]
416 ; CGSCC-NEXT: store ptr null, ptr @g, align 8
417 ; CGSCC-NEXT: ret void
419 call void @test2(ptr %x2)
420 store ptr null, ptr @g
424 define void @test3(ptr %x3, ptr %y3, ptr %z3) {
425 ; TUNIT: Function Attrs: nofree nosync nounwind memory(write)
426 ; TUNIT-LABEL: define {{[^@]+}}@test3
427 ; TUNIT-SAME: (ptr nocapture nofree readnone [[X3:%.*]], ptr nocapture nofree readnone [[Y3:%.*]], ptr nocapture nofree readnone [[Z3:%.*]]) #[[ATTR7]] {
428 ; TUNIT-NEXT: call void @test3(ptr noalias nocapture nofree readnone undef, ptr noalias nocapture nofree readnone undef, ptr noalias nocapture nofree readnone undef) #[[ATTR7]]
429 ; TUNIT-NEXT: store ptr null, ptr @g, align 8
430 ; TUNIT-NEXT: ret void
432 ; CGSCC: Function Attrs: nofree nosync nounwind memory(write)
433 ; CGSCC-LABEL: define {{[^@]+}}@test3
434 ; CGSCC-SAME: (ptr nocapture nofree readnone [[X3:%.*]], ptr nocapture nofree readnone [[Y3:%.*]], ptr nocapture nofree readnone [[Z3:%.*]]) #[[ATTR10]] {
435 ; CGSCC-NEXT: call void @test3(ptr noalias nocapture nofree readnone undef, ptr noalias nocapture nofree readnone undef, ptr noalias nocapture nofree readnone undef) #[[ATTR10]]
436 ; CGSCC-NEXT: store ptr null, ptr @g, align 8
437 ; CGSCC-NEXT: ret void
439 call void @test3(ptr %z3, ptr %y3, ptr %x3)
440 store ptr null, ptr @g
444 define void @test4_1(ptr %x4_1, i1 %c) {
445 ; TUNIT: Function Attrs: nofree nosync nounwind memory(write)
446 ; TUNIT-LABEL: define {{[^@]+}}@test4_1
447 ; TUNIT-SAME: (ptr nocapture nofree readnone [[X4_1:%.*]], i1 [[C:%.*]]) #[[ATTR7]] {
448 ; TUNIT-NEXT: [[TMP1:%.*]] = call ptr @test4_2(ptr noalias nocapture nofree readnone undef, ptr noalias nofree readnone "no-capture-maybe-returned" [[X4_1]], ptr noalias nocapture nofree readnone undef, i1 noundef [[C]]) #[[ATTR7]]
449 ; TUNIT-NEXT: store ptr null, ptr @g, align 8
450 ; TUNIT-NEXT: ret void
452 ; CGSCC: Function Attrs: nofree nosync nounwind memory(write)
453 ; CGSCC-LABEL: define {{[^@]+}}@test4_1
454 ; CGSCC-SAME: (ptr nocapture nofree readnone [[X4_1:%.*]], i1 [[C:%.*]]) #[[ATTR10]] {
455 ; CGSCC-NEXT: [[TMP1:%.*]] = call ptr @test4_2(ptr noalias nocapture nofree readnone undef, ptr noalias nofree readnone "no-capture-maybe-returned" [[X4_1]], ptr noalias nocapture nofree readnone undef, i1 noundef [[C]]) #[[ATTR10]]
456 ; CGSCC-NEXT: store ptr null, ptr @g, align 8
457 ; CGSCC-NEXT: ret void
459 call ptr @test4_2(ptr %x4_1, ptr %x4_1, ptr %x4_1, i1 %c)
460 store ptr null, ptr @g
464 define ptr @test4_2(ptr %x4_2, ptr %y4_2, ptr %z4_2, i1 %c) {
465 ; TUNIT: Function Attrs: nofree nosync nounwind memory(write)
466 ; TUNIT-LABEL: define {{[^@]+}}@test4_2
467 ; TUNIT-SAME: (ptr nocapture nofree readnone [[X4_2:%.*]], ptr nofree readnone returned "no-capture-maybe-returned" [[Y4_2:%.*]], ptr nocapture nofree readnone [[Z4_2:%.*]], i1 noundef [[C:%.*]]) #[[ATTR7]] {
468 ; TUNIT-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
470 ; TUNIT-NEXT: call void @test4_1(ptr nofree noundef readnone align 4294967296 null, i1 noundef [[C]]) #[[ATTR7]]
471 ; TUNIT-NEXT: store ptr null, ptr @g, align 8
472 ; TUNIT-NEXT: br label [[F]]
474 ; TUNIT-NEXT: ret ptr [[Y4_2]]
476 ; CGSCC: Function Attrs: nofree nosync nounwind memory(write)
477 ; CGSCC-LABEL: define {{[^@]+}}@test4_2
478 ; CGSCC-SAME: (ptr nocapture nofree readnone [[X4_2:%.*]], ptr nofree readnone returned "no-capture-maybe-returned" [[Y4_2:%.*]], ptr nocapture nofree readnone [[Z4_2:%.*]], i1 noundef [[C:%.*]]) #[[ATTR10]] {
479 ; CGSCC-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
481 ; CGSCC-NEXT: call void @test4_1(ptr nofree noundef readnone align 4294967296 null, i1 noundef [[C]]) #[[ATTR10]]
482 ; CGSCC-NEXT: store ptr null, ptr @g, align 8
483 ; CGSCC-NEXT: br label [[F]]
485 ; CGSCC-NEXT: ret ptr [[Y4_2]]
487 br i1 %c, label %t, label %f
489 call void @test4_1(ptr null, i1 %c)
490 store ptr null, ptr @g
496 declare ptr @test5_1(ptr %x5_1)
498 define void @test5_2(ptr %x5_2) {
499 ; CHECK-LABEL: define {{[^@]+}}@test5_2
500 ; CHECK-SAME: (ptr [[X5_2:%.*]]) {
501 ; CHECK-NEXT: [[TMP1:%.*]] = call ptr @test5_1(ptr [[X5_2]])
502 ; CHECK-NEXT: store ptr null, ptr @g, align 8
503 ; CHECK-NEXT: ret void
505 call ptr @test5_1(ptr %x5_2)
506 store ptr null, ptr @g
510 declare void @test6_1(ptr %x6_1, ptr nocapture %y6_1, ...)
512 define void @test6_2(ptr %x6_2, ptr %y6_2, ptr %z6_2) {
513 ; CHECK-LABEL: define {{[^@]+}}@test6_2
514 ; CHECK-SAME: (ptr [[X6_2:%.*]], ptr nocapture [[Y6_2:%.*]], ptr [[Z6_2:%.*]]) {
515 ; CHECK-NEXT: call void (ptr, ptr, ...) @test6_1(ptr [[X6_2]], ptr nocapture [[Y6_2]], ptr [[Z6_2]])
516 ; CHECK-NEXT: store ptr null, ptr @g, align 8
517 ; CHECK-NEXT: ret void
519 call void (ptr, ptr, ...) @test6_1(ptr %x6_2, ptr %y6_2, ptr %z6_2)
520 store ptr null, ptr @g
524 define void @test_cmpxchg(ptr %p) {
525 ; TUNIT: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite)
526 ; TUNIT-LABEL: define {{[^@]+}}@test_cmpxchg
527 ; TUNIT-SAME: (ptr nocapture nofree noundef nonnull align 4 dereferenceable(4) [[P:%.*]]) #[[ATTR8:[0-9]+]] {
528 ; TUNIT-NEXT: [[TMP1:%.*]] = cmpxchg ptr [[P]], i32 0, i32 1 acquire monotonic, align 4
529 ; TUNIT-NEXT: ret void
531 ; CGSCC: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite)
532 ; CGSCC-LABEL: define {{[^@]+}}@test_cmpxchg
533 ; CGSCC-SAME: (ptr nocapture nofree noundef nonnull align 4 dereferenceable(4) [[P:%.*]]) #[[ATTR11:[0-9]+]] {
534 ; CGSCC-NEXT: [[TMP1:%.*]] = cmpxchg ptr [[P]], i32 0, i32 1 acquire monotonic, align 4
535 ; CGSCC-NEXT: ret void
537 cmpxchg ptr %p, i32 0, i32 1 acquire monotonic
541 define void @test_cmpxchg_ptr(ptr %p, ptr %q) {
542 ; TUNIT: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite)
543 ; TUNIT-LABEL: define {{[^@]+}}@test_cmpxchg_ptr
544 ; TUNIT-SAME: (ptr nocapture nofree noundef nonnull align 8 dereferenceable(8) [[P:%.*]], ptr nofree [[Q:%.*]]) #[[ATTR8]] {
545 ; TUNIT-NEXT: [[TMP1:%.*]] = cmpxchg ptr [[P]], ptr null, ptr [[Q]] acquire monotonic, align 8
546 ; TUNIT-NEXT: ret void
548 ; CGSCC: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite)
549 ; CGSCC-LABEL: define {{[^@]+}}@test_cmpxchg_ptr
550 ; CGSCC-SAME: (ptr nocapture nofree noundef nonnull align 8 dereferenceable(8) [[P:%.*]], ptr nofree [[Q:%.*]]) #[[ATTR11]] {
551 ; CGSCC-NEXT: [[TMP1:%.*]] = cmpxchg ptr [[P]], ptr null, ptr [[Q]] acquire monotonic, align 8
552 ; CGSCC-NEXT: ret void
554 cmpxchg ptr %p, ptr null, ptr %q acquire monotonic
558 define void @test_atomicrmw(ptr %p) {
559 ; TUNIT: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite)
560 ; TUNIT-LABEL: define {{[^@]+}}@test_atomicrmw
561 ; TUNIT-SAME: (ptr nocapture nofree noundef nonnull align 4 dereferenceable(4) [[P:%.*]]) #[[ATTR8]] {
562 ; TUNIT-NEXT: [[TMP1:%.*]] = atomicrmw add ptr [[P]], i32 1 seq_cst, align 4
563 ; TUNIT-NEXT: ret void
565 ; CGSCC: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite)
566 ; CGSCC-LABEL: define {{[^@]+}}@test_atomicrmw
567 ; CGSCC-SAME: (ptr nocapture nofree noundef nonnull align 4 dereferenceable(4) [[P:%.*]]) #[[ATTR11]] {
568 ; CGSCC-NEXT: [[TMP1:%.*]] = atomicrmw add ptr [[P]], i32 1 seq_cst, align 4
569 ; CGSCC-NEXT: ret void
571 atomicrmw add ptr %p, i32 1 seq_cst
575 define void @test_volatile(ptr %x) {
576 ; TUNIT: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite)
577 ; TUNIT-LABEL: define {{[^@]+}}@test_volatile
578 ; TUNIT-SAME: (ptr nofree align 4 [[X:%.*]]) #[[ATTR8]] {
580 ; TUNIT-NEXT: [[GEP:%.*]] = getelementptr i32, ptr [[X]], i64 1
581 ; TUNIT-NEXT: store volatile i32 0, ptr [[GEP]], align 4
582 ; TUNIT-NEXT: ret void
584 ; CGSCC: Function Attrs: mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite)
585 ; CGSCC-LABEL: define {{[^@]+}}@test_volatile
586 ; CGSCC-SAME: (ptr nofree align 4 [[X:%.*]]) #[[ATTR11]] {
588 ; CGSCC-NEXT: [[GEP:%.*]] = getelementptr i32, ptr [[X]], i64 1
589 ; CGSCC-NEXT: store volatile i32 0, ptr [[GEP]], align 4
590 ; CGSCC-NEXT: ret void
593 %gep = getelementptr i32, ptr %x, i64 1
594 store volatile i32 0, ptr %gep, align 4
598 define void @nocaptureLaunder(ptr %p) {
599 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite)
600 ; TUNIT-LABEL: define {{[^@]+}}@nocaptureLaunder
601 ; TUNIT-SAME: (ptr nocapture nofree [[P:%.*]]) #[[ATTR9:[0-9]+]] {
603 ; TUNIT-NEXT: [[B:%.*]] = call ptr @llvm.launder.invariant.group.p0(ptr nofree [[P]]) #[[ATTR21:[0-9]+]]
604 ; TUNIT-NEXT: store i8 42, ptr [[B]], align 1
605 ; TUNIT-NEXT: ret void
607 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite)
608 ; CGSCC-LABEL: define {{[^@]+}}@nocaptureLaunder
609 ; CGSCC-SAME: (ptr nocapture nofree [[P:%.*]]) #[[ATTR12:[0-9]+]] {
611 ; CGSCC-NEXT: [[B:%.*]] = call ptr @llvm.launder.invariant.group.p0(ptr nofree [[P]]) #[[ATTR24:[0-9]+]]
612 ; CGSCC-NEXT: store i8 42, ptr [[B]], align 1
613 ; CGSCC-NEXT: ret void
616 %b = call ptr @llvm.launder.invariant.group.p0(ptr %p)
621 @g2 = global ptr null
622 define void @captureLaunder(ptr %p) {
623 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn
624 ; TUNIT-LABEL: define {{[^@]+}}@captureLaunder
625 ; TUNIT-SAME: (ptr nofree [[P:%.*]]) #[[ATTR5]] {
626 ; TUNIT-NEXT: [[B:%.*]] = call ptr @llvm.launder.invariant.group.p0(ptr nofree [[P]]) #[[ATTR21]]
627 ; TUNIT-NEXT: store ptr [[B]], ptr @g2, align 8
628 ; TUNIT-NEXT: ret void
630 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn
631 ; CGSCC-LABEL: define {{[^@]+}}@captureLaunder
632 ; CGSCC-SAME: (ptr nofree [[P:%.*]]) #[[ATTR7]] {
633 ; CGSCC-NEXT: [[B:%.*]] = call ptr @llvm.launder.invariant.group.p0(ptr nofree [[P]]) #[[ATTR24]]
634 ; CGSCC-NEXT: store ptr [[B]], ptr @g2, align 8
635 ; CGSCC-NEXT: ret void
637 %b = call ptr @llvm.launder.invariant.group.p0(ptr %p)
638 store ptr %b, ptr @g2
642 define void @nocaptureStrip(ptr %p) {
643 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
644 ; TUNIT-LABEL: define {{[^@]+}}@nocaptureStrip
645 ; TUNIT-SAME: (ptr nocapture nofree writeonly [[P:%.*]]) #[[ATTR10:[0-9]+]] {
647 ; TUNIT-NEXT: [[B:%.*]] = call ptr @llvm.strip.invariant.group.p0(ptr noalias nofree readnone [[P]]) #[[ATTR22:[0-9]+]]
648 ; TUNIT-NEXT: store i8 42, ptr [[B]], align 1
649 ; TUNIT-NEXT: ret void
651 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
652 ; CGSCC-LABEL: define {{[^@]+}}@nocaptureStrip
653 ; CGSCC-SAME: (ptr nocapture nofree writeonly [[P:%.*]]) #[[ATTR13:[0-9]+]] {
655 ; CGSCC-NEXT: [[B:%.*]] = call ptr @llvm.strip.invariant.group.p0(ptr noalias nofree readnone [[P]]) #[[ATTR21]]
656 ; CGSCC-NEXT: store i8 42, ptr [[B]], align 1
657 ; CGSCC-NEXT: ret void
660 %b = call ptr @llvm.strip.invariant.group.p0(ptr %p)
665 @g3 = global ptr null
666 define void @captureStrip(ptr %p) {
667 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
668 ; TUNIT-LABEL: define {{[^@]+}}@captureStrip
669 ; TUNIT-SAME: (ptr nofree writeonly [[P:%.*]]) #[[ATTR1]] {
670 ; TUNIT-NEXT: [[B:%.*]] = call ptr @llvm.strip.invariant.group.p0(ptr noalias nofree readnone [[P]]) #[[ATTR22]]
671 ; TUNIT-NEXT: store ptr [[B]], ptr @g3, align 8
672 ; TUNIT-NEXT: ret void
674 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
675 ; CGSCC-LABEL: define {{[^@]+}}@captureStrip
676 ; CGSCC-SAME: (ptr nofree writeonly [[P:%.*]]) #[[ATTR1]] {
677 ; CGSCC-NEXT: [[B:%.*]] = call ptr @llvm.strip.invariant.group.p0(ptr noalias nofree readnone [[P]]) #[[ATTR21]]
678 ; CGSCC-NEXT: store ptr [[B]], ptr @g3, align 8
679 ; CGSCC-NEXT: ret void
681 %b = call ptr @llvm.strip.invariant.group.p0(ptr %p)
682 store ptr %b, ptr @g3
686 define i1 @captureICmp(ptr %x) {
687 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
688 ; CHECK-LABEL: define {{[^@]+}}@captureICmp
689 ; CHECK-SAME: (ptr nofree readnone [[X:%.*]]) #[[ATTR0]] {
690 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq ptr [[X]], null
691 ; CHECK-NEXT: ret i1 [[TMP1]]
693 %1 = icmp eq ptr %x, null
697 define i1 @captureICmpRev(ptr %x) {
698 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
699 ; CHECK-LABEL: define {{[^@]+}}@captureICmpRev
700 ; CHECK-SAME: (ptr nofree readnone [[X:%.*]]) #[[ATTR0]] {
701 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq ptr null, [[X]]
702 ; CHECK-NEXT: ret i1 [[TMP1]]
704 %1 = icmp eq ptr null, %x
708 define i1 @nocaptureInboundsGEPICmp(ptr %x) {
709 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
710 ; CHECK-LABEL: define {{[^@]+}}@nocaptureInboundsGEPICmp
711 ; CHECK-SAME: (ptr nocapture nofree readnone [[X:%.*]]) #[[ATTR0]] {
712 ; CHECK-NEXT: ret i1 false
714 %1 = getelementptr inbounds i32, ptr %x, i32 5
715 %2 = icmp eq ptr %1, null
719 define i1 @nocaptureInboundsGEPICmpRev(ptr %x) {
720 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
721 ; CHECK-LABEL: define {{[^@]+}}@nocaptureInboundsGEPICmpRev
722 ; CHECK-SAME: (ptr nocapture nofree readnone [[X:%.*]]) #[[ATTR0]] {
723 ; CHECK-NEXT: ret i1 true
725 %1 = getelementptr inbounds i32, ptr %x, i32 5
726 %2 = icmp ne ptr null, %1
730 define i1 @nocaptureDereferenceableOrNullICmp(ptr dereferenceable_or_null(4) %x) {
731 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
732 ; CHECK-LABEL: define {{[^@]+}}@nocaptureDereferenceableOrNullICmp
733 ; CHECK-SAME: (ptr nocapture nofree noundef readnone dereferenceable_or_null(4) [[X:%.*]]) #[[ATTR0]] {
734 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq ptr [[X]], null
735 ; CHECK-NEXT: ret i1 [[TMP1]]
737 %1 = icmp eq ptr %x, null
741 define i1 @captureDereferenceableOrNullICmp(ptr dereferenceable_or_null(4) %x) null_pointer_is_valid {
742 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind null_pointer_is_valid willreturn memory(none)
743 ; TUNIT-LABEL: define {{[^@]+}}@captureDereferenceableOrNullICmp
744 ; TUNIT-SAME: (ptr nofree noundef readnone dereferenceable_or_null(4) [[X:%.*]]) #[[ATTR11:[0-9]+]] {
745 ; TUNIT-NEXT: [[TMP1:%.*]] = icmp eq ptr [[X]], null
746 ; TUNIT-NEXT: ret i1 [[TMP1]]
748 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind null_pointer_is_valid willreturn memory(none)
749 ; CGSCC-LABEL: define {{[^@]+}}@captureDereferenceableOrNullICmp
750 ; CGSCC-SAME: (ptr nofree noundef readnone dereferenceable_or_null(4) [[X:%.*]]) #[[ATTR14:[0-9]+]] {
751 ; CGSCC-NEXT: [[TMP1:%.*]] = icmp eq ptr [[X]], null
752 ; CGSCC-NEXT: ret i1 [[TMP1]]
754 %1 = icmp eq ptr %x, null
758 declare void @unknown(ptr)
759 ; We know that 'null' in AS 0 does not alias anything and cannot be captured. Though the latter is not qurried -> derived atm.
760 define void @test_callsite() {
761 ; CHECK-LABEL: define {{[^@]+}}@test_callsite() {
763 ; CHECK-NEXT: call void @unknown(ptr noundef align 4294967296 null)
764 ; CHECK-NEXT: ret void
767 call void @unknown(ptr null)
771 declare ptr @unknownpi8pi8(ptr,ptr returned)
772 define ptr @test_returned1(ptr %A, ptr returned %B) nounwind readonly {
773 ; TUNIT: Function Attrs: nosync nounwind memory(read)
774 ; TUNIT-LABEL: define {{[^@]+}}@test_returned1
775 ; TUNIT-SAME: (ptr nocapture [[A:%.*]], ptr returned [[B:%.*]]) #[[ATTR12:[0-9]+]] {
777 ; TUNIT-NEXT: [[P:%.*]] = call ptr @unknownpi8pi8(ptr [[A]], ptr [[B]])
778 ; TUNIT-NEXT: ret ptr [[P]]
780 ; CGSCC: Function Attrs: nosync nounwind memory(read)
781 ; CGSCC-LABEL: define {{[^@]+}}@test_returned1
782 ; CGSCC-SAME: (ptr nocapture [[A:%.*]], ptr returned [[B:%.*]]) #[[ATTR15:[0-9]+]] {
784 ; CGSCC-NEXT: [[P:%.*]] = call ptr @unknownpi8pi8(ptr [[A]], ptr [[B]])
785 ; CGSCC-NEXT: ret ptr [[P]]
788 %p = call ptr @unknownpi8pi8(ptr %A, ptr %B)
792 define ptr @test_returned2(ptr %A, ptr %B) {
793 ; TUNIT: Function Attrs: nosync nounwind memory(read)
794 ; TUNIT-LABEL: define {{[^@]+}}@test_returned2
795 ; TUNIT-SAME: (ptr readonly [[A:%.*]], ptr readonly [[B:%.*]]) #[[ATTR12]] {
797 ; TUNIT-NEXT: [[P:%.*]] = call ptr @unknownpi8pi8(ptr readonly [[A]], ptr readonly [[B]]) #[[ATTR12]]
798 ; TUNIT-NEXT: ret ptr [[P]]
800 ; CGSCC: Function Attrs: nosync nounwind memory(read)
801 ; CGSCC-LABEL: define {{[^@]+}}@test_returned2
802 ; CGSCC-SAME: (ptr readonly [[A:%.*]], ptr readonly [[B:%.*]]) #[[ATTR15]] {
804 ; CGSCC-NEXT: [[P:%.*]] = call ptr @unknownpi8pi8(ptr readonly [[A]], ptr readonly [[B]]) #[[ATTR15]]
805 ; CGSCC-NEXT: ret ptr [[P]]
808 %p = call ptr @unknownpi8pi8(ptr %A, ptr %B) nounwind readonly
812 declare ptr @maybe_returned_ptr(ptr readonly %ptr) readonly nounwind willreturn
813 declare i8 @maybe_returned_val(ptr %ptr) readonly nounwind willreturn
814 declare void @val_use(i8 %ptr) readonly nounwind willreturn
816 ; FIXME: Both pointers should be nocapture
817 define void @ptr_uses(ptr %ptr, ptr %wptr) {
818 ; TUNIT: Function Attrs: mustprogress nosync nounwind willreturn
819 ; TUNIT-LABEL: define {{[^@]+}}@ptr_uses
820 ; TUNIT-SAME: (ptr nofree [[PTR:%.*]], ptr nocapture nofree noundef nonnull writeonly dereferenceable(1) [[WPTR:%.*]]) #[[ATTR14:[0-9]+]] {
821 ; TUNIT-NEXT: store i8 0, ptr [[WPTR]], align 1
822 ; TUNIT-NEXT: ret void
824 ; CGSCC: Function Attrs: mustprogress nosync nounwind willreturn
825 ; CGSCC-LABEL: define {{[^@]+}}@ptr_uses
826 ; CGSCC-SAME: (ptr nofree [[PTR:%.*]], ptr nocapture nofree noundef nonnull writeonly dereferenceable(1) [[WPTR:%.*]]) #[[ATTR17:[0-9]+]] {
827 ; CGSCC-NEXT: store i8 0, ptr [[WPTR]], align 1
828 ; CGSCC-NEXT: ret void
830 %call_ptr = call ptr @maybe_returned_ptr(ptr %ptr)
831 %call_val = call i8 @maybe_returned_val(ptr %call_ptr)
832 call void @val_use(i8 %call_val)
833 store i8 0, ptr %wptr
837 declare ptr @llvm.launder.invariant.group.p0(ptr)
838 declare ptr @llvm.strip.invariant.group.p0(ptr)
840 ; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
841 ; TUNIT: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(write) }
842 ; TUNIT: attributes #[[ATTR2]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(read) }
843 ; TUNIT: attributes #[[ATTR3:[0-9]+]] = { memory(read) }
844 ; TUNIT: attributes #[[ATTR4]] = { nosync memory(read) }
845 ; TUNIT: attributes #[[ATTR5]] = { mustprogress nofree norecurse nosync nounwind willreturn }
846 ; TUNIT: attributes #[[ATTR6]] = { nounwind memory(argmem: readwrite) }
847 ; TUNIT: attributes #[[ATTR7]] = { nofree nosync nounwind memory(write) }
848 ; TUNIT: attributes #[[ATTR8]] = { mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite) }
849 ; TUNIT: attributes #[[ATTR9]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite) }
850 ; TUNIT: attributes #[[ATTR10]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) }
851 ; TUNIT: attributes #[[ATTR11]] = { mustprogress nofree norecurse nosync nounwind null_pointer_is_valid willreturn memory(none) }
852 ; TUNIT: attributes #[[ATTR12]] = { nosync nounwind memory(read) }
853 ; TUNIT: attributes #[[ATTR13:[0-9]+]] = { nounwind willreturn memory(read) }
854 ; TUNIT: attributes #[[ATTR14]] = { mustprogress nosync nounwind willreturn }
855 ; TUNIT: attributes #[[ATTR15:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(inaccessiblemem: readwrite) }
856 ; TUNIT: attributes #[[ATTR16:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
857 ; TUNIT: attributes #[[ATTR17]] = { nofree nosync nounwind willreturn memory(write) }
858 ; TUNIT: attributes #[[ATTR18]] = { nofree nosync nounwind willreturn memory(none) }
859 ; TUNIT: attributes #[[ATTR19]] = { nofree nosync nounwind willreturn }
860 ; TUNIT: attributes #[[ATTR20]] = { nounwind }
861 ; TUNIT: attributes #[[ATTR21]] = { nofree willreturn }
862 ; TUNIT: attributes #[[ATTR22]] = { nofree nosync willreturn }
864 ; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
865 ; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(write) }
866 ; CGSCC: attributes #[[ATTR2]] = { mustprogress nofree nosync nounwind willreturn memory(write) }
867 ; CGSCC: attributes #[[ATTR3]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(read) }
868 ; CGSCC: attributes #[[ATTR4:[0-9]+]] = { memory(read) }
869 ; CGSCC: attributes #[[ATTR5]] = { nosync memory(read) }
870 ; CGSCC: attributes #[[ATTR6]] = { mustprogress nofree nosync nounwind willreturn memory(read) }
871 ; CGSCC: attributes #[[ATTR7]] = { mustprogress nofree norecurse nosync nounwind willreturn }
872 ; CGSCC: attributes #[[ATTR8]] = { mustprogress nofree nosync nounwind willreturn }
873 ; CGSCC: attributes #[[ATTR9]] = { nounwind memory(argmem: readwrite) }
874 ; CGSCC: attributes #[[ATTR10]] = { nofree nosync nounwind memory(write) }
875 ; CGSCC: attributes #[[ATTR11]] = { mustprogress nofree norecurse nounwind willreturn memory(argmem: readwrite) }
876 ; CGSCC: attributes #[[ATTR12]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite) }
877 ; CGSCC: attributes #[[ATTR13]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) }
878 ; CGSCC: attributes #[[ATTR14]] = { mustprogress nofree norecurse nosync nounwind null_pointer_is_valid willreturn memory(none) }
879 ; CGSCC: attributes #[[ATTR15]] = { nosync nounwind memory(read) }
880 ; CGSCC: attributes #[[ATTR16:[0-9]+]] = { nounwind willreturn memory(read) }
881 ; CGSCC: attributes #[[ATTR17]] = { mustprogress nosync nounwind willreturn }
882 ; CGSCC: attributes #[[ATTR18:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(inaccessiblemem: readwrite) }
883 ; CGSCC: attributes #[[ATTR19:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
884 ; CGSCC: attributes #[[ATTR20]] = { nofree nounwind willreturn memory(write) }
885 ; CGSCC: attributes #[[ATTR21]] = { nofree nosync willreturn }
886 ; CGSCC: attributes #[[ATTR22]] = { nofree nounwind willreturn }
887 ; CGSCC: attributes #[[ATTR23]] = { nounwind }
888 ; CGSCC: attributes #[[ATTR24]] = { nofree willreturn }