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
4 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
6 @G = external dso_local global i32, align 4
8 declare noalias ptr @malloc(i64) inaccessiblememonly
11 ; CHECK: @[[G:[a-zA-Z0-9_$"\\.-]+]] = external dso_local global i32, align 4
13 define dso_local ptr @internal_only(i32 %arg) {
14 ; CHECK: Function Attrs: memory(inaccessiblemem: readwrite)
15 ; CHECK-LABEL: define {{[^@]+}}@internal_only
16 ; CHECK-SAME: (i32 [[ARG:%.*]]) #[[ATTR0:[0-9]+]] {
18 ; CHECK-NEXT: [[CONV:%.*]] = sext i32 [[ARG]] to i64
19 ; CHECK-NEXT: [[CALL:%.*]] = call noalias ptr @malloc(i64 [[CONV]])
20 ; CHECK-NEXT: ret ptr [[CALL]]
23 %conv = sext i32 %arg to i64
24 %call = call ptr @malloc(i64 %conv)
28 define dso_local ptr @internal_only_rec(i32 %arg) {
29 ; CHECK: Function Attrs: memory(inaccessiblemem: readwrite)
30 ; CHECK-LABEL: define {{[^@]+}}@internal_only_rec
31 ; CHECK-SAME: (i32 [[ARG:%.*]]) #[[ATTR0]] {
33 ; CHECK-NEXT: [[REM:%.*]] = srem i32 [[ARG]], 2
34 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[REM]], 1
35 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
37 ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[ARG]], 2
38 ; CHECK-NEXT: [[CALL:%.*]] = call noalias ptr @internal_only_rec(i32 [[DIV]])
39 ; CHECK-NEXT: br label [[RETURN:%.*]]
41 ; CHECK-NEXT: [[CONV:%.*]] = sext i32 [[ARG]] to i64
42 ; CHECK-NEXT: [[CALL1:%.*]] = call noalias ptr @malloc(i64 [[CONV]])
43 ; CHECK-NEXT: br label [[RETURN]]
45 ; CHECK-NEXT: [[RETVAL_0:%.*]] = phi ptr [ [[CALL]], [[IF_THEN]] ], [ [[CALL1]], [[IF_END]] ]
46 ; CHECK-NEXT: ret ptr [[RETVAL_0]]
49 %rem = srem i32 %arg, 2
50 %cmp = icmp eq i32 %rem, 1
51 br i1 %cmp, label %if.then, label %if.end
53 if.then: ; preds = %entry
54 %div = sdiv i32 %arg, 2
55 %call = call ptr @internal_only_rec(i32 %div)
58 if.end: ; preds = %entry
59 %conv = sext i32 %arg to i64
60 %call1 = call ptr @malloc(i64 %conv)
63 return: ; preds = %if.end, %if.then
64 %retval.0 = phi ptr [ %call, %if.then ], [ %call1, %if.end ]
68 define dso_local ptr @internal_only_rec_static_helper(i32 %arg) {
69 ; CHECK: Function Attrs: memory(inaccessiblemem: readwrite)
70 ; CHECK-LABEL: define {{[^@]+}}@internal_only_rec_static_helper
71 ; CHECK-SAME: (i32 [[ARG:%.*]]) #[[ATTR0]] {
73 ; CHECK-NEXT: [[CALL:%.*]] = call noalias ptr @internal_only_rec_static(i32 [[ARG]])
74 ; CHECK-NEXT: ret ptr [[CALL]]
77 %call = call ptr @internal_only_rec_static(i32 %arg)
81 define internal ptr @internal_only_rec_static(i32 %arg) {
82 ; CHECK: Function Attrs: memory(inaccessiblemem: readwrite)
83 ; CHECK-LABEL: define {{[^@]+}}@internal_only_rec_static
84 ; CHECK-SAME: (i32 [[ARG:%.*]]) #[[ATTR0]] {
86 ; CHECK-NEXT: [[REM:%.*]] = srem i32 [[ARG]], 2
87 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[REM]], 1
88 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
90 ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[ARG]], 2
91 ; CHECK-NEXT: [[CALL:%.*]] = call noalias ptr @internal_only_rec(i32 [[DIV]])
92 ; CHECK-NEXT: br label [[RETURN:%.*]]
94 ; CHECK-NEXT: [[CONV:%.*]] = sext i32 [[ARG]] to i64
95 ; CHECK-NEXT: [[CALL1:%.*]] = call noalias ptr @malloc(i64 [[CONV]])
96 ; CHECK-NEXT: br label [[RETURN]]
98 ; CHECK-NEXT: [[RETVAL_0:%.*]] = phi ptr [ [[CALL]], [[IF_THEN]] ], [ [[CALL1]], [[IF_END]] ]
99 ; CHECK-NEXT: ret ptr [[RETVAL_0]]
102 %rem = srem i32 %arg, 2
103 %cmp = icmp eq i32 %rem, 1
104 br i1 %cmp, label %if.then, label %if.end
106 if.then: ; preds = %entry
107 %div = sdiv i32 %arg, 2
108 %call = call ptr @internal_only_rec(i32 %div)
111 if.end: ; preds = %entry
112 %conv = sext i32 %arg to i64
113 %call1 = call ptr @malloc(i64 %conv)
116 return: ; preds = %if.end, %if.then
117 %retval.0 = phi ptr [ %call, %if.then ], [ %call1, %if.end ]
121 define dso_local ptr @internal_only_rec_static_helper_malloc_noescape(i32 %arg) {
122 ; FIXME: This is actually inaccessiblememonly because the malloced memory does not escape
123 ; CHECK-LABEL: define {{[^@]+}}@internal_only_rec_static_helper_malloc_noescape
124 ; CHECK-SAME: (i32 [[ARG:%.*]]) {
126 ; CHECK-NEXT: [[CALL:%.*]] = call noalias ptr @internal_only_rec_static_malloc_noescape(i32 [[ARG]])
127 ; CHECK-NEXT: ret ptr [[CALL]]
130 %call = call ptr @internal_only_rec_static_malloc_noescape(i32 %arg)
134 define internal ptr @internal_only_rec_static_malloc_noescape(i32 %arg) {
135 ; FIXME: This is actually inaccessiblememonly because the malloced memory does not escape
136 ; CHECK-LABEL: define {{[^@]+}}@internal_only_rec_static_malloc_noescape
137 ; CHECK-SAME: (i32 [[ARG:%.*]]) {
139 ; CHECK-NEXT: [[REM:%.*]] = srem i32 [[ARG]], 2
140 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[REM]], 1
141 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
143 ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[ARG]], 2
144 ; CHECK-NEXT: [[CALL:%.*]] = call noalias ptr @internal_only_rec(i32 [[DIV]])
145 ; CHECK-NEXT: br label [[RETURN:%.*]]
147 ; CHECK-NEXT: [[CONV:%.*]] = sext i32 [[ARG]] to i64
148 ; CHECK-NEXT: [[CALL1:%.*]] = call noalias ptr @malloc(i64 [[CONV]])
149 ; CHECK-NEXT: br label [[RETURN]]
151 ; CHECK-NEXT: [[RETVAL_0:%.*]] = phi ptr [ [[CALL]], [[IF_THEN]] ], [ null, [[IF_END]] ]
152 ; CHECK-NEXT: ret ptr [[RETVAL_0]]
155 %rem = srem i32 %arg, 2
156 %cmp = icmp eq i32 %rem, 1
157 br i1 %cmp, label %if.then, label %if.end
159 if.then: ; preds = %entry
160 %div = sdiv i32 %arg, 2
161 %call = call ptr @internal_only_rec(i32 %div)
164 if.end: ; preds = %entry
165 %conv = sext i32 %arg to i64
166 %call1 = call ptr @malloc(i64 %conv)
167 store i8 0, ptr %call1
170 return: ; preds = %if.end, %if.then
171 %retval.0 = phi ptr [ %call, %if.then ], [ null, %if.end ]
175 define dso_local ptr @internal_argmem_only_read(ptr %arg) {
176 ; CHECK: Function Attrs: memory(argmem: readwrite, inaccessiblemem: readwrite)
177 ; CHECK-LABEL: define {{[^@]+}}@internal_argmem_only_read
178 ; CHECK-SAME: (ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[ARG:%.*]]) #[[ATTR1:[0-9]+]] {
180 ; CHECK-NEXT: [[TMP:%.*]] = load i32, ptr [[ARG]], align 4
181 ; CHECK-NEXT: [[CONV:%.*]] = sext i32 [[TMP]] to i64
182 ; CHECK-NEXT: [[CALL:%.*]] = call noalias ptr @malloc(i64 [[CONV]])
183 ; CHECK-NEXT: ret ptr [[CALL]]
186 %tmp = load i32, ptr %arg, align 4
187 %conv = sext i32 %tmp to i64
188 %call = call ptr @malloc(i64 %conv)
192 define dso_local ptr @internal_argmem_only_write(ptr %arg) {
193 ; CHECK: Function Attrs: memory(argmem: readwrite, inaccessiblemem: readwrite)
194 ; CHECK-LABEL: define {{[^@]+}}@internal_argmem_only_write
195 ; CHECK-SAME: (ptr nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[ARG:%.*]]) #[[ATTR1]] {
197 ; CHECK-NEXT: store i32 10, ptr [[ARG]], align 4
198 ; CHECK-NEXT: [[CALL:%.*]] = call noalias noundef dereferenceable_or_null(10) ptr @malloc(i64 noundef 10)
199 ; CHECK-NEXT: ret ptr [[CALL]]
202 store i32 10, ptr %arg, align 4
203 %call = call dereferenceable_or_null(10) ptr @malloc(i64 10)
207 define dso_local ptr @internal_argmem_only_rec(ptr %arg) {
208 ; TUNIT: Function Attrs: memory(argmem: readwrite, inaccessiblemem: readwrite)
209 ; TUNIT-LABEL: define {{[^@]+}}@internal_argmem_only_rec
210 ; TUNIT-SAME: (ptr nocapture nofree [[ARG:%.*]]) #[[ATTR1]] {
212 ; TUNIT-NEXT: [[CALL:%.*]] = call noalias ptr @internal_argmem_only_rec_1(ptr nocapture nofree noundef align 4 [[ARG]])
213 ; TUNIT-NEXT: ret ptr [[CALL]]
215 ; CGSCC: Function Attrs: memory(argmem: readwrite, inaccessiblemem: readwrite)
216 ; CGSCC-LABEL: define {{[^@]+}}@internal_argmem_only_rec
217 ; CGSCC-SAME: (ptr nocapture nofree noundef nonnull align 4 dereferenceable(4) [[ARG:%.*]]) #[[ATTR1]] {
219 ; CGSCC-NEXT: [[CALL:%.*]] = call noalias ptr @internal_argmem_only_rec_1(ptr nocapture nofree noundef nonnull align 4 dereferenceable(4) [[ARG]])
220 ; CGSCC-NEXT: ret ptr [[CALL]]
223 %call = call ptr @internal_argmem_only_rec_1(ptr %arg)
227 define internal ptr @internal_argmem_only_rec_1(ptr %arg) {
228 ; CHECK: Function Attrs: memory(argmem: readwrite, inaccessiblemem: readwrite)
229 ; CHECK-LABEL: define {{[^@]+}}@internal_argmem_only_rec_1
230 ; CHECK-SAME: (ptr nocapture nofree noundef nonnull align 4 dereferenceable(4) [[ARG:%.*]]) #[[ATTR1]] {
232 ; CHECK-NEXT: [[TMP:%.*]] = load i32, ptr [[ARG]], align 4
233 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[TMP]], 0
234 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
236 ; CHECK-NEXT: br label [[RETURN:%.*]]
238 ; CHECK-NEXT: [[TRUETMP1:%.*]] = load i32, ptr [[ARG]], align 4
239 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[TRUETMP1]], 1
240 ; CHECK-NEXT: br i1 [[CMP1]], label [[IF_THEN2:%.*]], label [[IF_END3:%.*]]
242 ; CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i32, ptr [[ARG]], i64 -1
243 ; CHECK-NEXT: [[CALL:%.*]] = call noalias ptr @internal_argmem_only_rec_2(ptr nocapture nofree noundef nonnull align 4 dereferenceable(4) [[ADD_PTR]])
244 ; CHECK-NEXT: br label [[RETURN]]
246 ; CHECK-NEXT: [[TRUETMP2:%.*]] = load i32, ptr [[ARG]], align 4
247 ; CHECK-NEXT: [[CONV:%.*]] = sext i32 [[TRUETMP2]] to i64
248 ; CHECK-NEXT: [[CALL4:%.*]] = call noalias ptr @malloc(i64 [[CONV]])
249 ; CHECK-NEXT: br label [[RETURN]]
251 ; CHECK-NEXT: [[RETVAL_0:%.*]] = phi ptr [ null, [[IF_THEN]] ], [ [[CALL]], [[IF_THEN2]] ], [ [[CALL4]], [[IF_END3]] ]
252 ; CHECK-NEXT: ret ptr [[RETVAL_0]]
255 %tmp = load i32, ptr %arg, align 4
256 %cmp = icmp eq i32 %tmp, 0
257 br i1 %cmp, label %if.then, label %if.end
259 if.then: ; preds = %entry
262 if.end: ; preds = %entry
263 %tmp1 = load i32, ptr %arg, align 4
264 %cmp1 = icmp eq i32 %tmp1, 1
265 br i1 %cmp1, label %if.then2, label %if.end3
267 if.then2: ; preds = %if.end
268 %add.ptr = getelementptr inbounds i32, ptr %arg, i64 -1
269 %call = call ptr @internal_argmem_only_rec_2(ptr nonnull %add.ptr)
272 if.end3: ; preds = %if.end
273 %tmp2 = load i32, ptr %arg, align 4
274 %conv = sext i32 %tmp2 to i64
275 %call4 = call ptr @malloc(i64 %conv)
278 return: ; preds = %if.end3, %if.then2, %if.then
279 %retval.0 = phi ptr [ null, %if.then ], [ %call, %if.then2 ], [ %call4, %if.end3 ]
283 define internal ptr @internal_argmem_only_rec_2(ptr %arg) {
284 ; CHECK: Function Attrs: memory(argmem: readwrite, inaccessiblemem: readwrite)
285 ; CHECK-LABEL: define {{[^@]+}}@internal_argmem_only_rec_2
286 ; CHECK-SAME: (ptr nocapture nofree noundef nonnull align 4 dereferenceable(4) [[ARG:%.*]]) #[[ATTR1]] {
288 ; CHECK-NEXT: store i32 0, ptr [[ARG]], align 4
289 ; CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i32, ptr [[ARG]], i64 -1
290 ; CHECK-NEXT: [[CALL:%.*]] = call noalias ptr @internal_argmem_only_rec_1(ptr nocapture nofree noundef nonnull align 4 dereferenceable(4) [[ADD_PTR]])
291 ; CHECK-NEXT: ret ptr [[CALL]]
294 store i32 0, ptr %arg, align 4
295 %add.ptr = getelementptr inbounds i32, ptr %arg, i64 -1
296 %call = call ptr @internal_argmem_only_rec_1(ptr nonnull %add.ptr)
300 declare ptr @unknown_ptr() readnone
301 declare ptr @argmem_only(ptr %arg) argmemonly
302 declare ptr @inaccesible_argmem_only_decl(ptr %arg) inaccessiblemem_or_argmemonly
303 declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) nounwind argmemonly willreturn
305 define void @callerA1(ptr %arg) {
306 ; CHECK: Function Attrs: memory(argmem: readwrite)
307 ; CHECK-LABEL: define {{[^@]+}}@callerA1
308 ; CHECK-SAME: (ptr [[ARG:%.*]]) #[[ATTR3:[0-9]+]] {
309 ; CHECK-NEXT: [[TMP1:%.*]] = call ptr @argmem_only(ptr [[ARG]])
310 ; CHECK-NEXT: ret void
312 call ptr @argmem_only(ptr %arg)
315 define void @callerA2(ptr %arg) {
316 ; CHECK: Function Attrs: memory(argmem: readwrite, inaccessiblemem: readwrite)
317 ; CHECK-LABEL: define {{[^@]+}}@callerA2
318 ; CHECK-SAME: (ptr [[ARG:%.*]]) #[[ATTR1]] {
319 ; CHECK-NEXT: [[TMP1:%.*]] = call ptr @inaccesible_argmem_only_decl(ptr [[ARG]])
320 ; CHECK-NEXT: ret void
322 call ptr @inaccesible_argmem_only_decl(ptr %arg)
325 define void @callerB1() {
326 ; CHECK: Function Attrs: memory(none)
327 ; CHECK-LABEL: define {{[^@]+}}@callerB1
328 ; CHECK-SAME: () #[[ATTR2:[0-9]+]] {
329 ; CHECK-NEXT: [[STACK:%.*]] = alloca i8, align 1
330 ; CHECK-NEXT: [[TMP1:%.*]] = call ptr @argmem_only(ptr noundef nonnull dereferenceable(1) [[STACK]])
331 ; CHECK-NEXT: ret void
334 call ptr @argmem_only(ptr %stack)
337 define void @callerB2() {
338 ; CHECK: Function Attrs: memory(inaccessiblemem: readwrite)
339 ; CHECK-LABEL: define {{[^@]+}}@callerB2
340 ; CHECK-SAME: () #[[ATTR0]] {
341 ; CHECK-NEXT: [[STACK:%.*]] = alloca i8, align 1
342 ; CHECK-NEXT: [[TMP1:%.*]] = call ptr @inaccesible_argmem_only_decl(ptr noundef nonnull dereferenceable(1) [[STACK]])
343 ; CHECK-NEXT: ret void
346 call ptr @inaccesible_argmem_only_decl(ptr %stack)
349 define void @callerC1() {
350 ; CHECK-LABEL: define {{[^@]+}}@callerC1() {
351 ; CHECK-NEXT: [[UNKNOWN:%.*]] = call ptr @unknown_ptr()
352 ; CHECK-NEXT: [[TMP1:%.*]] = call ptr @argmem_only(ptr [[UNKNOWN]])
353 ; CHECK-NEXT: ret void
355 %unknown = call ptr @unknown_ptr()
356 call ptr @argmem_only(ptr %unknown)
359 define void @callerC2() {
360 ; CHECK-LABEL: define {{[^@]+}}@callerC2() {
361 ; CHECK-NEXT: [[UNKNOWN:%.*]] = call ptr @unknown_ptr()
362 ; CHECK-NEXT: [[TMP1:%.*]] = call ptr @inaccesible_argmem_only_decl(ptr [[UNKNOWN]])
363 ; CHECK-NEXT: ret void
365 %unknown = call ptr @unknown_ptr()
366 call ptr @inaccesible_argmem_only_decl(ptr %unknown)
369 define void @callerD1() {
370 ; CHECK-LABEL: define {{[^@]+}}@callerD1() {
371 ; CHECK-NEXT: [[UNKNOWN:%.*]] = call ptr @argmem_only(ptr noundef align 4294967296 null)
372 ; CHECK-NEXT: store i8 0, ptr [[UNKNOWN]], align 1
373 ; CHECK-NEXT: ret void
375 %unknown = call ptr @argmem_only(ptr null)
376 store i8 0, ptr %unknown
379 define void @callerD2() {
380 ; CHECK-LABEL: define {{[^@]+}}@callerD2() {
381 ; CHECK-NEXT: [[UNKNOWN:%.*]] = call ptr @inaccesible_argmem_only_decl(ptr noundef align 4294967296 null)
382 ; CHECK-NEXT: store i8 0, ptr [[UNKNOWN]], align 1
383 ; CHECK-NEXT: ret void
385 %unknown = call ptr @inaccesible_argmem_only_decl(ptr null)
386 store i8 0, ptr %unknown
390 define void @callerE(ptr %arg) {
391 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
392 ; CHECK-LABEL: define {{[^@]+}}@callerE
393 ; CHECK-SAME: (ptr nocapture nofree readnone [[ARG:%.*]]) #[[ATTR5:[0-9]+]] {
394 ; CHECK-NEXT: ret void
396 call void @llvm.lifetime.start.p0(i64 4, ptr %arg)
401 define void @write_global() {
402 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
403 ; CHECK-LABEL: define {{[^@]+}}@write_global
404 ; CHECK-SAME: () #[[ATTR6:[0-9]+]] {
405 ; CHECK-NEXT: store i32 0, ptr @G, align 4
406 ; CHECK-NEXT: ret void
408 store i32 0, ptr @G, align 4
411 define void @write_global_via_arg(ptr %GPtr) {
412 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
413 ; CHECK-LABEL: define {{[^@]+}}@write_global_via_arg
414 ; CHECK-SAME: (ptr nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[GPTR:%.*]]) #[[ATTR7:[0-9]+]] {
415 ; CHECK-NEXT: store i32 0, ptr [[GPTR]], align 4
416 ; CHECK-NEXT: ret void
418 store i32 0, ptr %GPtr, align 4
421 define internal void @write_global_via_arg_internal(ptr %GPtr) {
422 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: none)
423 ; CHECK-LABEL: define {{[^@]+}}@write_global_via_arg_internal
424 ; CHECK-SAME: () #[[ATTR8:[0-9]+]] {
425 ; CHECK-NEXT: store i32 0, ptr @G, align 4
426 ; CHECK-NEXT: ret void
428 store i32 0, ptr %GPtr, align 4
432 define void @writeonly_global() {
433 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
434 ; TUNIT-LABEL: define {{[^@]+}}@writeonly_global
435 ; TUNIT-SAME: () #[[ATTR6]] {
436 ; TUNIT-NEXT: call void @write_global() #[[ATTR12:[0-9]+]]
437 ; TUNIT-NEXT: ret void
439 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(write)
440 ; CGSCC-LABEL: define {{[^@]+}}@writeonly_global
441 ; CGSCC-SAME: () #[[ATTR9:[0-9]+]] {
442 ; CGSCC-NEXT: call void @write_global() #[[ATTR13:[0-9]+]]
443 ; CGSCC-NEXT: ret void
445 call void @write_global()
448 define void @writeonly_global_via_arg() {
449 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
450 ; TUNIT-LABEL: define {{[^@]+}}@writeonly_global_via_arg
451 ; TUNIT-SAME: () #[[ATTR6]] {
452 ; TUNIT-NEXT: call void @write_global_via_arg(ptr nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) @G) #[[ATTR12]]
453 ; TUNIT-NEXT: ret void
455 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(write)
456 ; CGSCC-LABEL: define {{[^@]+}}@writeonly_global_via_arg
457 ; CGSCC-SAME: () #[[ATTR9]] {
458 ; CGSCC-NEXT: call void @write_global_via_arg(ptr nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) @G) #[[ATTR13]]
459 ; CGSCC-NEXT: ret void
461 call void @write_global_via_arg(ptr @G)
465 define void @writeonly_global_via_arg_internal() {
467 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
468 ; TUNIT-LABEL: define {{[^@]+}}@writeonly_global_via_arg_internal
469 ; TUNIT-SAME: () #[[ATTR6]] {
470 ; TUNIT-NEXT: call void @write_global_via_arg_internal() #[[ATTR12]]
471 ; TUNIT-NEXT: ret void
473 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(write)
474 ; CGSCC-LABEL: define {{[^@]+}}@writeonly_global_via_arg_internal
475 ; CGSCC-SAME: () #[[ATTR9]] {
476 ; CGSCC-NEXT: call void @write_global_via_arg_internal() #[[ATTR13]]
477 ; CGSCC-NEXT: ret void
479 call void @write_global_via_arg_internal(ptr @G)
483 define i8 @recursive_not_readnone(ptr %ptr, i1 %c) {
484 ; TUNIT: Function Attrs: nofree nosync nounwind memory(argmem: write)
485 ; TUNIT-LABEL: define {{[^@]+}}@recursive_not_readnone
486 ; TUNIT-SAME: (ptr nocapture nofree writeonly [[PTR:%.*]], i1 noundef [[C:%.*]]) #[[ATTR9:[0-9]+]] {
487 ; TUNIT-NEXT: [[ALLOC:%.*]] = alloca i8, align 1
488 ; TUNIT-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
490 ; TUNIT-NEXT: [[TMP1:%.*]] = call i8 @recursive_not_readnone(ptr noalias nocapture nofree noundef nonnull writeonly dereferenceable(1) [[ALLOC]], i1 noundef false) #[[ATTR13:[0-9]+]]
491 ; TUNIT-NEXT: ret i8 1
493 ; TUNIT-NEXT: store i8 1, ptr [[PTR]], align 1
494 ; TUNIT-NEXT: ret i8 0
496 ; CGSCC: Function Attrs: nofree nosync nounwind memory(argmem: write)
497 ; CGSCC-LABEL: define {{[^@]+}}@recursive_not_readnone
498 ; CGSCC-SAME: (ptr nocapture nofree writeonly [[PTR:%.*]], i1 noundef [[C:%.*]]) #[[ATTR10:[0-9]+]] {
499 ; CGSCC-NEXT: [[ALLOC:%.*]] = alloca i8, align 1
500 ; CGSCC-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
502 ; CGSCC-NEXT: [[TMP1:%.*]] = call i8 @recursive_not_readnone(ptr noalias nocapture nofree noundef nonnull writeonly dereferenceable(1) [[ALLOC]], i1 noundef false) #[[ATTR14:[0-9]+]]
503 ; CGSCC-NEXT: ret i8 1
505 ; CGSCC-NEXT: store i8 1, ptr [[PTR]], align 1
506 ; CGSCC-NEXT: ret i8 0
509 br i1 %c, label %t, label %f
511 call i8 @recursive_not_readnone(ptr %alloc, i1 false)
512 %r = load i8, ptr %alloc
519 define internal i8 @recursive_not_readnone_internal(ptr %ptr, i1 %c) {
520 ; TUNIT: Function Attrs: nofree nosync nounwind memory(argmem: write)
521 ; TUNIT-LABEL: define {{[^@]+}}@recursive_not_readnone_internal
522 ; TUNIT-SAME: (ptr noalias nocapture nofree noundef nonnull writeonly dereferenceable(1) [[PTR:%.*]], i1 noundef [[C:%.*]]) #[[ATTR9]] {
523 ; TUNIT-NEXT: [[ALLOC:%.*]] = alloca i8, align 1
524 ; TUNIT-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
526 ; TUNIT-NEXT: [[TMP1:%.*]] = call i8 @recursive_not_readnone_internal(ptr noalias nocapture nofree noundef nonnull writeonly dereferenceable(1) [[ALLOC]], i1 noundef false) #[[ATTR13]]
527 ; TUNIT-NEXT: ret i8 1
529 ; TUNIT-NEXT: store i8 1, ptr [[PTR]], align 1
530 ; TUNIT-NEXT: ret i8 0
532 ; CGSCC: Function Attrs: nofree nosync nounwind memory(argmem: write)
533 ; CGSCC-LABEL: define {{[^@]+}}@recursive_not_readnone_internal
534 ; CGSCC-SAME: (ptr noalias nocapture nofree noundef nonnull writeonly dereferenceable(1) [[PTR:%.*]], i1 noundef [[C:%.*]]) #[[ATTR10]] {
535 ; CGSCC-NEXT: [[ALLOC:%.*]] = alloca i8, align 1
536 ; CGSCC-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
538 ; CGSCC-NEXT: [[TMP1:%.*]] = call i8 @recursive_not_readnone_internal(ptr noalias nocapture nofree noundef nonnull writeonly dereferenceable(1) [[ALLOC]], i1 noundef false) #[[ATTR14]]
539 ; CGSCC-NEXT: ret i8 1
541 ; CGSCC-NEXT: store i8 1, ptr [[PTR]], align 1
542 ; CGSCC-NEXT: ret i8 0
545 br i1 %c, label %t, label %f
547 call i8 @recursive_not_readnone_internal(ptr %alloc, i1 false)
548 %r = load i8, ptr %alloc
555 define i8 @readnone_caller(i1 %c) {
556 ; TUNIT: Function Attrs: nofree norecurse nosync nounwind memory(none)
557 ; TUNIT-LABEL: define {{[^@]+}}@readnone_caller
558 ; TUNIT-SAME: (i1 [[C:%.*]]) #[[ATTR10:[0-9]+]] {
559 ; TUNIT-NEXT: [[A:%.*]] = alloca i8, align 1
560 ; TUNIT-NEXT: [[R:%.*]] = call i8 @recursive_not_readnone_internal(ptr noalias nocapture nofree noundef nonnull writeonly dereferenceable(1) [[A]], i1 noundef [[C]]) #[[ATTR13]]
561 ; TUNIT-NEXT: ret i8 [[R]]
563 ; CGSCC: Function Attrs: nofree nosync nounwind memory(none)
564 ; CGSCC-LABEL: define {{[^@]+}}@readnone_caller
565 ; CGSCC-SAME: (i1 noundef [[C:%.*]]) #[[ATTR11:[0-9]+]] {
566 ; CGSCC-NEXT: [[A:%.*]] = alloca i8, align 1
567 ; CGSCC-NEXT: [[R:%.*]] = call i8 @recursive_not_readnone_internal(ptr noalias nocapture nofree noundef nonnull writeonly dereferenceable(1) [[A]], i1 noundef [[C]]) #[[ATTR15:[0-9]+]]
568 ; CGSCC-NEXT: ret i8 [[R]]
571 %r = call i8 @recursive_not_readnone_internal(ptr %a, i1 %c)
575 define internal i8 @recursive_readnone_internal2(ptr %ptr, i1 %c) {
576 ; TUNIT: Function Attrs: nofree nosync nounwind memory(argmem: write)
577 ; TUNIT-LABEL: define {{[^@]+}}@recursive_readnone_internal2
578 ; TUNIT-SAME: (ptr noalias nocapture nofree writeonly [[PTR:%.*]], i1 noundef [[C:%.*]]) #[[ATTR9]] {
579 ; TUNIT-NEXT: [[ALLOC:%.*]] = alloca i8, align 1
580 ; TUNIT-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
582 ; TUNIT-NEXT: [[TMP1:%.*]] = call i8 @recursive_readnone_internal2(ptr noalias nocapture nofree noundef nonnull writeonly dereferenceable(1) [[ALLOC]], i1 noundef false) #[[ATTR13]]
583 ; TUNIT-NEXT: ret i8 1
585 ; TUNIT-NEXT: store i8 1, ptr [[PTR]], align 1
586 ; TUNIT-NEXT: ret i8 0
588 ; CGSCC: Function Attrs: nofree nosync nounwind memory(argmem: write)
589 ; CGSCC-LABEL: define {{[^@]+}}@recursive_readnone_internal2
590 ; CGSCC-SAME: (ptr noalias nocapture nofree writeonly [[PTR:%.*]], i1 noundef [[C:%.*]]) #[[ATTR10]] {
591 ; CGSCC-NEXT: [[ALLOC:%.*]] = alloca i8, align 1
592 ; CGSCC-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
594 ; CGSCC-NEXT: [[TMP1:%.*]] = call i8 @recursive_readnone_internal2(ptr noalias nocapture nofree noundef nonnull writeonly dereferenceable(1) [[ALLOC]], i1 noundef false) #[[ATTR14]]
595 ; CGSCC-NEXT: ret i8 1
597 ; CGSCC-NEXT: store i8 1, ptr [[PTR]], align 1
598 ; CGSCC-NEXT: ret i8 0
601 br i1 %c, label %t, label %f
603 call i8 @recursive_readnone_internal2(ptr %alloc, i1 false)
604 %r = load i8, ptr %alloc
611 define i8 @readnone_caller2(i1 %c) {
612 ; TUNIT: Function Attrs: nofree norecurse nosync nounwind memory(none)
613 ; TUNIT-LABEL: define {{[^@]+}}@readnone_caller2
614 ; TUNIT-SAME: (i1 [[C:%.*]]) #[[ATTR10]] {
615 ; TUNIT-NEXT: [[R:%.*]] = call i8 @recursive_readnone_internal2(ptr undef, i1 noundef [[C]]) #[[ATTR13]]
616 ; TUNIT-NEXT: ret i8 [[R]]
618 ; CGSCC: Function Attrs: nofree nosync nounwind memory(none)
619 ; CGSCC-LABEL: define {{[^@]+}}@readnone_caller2
620 ; CGSCC-SAME: (i1 noundef [[C:%.*]]) #[[ATTR11]] {
621 ; CGSCC-NEXT: [[R:%.*]] = call i8 @recursive_readnone_internal2(ptr nofree undef, i1 noundef [[C]]) #[[ATTR15]]
622 ; CGSCC-NEXT: ret i8 [[R]]
624 %r = call i8 @recursive_readnone_internal2(ptr undef, i1 %c)
628 define internal i8 @recursive_not_readnone_internal3(ptr %ptr, i1 %c) {
629 ; TUNIT: Function Attrs: nofree nosync nounwind memory(argmem: write)
630 ; TUNIT-LABEL: define {{[^@]+}}@recursive_not_readnone_internal3
631 ; TUNIT-SAME: (ptr noalias nocapture nofree noundef nonnull writeonly dereferenceable(1) [[PTR:%.*]], i1 noundef [[C:%.*]]) #[[ATTR9]] {
632 ; TUNIT-NEXT: [[ALLOC:%.*]] = alloca i8, align 1
633 ; TUNIT-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
635 ; TUNIT-NEXT: [[TMP1:%.*]] = call i8 @recursive_not_readnone_internal3(ptr noalias nocapture nofree noundef nonnull writeonly dereferenceable(1) [[ALLOC]], i1 noundef false) #[[ATTR13]]
636 ; TUNIT-NEXT: ret i8 1
638 ; TUNIT-NEXT: store i8 1, ptr [[PTR]], align 1
639 ; TUNIT-NEXT: ret i8 0
641 ; CGSCC: Function Attrs: nofree nosync nounwind memory(argmem: write)
642 ; CGSCC-LABEL: define {{[^@]+}}@recursive_not_readnone_internal3
643 ; CGSCC-SAME: (ptr noalias nocapture nofree noundef nonnull writeonly dereferenceable(1) [[PTR:%.*]], i1 noundef [[C:%.*]]) #[[ATTR10]] {
644 ; CGSCC-NEXT: [[ALLOC:%.*]] = alloca i8, align 1
645 ; CGSCC-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
647 ; CGSCC-NEXT: [[TMP1:%.*]] = call i8 @recursive_not_readnone_internal3(ptr noalias nocapture nofree noundef nonnull writeonly dereferenceable(1) [[ALLOC]], i1 noundef false) #[[ATTR14]]
648 ; CGSCC-NEXT: ret i8 1
650 ; CGSCC-NEXT: store i8 1, ptr [[PTR]], align 1
651 ; CGSCC-NEXT: ret i8 0
654 br i1 %c, label %t, label %f
656 call i8 @recursive_not_readnone_internal3(ptr %alloc, i1 false)
657 %r = load i8, ptr %alloc
664 define i8 @readnone_caller3(i1 %c) {
665 ; TUNIT: Function Attrs: nofree norecurse nosync nounwind memory(none)
666 ; TUNIT-LABEL: define {{[^@]+}}@readnone_caller3
667 ; TUNIT-SAME: (i1 [[C:%.*]]) #[[ATTR10]] {
668 ; TUNIT-NEXT: [[ALLOC:%.*]] = alloca i8, align 1
669 ; TUNIT-NEXT: [[R:%.*]] = call i8 @recursive_not_readnone_internal3(ptr noalias nocapture nofree noundef nonnull writeonly dereferenceable(1) [[ALLOC]], i1 noundef [[C]]) #[[ATTR13]]
670 ; TUNIT-NEXT: ret i8 [[R]]
672 ; CGSCC: Function Attrs: nofree nosync nounwind memory(none)
673 ; CGSCC-LABEL: define {{[^@]+}}@readnone_caller3
674 ; CGSCC-SAME: (i1 noundef [[C:%.*]]) #[[ATTR11]] {
675 ; CGSCC-NEXT: [[ALLOC:%.*]] = alloca i8, align 1
676 ; CGSCC-NEXT: [[R:%.*]] = call i8 @recursive_not_readnone_internal3(ptr noalias nocapture nofree noundef nonnull writeonly dereferenceable(1) [[ALLOC]], i1 noundef [[C]]) #[[ATTR15]]
677 ; CGSCC-NEXT: ret i8 [[R]]
680 %r = call i8 @recursive_not_readnone_internal3(ptr %alloc, i1 %c)
684 define internal void @argmemonly_before_ipconstprop(ptr %p) argmemonly {
685 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: none)
686 ; CHECK-LABEL: define {{[^@]+}}@argmemonly_before_ipconstprop
687 ; CHECK-SAME: () #[[ATTR8]] {
688 ; CHECK-NEXT: store i32 0, ptr @G, align 4
689 ; CHECK-NEXT: ret void
695 define void @argmemonly_caller() {
696 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
697 ; TUNIT-LABEL: define {{[^@]+}}@argmemonly_caller
698 ; TUNIT-SAME: () #[[ATTR6]] {
699 ; TUNIT-NEXT: call void @argmemonly_before_ipconstprop() #[[ATTR12]]
700 ; TUNIT-NEXT: ret void
702 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(write)
703 ; CGSCC-LABEL: define {{[^@]+}}@argmemonly_caller
704 ; CGSCC-SAME: () #[[ATTR9]] {
705 ; CGSCC-NEXT: call void @argmemonly_before_ipconstprop() #[[ATTR13]]
706 ; CGSCC-NEXT: ret void
708 call void @argmemonly_before_ipconstprop(ptr @G)
712 declare ptr @no_mem_unknown_ptr(ptr %arg) memory(none)
714 define void @argmem_and_unknown(i1 %c, ptr %arg) memory(argmem: readwrite) {
715 ; TUNIT: Function Attrs: nosync memory(argmem: write)
716 ; TUNIT-LABEL: define {{[^@]+}}@argmem_and_unknown
717 ; TUNIT-SAME: (i1 noundef [[C:%.*]], ptr writeonly [[ARG:%.*]]) #[[ATTR11:[0-9]+]] {
718 ; TUNIT-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
720 ; TUNIT-NEXT: [[P:%.*]] = call ptr @no_mem_unknown_ptr(ptr noalias readnone [[ARG]]) #[[ATTR14:[0-9]+]]
721 ; TUNIT-NEXT: store i32 0, ptr [[P]], align 4
722 ; TUNIT-NEXT: br label [[F]]
724 ; TUNIT-NEXT: ret void
726 ; CGSCC: Function Attrs: nosync memory(argmem: write)
727 ; CGSCC-LABEL: define {{[^@]+}}@argmem_and_unknown
728 ; CGSCC-SAME: (i1 noundef [[C:%.*]], ptr writeonly [[ARG:%.*]]) #[[ATTR12:[0-9]+]] {
729 ; CGSCC-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
731 ; CGSCC-NEXT: [[P:%.*]] = call ptr @no_mem_unknown_ptr(ptr noalias readnone [[ARG]]) #[[ATTR16:[0-9]+]]
732 ; CGSCC-NEXT: store i32 0, ptr [[P]], align 4
733 ; CGSCC-NEXT: br label [[F]]
735 ; CGSCC-NEXT: ret void
737 br i1 %c, label %t, label %f
739 %p = call ptr @no_mem_unknown_ptr(ptr %arg)
746 ; TUNIT: attributes #[[ATTR0]] = { memory(inaccessiblemem: readwrite) }
747 ; TUNIT: attributes #[[ATTR1]] = { memory(argmem: readwrite, inaccessiblemem: readwrite) }
748 ; TUNIT: attributes #[[ATTR2]] = { memory(none) }
749 ; TUNIT: attributes #[[ATTR3]] = { memory(argmem: readwrite) }
750 ; TUNIT: attributes #[[ATTR4:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
751 ; TUNIT: attributes #[[ATTR5]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
752 ; TUNIT: attributes #[[ATTR6]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(write) }
753 ; TUNIT: attributes #[[ATTR7]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) }
754 ; TUNIT: attributes #[[ATTR8]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: none) }
755 ; TUNIT: attributes #[[ATTR9]] = { nofree nosync nounwind memory(argmem: write) }
756 ; TUNIT: attributes #[[ATTR10]] = { nofree norecurse nosync nounwind memory(none) }
757 ; TUNIT: attributes #[[ATTR11]] = { nosync memory(argmem: write) }
758 ; TUNIT: attributes #[[ATTR12]] = { nofree nosync nounwind willreturn memory(write) }
759 ; TUNIT: attributes #[[ATTR13]] = { nofree nosync nounwind memory(write) }
760 ; TUNIT: attributes #[[ATTR14]] = { nosync }
762 ; CGSCC: attributes #[[ATTR0]] = { memory(inaccessiblemem: readwrite) }
763 ; CGSCC: attributes #[[ATTR1]] = { memory(argmem: readwrite, inaccessiblemem: readwrite) }
764 ; CGSCC: attributes #[[ATTR2]] = { memory(none) }
765 ; CGSCC: attributes #[[ATTR3]] = { memory(argmem: readwrite) }
766 ; CGSCC: attributes #[[ATTR4:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
767 ; CGSCC: attributes #[[ATTR5]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
768 ; CGSCC: attributes #[[ATTR6]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(write) }
769 ; CGSCC: attributes #[[ATTR7]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) }
770 ; CGSCC: attributes #[[ATTR8]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(write, argmem: none) }
771 ; CGSCC: attributes #[[ATTR9]] = { mustprogress nofree nosync nounwind willreturn memory(write) }
772 ; CGSCC: attributes #[[ATTR10]] = { nofree nosync nounwind memory(argmem: write) }
773 ; CGSCC: attributes #[[ATTR11]] = { nofree nosync nounwind memory(none) }
774 ; CGSCC: attributes #[[ATTR12]] = { nosync memory(argmem: write) }
775 ; CGSCC: attributes #[[ATTR13]] = { nofree nounwind willreturn memory(write) }
776 ; CGSCC: attributes #[[ATTR14]] = { nofree nosync nounwind memory(write) }
777 ; CGSCC: attributes #[[ATTR15]] = { nofree nounwind memory(write) }
778 ; CGSCC: attributes #[[ATTR16]] = { nosync }