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 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
7 declare token @llvm.call.preallocated.setup(i32)
8 declare ptr @llvm.call.preallocated.arg(token, i32)
10 @str = private unnamed_addr addrspace(4) constant [1 x i8] c"\00", align 1
11 @ConstAS3Ptr = addrspace(3) global i32 0, align 4
12 @ConstPtr = constant i32 0, align 4
13 @ConstWeakPtr = weak constant i32 0, align 4
14 @ConstWeakODRPtr = weak_odr constant i32 0, align 4
17 ; CHECK: @[[STR:[a-zA-Z0-9_$"\\.-]+]] = private unnamed_addr addrspace(4) constant [1 x i8] zeroinitializer, align 1
18 ; CHECK: @[[CONSTAS3PTR:[a-zA-Z0-9_$"\\.-]+]] = addrspace(3) global i32 0, align 4
19 ; CHECK: @[[CONSTPTR:[a-zA-Z0-9_$"\\.-]+]] = constant i32 0, align 4
20 ; CHECK: @[[CONSTWEAKPTR:[a-zA-Z0-9_$"\\.-]+]] = weak constant i32 0, align 4
21 ; CHECK: @[[CONSTWEAKODRPTR:[a-zA-Z0-9_$"\\.-]+]] = weak_odr constant i32 0, align 4
22 ; CHECK: @[[S:[a-zA-Z0-9_$"\\.-]+]] = external global [[STRUCT_X:%.*]]
23 ; CHECK: @[[G:[a-zA-Z0-9_$"\\.-]+]] = internal constant { [2 x ptr] } { [2 x ptr] [ptr @f1, ptr @f2] }
24 ; CHECK: @[[X:[a-zA-Z0-9_$"\\.-]+]] = external global i32
26 define internal ptr addrspace(3) @const_ptr_return_as3() {
27 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
28 ; CGSCC-LABEL: define {{[^@]+}}@const_ptr_return_as3
29 ; CGSCC-SAME: () #[[ATTR1:[0-9]+]] {
30 ; CGSCC-NEXT: ret ptr addrspace(3) @ConstAS3Ptr
32 ret ptr addrspace(3) @ConstAS3Ptr
34 define internal ptr @const_ptr_return() {
35 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
36 ; CGSCC-LABEL: define {{[^@]+}}@const_ptr_return
37 ; CGSCC-SAME: () #[[ATTR1]] {
38 ; CGSCC-NEXT: ret ptr addrspacecast (ptr addrspace(3) @ConstAS3Ptr to ptr)
40 ret ptr addrspacecast (ptr addrspace(3) @ConstAS3Ptr to ptr)
43 ; Test1: Replace argument with constant
44 define internal void @test1(i32 %a) {
45 ; TUNIT: Function Attrs: memory(readwrite, argmem: none)
46 ; TUNIT-LABEL: define {{[^@]+}}@test1
47 ; TUNIT-SAME: () #[[ATTR1:[0-9]+]] {
48 ; TUNIT-NEXT: tail call void @f(i32 noundef 1)
49 ; TUNIT-NEXT: ret void
51 ; CGSCC: Function Attrs: memory(readwrite, argmem: none)
52 ; CGSCC-LABEL: define {{[^@]+}}@test1
53 ; CGSCC-SAME: () #[[ATTR2:[0-9]+]] {
54 ; CGSCC-NEXT: tail call void @f(i32 noundef 1)
55 ; CGSCC-NEXT: ret void
57 tail call void @f(i32 %a)
61 define void @test1_helper() {
62 ; CHECK-LABEL: define {{[^@]+}}@test1_helper() {
63 ; CHECK-NEXT: tail call void @test1()
64 ; CHECK-NEXT: ret void
66 tail call void @test1(i32 1)
70 ; TEST 2 : Simplify return value
71 define i32 @return0() {
72 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
73 ; TUNIT-LABEL: define {{[^@]+}}@return0
74 ; TUNIT-SAME: () #[[ATTR2:[0-9]+]] {
75 ; TUNIT-NEXT: ret i32 0
77 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
78 ; CGSCC-LABEL: define {{[^@]+}}@return0
79 ; CGSCC-SAME: () #[[ATTR1]] {
80 ; CGSCC-NEXT: ret i32 0
85 define i32 @return1() {
86 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
87 ; TUNIT-LABEL: define {{[^@]+}}@return1
88 ; TUNIT-SAME: () #[[ATTR2]] {
89 ; TUNIT-NEXT: ret i32 1
91 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
92 ; CGSCC-LABEL: define {{[^@]+}}@return1
93 ; CGSCC-SAME: () #[[ATTR1]] {
94 ; CGSCC-NEXT: ret i32 1
99 define i32 @test2_1(i1 %c) {
100 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
101 ; TUNIT-LABEL: define {{[^@]+}}@test2_1
102 ; TUNIT-SAME: (i1 noundef [[C:%.*]]) #[[ATTR2]] {
103 ; TUNIT-NEXT: br i1 [[C]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
105 ; TUNIT-NEXT: [[RET0:%.*]] = add i32 0, 1
106 ; TUNIT-NEXT: br label [[END:%.*]]
108 ; TUNIT-NEXT: br label [[END]]
110 ; TUNIT-NEXT: [[RET:%.*]] = phi i32 [ [[RET0]], [[IF_TRUE]] ], [ 1, [[IF_FALSE]] ]
111 ; TUNIT-NEXT: ret i32 1
113 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
114 ; CGSCC-LABEL: define {{[^@]+}}@test2_1
115 ; CGSCC-SAME: (i1 noundef [[C:%.*]]) #[[ATTR3:[0-9]+]] {
116 ; CGSCC-NEXT: br i1 [[C]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
118 ; CGSCC-NEXT: [[CALL:%.*]] = tail call i32 @return0() #[[ATTR12:[0-9]+]]
119 ; CGSCC-NEXT: [[RET0:%.*]] = add i32 [[CALL]], 1
120 ; CGSCC-NEXT: br label [[END:%.*]]
122 ; CGSCC-NEXT: [[RET1:%.*]] = tail call i32 @return1() #[[ATTR12]]
123 ; CGSCC-NEXT: br label [[END]]
125 ; CGSCC-NEXT: [[RET:%.*]] = phi i32 [ [[RET0]], [[IF_TRUE]] ], [ [[RET1]], [[IF_FALSE]] ]
126 ; CGSCC-NEXT: ret i32 1
128 br i1 %c, label %if.true, label %if.false
130 %call = tail call i32 @return0()
131 %ret0 = add i32 %call, 1
134 %ret1 = tail call i32 @return1()
138 %ret = phi i32 [ %ret0, %if.true ], [ %ret1, %if.false ]
145 define i32 @test2_2(i1 %c) {
146 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
147 ; TUNIT-LABEL: define {{[^@]+}}@test2_2
148 ; TUNIT-SAME: (i1 [[C:%.*]]) #[[ATTR2]] {
149 ; TUNIT-NEXT: ret i32 1
151 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
152 ; CGSCC-LABEL: define {{[^@]+}}@test2_2
153 ; CGSCC-SAME: (i1 noundef [[C:%.*]]) #[[ATTR3]] {
154 ; CGSCC-NEXT: [[RET:%.*]] = tail call noundef i32 @test2_1(i1 noundef [[C]]) #[[ATTR12]]
155 ; CGSCC-NEXT: ret i32 [[RET]]
157 %ret = tail call i32 @test2_1(i1 %c)
161 declare void @use(i32)
162 define void @test3(i1 %c) {
163 ; TUNIT-LABEL: define {{[^@]+}}@test3
164 ; TUNIT-SAME: (i1 noundef [[C:%.*]]) {
165 ; TUNIT-NEXT: br i1 [[C]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
167 ; TUNIT-NEXT: br label [[END:%.*]]
169 ; TUNIT-NEXT: br label [[END]]
171 ; TUNIT-NEXT: [[R:%.*]] = phi i32 [ 1, [[IF_TRUE]] ], [ 1, [[IF_FALSE]] ]
172 ; TUNIT-NEXT: tail call void @use(i32 noundef 1)
173 ; TUNIT-NEXT: ret void
175 ; CGSCC-LABEL: define {{[^@]+}}@test3
176 ; CGSCC-SAME: (i1 noundef [[C:%.*]]) {
177 ; CGSCC-NEXT: br i1 [[C]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
179 ; CGSCC-NEXT: br label [[END:%.*]]
181 ; CGSCC-NEXT: [[RET1:%.*]] = tail call i32 @return1() #[[ATTR13:[0-9]+]]
182 ; CGSCC-NEXT: br label [[END]]
184 ; CGSCC-NEXT: [[R:%.*]] = phi i32 [ 1, [[IF_TRUE]] ], [ [[RET1]], [[IF_FALSE]] ]
185 ; CGSCC-NEXT: tail call void @use(i32 noundef [[R]])
186 ; CGSCC-NEXT: ret void
188 br i1 %c, label %if.true, label %if.false
192 %ret1 = tail call i32 @return1()
196 %r = phi i32 [ 1, %if.true ], [ %ret1, %if.false ]
198 tail call void @use(i32 %r)
202 define void @test-select-phi(i1 %c) {
203 ; CHECK-LABEL: define {{[^@]+}}@test-select-phi
204 ; CHECK-SAME: (i1 [[C:%.*]]) {
205 ; CHECK-NEXT: tail call void @use(i32 noundef 1)
206 ; CHECK-NEXT: [[SELECT_NOT_SAME:%.*]] = select i1 [[C]], i32 1, i32 0
207 ; CHECK-NEXT: tail call void @use(i32 noundef [[SELECT_NOT_SAME]])
208 ; CHECK-NEXT: br i1 [[C]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
210 ; CHECK-NEXT: br label [[END:%.*]]
212 ; CHECK-NEXT: br label [[END]]
214 ; CHECK-NEXT: [[PHI_SAME:%.*]] = phi i32 [ 1, [[IF_TRUE]] ], [ 1, [[IF_FALSE]] ]
215 ; CHECK-NEXT: [[PHI_NOT_SAME:%.*]] = phi i32 [ 0, [[IF_TRUE]] ], [ 1, [[IF_FALSE]] ]
216 ; CHECK-NEXT: [[PHI_SAME_PROP:%.*]] = phi i32 [ 1, [[IF_TRUE]] ], [ 1, [[IF_FALSE]] ]
217 ; CHECK-NEXT: [[PHI_SAME_UNDEF:%.*]] = phi i32 [ 1, [[IF_TRUE]] ], [ undef, [[IF_FALSE]] ]
218 ; CHECK-NEXT: [[SELECT_NOT_SAME_UNDEF:%.*]] = select i1 [[C]], i32 [[PHI_NOT_SAME]], i32 undef
219 ; CHECK-NEXT: tail call void @use(i32 noundef 1)
220 ; CHECK-NEXT: tail call void @use(i32 noundef [[PHI_NOT_SAME]])
221 ; CHECK-NEXT: tail call void @use(i32 noundef 1)
222 ; CHECK-NEXT: tail call void @use(i32 1)
223 ; CHECK-NEXT: tail call void @use(i32 [[SELECT_NOT_SAME_UNDEF]])
224 ; CHECK-NEXT: ret void
226 %select-same = select i1 %c, i32 1, i32 1
227 tail call void @use(i32 %select-same)
229 %select-not-same = select i1 %c, i32 1, i32 0
230 tail call void @use(i32 %select-not-same)
231 br i1 %c, label %if-true, label %if-false
237 %phi-same = phi i32 [ 1, %if-true ], [ 1, %if-false ]
238 %phi-not-same = phi i32 [ 0, %if-true ], [ 1, %if-false ]
239 %phi-same-prop = phi i32 [ 1, %if-true ], [ %select-same, %if-false ]
240 %phi-same-undef = phi i32 [ 1, %if-true ], [ undef, %if-false ]
241 %select-not-same-undef = select i1 %c, i32 %phi-not-same, i32 undef
244 tail call void @use(i32 %phi-same)
246 tail call void @use(i32 %phi-not-same)
248 tail call void @use(i32 %phi-same-prop)
250 tail call void @use(i32 %phi-same-undef)
252 tail call void @use(i32 %select-not-same-undef)
258 define i32 @ipccp1(i32 %a) {
259 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
260 ; TUNIT-LABEL: define {{[^@]+}}@ipccp1
261 ; TUNIT-SAME: (i32 returned [[A:%.*]]) #[[ATTR2]] {
262 ; TUNIT-NEXT: br i1 true, label [[T:%.*]], label [[F:%.*]]
264 ; TUNIT-NEXT: ret i32 [[A]]
266 ; TUNIT-NEXT: unreachable
268 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
269 ; CGSCC-LABEL: define {{[^@]+}}@ipccp1
270 ; CGSCC-SAME: (i32 returned [[A:%.*]]) #[[ATTR1]] {
271 ; CGSCC-NEXT: br i1 true, label [[T:%.*]], label [[F:%.*]]
273 ; CGSCC-NEXT: ret i32 [[A]]
275 ; CGSCC-NEXT: unreachable
277 br i1 true, label %t, label %f
281 %r = call i32 @ipccp1(i32 5)
285 define internal i1 @ipccp2i(i1 %a) {
286 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
287 ; CGSCC-LABEL: define {{[^@]+}}@ipccp2i
288 ; CGSCC-SAME: () #[[ATTR1]] {
289 ; CGSCC-NEXT: br label [[T:%.*]]
291 ; CGSCC-NEXT: ret i1 true
293 ; CGSCC-NEXT: unreachable
295 br i1 %a, label %t, label %f
299 %r = call i1 @ipccp2i(i1 false)
303 define i1 @ipccp2() {
304 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
305 ; TUNIT-LABEL: define {{[^@]+}}@ipccp2
306 ; TUNIT-SAME: () #[[ATTR2]] {
307 ; TUNIT-NEXT: ret i1 true
309 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
310 ; CGSCC-LABEL: define {{[^@]+}}@ipccp2
311 ; CGSCC-SAME: () #[[ATTR3]] {
312 ; CGSCC-NEXT: [[R:%.*]] = call noundef i1 @ipccp2i() #[[ATTR12]]
313 ; CGSCC-NEXT: ret i1 [[R]]
315 %r = call i1 @ipccp2i(i1 true)
319 define internal i1 @ipccp2ib(i1 %a) {
320 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
321 ; CGSCC-LABEL: define {{[^@]+}}@ipccp2ib
322 ; CGSCC-SAME: () #[[ATTR1]] {
323 ; CGSCC-NEXT: br label [[T:%.*]]
325 ; CGSCC-NEXT: ret i1 true
327 ; CGSCC-NEXT: unreachable
329 br i1 %a, label %t, label %f
333 %r = call i1 @ipccp2ib(i1 false)
337 define i1 @ipccp2b() {
338 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
339 ; TUNIT-LABEL: define {{[^@]+}}@ipccp2b
340 ; TUNIT-SAME: () #[[ATTR2]] {
341 ; TUNIT-NEXT: ret i1 true
343 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
344 ; CGSCC-LABEL: define {{[^@]+}}@ipccp2b
345 ; CGSCC-SAME: () #[[ATTR3]] {
346 ; CGSCC-NEXT: [[R:%.*]] = call noundef i1 @ipccp2ib() #[[ATTR12]]
347 ; CGSCC-NEXT: ret i1 [[R]]
349 %r = call i1 @ipccp2ib(i1 true)
353 define internal i32 @ipccp3i(i32 %a) {
354 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
355 ; CGSCC-LABEL: define {{[^@]+}}@ipccp3i
356 ; CGSCC-SAME: () #[[ATTR1]] {
357 ; CGSCC-NEXT: br label [[T:%.*]]
359 ; CGSCC-NEXT: ret i32 7
361 ; CGSCC-NEXT: unreachable
363 %c = icmp eq i32 %a, 7
364 br i1 %c, label %t, label %f
368 %r = call i32 @ipccp3i(i32 5)
372 define i32 @ipccp3() {
373 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
374 ; TUNIT-LABEL: define {{[^@]+}}@ipccp3
375 ; TUNIT-SAME: () #[[ATTR2]] {
376 ; TUNIT-NEXT: ret i32 7
378 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
379 ; CGSCC-LABEL: define {{[^@]+}}@ipccp3
380 ; CGSCC-SAME: () #[[ATTR3]] {
381 ; CGSCC-NEXT: [[R:%.*]] = call noundef i32 @ipccp3i() #[[ATTR12]]
382 ; CGSCC-NEXT: ret i32 [[R]]
384 %r = call i32 @ipccp3i(i32 7)
388 define internal i32 @ipccp4ia(i1 %c) {
389 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
390 ; CGSCC-LABEL: define {{[^@]+}}@ipccp4ia
391 ; CGSCC-SAME: (i1 noundef [[C:%.*]]) #[[ATTR1]] {
392 ; CGSCC-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
394 ; CGSCC-NEXT: ret i32 0
396 ; CGSCC-NEXT: ret i32 1
398 br i1 %c, label %t, label %f
404 define internal i32 @ipccp4ib(i32 %a) {
405 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
406 ; CGSCC-LABEL: define {{[^@]+}}@ipccp4ib
407 ; CGSCC-SAME: () #[[ATTR3]] {
408 ; CGSCC-NEXT: br label [[T:%.*]]
410 ; CGSCC-NEXT: [[R:%.*]] = call noundef i32 @ipccp4ia(i1 noundef true) #[[ATTR12]]
411 ; CGSCC-NEXT: ret i32 [[R]]
413 ; CGSCC-NEXT: unreachable
415 %c = icmp eq i32 %a, 7
416 br i1 %c, label %t, label %f
418 %r = call i32 @ipccp4ia(i1 %c)
424 define i32 @ipccp4(i1 %c) {
425 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
426 ; TUNIT-LABEL: define {{[^@]+}}@ipccp4
427 ; TUNIT-SAME: (i1 noundef [[C:%.*]]) #[[ATTR2]] {
428 ; TUNIT-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
430 ; TUNIT-NEXT: br label [[F]]
432 ; TUNIT-NEXT: ret i32 0
434 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
435 ; CGSCC-LABEL: define {{[^@]+}}@ipccp4
436 ; CGSCC-SAME: (i1 noundef [[C:%.*]]) #[[ATTR3]] {
437 ; CGSCC-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
439 ; CGSCC-NEXT: br label [[F]]
441 ; CGSCC-NEXT: [[R:%.*]] = call noundef i32 @ipccp4ib() #[[ATTR12]]
442 ; CGSCC-NEXT: ret i32 [[R]]
444 br i1 %c, label %t, label %f
446 %q = call i32 @ipccp4ia(i1 undef)
449 %r = call i32 @ipccp4ib(i32 7)
453 ; Do not touch complicated arguments (for now)
454 %struct.X = type { ptr }
455 define internal ptr @test_inalloca(ptr inalloca(i32) %a) {
456 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
457 ; TUNIT-LABEL: define {{[^@]+}}@test_inalloca
458 ; TUNIT-SAME: (ptr noalias nofree nonnull returned writeonly inalloca(i32) dereferenceable(4) "no-capture-maybe-returned" [[A:%.*]]) #[[ATTR2]] {
459 ; TUNIT-NEXT: ret ptr [[A]]
461 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
462 ; CGSCC-LABEL: define {{[^@]+}}@test_inalloca
463 ; CGSCC-SAME: (ptr noalias nofree noundef nonnull returned writeonly inalloca(i32) dereferenceable(4) "no-capture-maybe-returned" [[A:%.*]]) #[[ATTR1]] {
464 ; CGSCC-NEXT: ret ptr [[A]]
468 define ptr @complicated_args_inalloca(ptr %arg) {
469 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
470 ; TUNIT-LABEL: define {{[^@]+}}@complicated_args_inalloca
471 ; TUNIT-SAME: (ptr nofree nonnull readnone "no-capture-maybe-returned" [[ARG:%.*]]) #[[ATTR2]] {
472 ; TUNIT-NEXT: [[CALL:%.*]] = call nonnull dereferenceable(4) ptr @test_inalloca(ptr noalias nofree nonnull writeonly inalloca(i32) "no-capture-maybe-returned" [[ARG]]) #[[ATTR9:[0-9]+]]
473 ; TUNIT-NEXT: ret ptr [[CALL]]
475 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
476 ; CGSCC-LABEL: define {{[^@]+}}@complicated_args_inalloca
477 ; CGSCC-SAME: (ptr nofree noundef nonnull readnone dereferenceable(4) [[ARG:%.*]]) #[[ATTR3]] {
478 ; CGSCC-NEXT: [[CALL:%.*]] = call noalias noundef nonnull dereferenceable(4) ptr @test_inalloca(ptr noalias nofree noundef nonnull writeonly inalloca(i32) dereferenceable(4) [[ARG]]) #[[ATTR12]]
479 ; CGSCC-NEXT: ret ptr [[CALL]]
481 %call = call ptr @test_inalloca(ptr inalloca(i32) %arg)
485 define internal ptr @test_preallocated(ptr preallocated(i32) %a) {
486 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
487 ; TUNIT-LABEL: define {{[^@]+}}@test_preallocated
488 ; TUNIT-SAME: (ptr noalias nofree noundef nonnull returned writeonly preallocated(i32) align 4294967296 dereferenceable(4) "no-capture-maybe-returned" [[A:%.*]]) #[[ATTR2]] {
489 ; TUNIT-NEXT: ret ptr [[A]]
491 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
492 ; CGSCC-LABEL: define {{[^@]+}}@test_preallocated
493 ; CGSCC-SAME: (ptr noalias nofree noundef nonnull returned writeonly preallocated(i32) align 4294967296 dereferenceable(4) "no-capture-maybe-returned" [[A:%.*]]) #[[ATTR1]] {
494 ; CGSCC-NEXT: ret ptr [[A]]
498 define ptr @complicated_args_preallocated() {
499 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn
500 ; TUNIT-LABEL: define {{[^@]+}}@complicated_args_preallocated
501 ; TUNIT-SAME: () #[[ATTR3:[0-9]+]] {
502 ; TUNIT-NEXT: [[C:%.*]] = call token @llvm.call.preallocated.setup(i32 noundef 1) #[[ATTR10:[0-9]+]]
503 ; TUNIT-NEXT: [[CALL:%.*]] = call noundef nonnull align 4294967296 dereferenceable(4) ptr @test_preallocated(ptr nofree noundef writeonly preallocated(i32) align 4294967296 null) #[[ATTR9]] [ "preallocated"(token [[C]]) ]
504 ; TUNIT-NEXT: ret ptr [[CALL]]
506 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn
507 ; CGSCC-LABEL: define {{[^@]+}}@complicated_args_preallocated
508 ; CGSCC-SAME: () #[[ATTR4:[0-9]+]] {
509 ; CGSCC-NEXT: [[C:%.*]] = call token @llvm.call.preallocated.setup(i32 noundef 1) #[[ATTR13]]
510 ; CGSCC-NEXT: [[CALL:%.*]] = call ptr @test_preallocated(ptr nofree noundef writeonly preallocated(i32) align 4294967296 null) #[[ATTR14:[0-9]+]] [ "preallocated"(token [[C]]) ]
511 ; CGSCC-NEXT: unreachable
513 %c = call token @llvm.call.preallocated.setup(i32 1)
514 %call = call ptr @test_preallocated(ptr preallocated(i32) null) ["preallocated"(token %c)]
518 define internal void @test_sret(ptr sret(%struct.X) %a, ptr %b) {
520 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
521 ; TUNIT-LABEL: define {{[^@]+}}@test_sret
522 ; TUNIT-SAME: (ptr noalias nofree noundef writeonly sret([[STRUCT_X:%.*]]) align 4294967296 dereferenceable_or_null(8) [[A:%.*]], ptr nocapture nofree noundef nonnull writeonly align 8 dereferenceable(8) [[B:%.*]]) #[[ATTR4:[0-9]+]] {
523 ; TUNIT-NEXT: store ptr [[A]], ptr [[B]], align 8
524 ; TUNIT-NEXT: ret void
526 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
527 ; CGSCC-LABEL: define {{[^@]+}}@test_sret
528 ; CGSCC-SAME: (ptr noalias nofree noundef writeonly sret([[STRUCT_X:%.*]]) align 4294967296 dereferenceable_or_null(8) [[A:%.*]], ptr nocapture nofree noundef nonnull writeonly align 8 dereferenceable(8) [[B:%.*]]) #[[ATTR5:[0-9]+]] {
529 ; CGSCC-NEXT: store ptr [[A]], ptr [[B]], align 8
530 ; CGSCC-NEXT: ret void
535 ; FIXME: Alignment and dereferenceability are not propagated to the argument
536 define void @complicated_args_sret(ptr %b) {
539 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
540 ; TUNIT-LABEL: define {{[^@]+}}@complicated_args_sret
541 ; TUNIT-SAME: (ptr nocapture nofree writeonly [[B:%.*]]) #[[ATTR4]] {
542 ; TUNIT-NEXT: call void @test_sret(ptr nofree noundef writeonly sret([[STRUCT_X:%.*]]) align 4294967296 null, ptr nocapture nofree noundef writeonly align 8 [[B]]) #[[ATTR11:[0-9]+]]
543 ; TUNIT-NEXT: ret void
545 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(argmem: write)
546 ; CGSCC-LABEL: define {{[^@]+}}@complicated_args_sret
547 ; CGSCC-SAME: (ptr nocapture nofree noundef nonnull writeonly align 8 dereferenceable(8) [[B:%.*]]) #[[ATTR6:[0-9]+]] {
548 ; CGSCC-NEXT: call void @test_sret(ptr nofree noundef writeonly sret([[STRUCT_X:%.*]]) align 4294967296 dereferenceable_or_null(8) null, ptr nocapture nofree noundef nonnull writeonly align 8 dereferenceable(8) [[B]]) #[[ATTR15:[0-9]+]]
549 ; CGSCC-NEXT: ret void
551 call void @test_sret(ptr sret(%struct.X) null, ptr %b)
555 define internal ptr @test_nest(ptr nest %a) {
556 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
557 ; CGSCC-LABEL: define {{[^@]+}}@test_nest
558 ; CGSCC-SAME: (ptr nest noalias nocapture nofree readnone align 4294967296 [[A:%.*]]) #[[ATTR1]] {
559 ; CGSCC-NEXT: ret ptr null
563 define ptr @complicated_args_nest() {
564 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
565 ; TUNIT-LABEL: define {{[^@]+}}@complicated_args_nest
566 ; TUNIT-SAME: () #[[ATTR2]] {
567 ; TUNIT-NEXT: ret ptr null
569 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
570 ; CGSCC-LABEL: define {{[^@]+}}@complicated_args_nest
571 ; CGSCC-SAME: () #[[ATTR3]] {
572 ; CGSCC-NEXT: [[CALL:%.*]] = call noalias noundef align 4294967296 ptr @test_nest(ptr nofree noundef readnone align 4294967296 null) #[[ATTR12]]
573 ; CGSCC-NEXT: ret ptr [[CALL]]
575 %call = call ptr @test_nest(ptr null)
579 @S = external global %struct.X
580 define internal void @test_byval(ptr byval(%struct.X) %a) {
581 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
582 ; TUNIT-LABEL: define {{[^@]+}}@test_byval
583 ; TUNIT-SAME: (ptr [[TMP0:%.*]]) #[[ATTR4]] {
584 ; TUNIT-NEXT: [[A_PRIV:%.*]] = alloca [[STRUCT_X:%.*]], align 8
585 ; TUNIT-NEXT: store ptr [[TMP0]], ptr [[A_PRIV]], align 8
586 ; TUNIT-NEXT: store ptr null, ptr [[A_PRIV]], align 8
587 ; TUNIT-NEXT: ret void
589 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
590 ; CGSCC-LABEL: define {{[^@]+}}@test_byval
591 ; CGSCC-SAME: (ptr nofree [[TMP0:%.*]]) #[[ATTR5]] {
592 ; CGSCC-NEXT: [[A_PRIV:%.*]] = alloca [[STRUCT_X:%.*]], align 8
593 ; CGSCC-NEXT: store ptr [[TMP0]], ptr [[A_PRIV]], align 8
594 ; CGSCC-NEXT: store ptr null, ptr [[A_PRIV]], align 8
595 ; CGSCC-NEXT: ret void
597 store ptr null, ptr %a
600 define void @complicated_args_byval() {
601 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
602 ; TUNIT-LABEL: define {{[^@]+}}@complicated_args_byval
603 ; TUNIT-SAME: () #[[ATTR5:[0-9]+]] {
604 ; TUNIT-NEXT: [[TMP1:%.*]] = load ptr, ptr @S, align 8
605 ; TUNIT-NEXT: call void @test_byval(ptr [[TMP1]]) #[[ATTR11]]
606 ; TUNIT-NEXT: ret void
608 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn
609 ; CGSCC-LABEL: define {{[^@]+}}@complicated_args_byval
610 ; CGSCC-SAME: () #[[ATTR4]] {
611 ; CGSCC-NEXT: [[TMP1:%.*]] = load ptr, ptr @S, align 8
612 ; CGSCC-NEXT: call void @test_byval(ptr nofree writeonly [[TMP1]]) #[[ATTR15]]
613 ; CGSCC-NEXT: ret void
615 call void @test_byval(ptr byval(%struct.X) @S)
620 ; Make sure we *do not* load @S here!
621 define internal ptr @test_byval2(ptr byval(%struct.X) %a) {
622 ; CHECK-LABEL: define {{[^@]+}}@test_byval2
623 ; CHECK-SAME: (ptr [[TMP0:%.*]]) {
624 ; CHECK-NEXT: [[A_PRIV:%.*]] = alloca [[STRUCT_X:%.*]], align 8
625 ; CHECK-NEXT: store ptr [[TMP0]], ptr [[A_PRIV]], align 8
626 ; CHECK-NEXT: call void @sync()
627 ; CHECK-NEXT: [[L:%.*]] = load ptr, ptr [[A_PRIV]], align 8
628 ; CHECK-NEXT: ret ptr [[L]]
631 %l = load ptr, ptr %a
634 define ptr @complicated_args_byval2() {
636 ; CHECK-LABEL: define {{[^@]+}}@complicated_args_byval2() {
637 ; CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr @S, align 8
638 ; CHECK-NEXT: [[C:%.*]] = call ptr @test_byval2(ptr [[TMP1]])
639 ; CHECK-NEXT: ret ptr [[C]]
641 %c = call ptr @test_byval2(ptr byval(%struct.X) @S)
645 define void @fixpoint_changed(ptr %p) {
646 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
647 ; TUNIT-LABEL: define {{[^@]+}}@fixpoint_changed
648 ; TUNIT-SAME: (ptr nocapture nofree writeonly [[P:%.*]]) #[[ATTR4]] {
650 ; TUNIT-NEXT: br label [[FOR_COND:%.*]]
652 ; TUNIT-NEXT: [[J_0:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[SW_EPILOG:%.*]] ]
653 ; TUNIT-NEXT: [[CMP:%.*]] = icmp slt i32 [[J_0]], 30
654 ; TUNIT-NEXT: br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_END:%.*]]
656 ; TUNIT-NEXT: switch i32 [[J_0]], label [[SW_EPILOG]] [
657 ; TUNIT-NEXT: i32 1, label [[SW_BB:%.*]]
660 ; TUNIT-NEXT: br label [[SW_EPILOG]]
662 ; TUNIT-NEXT: [[X_0:%.*]] = phi i32 [ 255, [[FOR_BODY]] ], [ 253, [[SW_BB]] ]
663 ; TUNIT-NEXT: store i32 [[X_0]], ptr [[P]], align 4
664 ; TUNIT-NEXT: [[INC]] = add nsw i32 [[J_0]], 1
665 ; TUNIT-NEXT: br label [[FOR_COND]]
667 ; TUNIT-NEXT: ret void
669 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
670 ; CGSCC-LABEL: define {{[^@]+}}@fixpoint_changed
671 ; CGSCC-SAME: (ptr nocapture nofree writeonly [[P:%.*]]) #[[ATTR5]] {
673 ; CGSCC-NEXT: br label [[FOR_COND:%.*]]
675 ; CGSCC-NEXT: [[J_0:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[SW_EPILOG:%.*]] ]
676 ; CGSCC-NEXT: [[CMP:%.*]] = icmp slt i32 [[J_0]], 30
677 ; CGSCC-NEXT: br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_END:%.*]]
679 ; CGSCC-NEXT: switch i32 [[J_0]], label [[SW_EPILOG]] [
680 ; CGSCC-NEXT: i32 1, label [[SW_BB:%.*]]
683 ; CGSCC-NEXT: br label [[SW_EPILOG]]
685 ; CGSCC-NEXT: [[X_0:%.*]] = phi i32 [ 255, [[FOR_BODY]] ], [ 253, [[SW_BB]] ]
686 ; CGSCC-NEXT: store i32 [[X_0]], ptr [[P]], align 4
687 ; CGSCC-NEXT: [[INC]] = add nsw i32 [[J_0]], 1
688 ; CGSCC-NEXT: br label [[FOR_COND]]
690 ; CGSCC-NEXT: ret void
696 %j.0 = phi i32 [ 0, %entry ], [ %inc, %sw.epilog ]
697 %cmp = icmp slt i32 %j.0, 30
698 br i1 %cmp, label %for.body, label %for.end
701 switch i32 %j.0, label %sw.epilog [
709 %x.0 = phi i32 [ 255, %for.body ], [ 253, %sw.bb ]
710 store i32 %x.0, ptr %p
711 %inc = add nsw i32 %j.0, 1
718 ; Check we merge undef and a constant properly.
719 define i8 @caller0() {
720 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
721 ; TUNIT-LABEL: define {{[^@]+}}@caller0
722 ; TUNIT-SAME: () #[[ATTR2]] {
723 ; TUNIT-NEXT: ret i8 49
725 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
726 ; CGSCC-LABEL: define {{[^@]+}}@caller0
727 ; CGSCC-SAME: () #[[ATTR3]] {
728 ; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR12]]
729 ; CGSCC-NEXT: ret i8 [[C]]
731 %c = call i8 @callee(i8 undef)
734 define i8 @caller1() {
735 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
736 ; TUNIT-LABEL: define {{[^@]+}}@caller1
737 ; TUNIT-SAME: () #[[ATTR2]] {
738 ; TUNIT-NEXT: ret i8 49
740 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
741 ; CGSCC-LABEL: define {{[^@]+}}@caller1
742 ; CGSCC-SAME: () #[[ATTR3]] {
743 ; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR12]]
744 ; CGSCC-NEXT: ret i8 [[C]]
746 %c = call i8 @callee(i8 undef)
749 define i8 @caller2() {
750 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
751 ; TUNIT-LABEL: define {{[^@]+}}@caller2
752 ; TUNIT-SAME: () #[[ATTR2]] {
753 ; TUNIT-NEXT: ret i8 49
755 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
756 ; CGSCC-LABEL: define {{[^@]+}}@caller2
757 ; CGSCC-SAME: () #[[ATTR3]] {
758 ; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR12]]
759 ; CGSCC-NEXT: ret i8 [[C]]
761 %c = call i8 @callee(i8 undef)
764 define i8 @caller_middle() {
765 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
766 ; TUNIT-LABEL: define {{[^@]+}}@caller_middle
767 ; TUNIT-SAME: () #[[ATTR2]] {
768 ; TUNIT-NEXT: ret i8 49
770 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
771 ; CGSCC-LABEL: define {{[^@]+}}@caller_middle
772 ; CGSCC-SAME: () #[[ATTR3]] {
773 ; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR12]]
774 ; CGSCC-NEXT: ret i8 [[C]]
776 %c = call i8 @callee(i8 42)
779 define i8 @caller3() {
780 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
781 ; TUNIT-LABEL: define {{[^@]+}}@caller3
782 ; TUNIT-SAME: () #[[ATTR2]] {
783 ; TUNIT-NEXT: ret i8 49
785 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
786 ; CGSCC-LABEL: define {{[^@]+}}@caller3
787 ; CGSCC-SAME: () #[[ATTR3]] {
788 ; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR12]]
789 ; CGSCC-NEXT: ret i8 [[C]]
791 %c = call i8 @callee(i8 undef)
794 define i8 @caller4() {
795 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
796 ; TUNIT-LABEL: define {{[^@]+}}@caller4
797 ; TUNIT-SAME: () #[[ATTR2]] {
798 ; TUNIT-NEXT: ret i8 49
800 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
801 ; CGSCC-LABEL: define {{[^@]+}}@caller4
802 ; CGSCC-SAME: () #[[ATTR3]] {
803 ; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR12]]
804 ; CGSCC-NEXT: ret i8 [[C]]
806 %c = call i8 @callee(i8 undef)
809 define internal i8 @callee(i8 %a) {
810 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
811 ; CGSCC-LABEL: define {{[^@]+}}@callee
812 ; CGSCC-SAME: () #[[ATTR1]] {
813 ; CGSCC-NEXT: ret i8 49
819 define void @user_as3() {
820 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
821 ; TUNIT-LABEL: define {{[^@]+}}@user_as3
822 ; TUNIT-SAME: () #[[ATTR5]] {
823 ; TUNIT-NEXT: store i32 0, ptr addrspace(3) @ConstAS3Ptr, align 4
824 ; TUNIT-NEXT: ret void
826 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(write)
827 ; CGSCC-LABEL: define {{[^@]+}}@user_as3
828 ; CGSCC-SAME: () #[[ATTR7:[0-9]+]] {
829 ; CGSCC-NEXT: [[CALL:%.*]] = call fastcc align 4 ptr addrspace(3) @const_ptr_return_as3() #[[ATTR12]]
830 ; CGSCC-NEXT: store i32 0, ptr addrspace(3) [[CALL]], align 4
831 ; CGSCC-NEXT: ret void
833 %call = call fastcc ptr addrspace(3) @const_ptr_return_as3()
834 store i32 0, ptr addrspace(3) %call
837 define void @user() {
838 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
839 ; TUNIT-LABEL: define {{[^@]+}}@user
840 ; TUNIT-SAME: () #[[ATTR5]] {
841 ; TUNIT-NEXT: [[TMP1:%.*]] = addrspacecast ptr addrspacecast (ptr addrspace(3) @ConstAS3Ptr to ptr) to ptr addrspace(3)
842 ; TUNIT-NEXT: store i32 0, ptr addrspace(3) [[TMP1]], align 4
843 ; TUNIT-NEXT: ret void
845 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(write)
846 ; CGSCC-LABEL: define {{[^@]+}}@user
847 ; CGSCC-SAME: () #[[ATTR7]] {
848 ; CGSCC-NEXT: [[CALL:%.*]] = call fastcc align 4 ptr @const_ptr_return() #[[ATTR12]]
849 ; CGSCC-NEXT: store i32 0, ptr [[CALL]], align 4
850 ; CGSCC-NEXT: ret void
852 %call = call fastcc ptr @const_ptr_return()
853 store i32 0, ptr %call
858 define i1 @test_merge_with_undef_values_ptr(i1 %c) {
859 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
860 ; TUNIT-LABEL: define {{[^@]+}}@test_merge_with_undef_values_ptr
861 ; TUNIT-SAME: (i1 [[C:%.*]]) #[[ATTR2]] {
862 ; TUNIT-NEXT: ret i1 false
864 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
865 ; CGSCC-LABEL: define {{[^@]+}}@test_merge_with_undef_values_ptr
866 ; CGSCC-SAME: (i1 [[C:%.*]]) #[[ATTR3]] {
867 ; CGSCC-NEXT: [[R1:%.*]] = call i1 @undef_then_null(i1 [[C]]) #[[ATTR12]]
868 ; CGSCC-NEXT: ret i1 [[R1]]
870 %r1 = call i1 @undef_then_null(i1 %c, ptr undef, ptr undef)
873 define internal i1 @undef_then_null(i1 %c, ptr %i32Aptr, ptr %i32Bptr) {
874 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
875 ; CGSCC-LABEL: define {{[^@]+}}@undef_then_null
876 ; CGSCC-SAME: (i1 [[C:%.*]]) #[[ATTR3]] {
877 ; CGSCC-NEXT: [[OR:%.*]] = or i1 false, [[C]]
878 ; CGSCC-NEXT: br i1 [[OR]], label [[A:%.*]], label [[B:%.*]]
880 ; CGSCC-NEXT: ret i1 false
882 ; CGSCC-NEXT: ret i1 false
884 %cmp1 = icmp eq ptr %i32Aptr, %i32Bptr
885 %cmp2 = icmp eq i1 %cmp1, false
886 %or = or i1 %cmp2, %c
887 br i1 %or, label %a, label %b
889 %r2 = call i1 @undef_then_null(i1 false, ptr null, ptr null)
895 define i1 @test_merge_with_undef_values(i1 %c) {
896 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
897 ; TUNIT-LABEL: define {{[^@]+}}@test_merge_with_undef_values
898 ; TUNIT-SAME: (i1 [[C:%.*]]) #[[ATTR2]] {
899 ; TUNIT-NEXT: ret i1 false
901 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
902 ; CGSCC-LABEL: define {{[^@]+}}@test_merge_with_undef_values
903 ; CGSCC-SAME: (i1 [[C:%.*]]) #[[ATTR3]] {
904 ; CGSCC-NEXT: [[R1:%.*]] = call i1 @undef_then_1(i1 [[C]]) #[[ATTR12]]
905 ; CGSCC-NEXT: ret i1 [[R1]]
907 %r1 = call i1 @undef_then_1(i1 %c, i32 undef, i32 undef)
910 define internal i1 @undef_then_1(i1 %c, i32 %i32A, i32 %i32B) {
912 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
913 ; CGSCC-LABEL: define {{[^@]+}}@undef_then_1
914 ; CGSCC-SAME: (i1 [[C:%.*]]) #[[ATTR3]] {
915 ; CGSCC-NEXT: [[OR:%.*]] = or i1 false, [[C]]
916 ; CGSCC-NEXT: br i1 [[OR]], label [[A:%.*]], label [[B:%.*]]
918 ; CGSCC-NEXT: ret i1 false
920 ; CGSCC-NEXT: ret i1 false
922 %cmp1 = icmp eq i32 %i32A, %i32B
923 %cmp2 = icmp eq i1 %cmp1, false
924 %or = or i1 %cmp2, %c
925 br i1 %or, label %a, label %b
927 %r2 = call i1 @undef_then_1(i1 false, i32 1, i32 1)
933 define i32 @test_select(i32 %c) {
934 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
935 ; TUNIT-LABEL: define {{[^@]+}}@test_select
936 ; TUNIT-SAME: (i32 [[C:%.*]]) #[[ATTR2]] {
937 ; TUNIT-NEXT: ret i32 42
939 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
940 ; CGSCC-LABEL: define {{[^@]+}}@test_select
941 ; CGSCC-SAME: (i32 [[C:%.*]]) #[[ATTR3]] {
942 ; CGSCC-NEXT: [[CALL:%.*]] = call noundef i32 @select() #[[ATTR12]]
943 ; CGSCC-NEXT: ret i32 [[CALL]]
945 %call = call i32 @select(i1 1, i32 42, i32 %c)
949 define internal i32 @select(i1 %a, i32 %b, i32 %c) {
950 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
951 ; CGSCC-LABEL: define {{[^@]+}}@select
952 ; CGSCC-SAME: () #[[ATTR1]] {
953 ; CGSCC-NEXT: ret i32 42
955 %s = select i1 %a, i32 %b, i32 %c
960 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
961 ; TUNIT-LABEL: define {{[^@]+}}@icmp
962 ; TUNIT-SAME: () #[[ATTR2]] {
963 ; TUNIT-NEXT: ret i1 true
965 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
966 ; CGSCC-LABEL: define {{[^@]+}}@icmp
967 ; CGSCC-SAME: () #[[ATTR1]] {
968 ; CGSCC-NEXT: ret i1 true
970 %c = icmp eq ptr null, null
974 define void @test_callee_is_undef(ptr %fn) {
975 ; TUNIT-LABEL: define {{[^@]+}}@test_callee_is_undef
976 ; TUNIT-SAME: (ptr nocapture nofree [[FN:%.*]]) {
977 ; TUNIT-NEXT: call void @unknown_calle_arg_is_undef(ptr nocapture nofree noundef [[FN]])
978 ; TUNIT-NEXT: ret void
980 ; CGSCC-LABEL: define {{[^@]+}}@test_callee_is_undef
981 ; CGSCC-SAME: (ptr nocapture nofree noundef nonnull [[FN:%.*]]) {
982 ; CGSCC-NEXT: call void @unknown_calle_arg_is_undef(ptr nocapture nofree noundef nonnull [[FN]])
983 ; CGSCC-NEXT: ret void
985 call void @callee_is_undef(ptr undef)
986 call void @unknown_calle_arg_is_undef(ptr %fn, i32 undef)
989 define internal void @callee_is_undef(ptr %fn) {
991 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
992 ; CGSCC-LABEL: define {{[^@]+}}@callee_is_undef
993 ; CGSCC-SAME: () #[[ATTR1]] {
994 ; CGSCC-NEXT: unreachable
999 define internal void @unknown_calle_arg_is_undef(ptr %fn, i32 %arg) {
1001 ; CHECK-LABEL: define {{[^@]+}}@unknown_calle_arg_is_undef
1002 ; CHECK-SAME: (ptr nocapture nofree noundef nonnull [[FN:%.*]]) {
1003 ; CHECK-NEXT: call void [[FN]](i32 undef)
1004 ; CHECK-NEXT: ret void
1006 call void %fn(i32 %arg)
1013 @g = internal constant { [2 x ptr] } { [2 x ptr] [ptr @f1, ptr @f2] }
1015 define internal void @f1(ptr %a) {
1016 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
1017 ; TUNIT-LABEL: define {{[^@]+}}@f1
1018 ; TUNIT-SAME: (ptr nocapture nofree noundef nonnull writeonly align 8 dereferenceable(8) [[A:%.*]]) #[[ATTR4]] {
1019 ; TUNIT-NEXT: entry:
1020 ; TUNIT-NEXT: store ptr @g, ptr [[A]], align 8
1021 ; TUNIT-NEXT: ret void
1023 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
1024 ; CGSCC-LABEL: define {{[^@]+}}@f1
1025 ; CGSCC-SAME: (ptr nocapture nofree noundef nonnull writeonly align 8 dereferenceable(8) [[A:%.*]]) #[[ATTR5]] {
1026 ; CGSCC-NEXT: entry:
1027 ; CGSCC-NEXT: store ptr @g, ptr [[A]], align 8
1028 ; CGSCC-NEXT: ret void
1031 store ptr @g , ptr %a, align 8
1035 define internal void @f2(ptr %a) {
1036 ; CHECK-LABEL: define {{[^@]+}}@f2
1037 ; CHECK-SAME: (ptr [[A:%.*]]) {
1038 ; CHECK-NEXT: cont461:
1039 ; CHECK-NEXT: call void @f3(ptr [[A]], ptr nocapture nofree [[A]])
1040 ; CHECK-NEXT: ret void
1043 call void @f3(ptr %a, ptr %a)
1047 define internal void @f3(ptr %a1, ptr %a) {
1048 ; CHECK-LABEL: define {{[^@]+}}@f3
1049 ; CHECK-SAME: (ptr [[A1:%.*]], ptr nocapture nofree [[A:%.*]]) {
1050 ; CHECK-NEXT: entry:
1051 ; CHECK-NEXT: [[CALL20:%.*]] = call i1 @f9()
1052 ; CHECK-NEXT: br i1 [[CALL20]], label [[LAND_LHS_TRUE:%.*]], label [[IF_END40:%.*]]
1053 ; CHECK: land.lhs.true:
1054 ; CHECK-NEXT: [[TMP0:%.*]] = call i1 [[A]](ptr [[A1]])
1055 ; CHECK-NEXT: br label [[IF_END40]]
1057 ; CHECK-NEXT: ret void
1060 %call20 = call i1 @f9()
1061 br i1 %call20, label %land.lhs.true, label %if.end40
1071 define linkonce_odr i1 @f9() {
1072 ; CHECK-LABEL: define {{[^@]+}}@f9() {
1073 ; CHECK-NEXT: entry:
1074 ; CHECK-NEXT: ret i1 false
1083 define i1 @test_cmp_null_after_cast() {
1084 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1085 ; TUNIT-LABEL: define {{[^@]+}}@test_cmp_null_after_cast
1086 ; TUNIT-SAME: () #[[ATTR2]] {
1087 ; TUNIT-NEXT: ret i1 true
1089 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
1090 ; CGSCC-LABEL: define {{[^@]+}}@test_cmp_null_after_cast
1091 ; CGSCC-SAME: () #[[ATTR3]] {
1092 ; CGSCC-NEXT: [[C:%.*]] = call noundef i1 @cmp_null_after_cast() #[[ATTR12]]
1093 ; CGSCC-NEXT: ret i1 [[C]]
1095 %c = call i1 @cmp_null_after_cast(i32 0, i8 0)
1098 define internal i1 @cmp_null_after_cast(i32 %a, i8 %b) {
1099 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1100 ; CGSCC-LABEL: define {{[^@]+}}@cmp_null_after_cast
1101 ; CGSCC-SAME: () #[[ATTR1]] {
1102 ; CGSCC-NEXT: ret i1 true
1104 %t = trunc i32 %a to i8
1105 %c = icmp eq i8 %t, %b
1112 define i32 @test(i1 %c) {
1113 ; TUNIT-LABEL: define {{[^@]+}}@test
1114 ; TUNIT-SAME: (i1 [[C:%.*]]) {
1115 ; TUNIT-NEXT: [[R1:%.*]] = call i32 @ctx_test1(i1 noundef [[C]])
1116 ; TUNIT-NEXT: [[R2:%.*]] = call i32 @ctx_test2(i1 noundef [[C]]), !range [[RNG0:![0-9]+]]
1117 ; TUNIT-NEXT: [[ADD:%.*]] = add i32 [[R1]], [[R2]]
1118 ; TUNIT-NEXT: ret i32 [[ADD]]
1120 ; CGSCC-LABEL: define {{[^@]+}}@test
1121 ; CGSCC-SAME: (i1 noundef [[C:%.*]]) {
1122 ; CGSCC-NEXT: [[R1:%.*]] = call i32 @ctx_test1(i1 noundef [[C]])
1123 ; CGSCC-NEXT: [[R2:%.*]] = call i32 @ctx_test2(i1 noundef [[C]])
1124 ; CGSCC-NEXT: [[ADD:%.*]] = add i32 [[R1]], [[R2]]
1125 ; CGSCC-NEXT: ret i32 [[ADD]]
1127 %r1 = call i32 @ctx_test1(i1 %c)
1128 %r2 = call i32 @ctx_test2(i1 %c)
1129 %add = add i32 %r1, %r2
1133 define internal i32 @ctx_test1(i1 %c) {
1134 ; CHECK-LABEL: define {{[^@]+}}@ctx_test1
1135 ; CHECK-SAME: (i1 noundef [[C:%.*]]) {
1136 ; CHECK-NEXT: entry:
1137 ; CHECK-NEXT: br i1 [[C]], label [[THEN:%.*]], label [[JOIN:%.*]]
1139 ; CHECK-NEXT: [[M:%.*]] = tail call ptr @m()
1140 ; CHECK-NEXT: [[I:%.*]] = ptrtoint ptr [[M]] to i64
1141 ; CHECK-NEXT: br label [[JOIN]]
1143 ; CHECK-NEXT: [[PHI:%.*]] = phi i64 [ [[I]], [[THEN]] ], [ undef, [[ENTRY:%.*]] ]
1144 ; CHECK-NEXT: [[RET:%.*]] = trunc i64 [[PHI]] to i32
1145 ; CHECK-NEXT: ret i32 [[RET]]
1148 br i1 %c, label %then, label %join
1151 %m = tail call ptr @m()
1152 %i = ptrtoint ptr %m to i64
1156 %phi = phi i64 [ %i, %then ], [ undef, %entry ]
1157 %ret = trunc i64 %phi to i32
1161 define internal i32 @ctx_test2(i1 %c) {
1162 ; CHECK-LABEL: define {{[^@]+}}@ctx_test2
1163 ; CHECK-SAME: (i1 noundef [[C:%.*]]) {
1164 ; CHECK-NEXT: entry:
1165 ; CHECK-NEXT: br i1 [[C]], label [[THEN:%.*]], label [[JOIN:%.*]]
1167 ; CHECK-NEXT: [[M:%.*]] = tail call ptr @m()
1168 ; CHECK-NEXT: [[I:%.*]] = ptrtoint ptr [[M]] to i32
1169 ; CHECK-NEXT: br label [[JOIN]]
1171 ; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[I]], [[THEN]] ], [ undef, [[ENTRY:%.*]] ]
1172 ; CHECK-NEXT: [[RET:%.*]] = lshr i32 [[PHI]], 1
1173 ; CHECK-NEXT: ret i32 [[RET]]
1176 br i1 %c, label %then, label %join
1179 %m = tail call ptr @m()
1180 %i = ptrtoint ptr %m to i32
1184 %phi = phi i32 [ %i, %then ], [ undef, %entry ]
1185 %ret = lshr i32 %phi, 1
1188 uselistorder label %join, { 1, 0 }
1191 define i1 @test_liveness(i1 %c) {
1192 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1193 ; TUNIT-LABEL: define {{[^@]+}}@test_liveness
1194 ; TUNIT-SAME: (i1 noundef [[C:%.*]]) #[[ATTR2]] {
1195 ; TUNIT-NEXT: entry:
1196 ; TUNIT-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
1198 ; TUNIT-NEXT: br label [[F]]
1200 ; TUNIT-NEXT: ret i1 false
1202 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
1203 ; CGSCC-LABEL: define {{[^@]+}}@test_liveness
1204 ; CGSCC-SAME: (i1 noundef [[C:%.*]]) #[[ATTR3]] {
1205 ; CGSCC-NEXT: entry:
1206 ; CGSCC-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
1208 ; CGSCC-NEXT: br label [[F]]
1210 ; CGSCC-NEXT: [[P:%.*]] = phi i1 [ true, [[ENTRY:%.*]] ], [ false, [[T]] ]
1211 ; CGSCC-NEXT: [[RC1:%.*]] = call noundef i1 @ret(i1 noundef [[P]]) #[[ATTR12]]
1212 ; CGSCC-NEXT: ret i1 [[RC1]]
1215 br i1 %c, label %t, label %f
1219 %p = phi i1 [true, %entry], [false, %t]
1220 %rc1 = call i1 @ret(i1 %p)
1224 define internal i1 @ret(i1 %c) {
1225 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1226 ; CGSCC-LABEL: define {{[^@]+}}@ret
1227 ; CGSCC-SAME: (i1 noundef [[C:%.*]]) #[[ATTR1]] {
1228 ; CGSCC-NEXT: entry:
1229 ; CGSCC-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
1231 ; CGSCC-NEXT: br label [[F]]
1233 ; CGSCC-NEXT: [[P:%.*]] = phi i1 [ [[C]], [[ENTRY:%.*]] ], [ false, [[T]] ]
1234 ; CGSCC-NEXT: ret i1 false
1237 br i1 %c, label %t, label %f
1241 %p = phi i1 [%c, %entry], [false, %t]
1245 declare ptr @unknown()
1246 define internal i8 @dead_ret() {
1247 ; CHECK-LABEL: define {{[^@]+}}@dead_ret() {
1248 ; CHECK-NEXT: [[R:%.*]] = call ptr @unknown()
1249 ; CHECK-NEXT: ret i8 undef
1251 %r = call ptr @unknown()
1252 %l = load i8, ptr %r
1256 define void @dead_ret_caller() {
1257 ; CHECK-LABEL: define {{[^@]+}}@dead_ret_caller() {
1258 ; CHECK-NEXT: [[R:%.*]] = call i8 @dead_ret()
1259 ; CHECK-NEXT: ret void
1261 %r = call i8 @dead_ret()
1265 declare void @llvm.memcpy(ptr %dest, ptr %src, i32 %len, i1 %isvolatile)
1266 define internal i8 @memcpy_uses_store(i8 %arg) {
1267 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1268 ; TUNIT-LABEL: define {{[^@]+}}@memcpy_uses_store
1269 ; TUNIT-SAME: (i8 [[ARG:%.*]]) #[[ATTR2]] {
1270 ; TUNIT-NEXT: [[SRC:%.*]] = alloca i8, align 1
1271 ; TUNIT-NEXT: [[DST:%.*]] = alloca i8, align 1
1272 ; TUNIT-NEXT: store i8 [[ARG]], ptr [[SRC]], align 1
1273 ; TUNIT-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr noalias nocapture nofree noundef nonnull writeonly dereferenceable(1) [[DST]], ptr noalias nocapture nofree noundef nonnull readonly dereferenceable(1) [[SRC]], i32 noundef 1, i1 noundef false) #[[ATTR12:[0-9]+]]
1274 ; TUNIT-NEXT: [[L:%.*]] = load i8, ptr [[DST]], align 1
1275 ; TUNIT-NEXT: ret i8 [[L]]
1277 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1278 ; CGSCC-LABEL: define {{[^@]+}}@memcpy_uses_store
1279 ; CGSCC-SAME: (i8 [[ARG:%.*]]) #[[ATTR1]] {
1280 ; CGSCC-NEXT: [[SRC:%.*]] = alloca i8, align 1
1281 ; CGSCC-NEXT: [[DST:%.*]] = alloca i8, align 1
1282 ; CGSCC-NEXT: store i8 [[ARG]], ptr [[SRC]], align 1
1283 ; CGSCC-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr noalias nocapture nofree noundef nonnull writeonly dereferenceable(1) [[DST]], ptr noalias nocapture nofree noundef nonnull readonly dereferenceable(1) [[SRC]], i32 noundef 1, i1 noundef false) #[[ATTR16:[0-9]+]]
1284 ; CGSCC-NEXT: [[L:%.*]] = load i8, ptr [[DST]], align 1
1285 ; CGSCC-NEXT: ret i8 [[L]]
1289 store i8 %arg, ptr %src
1290 call void @llvm.memcpy(ptr %dst, ptr %src, i32 1, i1 false)
1291 %l = load i8, ptr %dst
1295 define i8 @memcpy_uses_store_caller(i8 %arg) {
1296 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1297 ; TUNIT-LABEL: define {{[^@]+}}@memcpy_uses_store_caller
1298 ; TUNIT-SAME: (i8 [[ARG:%.*]]) #[[ATTR2]] {
1299 ; TUNIT-NEXT: [[R:%.*]] = call i8 @memcpy_uses_store(i8 [[ARG]]) #[[ATTR13:[0-9]+]]
1300 ; TUNIT-NEXT: ret i8 [[R]]
1302 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
1303 ; CGSCC-LABEL: define {{[^@]+}}@memcpy_uses_store_caller
1304 ; CGSCC-SAME: (i8 [[ARG:%.*]]) #[[ATTR3]] {
1305 ; CGSCC-NEXT: [[R:%.*]] = call i8 @memcpy_uses_store(i8 [[ARG]]) #[[ATTR12]]
1306 ; CGSCC-NEXT: ret i8 [[R]]
1308 %r = call i8 @memcpy_uses_store(i8 %arg)
1313 declare i32 @speculatable() speculatable readnone
1315 define i32 @test_speculatable_expr() norecurse {
1316 ; TUNIT: Function Attrs: norecurse nosync memory(none)
1317 ; TUNIT-LABEL: define {{[^@]+}}@test_speculatable_expr
1318 ; TUNIT-SAME: () #[[ATTR7:[0-9]+]] {
1319 ; TUNIT-NEXT: [[STACK:%.*]] = alloca i32, align 4
1320 ; TUNIT-NEXT: [[SPEC_RESULT:%.*]] = call i32 @speculatable() #[[ATTR14:[0-9]+]]
1321 ; TUNIT-NEXT: [[PLUS1:%.*]] = add i32 [[SPEC_RESULT]], 1
1322 ; TUNIT-NEXT: store i32 [[PLUS1]], ptr [[STACK]], align 4
1323 ; TUNIT-NEXT: [[TMP1:%.*]] = load i32, ptr [[STACK]], align 4
1324 ; TUNIT-NEXT: [[RSPEC:%.*]] = call i32 @ret_speculatable_expr(i32 [[TMP1]]) #[[ATTR15:[0-9]+]]
1325 ; TUNIT-NEXT: ret i32 [[RSPEC]]
1327 ; CGSCC: Function Attrs: norecurse nosync memory(none)
1328 ; CGSCC-LABEL: define {{[^@]+}}@test_speculatable_expr
1329 ; CGSCC-SAME: () #[[ATTR9:[0-9]+]] {
1330 ; CGSCC-NEXT: [[STACK:%.*]] = alloca i32, align 4
1331 ; CGSCC-NEXT: [[SPEC_RESULT:%.*]] = call i32 @speculatable() #[[ATTR17:[0-9]+]]
1332 ; CGSCC-NEXT: [[PLUS1:%.*]] = add i32 [[SPEC_RESULT]], 1
1333 ; CGSCC-NEXT: store i32 [[PLUS1]], ptr [[STACK]], align 4
1334 ; CGSCC-NEXT: [[RSPEC:%.*]] = call i32 @ret_speculatable_expr(i32 [[PLUS1]]) #[[ATTR17]]
1335 ; CGSCC-NEXT: ret i32 [[RSPEC]]
1338 %spec_result = call i32 @speculatable()
1339 %plus1 = add i32 %spec_result, 1
1340 store i32 %plus1, ptr %stack
1341 %rspec = call i32 @ret_speculatable_expr(ptr %stack, i32 13)
1345 define internal i32 @ret_speculatable_expr(ptr %mem, i32 %a2) {
1346 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1347 ; TUNIT-LABEL: define {{[^@]+}}@ret_speculatable_expr
1348 ; TUNIT-SAME: (i32 [[TMP0:%.*]]) #[[ATTR2]] {
1349 ; TUNIT-NEXT: [[MEM_PRIV:%.*]] = alloca i32, align 4
1350 ; TUNIT-NEXT: store i32 [[TMP0]], ptr [[MEM_PRIV]], align 4
1351 ; TUNIT-NEXT: [[L:%.*]] = load i32, ptr [[MEM_PRIV]], align 4
1352 ; TUNIT-NEXT: [[MUL:%.*]] = mul i32 [[L]], 13
1353 ; TUNIT-NEXT: [[ADD:%.*]] = add i32 [[MUL]], 7
1354 ; TUNIT-NEXT: ret i32 [[ADD]]
1356 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1357 ; CGSCC-LABEL: define {{[^@]+}}@ret_speculatable_expr
1358 ; CGSCC-SAME: (i32 [[TMP0:%.*]]) #[[ATTR1]] {
1359 ; CGSCC-NEXT: [[MEM_PRIV:%.*]] = alloca i32, align 4
1360 ; CGSCC-NEXT: store i32 [[TMP0]], ptr [[MEM_PRIV]], align 4
1361 ; CGSCC-NEXT: [[L:%.*]] = load i32, ptr [[MEM_PRIV]], align 4
1362 ; CGSCC-NEXT: [[MUL:%.*]] = mul i32 [[L]], 13
1363 ; CGSCC-NEXT: [[ADD:%.*]] = add i32 [[MUL]], 7
1364 ; CGSCC-NEXT: ret i32 [[ADD]]
1366 %l = load i32, ptr %mem
1367 %mul = mul i32 %l, %a2
1368 %add = add i32 %mul, 7
1372 define internal void @not_called1() {
1373 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1374 ; TUNIT-LABEL: define {{[^@]+}}@not_called1
1375 ; TUNIT-SAME: () #[[ATTR2]] {
1376 ; TUNIT-NEXT: ret void
1378 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1379 ; CGSCC-LABEL: define {{[^@]+}}@not_called1
1380 ; CGSCC-SAME: () #[[ATTR1]] {
1381 ; CGSCC-NEXT: ret void
1385 define internal void @not_called2() {
1386 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1387 ; TUNIT-LABEL: define {{[^@]+}}@not_called2
1388 ; TUNIT-SAME: () #[[ATTR2]] {
1389 ; TUNIT-NEXT: ret void
1391 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1392 ; CGSCC-LABEL: define {{[^@]+}}@not_called2
1393 ; CGSCC-SAME: () #[[ATTR1]] {
1394 ; CGSCC-NEXT: ret void
1398 define internal void @not_called3() {
1399 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1400 ; TUNIT-LABEL: define {{[^@]+}}@not_called3
1401 ; TUNIT-SAME: () #[[ATTR2]] {
1402 ; TUNIT-NEXT: ret void
1404 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1405 ; CGSCC-LABEL: define {{[^@]+}}@not_called3
1406 ; CGSCC-SAME: () #[[ATTR1]] {
1407 ; CGSCC-NEXT: ret void
1411 declare void @useFnDecl(ptr addrspace(42));
1412 define void @useFnDef(ptr addrspace(42) %arg) {
1413 ; CHECK-LABEL: define {{[^@]+}}@useFnDef
1414 ; CHECK-SAME: (ptr addrspace(42) [[ARG:%.*]]) {
1415 ; CHECK-NEXT: call void @useFnDecl(ptr addrspace(42) [[ARG]])
1416 ; CHECK-NEXT: ret void
1418 call void @useFnDecl(ptr addrspace(42) %arg)
1421 define i1 @user_of_not_called() {
1422 ; CHECK-LABEL: define {{[^@]+}}@user_of_not_called() {
1423 ; CHECK-NEXT: call void @useFnDecl(ptr addrspace(42) noundef nonnull addrspacecast (ptr @not_called1 to ptr addrspace(42)))
1424 ; CHECK-NEXT: call void @useFnDef(ptr addrspace(42) noundef nonnull addrspacecast (ptr @not_called2 to ptr addrspace(42)))
1425 ; CHECK-NEXT: ret i1 icmp eq (ptr addrspace(42) addrspacecast (ptr @not_called3 to ptr addrspace(42)), ptr addrspace(42) null)
1427 call void @useFnDecl(ptr addrspace(42) addrspacecast (ptr @not_called1 to ptr addrspace(42)))
1428 call void @useFnDef(ptr addrspace(42) addrspacecast (ptr @not_called2 to ptr addrspace(42)))
1429 %cmp = icmp eq ptr addrspace(42) addrspacecast (ptr @not_called3 to ptr addrspace(42)), null
1433 @x = external global i32
1434 define internal void @indirect() {
1435 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
1436 ; TUNIT-LABEL: define {{[^@]+}}@indirect
1437 ; TUNIT-SAME: () #[[ATTR5]] {
1438 ; TUNIT-NEXT: store i32 0, ptr @x, align 4
1439 ; TUNIT-NEXT: ret void
1441 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
1442 ; CGSCC-LABEL: define {{[^@]+}}@indirect
1443 ; CGSCC-SAME: () #[[ATTR10:[0-9]+]] {
1444 ; CGSCC-NEXT: store i32 0, ptr @x, align 4
1445 ; CGSCC-NEXT: ret void
1451 define internal void @broker(ptr %ptr) {
1452 ; TUNIT: Function Attrs: memory(readwrite, argmem: none)
1453 ; TUNIT-LABEL: define {{[^@]+}}@broker
1454 ; TUNIT-SAME: () #[[ATTR1]] {
1455 ; TUNIT-NEXT: entry:
1456 ; TUNIT-NEXT: call void @indirect() #[[ATTR16:[0-9]+]]
1457 ; TUNIT-NEXT: call void @unknown()
1458 ; TUNIT-NEXT: ret void
1460 ; CGSCC: Function Attrs: memory(readwrite, argmem: none)
1461 ; CGSCC-LABEL: define {{[^@]+}}@broker
1462 ; CGSCC-SAME: () #[[ATTR2]] {
1463 ; CGSCC-NEXT: entry:
1464 ; CGSCC-NEXT: call void @indirect() #[[ATTR18:[0-9]+]]
1465 ; CGSCC-NEXT: call void @unknown()
1466 ; CGSCC-NEXT: ret void
1470 call void @unknown()
1474 define void @entry() {
1475 ; CHECK-LABEL: define {{[^@]+}}@entry() {
1476 ; CHECK-NEXT: entry:
1477 ; CHECK-NEXT: call void @broker()
1478 ; CHECK-NEXT: ret void
1481 call void @broker(ptr @indirect)
1485 define i1 @constexpr_icmp1() {
1486 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1487 ; TUNIT-LABEL: define {{[^@]+}}@constexpr_icmp1
1488 ; TUNIT-SAME: () #[[ATTR2]] {
1489 ; TUNIT-NEXT: ret i1 icmp ne (ptr addrspacecast (ptr addrspace(4) @str to ptr), ptr null)
1491 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1492 ; CGSCC-LABEL: define {{[^@]+}}@constexpr_icmp1
1493 ; CGSCC-SAME: () #[[ATTR1]] {
1494 ; CGSCC-NEXT: ret i1 icmp ne (ptr addrspacecast (ptr addrspace(4) @str to ptr), ptr null)
1496 ret i1 icmp ne (ptr addrspacecast (ptr addrspace(4) @str to ptr), ptr null)
1499 define i1 @constexpr_icmp2() {
1500 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1501 ; TUNIT-LABEL: define {{[^@]+}}@constexpr_icmp2
1502 ; TUNIT-SAME: () #[[ATTR2]] {
1503 ; TUNIT-NEXT: ret i1 icmp eq (ptr addrspacecast (ptr addrspace(4) @str to ptr), ptr null)
1505 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1506 ; CGSCC-LABEL: define {{[^@]+}}@constexpr_icmp2
1507 ; CGSCC-SAME: () #[[ATTR1]] {
1508 ; CGSCC-NEXT: ret i1 icmp eq (ptr addrspacecast (ptr addrspace(4) @str to ptr), ptr null)
1510 ret i1 icmp eq (ptr addrspacecast (ptr addrspace(4) @str to ptr), ptr null)
1513 define i8 @switch(i1 %c1, i1 %c2) {
1514 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1515 ; TUNIT-LABEL: define {{[^@]+}}@switch
1516 ; TUNIT-SAME: (i1 noundef [[C1:%.*]], i1 [[C2:%.*]]) #[[ATTR2]] {
1517 ; TUNIT-NEXT: entry:
1518 ; TUNIT-NEXT: br i1 [[C1]], label [[T:%.*]], label [[F:%.*]]
1520 ; TUNIT-NEXT: br label [[M:%.*]]
1522 ; TUNIT-NEXT: br label [[M]]
1524 ; TUNIT-NEXT: [[J:%.*]] = phi i32 [ 0, [[T]] ], [ 4, [[F]] ]
1525 ; TUNIT-NEXT: switch i32 [[J]], label [[DEFAULT1:%.*]] [
1526 ; TUNIT-NEXT: i32 1, label [[DEAD1:%.*]]
1527 ; TUNIT-NEXT: i32 2, label [[DEAD2:%.*]]
1528 ; TUNIT-NEXT: i32 3, label [[DEAD3:%.*]]
1529 ; TUNIT-NEXT: i32 4, label [[ALIVE1:%.*]]
1532 ; TUNIT-NEXT: br label [[ALIVE1]]
1534 ; TUNIT-NEXT: [[K:%.*]] = phi i32 [ 1, [[M]] ], [ 4, [[DEFAULT1]] ]
1535 ; TUNIT-NEXT: switch i32 [[K]], label [[DEAD4:%.*]] [
1536 ; TUNIT-NEXT: i32 1, label [[END1:%.*]]
1537 ; TUNIT-NEXT: i32 2, label [[DEAD5:%.*]]
1538 ; TUNIT-NEXT: i32 4, label [[END2:%.*]]
1541 ; TUNIT-NEXT: ret i8 -1
1543 ; TUNIT-NEXT: ret i8 -2
1545 ; TUNIT-NEXT: unreachable
1547 ; TUNIT-NEXT: unreachable
1549 ; TUNIT-NEXT: unreachable
1551 ; TUNIT-NEXT: unreachable
1553 ; TUNIT-NEXT: unreachable
1555 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1556 ; CGSCC-LABEL: define {{[^@]+}}@switch
1557 ; CGSCC-SAME: (i1 noundef [[C1:%.*]], i1 [[C2:%.*]]) #[[ATTR1]] {
1558 ; CGSCC-NEXT: entry:
1559 ; CGSCC-NEXT: br i1 [[C1]], label [[T:%.*]], label [[F:%.*]]
1561 ; CGSCC-NEXT: br label [[M:%.*]]
1563 ; CGSCC-NEXT: br label [[M]]
1565 ; CGSCC-NEXT: [[J:%.*]] = phi i32 [ 0, [[T]] ], [ 4, [[F]] ]
1566 ; CGSCC-NEXT: switch i32 [[J]], label [[DEFAULT1:%.*]] [
1567 ; CGSCC-NEXT: i32 1, label [[DEAD1:%.*]]
1568 ; CGSCC-NEXT: i32 2, label [[DEAD2:%.*]]
1569 ; CGSCC-NEXT: i32 3, label [[DEAD3:%.*]]
1570 ; CGSCC-NEXT: i32 4, label [[ALIVE1:%.*]]
1573 ; CGSCC-NEXT: br label [[ALIVE1]]
1575 ; CGSCC-NEXT: [[K:%.*]] = phi i32 [ 1, [[M]] ], [ 4, [[DEFAULT1]] ]
1576 ; CGSCC-NEXT: switch i32 [[K]], label [[DEAD4:%.*]] [
1577 ; CGSCC-NEXT: i32 1, label [[END1:%.*]]
1578 ; CGSCC-NEXT: i32 2, label [[DEAD5:%.*]]
1579 ; CGSCC-NEXT: i32 4, label [[END2:%.*]]
1582 ; CGSCC-NEXT: ret i8 -1
1584 ; CGSCC-NEXT: ret i8 -2
1586 ; CGSCC-NEXT: unreachable
1588 ; CGSCC-NEXT: unreachable
1590 ; CGSCC-NEXT: unreachable
1592 ; CGSCC-NEXT: unreachable
1594 ; CGSCC-NEXT: unreachable
1597 br i1 %c1, label %t, label %f
1606 %j = phi i32 [ 0, %t ], [ 4, %f ]
1607 switch i32 %j, label %default1 [
1611 i32 4, label %alive1
1618 %k = phi i32 [ 1, %m ], [ 4, %default1 ]
1619 switch i32 %k, label %dead4 [
1641 define i32 @readConst() {
1642 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1643 ; TUNIT-LABEL: define {{[^@]+}}@readConst
1644 ; TUNIT-SAME: () #[[ATTR2]] {
1645 ; TUNIT-NEXT: ret i32 0
1647 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1648 ; CGSCC-LABEL: define {{[^@]+}}@readConst
1649 ; CGSCC-SAME: () #[[ATTR1]] {
1650 ; CGSCC-NEXT: ret i32 0
1652 %l = load i32, ptr @ConstPtr
1656 define i32 @readWeakConst() {
1657 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1658 ; TUNIT-LABEL: define {{[^@]+}}@readWeakConst
1659 ; TUNIT-SAME: () #[[ATTR2]] {
1660 ; TUNIT-NEXT: [[L:%.*]] = load i32, ptr @ConstWeakPtr, align 4
1661 ; TUNIT-NEXT: ret i32 [[L]]
1663 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1664 ; CGSCC-LABEL: define {{[^@]+}}@readWeakConst
1665 ; CGSCC-SAME: () #[[ATTR1]] {
1666 ; CGSCC-NEXT: [[L:%.*]] = load i32, ptr @ConstWeakPtr, align 4
1667 ; CGSCC-NEXT: ret i32 [[L]]
1669 %l = load i32, ptr @ConstWeakPtr
1673 define i32 @readWeakOdrConst() {
1674 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1675 ; TUNIT-LABEL: define {{[^@]+}}@readWeakOdrConst
1676 ; TUNIT-SAME: () #[[ATTR2]] {
1677 ; TUNIT-NEXT: ret i32 0
1679 ; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
1680 ; CGSCC-LABEL: define {{[^@]+}}@readWeakOdrConst
1681 ; CGSCC-SAME: () #[[ATTR1]] {
1682 ; CGSCC-NEXT: ret i32 0
1684 %l = load i32, ptr @ConstWeakODRPtr
1689 ; TUNIT: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind willreturn }
1690 ; TUNIT: attributes #[[ATTR1]] = { memory(readwrite, argmem: none) }
1691 ; TUNIT: attributes #[[ATTR2]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
1692 ; TUNIT: attributes #[[ATTR3]] = { mustprogress nofree norecurse nosync nounwind willreturn }
1693 ; TUNIT: attributes #[[ATTR4]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) }
1694 ; TUNIT: attributes #[[ATTR5]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(write) }
1695 ; TUNIT: attributes #[[ATTR6:[0-9]+]] = { speculatable memory(none) }
1696 ; TUNIT: attributes #[[ATTR7]] = { norecurse nosync memory(none) }
1697 ; TUNIT: attributes #[[ATTR8:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
1698 ; TUNIT: attributes #[[ATTR9]] = { nofree nosync nounwind willreturn memory(none) }
1699 ; TUNIT: attributes #[[ATTR10]] = { nofree willreturn }
1700 ; TUNIT: attributes #[[ATTR11]] = { nofree nosync nounwind willreturn memory(write) }
1701 ; TUNIT: attributes #[[ATTR12]] = { nofree willreturn memory(readwrite) }
1702 ; TUNIT: attributes #[[ATTR13]] = { nofree nosync nounwind willreturn }
1703 ; TUNIT: attributes #[[ATTR14]] = { nosync }
1704 ; TUNIT: attributes #[[ATTR15]] = { nosync nounwind memory(read) }
1705 ; TUNIT: attributes #[[ATTR16]] = { nounwind memory(write) }
1707 ; CGSCC: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind willreturn }
1708 ; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
1709 ; CGSCC: attributes #[[ATTR2]] = { memory(readwrite, argmem: none) }
1710 ; CGSCC: attributes #[[ATTR3]] = { mustprogress nofree nosync nounwind willreturn memory(none) }
1711 ; CGSCC: attributes #[[ATTR4]] = { mustprogress nofree nosync nounwind willreturn }
1712 ; CGSCC: attributes #[[ATTR5]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) }
1713 ; CGSCC: attributes #[[ATTR6]] = { mustprogress nofree nosync nounwind willreturn memory(argmem: write) }
1714 ; CGSCC: attributes #[[ATTR7]] = { mustprogress nofree nosync nounwind willreturn memory(write) }
1715 ; CGSCC: attributes #[[ATTR8:[0-9]+]] = { speculatable memory(none) }
1716 ; CGSCC: attributes #[[ATTR9]] = { norecurse nosync memory(none) }
1717 ; CGSCC: attributes #[[ATTR10]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(write) }
1718 ; CGSCC: attributes #[[ATTR11:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
1719 ; CGSCC: attributes #[[ATTR12]] = { nofree nosync willreturn }
1720 ; CGSCC: attributes #[[ATTR13]] = { nofree willreturn }
1721 ; CGSCC: attributes #[[ATTR14]] = { nofree nounwind willreturn }
1722 ; CGSCC: attributes #[[ATTR15]] = { nofree nounwind willreturn memory(write) }
1723 ; CGSCC: attributes #[[ATTR16]] = { nofree willreturn memory(readwrite) }
1724 ; CGSCC: attributes #[[ATTR17]] = { nosync }
1725 ; CGSCC: attributes #[[ATTR18]] = { nounwind }
1727 ; TUNIT: [[RNG0]] = !{i32 0, i32 -2147483648}