1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
2 ; RUN: opt -attributor -enable-new-pm=0 -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=2 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT____,IS________OPM,IS__TUNIT_OPM
3 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=2 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT____,IS________NPM,IS__TUNIT_NPM
4 ; RUN: opt -attributor-cgscc -enable-new-pm=0 -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_NPM,IS__CGSCC____,IS________OPM,IS__CGSCC_OPM
5 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_OPM,IS__CGSCC____,IS________NPM,IS__CGSCC_NPM
7 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
9 ; Test cases specifically designed for the "undefined behavior" abstract function attribute.
10 ; We want to verify that whenever undefined behavior is assumed, the code becomes unreachable.
11 ; We use FIXME's to indicate problems and missing attributes.
15 define void @load_wholly_unreachable() {
16 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
17 ; IS__TUNIT____-LABEL: define {{[^@]+}}@load_wholly_unreachable
18 ; IS__TUNIT____-SAME: () #[[ATTR0:[0-9]+]] {
19 ; IS__TUNIT____-NEXT: unreachable
21 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
22 ; IS__CGSCC____-LABEL: define {{[^@]+}}@load_wholly_unreachable
23 ; IS__CGSCC____-SAME: () #[[ATTR0:[0-9]+]] {
24 ; IS__CGSCC____-NEXT: unreachable
26 %a = load i32, i32* null
30 define void @loads_wholly_unreachable() {
31 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
32 ; IS__TUNIT____-LABEL: define {{[^@]+}}@loads_wholly_unreachable
33 ; IS__TUNIT____-SAME: () #[[ATTR0]] {
34 ; IS__TUNIT____-NEXT: unreachable
36 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
37 ; IS__CGSCC____-LABEL: define {{[^@]+}}@loads_wholly_unreachable
38 ; IS__CGSCC____-SAME: () #[[ATTR0]] {
39 ; IS__CGSCC____-NEXT: unreachable
41 %a = load i32, i32* null
42 %b = load i32, i32* null
47 define void @load_single_bb_unreachable(i1 %cond) {
48 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
49 ; IS__TUNIT____-LABEL: define {{[^@]+}}@load_single_bb_unreachable
50 ; IS__TUNIT____-SAME: (i1 [[COND:%.*]]) #[[ATTR0]] {
51 ; IS__TUNIT____-NEXT: br i1 [[COND]], label [[T:%.*]], label [[E:%.*]]
53 ; IS__TUNIT____-NEXT: unreachable
55 ; IS__TUNIT____-NEXT: ret void
57 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
58 ; IS__CGSCC____-LABEL: define {{[^@]+}}@load_single_bb_unreachable
59 ; IS__CGSCC____-SAME: (i1 [[COND:%.*]]) #[[ATTR0]] {
60 ; IS__CGSCC____-NEXT: br i1 [[COND]], label [[T:%.*]], label [[E:%.*]]
62 ; IS__CGSCC____-NEXT: unreachable
64 ; IS__CGSCC____-NEXT: ret void
66 br i1 %cond, label %t, label %e
68 %b = load i32, i32* null
74 ; Note that while the load is removed (because it's unused), the block
75 ; is not changed to unreachable
76 define void @load_null_pointer_is_defined() null_pointer_is_valid {
77 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind null_pointer_is_valid readnone willreturn
78 ; IS__TUNIT____-LABEL: define {{[^@]+}}@load_null_pointer_is_defined
79 ; IS__TUNIT____-SAME: () #[[ATTR1:[0-9]+]] {
80 ; IS__TUNIT____-NEXT: ret void
82 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind null_pointer_is_valid readnone willreturn
83 ; IS__CGSCC____-LABEL: define {{[^@]+}}@load_null_pointer_is_defined
84 ; IS__CGSCC____-SAME: () #[[ATTR1:[0-9]+]] {
85 ; IS__CGSCC____-NEXT: ret void
87 %a = load i32, i32* null
91 define internal i32* @ret_null() {
92 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
93 ; IS__CGSCC____-LABEL: define {{[^@]+}}@ret_null
94 ; IS__CGSCC____-SAME: () #[[ATTR0]] {
95 ; IS__CGSCC____-NEXT: ret i32* undef
100 define void @load_null_propagated() {
101 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
102 ; IS__TUNIT____-LABEL: define {{[^@]+}}@load_null_propagated
103 ; IS__TUNIT____-SAME: () #[[ATTR0]] {
104 ; IS__TUNIT____-NEXT: unreachable
106 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
107 ; IS__CGSCC____-LABEL: define {{[^@]+}}@load_null_propagated
108 ; IS__CGSCC____-SAME: () #[[ATTR0]] {
109 ; IS__CGSCC____-NEXT: unreachable
111 %ptr = call i32* @ret_null()
112 %a = load i32, i32* %ptr
118 define void @store_wholly_unreachable() {
119 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
120 ; IS__TUNIT____-LABEL: define {{[^@]+}}@store_wholly_unreachable
121 ; IS__TUNIT____-SAME: () #[[ATTR0]] {
122 ; IS__TUNIT____-NEXT: unreachable
124 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
125 ; IS__CGSCC____-LABEL: define {{[^@]+}}@store_wholly_unreachable
126 ; IS__CGSCC____-SAME: () #[[ATTR0]] {
127 ; IS__CGSCC____-NEXT: unreachable
129 store i32 5, i32* null
133 define void @store_wholly_unreachable_volatile() {
134 ; IS__TUNIT____: Function Attrs: nofree nounwind readnone willreturn
135 ; IS__TUNIT____-LABEL: define {{[^@]+}}@store_wholly_unreachable_volatile
136 ; IS__TUNIT____-SAME: () #[[ATTR2:[0-9]+]] {
137 ; IS__TUNIT____-NEXT: store volatile i32 5, i32* null, align 536870912
138 ; IS__TUNIT____-NEXT: ret void
140 ; IS__CGSCC____: Function Attrs: nofree norecurse nounwind readnone willreturn
141 ; IS__CGSCC____-LABEL: define {{[^@]+}}@store_wholly_unreachable_volatile
142 ; IS__CGSCC____-SAME: () #[[ATTR2:[0-9]+]] {
143 ; IS__CGSCC____-NEXT: store volatile i32 5, i32* null, align 536870912
144 ; IS__CGSCC____-NEXT: ret void
146 store volatile i32 5, i32* null
150 define void @store_single_bb_unreachable(i1 %cond) {
151 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
152 ; IS__TUNIT____-LABEL: define {{[^@]+}}@store_single_bb_unreachable
153 ; IS__TUNIT____-SAME: (i1 [[COND:%.*]]) #[[ATTR0]] {
154 ; IS__TUNIT____-NEXT: br i1 [[COND]], label [[T:%.*]], label [[E:%.*]]
156 ; IS__TUNIT____-NEXT: unreachable
158 ; IS__TUNIT____-NEXT: ret void
160 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
161 ; IS__CGSCC____-LABEL: define {{[^@]+}}@store_single_bb_unreachable
162 ; IS__CGSCC____-SAME: (i1 [[COND:%.*]]) #[[ATTR0]] {
163 ; IS__CGSCC____-NEXT: br i1 [[COND]], label [[T:%.*]], label [[E:%.*]]
165 ; IS__CGSCC____-NEXT: unreachable
167 ; IS__CGSCC____-NEXT: ret void
169 br i1 %cond, label %t, label %e
171 store i32 5, i32* null
177 define void @store_null_pointer_is_defined() null_pointer_is_valid {
178 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind null_pointer_is_valid willreturn writeonly
179 ; IS__TUNIT____-LABEL: define {{[^@]+}}@store_null_pointer_is_defined
180 ; IS__TUNIT____-SAME: () #[[ATTR3:[0-9]+]] {
181 ; IS__TUNIT____-NEXT: store i32 5, i32* null, align 536870912
182 ; IS__TUNIT____-NEXT: ret void
184 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind null_pointer_is_valid willreturn writeonly
185 ; IS__CGSCC____-LABEL: define {{[^@]+}}@store_null_pointer_is_defined
186 ; IS__CGSCC____-SAME: () #[[ATTR3:[0-9]+]] {
187 ; IS__CGSCC____-NEXT: store i32 5, i32* null, align 536870912
188 ; IS__CGSCC____-NEXT: ret void
190 store i32 5, i32* null
194 define void @store_null_propagated() {
195 ; ATTRIBUTOR-LABEL: @store_null_propagated(
196 ; ATTRIBUTOR-NEXT: unreachable
198 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
199 ; IS__TUNIT____-LABEL: define {{[^@]+}}@store_null_propagated
200 ; IS__TUNIT____-SAME: () #[[ATTR0]] {
201 ; IS__TUNIT____-NEXT: unreachable
203 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
204 ; IS__CGSCC____-LABEL: define {{[^@]+}}@store_null_propagated
205 ; IS__CGSCC____-SAME: () #[[ATTR0]] {
206 ; IS__CGSCC____-NEXT: unreachable
208 %ptr = call i32* @ret_null()
209 store i32 5, i32* %ptr
213 ; -- AtomicRMW tests --
215 define void @atomicrmw_wholly_unreachable() {
216 ; IS__TUNIT____: Function Attrs: nofree nounwind readnone willreturn
217 ; IS__TUNIT____-LABEL: define {{[^@]+}}@atomicrmw_wholly_unreachable
218 ; IS__TUNIT____-SAME: () #[[ATTR2]] {
219 ; IS__TUNIT____-NEXT: unreachable
221 ; IS__CGSCC____: Function Attrs: nofree norecurse nounwind readnone willreturn
222 ; IS__CGSCC____-LABEL: define {{[^@]+}}@atomicrmw_wholly_unreachable
223 ; IS__CGSCC____-SAME: () #[[ATTR2]] {
224 ; IS__CGSCC____-NEXT: unreachable
226 %a = atomicrmw add i32* null, i32 1 acquire
230 define void @atomicrmw_single_bb_unreachable(i1 %cond) {
231 ; IS__TUNIT____: Function Attrs: nofree nounwind readnone willreturn
232 ; IS__TUNIT____-LABEL: define {{[^@]+}}@atomicrmw_single_bb_unreachable
233 ; IS__TUNIT____-SAME: (i1 [[COND:%.*]]) #[[ATTR2]] {
234 ; IS__TUNIT____-NEXT: br i1 [[COND]], label [[T:%.*]], label [[E:%.*]]
236 ; IS__TUNIT____-NEXT: unreachable
238 ; IS__TUNIT____-NEXT: ret void
240 ; IS__CGSCC____: Function Attrs: nofree norecurse nounwind readnone willreturn
241 ; IS__CGSCC____-LABEL: define {{[^@]+}}@atomicrmw_single_bb_unreachable
242 ; IS__CGSCC____-SAME: (i1 [[COND:%.*]]) #[[ATTR2]] {
243 ; IS__CGSCC____-NEXT: br i1 [[COND]], label [[T:%.*]], label [[E:%.*]]
245 ; IS__CGSCC____-NEXT: unreachable
247 ; IS__CGSCC____-NEXT: ret void
249 br i1 %cond, label %t, label %e
251 %a = atomicrmw add i32* null, i32 1 acquire
257 define void @atomicrmw_null_pointer_is_defined() null_pointer_is_valid {
258 ; IS__TUNIT____: Function Attrs: nofree nounwind null_pointer_is_valid willreturn
259 ; IS__TUNIT____-LABEL: define {{[^@]+}}@atomicrmw_null_pointer_is_defined
260 ; IS__TUNIT____-SAME: () #[[ATTR4:[0-9]+]] {
261 ; IS__TUNIT____-NEXT: [[A:%.*]] = atomicrmw add i32* null, i32 1 acquire, align 4
262 ; IS__TUNIT____-NEXT: ret void
264 ; IS__CGSCC____: Function Attrs: nofree norecurse nounwind null_pointer_is_valid willreturn
265 ; IS__CGSCC____-LABEL: define {{[^@]+}}@atomicrmw_null_pointer_is_defined
266 ; IS__CGSCC____-SAME: () #[[ATTR4:[0-9]+]] {
267 ; IS__CGSCC____-NEXT: [[A:%.*]] = atomicrmw add i32* null, i32 1 acquire, align 4
268 ; IS__CGSCC____-NEXT: ret void
270 %a = atomicrmw add i32* null, i32 1 acquire
274 define void @atomicrmw_null_propagated() {
275 ; ATTRIBUTOR-LABEL: @atomicrmw_null_propagated(
276 ; ATTRIBUTOR-NEXT: unreachable
278 ; IS__TUNIT____: Function Attrs: nofree nounwind readnone willreturn
279 ; IS__TUNIT____-LABEL: define {{[^@]+}}@atomicrmw_null_propagated
280 ; IS__TUNIT____-SAME: () #[[ATTR2]] {
281 ; IS__TUNIT____-NEXT: unreachable
283 ; IS__CGSCC____: Function Attrs: nofree norecurse nounwind readnone willreturn
284 ; IS__CGSCC____-LABEL: define {{[^@]+}}@atomicrmw_null_propagated
285 ; IS__CGSCC____-SAME: () #[[ATTR2]] {
286 ; IS__CGSCC____-NEXT: unreachable
288 %ptr = call i32* @ret_null()
289 %a = atomicrmw add i32* %ptr, i32 1 acquire
293 ; -- AtomicCmpXchg tests --
295 define void @atomiccmpxchg_wholly_unreachable() {
296 ; IS__TUNIT____: Function Attrs: nofree nounwind readnone willreturn
297 ; IS__TUNIT____-LABEL: define {{[^@]+}}@atomiccmpxchg_wholly_unreachable
298 ; IS__TUNIT____-SAME: () #[[ATTR2]] {
299 ; IS__TUNIT____-NEXT: unreachable
301 ; IS__CGSCC____: Function Attrs: nofree norecurse nounwind readnone willreturn
302 ; IS__CGSCC____-LABEL: define {{[^@]+}}@atomiccmpxchg_wholly_unreachable
303 ; IS__CGSCC____-SAME: () #[[ATTR2]] {
304 ; IS__CGSCC____-NEXT: unreachable
306 %a = cmpxchg i32* null, i32 2, i32 3 acq_rel monotonic
310 define void @atomiccmpxchg_single_bb_unreachable(i1 %cond) {
311 ; IS__TUNIT____: Function Attrs: nofree nounwind readnone willreturn
312 ; IS__TUNIT____-LABEL: define {{[^@]+}}@atomiccmpxchg_single_bb_unreachable
313 ; IS__TUNIT____-SAME: (i1 [[COND:%.*]]) #[[ATTR2]] {
314 ; IS__TUNIT____-NEXT: br i1 [[COND]], label [[T:%.*]], label [[E:%.*]]
316 ; IS__TUNIT____-NEXT: unreachable
318 ; IS__TUNIT____-NEXT: ret void
320 ; IS__CGSCC____: Function Attrs: nofree norecurse nounwind readnone willreturn
321 ; IS__CGSCC____-LABEL: define {{[^@]+}}@atomiccmpxchg_single_bb_unreachable
322 ; IS__CGSCC____-SAME: (i1 [[COND:%.*]]) #[[ATTR2]] {
323 ; IS__CGSCC____-NEXT: br i1 [[COND]], label [[T:%.*]], label [[E:%.*]]
325 ; IS__CGSCC____-NEXT: unreachable
327 ; IS__CGSCC____-NEXT: ret void
329 br i1 %cond, label %t, label %e
331 %a = cmpxchg i32* null, i32 2, i32 3 acq_rel monotonic
337 define void @atomiccmpxchg_null_pointer_is_defined() null_pointer_is_valid {
338 ; IS__TUNIT____: Function Attrs: nofree nounwind null_pointer_is_valid willreturn
339 ; IS__TUNIT____-LABEL: define {{[^@]+}}@atomiccmpxchg_null_pointer_is_defined
340 ; IS__TUNIT____-SAME: () #[[ATTR4]] {
341 ; IS__TUNIT____-NEXT: [[A:%.*]] = cmpxchg i32* null, i32 2, i32 3 acq_rel monotonic, align 4
342 ; IS__TUNIT____-NEXT: ret void
344 ; IS__CGSCC____: Function Attrs: nofree norecurse nounwind null_pointer_is_valid willreturn
345 ; IS__CGSCC____-LABEL: define {{[^@]+}}@atomiccmpxchg_null_pointer_is_defined
346 ; IS__CGSCC____-SAME: () #[[ATTR4]] {
347 ; IS__CGSCC____-NEXT: [[A:%.*]] = cmpxchg i32* null, i32 2, i32 3 acq_rel monotonic, align 4
348 ; IS__CGSCC____-NEXT: ret void
350 %a = cmpxchg i32* null, i32 2, i32 3 acq_rel monotonic
354 define void @atomiccmpxchg_null_propagated() {
355 ; ATTRIBUTOR-LABEL: @atomiccmpxchg_null_propagated(
356 ; ATTRIBUTOR-NEXT: unreachable
358 ; IS__TUNIT____: Function Attrs: nofree nounwind readnone willreturn
359 ; IS__TUNIT____-LABEL: define {{[^@]+}}@atomiccmpxchg_null_propagated
360 ; IS__TUNIT____-SAME: () #[[ATTR2]] {
361 ; IS__TUNIT____-NEXT: unreachable
363 ; IS__CGSCC____: Function Attrs: nofree norecurse nounwind readnone willreturn
364 ; IS__CGSCC____-LABEL: define {{[^@]+}}@atomiccmpxchg_null_propagated
365 ; IS__CGSCC____-SAME: () #[[ATTR2]] {
366 ; IS__CGSCC____-NEXT: unreachable
368 %ptr = call i32* @ret_null()
369 %a = cmpxchg i32* %ptr, i32 2, i32 3 acq_rel monotonic
373 ; -- Conditional branching tests --
375 ; Note: The unreachable on %t and %e is _not_ from AAUndefinedBehavior
377 define i32 @cond_br_on_undef() {
378 ; IS__TUNIT____: Function Attrs: nofree noreturn nosync nounwind readnone willreturn
379 ; IS__TUNIT____-LABEL: define {{[^@]+}}@cond_br_on_undef
380 ; IS__TUNIT____-SAME: () #[[ATTR5:[0-9]+]] {
381 ; IS__TUNIT____-NEXT: unreachable
383 ; IS__TUNIT____-NEXT: unreachable
385 ; IS__TUNIT____-NEXT: unreachable
387 ; IS__CGSCC____: Function Attrs: nofree norecurse noreturn nosync nounwind readnone willreturn
388 ; IS__CGSCC____-LABEL: define {{[^@]+}}@cond_br_on_undef
389 ; IS__CGSCC____-SAME: () #[[ATTR5:[0-9]+]] {
390 ; IS__CGSCC____-NEXT: unreachable
392 ; IS__CGSCC____-NEXT: unreachable
394 ; IS__CGSCC____-NEXT: unreachable
396 br i1 undef, label %t, label %e
403 ; More complicated branching
404 ; Valid branch - verify that this is not converted
406 define void @cond_br_on_undef2(i1 %cond) {
407 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
408 ; IS__TUNIT____-LABEL: define {{[^@]+}}@cond_br_on_undef2
409 ; IS__TUNIT____-SAME: (i1 [[COND:%.*]]) #[[ATTR0]] {
410 ; IS__TUNIT____-NEXT: br i1 [[COND]], label [[T1:%.*]], label [[E1:%.*]]
412 ; IS__TUNIT____-NEXT: unreachable
414 ; IS__TUNIT____-NEXT: unreachable
416 ; IS__TUNIT____-NEXT: unreachable
418 ; IS__TUNIT____-NEXT: ret void
420 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
421 ; IS__CGSCC____-LABEL: define {{[^@]+}}@cond_br_on_undef2
422 ; IS__CGSCC____-SAME: (i1 [[COND:%.*]]) #[[ATTR0]] {
423 ; IS__CGSCC____-NEXT: br i1 [[COND]], label [[T1:%.*]], label [[E1:%.*]]
425 ; IS__CGSCC____-NEXT: unreachable
427 ; IS__CGSCC____-NEXT: unreachable
429 ; IS__CGSCC____-NEXT: unreachable
431 ; IS__CGSCC____-NEXT: ret void
433 br i1 %cond, label %t1, label %e1
435 br i1 undef, label %t2, label %e2
444 define i1 @ret_undef() {
445 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
446 ; IS__TUNIT____-LABEL: define {{[^@]+}}@ret_undef
447 ; IS__TUNIT____-SAME: () #[[ATTR0]] {
448 ; IS__TUNIT____-NEXT: ret i1 undef
450 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
451 ; IS__CGSCC____-LABEL: define {{[^@]+}}@ret_undef
452 ; IS__CGSCC____-SAME: () #[[ATTR0]] {
453 ; IS__CGSCC____-NEXT: ret i1 undef
458 define void @cond_br_on_undef_interproc() {
459 ; IS__TUNIT____: Function Attrs: nofree noreturn nosync nounwind readnone willreturn
460 ; IS__TUNIT____-LABEL: define {{[^@]+}}@cond_br_on_undef_interproc
461 ; IS__TUNIT____-SAME: () #[[ATTR5]] {
462 ; IS__TUNIT____-NEXT: unreachable
464 ; IS__TUNIT____-NEXT: unreachable
466 ; IS__TUNIT____-NEXT: unreachable
468 ; IS__CGSCC____: Function Attrs: nofree norecurse noreturn nosync nounwind readnone willreturn
469 ; IS__CGSCC____-LABEL: define {{[^@]+}}@cond_br_on_undef_interproc
470 ; IS__CGSCC____-SAME: () #[[ATTR5]] {
471 ; IS__CGSCC____-NEXT: unreachable
473 ; IS__CGSCC____-NEXT: unreachable
475 ; IS__CGSCC____-NEXT: unreachable
477 %cond = call i1 @ret_undef()
478 br i1 %cond, label %t, label %e
485 define i1 @ret_undef2() {
486 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
487 ; IS__TUNIT____-LABEL: define {{[^@]+}}@ret_undef2
488 ; IS__TUNIT____-SAME: () #[[ATTR0]] {
489 ; IS__TUNIT____-NEXT: br i1 true, label [[T:%.*]], label [[E:%.*]]
491 ; IS__TUNIT____-NEXT: ret i1 undef
493 ; IS__TUNIT____-NEXT: unreachable
495 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
496 ; IS__CGSCC____-LABEL: define {{[^@]+}}@ret_undef2
497 ; IS__CGSCC____-SAME: () #[[ATTR0]] {
498 ; IS__CGSCC____-NEXT: br i1 true, label [[T:%.*]], label [[E:%.*]]
500 ; IS__CGSCC____-NEXT: ret i1 undef
502 ; IS__CGSCC____-NEXT: unreachable
504 br i1 true, label %t, label %e
511 ; More complicated interproc deduction of undef
512 define void @cond_br_on_undef_interproc2() {
513 ; IS__TUNIT____: Function Attrs: nofree noreturn nosync nounwind readnone willreturn
514 ; IS__TUNIT____-LABEL: define {{[^@]+}}@cond_br_on_undef_interproc2
515 ; IS__TUNIT____-SAME: () #[[ATTR5]] {
516 ; IS__TUNIT____-NEXT: unreachable
518 ; IS__TUNIT____-NEXT: unreachable
520 ; IS__TUNIT____-NEXT: unreachable
522 ; IS__CGSCC____: Function Attrs: nofree norecurse noreturn nosync nounwind readnone willreturn
523 ; IS__CGSCC____-LABEL: define {{[^@]+}}@cond_br_on_undef_interproc2
524 ; IS__CGSCC____-SAME: () #[[ATTR5]] {
525 ; IS__CGSCC____-NEXT: unreachable
527 ; IS__CGSCC____-NEXT: unreachable
529 ; IS__CGSCC____-NEXT: unreachable
531 %cond = call i1 @ret_undef2()
532 br i1 %cond, label %t, label %e
539 ; Branch on undef that depends on propagation of
540 ; undef of a previous instruction.
541 define i32 @cond_br_on_undef3() {
542 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
543 ; IS__TUNIT____-LABEL: define {{[^@]+}}@cond_br_on_undef3
544 ; IS__TUNIT____-SAME: () #[[ATTR0]] {
545 ; IS__TUNIT____-NEXT: br label [[T:%.*]]
547 ; IS__TUNIT____-NEXT: ret i32 1
549 ; IS__TUNIT____-NEXT: unreachable
551 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
552 ; IS__CGSCC____-LABEL: define {{[^@]+}}@cond_br_on_undef3
553 ; IS__CGSCC____-SAME: () #[[ATTR0]] {
554 ; IS__CGSCC____-NEXT: br label [[T:%.*]]
556 ; IS__CGSCC____-NEXT: ret i32 1
558 ; IS__CGSCC____-NEXT: unreachable
560 %cond = icmp ne i32 1, undef
561 br i1 %cond, label %t, label %e
568 ; Branch on undef because of uninitialized value.
569 ; FIXME: Currently it doesn't propagate the undef.
570 define i32 @cond_br_on_undef_uninit() {
571 ; IS__TUNIT____: Function Attrs: nofree noreturn nosync nounwind readnone willreturn
572 ; IS__TUNIT____-LABEL: define {{[^@]+}}@cond_br_on_undef_uninit
573 ; IS__TUNIT____-SAME: () #[[ATTR5]] {
574 ; IS__TUNIT____-NEXT: unreachable
576 ; IS__TUNIT____-NEXT: unreachable
578 ; IS__TUNIT____-NEXT: unreachable
580 ; IS__CGSCC____: Function Attrs: nofree norecurse noreturn nosync nounwind readnone willreturn
581 ; IS__CGSCC____-LABEL: define {{[^@]+}}@cond_br_on_undef_uninit
582 ; IS__CGSCC____-SAME: () #[[ATTR5]] {
583 ; IS__CGSCC____-NEXT: unreachable
585 ; IS__CGSCC____-NEXT: unreachable
587 ; IS__CGSCC____-NEXT: unreachable
590 %cond = load i1, i1* %alloc
591 br i1 %cond, label %t, label %e
598 ; Note that the `load` has UB (so it will be changed to unreachable)
599 ; and the branch is a terminator that can be constant-folded.
600 ; We want to test that doing both won't cause a segfault.
601 ; MODULE-NOT: @callee(
602 define internal i32 @callee(i1 %C, i32* %A) {
604 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
605 ; IS__CGSCC____-LABEL: define {{[^@]+}}@callee
606 ; IS__CGSCC____-SAME: () #[[ATTR0]] {
607 ; IS__CGSCC____-NEXT: entry:
608 ; IS__CGSCC____-NEXT: unreachable
610 ; IS__CGSCC____-NEXT: unreachable
612 ; IS__CGSCC____-NEXT: ret i32 undef
615 %A.0 = load i32, i32* null
616 br i1 %C, label %T, label %F
626 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
627 ; IS__TUNIT____-LABEL: define {{[^@]+}}@foo
628 ; IS__TUNIT____-SAME: () #[[ATTR0]] {
629 ; IS__TUNIT____-NEXT: ret i32 1
631 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
632 ; IS__CGSCC____-LABEL: define {{[^@]+}}@foo
633 ; IS__CGSCC____-SAME: () #[[ATTR0]] {
634 ; IS__CGSCC____-NEXT: ret i32 1
636 %X = call i32 @callee(i1 false, i32* null)
640 ; Tests for nonnull noundef attribute violation.
642 ; Tests for argument position
644 define void @arg_nonnull_1(i32* nonnull %a) {
645 ; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind willreturn writeonly
646 ; IS__TUNIT____-LABEL: define {{[^@]+}}@arg_nonnull_1
647 ; IS__TUNIT____-SAME: (i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[A:%.*]]) #[[ATTR6:[0-9]+]] {
648 ; IS__TUNIT____-NEXT: store i32 0, i32* [[A]], align 4
649 ; IS__TUNIT____-NEXT: ret void
651 ; IS__CGSCC____: Function Attrs: argmemonly nofree norecurse nosync nounwind willreturn writeonly
652 ; IS__CGSCC____-LABEL: define {{[^@]+}}@arg_nonnull_1
653 ; IS__CGSCC____-SAME: (i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[A:%.*]]) #[[ATTR6:[0-9]+]] {
654 ; IS__CGSCC____-NEXT: store i32 0, i32* [[A]], align 4
655 ; IS__CGSCC____-NEXT: ret void
661 define void @arg_nonnull_1_noundef_1(i32* nonnull noundef %a) {
662 ; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind willreturn writeonly
663 ; IS__TUNIT____-LABEL: define {{[^@]+}}@arg_nonnull_1_noundef_1
664 ; IS__TUNIT____-SAME: (i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[A:%.*]]) #[[ATTR6]] {
665 ; IS__TUNIT____-NEXT: store i32 0, i32* [[A]], align 4
666 ; IS__TUNIT____-NEXT: ret void
668 ; IS__CGSCC____: Function Attrs: argmemonly nofree norecurse nosync nounwind willreturn writeonly
669 ; IS__CGSCC____-LABEL: define {{[^@]+}}@arg_nonnull_1_noundef_1
670 ; IS__CGSCC____-SAME: (i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[A:%.*]]) #[[ATTR6]] {
671 ; IS__CGSCC____-NEXT: store i32 0, i32* [[A]], align 4
672 ; IS__CGSCC____-NEXT: ret void
678 define void @arg_nonnull_12(i32* nonnull %a, i32* nonnull %b, i32* %c) {
679 ; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind willreturn writeonly
680 ; IS__TUNIT____-LABEL: define {{[^@]+}}@arg_nonnull_12
681 ; IS__TUNIT____-SAME: (i32* nocapture nofree nonnull writeonly [[A:%.*]], i32* nocapture nofree nonnull writeonly [[B:%.*]], i32* nofree writeonly [[C:%.*]]) #[[ATTR6]] {
682 ; IS__TUNIT____-NEXT: [[D:%.*]] = icmp eq i32* [[C]], null
683 ; IS__TUNIT____-NEXT: br i1 [[D]], label [[T:%.*]], label [[F:%.*]]
685 ; IS__TUNIT____-NEXT: store i32 0, i32* [[A]], align 4
686 ; IS__TUNIT____-NEXT: br label [[RET:%.*]]
688 ; IS__TUNIT____-NEXT: store i32 1, i32* [[B]], align 4
689 ; IS__TUNIT____-NEXT: br label [[RET]]
690 ; IS__TUNIT____: ret:
691 ; IS__TUNIT____-NEXT: ret void
693 ; IS__CGSCC____: Function Attrs: argmemonly nofree norecurse nosync nounwind willreturn writeonly
694 ; IS__CGSCC____-LABEL: define {{[^@]+}}@arg_nonnull_12
695 ; IS__CGSCC____-SAME: (i32* nocapture nofree nonnull writeonly [[A:%.*]], i32* nocapture nofree nonnull writeonly [[B:%.*]], i32* nofree writeonly [[C:%.*]]) #[[ATTR6]] {
696 ; IS__CGSCC____-NEXT: [[D:%.*]] = icmp eq i32* [[C]], null
697 ; IS__CGSCC____-NEXT: br i1 [[D]], label [[T:%.*]], label [[F:%.*]]
699 ; IS__CGSCC____-NEXT: store i32 0, i32* [[A]], align 4
700 ; IS__CGSCC____-NEXT: br label [[RET:%.*]]
702 ; IS__CGSCC____-NEXT: store i32 1, i32* [[B]], align 4
703 ; IS__CGSCC____-NEXT: br label [[RET]]
704 ; IS__CGSCC____: ret:
705 ; IS__CGSCC____-NEXT: ret void
707 %d = icmp eq i32* %c, null
708 br i1 %d, label %t, label %f
719 define void @arg_nonnull_12_noundef_2(i32* nonnull %a, i32* noundef nonnull %b, i32* %c) {
720 ; IS__TUNIT____: Function Attrs: argmemonly nofree nosync nounwind willreturn writeonly
721 ; IS__TUNIT____-LABEL: define {{[^@]+}}@arg_nonnull_12_noundef_2
722 ; IS__TUNIT____-SAME: (i32* nocapture nofree nonnull writeonly [[A:%.*]], i32* nocapture nofree noundef nonnull writeonly [[B:%.*]], i32* nofree writeonly [[C:%.*]]) #[[ATTR6]] {
723 ; IS__TUNIT____-NEXT: [[D:%.*]] = icmp eq i32* [[C]], null
724 ; IS__TUNIT____-NEXT: br i1 [[D]], label [[T:%.*]], label [[F:%.*]]
726 ; IS__TUNIT____-NEXT: store i32 0, i32* [[A]], align 4
727 ; IS__TUNIT____-NEXT: br label [[RET:%.*]]
729 ; IS__TUNIT____-NEXT: store i32 1, i32* [[B]], align 4
730 ; IS__TUNIT____-NEXT: br label [[RET]]
731 ; IS__TUNIT____: ret:
732 ; IS__TUNIT____-NEXT: ret void
734 ; IS__CGSCC____: Function Attrs: argmemonly nofree norecurse nosync nounwind willreturn writeonly
735 ; IS__CGSCC____-LABEL: define {{[^@]+}}@arg_nonnull_12_noundef_2
736 ; IS__CGSCC____-SAME: (i32* nocapture nofree nonnull writeonly [[A:%.*]], i32* nocapture nofree noundef nonnull writeonly [[B:%.*]], i32* nofree writeonly [[C:%.*]]) #[[ATTR6]] {
737 ; IS__CGSCC____-NEXT: [[D:%.*]] = icmp eq i32* [[C]], null
738 ; IS__CGSCC____-NEXT: br i1 [[D]], label [[T:%.*]], label [[F:%.*]]
740 ; IS__CGSCC____-NEXT: store i32 0, i32* [[A]], align 4
741 ; IS__CGSCC____-NEXT: br label [[RET:%.*]]
743 ; IS__CGSCC____-NEXT: store i32 1, i32* [[B]], align 4
744 ; IS__CGSCC____-NEXT: br label [[RET]]
745 ; IS__CGSCC____: ret:
746 ; IS__CGSCC____-NEXT: ret void
748 %d = icmp eq i32* %c, null
749 br i1 %d, label %t, label %f
760 ; Pass null directly to argument with nonnull attribute
761 define void @arg_nonnull_violation1_1() {
762 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
763 ; IS__TUNIT____-LABEL: define {{[^@]+}}@arg_nonnull_violation1_1
764 ; IS__TUNIT____-SAME: () #[[ATTR0]] {
765 ; IS__TUNIT____-NEXT: unreachable
767 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
768 ; IS__CGSCC____-LABEL: define {{[^@]+}}@arg_nonnull_violation1_1
769 ; IS__CGSCC____-SAME: () #[[ATTR0]] {
770 ; IS__CGSCC____-NEXT: unreachable
772 call void @arg_nonnull_1(i32* null)
776 define void @arg_nonnull_violation1_2() {
777 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
778 ; IS__TUNIT____-LABEL: define {{[^@]+}}@arg_nonnull_violation1_2
779 ; IS__TUNIT____-SAME: () #[[ATTR0]] {
780 ; IS__TUNIT____-NEXT: unreachable
782 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
783 ; IS__CGSCC____-LABEL: define {{[^@]+}}@arg_nonnull_violation1_2
784 ; IS__CGSCC____-SAME: () #[[ATTR0]] {
785 ; IS__CGSCC____-NEXT: unreachable
787 call void @arg_nonnull_1_noundef_1(i32* null)
791 ; A case that depends on value simplification
792 define void @arg_nonnull_violation2_1(i1 %c) {
793 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
794 ; IS__TUNIT____-LABEL: define {{[^@]+}}@arg_nonnull_violation2_1
795 ; IS__TUNIT____-SAME: (i1 [[C:%.*]]) #[[ATTR0]] {
796 ; IS__TUNIT____-NEXT: unreachable
798 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
799 ; IS__CGSCC____-LABEL: define {{[^@]+}}@arg_nonnull_violation2_1
800 ; IS__CGSCC____-SAME: (i1 [[C:%.*]]) #[[ATTR0]] {
801 ; IS__CGSCC____-NEXT: unreachable
803 %null = getelementptr i32, i32* null, i32 0
804 %mustnull = select i1 %c, i32* null, i32* %null
805 call void @arg_nonnull_1(i32* %mustnull)
809 define void @arg_nonnull_violation2_2(i1 %c) {
810 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
811 ; IS__TUNIT____-LABEL: define {{[^@]+}}@arg_nonnull_violation2_2
812 ; IS__TUNIT____-SAME: (i1 [[C:%.*]]) #[[ATTR0]] {
813 ; IS__TUNIT____-NEXT: unreachable
815 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
816 ; IS__CGSCC____-LABEL: define {{[^@]+}}@arg_nonnull_violation2_2
817 ; IS__CGSCC____-SAME: (i1 [[C:%.*]]) #[[ATTR0]] {
818 ; IS__CGSCC____-NEXT: unreachable
820 %null = getelementptr i32, i32* null, i32 0
821 %mustnull = select i1 %c, i32* null, i32* %null
822 call void @arg_nonnull_1_noundef_1(i32* %mustnull)
826 ; Cases for single and multiple violation at a callsite
827 define void @arg_nonnull_violation3_1(i1 %c) {
828 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
829 ; IS__TUNIT____-LABEL: define {{[^@]+}}@arg_nonnull_violation3_1
830 ; IS__TUNIT____-SAME: (i1 [[C:%.*]]) #[[ATTR0]] {
831 ; IS__TUNIT____-NEXT: [[PTR:%.*]] = alloca i32, align 4
832 ; IS__TUNIT____-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
834 ; IS__TUNIT____-NEXT: call void @arg_nonnull_12(i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[PTR]], i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[PTR]], i32* nofree noundef nonnull writeonly align 4 dereferenceable(4) [[PTR]]) #[[ATTR7:[0-9]+]]
835 ; IS__TUNIT____-NEXT: call void @arg_nonnull_12(i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[PTR]], i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[PTR]], i32* noalias nocapture nofree noundef writeonly align 536870912 null) #[[ATTR7]]
836 ; IS__TUNIT____-NEXT: unreachable
838 ; IS__TUNIT____-NEXT: unreachable
839 ; IS__TUNIT____: ret:
840 ; IS__TUNIT____-NEXT: ret void
842 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
843 ; IS__CGSCC____-LABEL: define {{[^@]+}}@arg_nonnull_violation3_1
844 ; IS__CGSCC____-SAME: (i1 [[C:%.*]]) #[[ATTR0]] {
845 ; IS__CGSCC____-NEXT: [[PTR:%.*]] = alloca i32, align 4
846 ; IS__CGSCC____-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
848 ; IS__CGSCC____-NEXT: call void @arg_nonnull_12(i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[PTR]], i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[PTR]], i32* nofree noundef nonnull writeonly align 4 dereferenceable(4) [[PTR]]) #[[ATTR7:[0-9]+]]
849 ; IS__CGSCC____-NEXT: call void @arg_nonnull_12(i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[PTR]], i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[PTR]], i32* noalias nocapture nofree noundef writeonly align 536870912 null) #[[ATTR7]]
850 ; IS__CGSCC____-NEXT: unreachable
852 ; IS__CGSCC____-NEXT: unreachable
853 ; IS__CGSCC____: ret:
854 ; IS__CGSCC____-NEXT: ret void
857 br i1 %c, label %t, label %f
859 call void @arg_nonnull_12(i32* %ptr, i32* %ptr, i32* %ptr)
860 call void @arg_nonnull_12(i32* %ptr, i32* %ptr, i32* null)
861 call void @arg_nonnull_12(i32* %ptr, i32* null, i32* %ptr)
862 call void @arg_nonnull_12(i32* %ptr, i32* null, i32* null)
865 call void @arg_nonnull_12(i32* null, i32* %ptr, i32* %ptr)
866 call void @arg_nonnull_12(i32* null, i32* %ptr, i32* null)
867 call void @arg_nonnull_12(i32* null, i32* null, i32* %ptr)
868 call void @arg_nonnull_12(i32* null, i32* null, i32* null)
874 define void @arg_nonnull_violation3_2(i1 %c) {
875 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
876 ; IS__TUNIT____-LABEL: define {{[^@]+}}@arg_nonnull_violation3_2
877 ; IS__TUNIT____-SAME: (i1 [[C:%.*]]) #[[ATTR0]] {
878 ; IS__TUNIT____-NEXT: [[PTR:%.*]] = alloca i32, align 4
879 ; IS__TUNIT____-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
881 ; IS__TUNIT____-NEXT: call void @arg_nonnull_12_noundef_2(i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[PTR]], i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[PTR]], i32* nofree noundef nonnull writeonly align 4 dereferenceable(4) [[PTR]]) #[[ATTR7]]
882 ; IS__TUNIT____-NEXT: call void @arg_nonnull_12_noundef_2(i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[PTR]], i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[PTR]], i32* noalias nocapture nofree noundef writeonly align 536870912 null) #[[ATTR7]]
883 ; IS__TUNIT____-NEXT: unreachable
885 ; IS__TUNIT____-NEXT: unreachable
886 ; IS__TUNIT____: ret:
887 ; IS__TUNIT____-NEXT: ret void
889 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
890 ; IS__CGSCC____-LABEL: define {{[^@]+}}@arg_nonnull_violation3_2
891 ; IS__CGSCC____-SAME: (i1 [[C:%.*]]) #[[ATTR0]] {
892 ; IS__CGSCC____-NEXT: [[PTR:%.*]] = alloca i32, align 4
893 ; IS__CGSCC____-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
895 ; IS__CGSCC____-NEXT: call void @arg_nonnull_12_noundef_2(i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[PTR]], i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[PTR]], i32* nofree noundef nonnull writeonly align 4 dereferenceable(4) [[PTR]]) #[[ATTR7]]
896 ; IS__CGSCC____-NEXT: call void @arg_nonnull_12_noundef_2(i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[PTR]], i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[PTR]], i32* noalias nocapture nofree noundef writeonly align 536870912 null) #[[ATTR7]]
897 ; IS__CGSCC____-NEXT: unreachable
899 ; IS__CGSCC____-NEXT: unreachable
900 ; IS__CGSCC____: ret:
901 ; IS__CGSCC____-NEXT: ret void
904 br i1 %c, label %t, label %f
906 call void @arg_nonnull_12_noundef_2(i32* %ptr, i32* %ptr, i32* %ptr)
907 call void @arg_nonnull_12_noundef_2(i32* %ptr, i32* %ptr, i32* null)
908 call void @arg_nonnull_12_noundef_2(i32* %ptr, i32* null, i32* %ptr)
909 call void @arg_nonnull_12_noundef_2(i32* %ptr, i32* null, i32* null)
912 call void @arg_nonnull_12_noundef_2(i32* null, i32* %ptr, i32* %ptr)
913 call void @arg_nonnull_12_noundef_2(i32* null, i32* %ptr, i32* null)
914 call void @arg_nonnull_12_noundef_2(i32* null, i32* null, i32* %ptr)
915 call void @arg_nonnull_12_noundef_2(i32* null, i32* null, i32* null)
921 ; Tests for returned position
923 define nonnull i32* @returned_nonnnull(i32 %c) {
924 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
925 ; IS__TUNIT____-LABEL: define {{[^@]+}}@returned_nonnnull
926 ; IS__TUNIT____-SAME: (i32 [[C:%.*]]) #[[ATTR0]] {
927 ; IS__TUNIT____-NEXT: switch i32 [[C]], label [[ONDEFAULT:%.*]] [
928 ; IS__TUNIT____-NEXT: i32 0, label [[ONZERO:%.*]]
929 ; IS__TUNIT____-NEXT: i32 1, label [[ONONE:%.*]]
930 ; IS__TUNIT____-NEXT: ]
931 ; IS__TUNIT____: onzero:
932 ; IS__TUNIT____-NEXT: [[PTR:%.*]] = alloca i32, align 4
933 ; IS__TUNIT____-NEXT: ret i32* [[PTR]]
934 ; IS__TUNIT____: onone:
935 ; IS__TUNIT____-NEXT: ret i32* null
936 ; IS__TUNIT____: ondefault:
937 ; IS__TUNIT____-NEXT: ret i32* undef
939 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
940 ; IS__CGSCC____-LABEL: define {{[^@]+}}@returned_nonnnull
941 ; IS__CGSCC____-SAME: (i32 [[C:%.*]]) #[[ATTR0]] {
942 ; IS__CGSCC____-NEXT: switch i32 [[C]], label [[ONDEFAULT:%.*]] [
943 ; IS__CGSCC____-NEXT: i32 0, label [[ONZERO:%.*]]
944 ; IS__CGSCC____-NEXT: i32 1, label [[ONONE:%.*]]
945 ; IS__CGSCC____-NEXT: ]
946 ; IS__CGSCC____: onzero:
947 ; IS__CGSCC____-NEXT: [[PTR:%.*]] = alloca i32, align 4
948 ; IS__CGSCC____-NEXT: ret i32* [[PTR]]
949 ; IS__CGSCC____: onone:
950 ; IS__CGSCC____-NEXT: ret i32* null
951 ; IS__CGSCC____: ondefault:
952 ; IS__CGSCC____-NEXT: ret i32* undef
954 switch i32 %c, label %ondefault [ i32 0, label %onzero
955 i32 1, label %onone ]
965 define noundef i32* @returned_noundef(i32 %c) {
966 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
967 ; IS__TUNIT____-LABEL: define {{[^@]+}}@returned_noundef
968 ; IS__TUNIT____-SAME: (i32 [[C:%.*]]) #[[ATTR0]] {
969 ; IS__TUNIT____-NEXT: switch i32 [[C]], label [[ONDEFAULT:%.*]] [
970 ; IS__TUNIT____-NEXT: i32 0, label [[ONZERO:%.*]]
971 ; IS__TUNIT____-NEXT: i32 1, label [[ONONE:%.*]]
972 ; IS__TUNIT____-NEXT: ]
973 ; IS__TUNIT____: onzero:
974 ; IS__TUNIT____-NEXT: [[PTR:%.*]] = alloca i32, align 4
975 ; IS__TUNIT____-NEXT: ret i32* [[PTR]]
976 ; IS__TUNIT____: onone:
977 ; IS__TUNIT____-NEXT: ret i32* null
978 ; IS__TUNIT____: ondefault:
979 ; IS__TUNIT____-NEXT: unreachable
981 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
982 ; IS__CGSCC____-LABEL: define {{[^@]+}}@returned_noundef
983 ; IS__CGSCC____-SAME: (i32 [[C:%.*]]) #[[ATTR0]] {
984 ; IS__CGSCC____-NEXT: switch i32 [[C]], label [[ONDEFAULT:%.*]] [
985 ; IS__CGSCC____-NEXT: i32 0, label [[ONZERO:%.*]]
986 ; IS__CGSCC____-NEXT: i32 1, label [[ONONE:%.*]]
987 ; IS__CGSCC____-NEXT: ]
988 ; IS__CGSCC____: onzero:
989 ; IS__CGSCC____-NEXT: [[PTR:%.*]] = alloca i32, align 4
990 ; IS__CGSCC____-NEXT: ret i32* [[PTR]]
991 ; IS__CGSCC____: onone:
992 ; IS__CGSCC____-NEXT: ret i32* null
993 ; IS__CGSCC____: ondefault:
994 ; IS__CGSCC____-NEXT: unreachable
996 switch i32 %c, label %ondefault [ i32 0, label %onzero
997 i32 1, label %onone ]
1007 define nonnull noundef i32* @returned_nonnnull_noundef(i32 %c) {
1008 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
1009 ; IS__TUNIT____-LABEL: define {{[^@]+}}@returned_nonnnull_noundef
1010 ; IS__TUNIT____-SAME: (i32 [[C:%.*]]) #[[ATTR0]] {
1011 ; IS__TUNIT____-NEXT: switch i32 [[C]], label [[ONDEFAULT:%.*]] [
1012 ; IS__TUNIT____-NEXT: i32 0, label [[ONZERO:%.*]]
1013 ; IS__TUNIT____-NEXT: i32 1, label [[ONONE:%.*]]
1014 ; IS__TUNIT____-NEXT: ]
1015 ; IS__TUNIT____: onzero:
1016 ; IS__TUNIT____-NEXT: [[PTR:%.*]] = alloca i32, align 4
1017 ; IS__TUNIT____-NEXT: ret i32* [[PTR]]
1018 ; IS__TUNIT____: onone:
1019 ; IS__TUNIT____-NEXT: unreachable
1020 ; IS__TUNIT____: ondefault:
1021 ; IS__TUNIT____-NEXT: unreachable
1023 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1024 ; IS__CGSCC____-LABEL: define {{[^@]+}}@returned_nonnnull_noundef
1025 ; IS__CGSCC____-SAME: (i32 [[C:%.*]]) #[[ATTR0]] {
1026 ; IS__CGSCC____-NEXT: switch i32 [[C]], label [[ONDEFAULT:%.*]] [
1027 ; IS__CGSCC____-NEXT: i32 0, label [[ONZERO:%.*]]
1028 ; IS__CGSCC____-NEXT: i32 1, label [[ONONE:%.*]]
1029 ; IS__CGSCC____-NEXT: ]
1030 ; IS__CGSCC____: onzero:
1031 ; IS__CGSCC____-NEXT: [[PTR:%.*]] = alloca i32, align 4
1032 ; IS__CGSCC____-NEXT: ret i32* [[PTR]]
1033 ; IS__CGSCC____: onone:
1034 ; IS__CGSCC____-NEXT: unreachable
1035 ; IS__CGSCC____: ondefault:
1036 ; IS__CGSCC____-NEXT: unreachable
1038 switch i32 %c, label %ondefault [ i32 0, label %onzero
1039 i32 1, label %onone ]
1049 define noundef i32 @returned_nonnnull_noundef_int() {
1050 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
1051 ; IS__TUNIT____-LABEL: define {{[^@]+}}@returned_nonnnull_noundef_int
1052 ; IS__TUNIT____-SAME: () #[[ATTR0]] {
1053 ; IS__TUNIT____-NEXT: ret i32 0
1055 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1056 ; IS__CGSCC____-LABEL: define {{[^@]+}}@returned_nonnnull_noundef_int
1057 ; IS__CGSCC____-SAME: () #[[ATTR0]] {
1058 ; IS__CGSCC____-NEXT: ret i32 0
1063 declare void @callee_int_arg(i32)
1065 define void @callsite_noundef_1() {
1066 ; CHECK-LABEL: define {{[^@]+}}@callsite_noundef_1() {
1067 ; CHECK-NEXT: call void @callee_int_arg(i32 noundef 0)
1068 ; CHECK-NEXT: ret void
1070 call void @callee_int_arg(i32 noundef 0)
1074 declare void @callee_ptr_arg(i32*)
1076 define void @callsite_noundef_2() {
1077 ; CHECK-LABEL: define {{[^@]+}}@callsite_noundef_2() {
1078 ; CHECK-NEXT: unreachable
1080 call void @callee_ptr_arg(i32* noundef undef)
1084 define i32 @argument_noundef1(i32 noundef %c) {
1085 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
1086 ; IS__TUNIT____-LABEL: define {{[^@]+}}@argument_noundef1
1087 ; IS__TUNIT____-SAME: (i32 noundef returned [[C:%.*]]) #[[ATTR0]] {
1088 ; IS__TUNIT____-NEXT: ret i32 [[C]]
1090 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1091 ; IS__CGSCC____-LABEL: define {{[^@]+}}@argument_noundef1
1092 ; IS__CGSCC____-SAME: (i32 noundef returned [[C:%.*]]) #[[ATTR0]] {
1093 ; IS__CGSCC____-NEXT: ret i32 [[C]]
1098 define i32 @violate_noundef_nonpointer() {
1099 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
1100 ; IS__TUNIT____-LABEL: define {{[^@]+}}@violate_noundef_nonpointer
1101 ; IS__TUNIT____-SAME: () #[[ATTR0]] {
1102 ; IS__TUNIT____-NEXT: ret i32 undef
1104 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1105 ; IS__CGSCC____-LABEL: define {{[^@]+}}@violate_noundef_nonpointer
1106 ; IS__CGSCC____-SAME: () #[[ATTR0]] {
1107 ; IS__CGSCC____-NEXT: ret i32 undef
1109 %ret = call i32 @argument_noundef1(i32 undef)
1113 define i32* @argument_noundef2(i32* noundef %c) {
1114 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
1115 ; IS__TUNIT____-LABEL: define {{[^@]+}}@argument_noundef2
1116 ; IS__TUNIT____-SAME: (i32* nofree noundef readnone returned "no-capture-maybe-returned" [[C:%.*]]) #[[ATTR0]] {
1117 ; IS__TUNIT____-NEXT: ret i32* [[C]]
1119 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1120 ; IS__CGSCC____-LABEL: define {{[^@]+}}@argument_noundef2
1121 ; IS__CGSCC____-SAME: (i32* nofree noundef readnone returned "no-capture-maybe-returned" [[C:%.*]]) #[[ATTR0]] {
1122 ; IS__CGSCC____-NEXT: ret i32* [[C]]
1127 define i32* @violate_noundef_pointer() {
1128 ; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
1129 ; IS__TUNIT____-LABEL: define {{[^@]+}}@violate_noundef_pointer
1130 ; IS__TUNIT____-SAME: () #[[ATTR0]] {
1131 ; IS__TUNIT____-NEXT: ret i32* undef
1133 ; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
1134 ; IS__CGSCC____-LABEL: define {{[^@]+}}@violate_noundef_pointer
1135 ; IS__CGSCC____-SAME: () #[[ATTR0]] {
1136 ; IS__CGSCC____-NEXT: ret i32* undef
1138 %ret = call i32* @argument_noundef2(i32* undef)
1142 ; IS__TUNIT____: attributes #[[ATTR0]] = { nofree nosync nounwind readnone willreturn }
1143 ; IS__TUNIT____: attributes #[[ATTR1]] = { nofree nosync nounwind null_pointer_is_valid readnone willreturn }
1144 ; IS__TUNIT____: attributes #[[ATTR2]] = { nofree nounwind readnone willreturn }
1145 ; IS__TUNIT____: attributes #[[ATTR3]] = { nofree nosync nounwind null_pointer_is_valid willreturn writeonly }
1146 ; IS__TUNIT____: attributes #[[ATTR4]] = { nofree nounwind null_pointer_is_valid willreturn }
1147 ; IS__TUNIT____: attributes #[[ATTR5]] = { nofree noreturn nosync nounwind readnone willreturn }
1148 ; IS__TUNIT____: attributes #[[ATTR6]] = { argmemonly nofree nosync nounwind willreturn writeonly }
1149 ; IS__TUNIT____: attributes #[[ATTR7]] = { nofree nosync nounwind willreturn writeonly }
1151 ; IS__CGSCC____: attributes #[[ATTR0]] = { nofree norecurse nosync nounwind readnone willreturn }
1152 ; IS__CGSCC____: attributes #[[ATTR1]] = { nofree norecurse nosync nounwind null_pointer_is_valid readnone willreturn }
1153 ; IS__CGSCC____: attributes #[[ATTR2]] = { nofree norecurse nounwind readnone willreturn }
1154 ; IS__CGSCC____: attributes #[[ATTR3]] = { nofree norecurse nosync nounwind null_pointer_is_valid willreturn writeonly }
1155 ; IS__CGSCC____: attributes #[[ATTR4]] = { nofree norecurse nounwind null_pointer_is_valid willreturn }
1156 ; IS__CGSCC____: attributes #[[ATTR5]] = { nofree norecurse noreturn nosync nounwind readnone willreturn }
1157 ; IS__CGSCC____: attributes #[[ATTR6]] = { argmemonly nofree norecurse nosync nounwind willreturn writeonly }
1158 ; IS__CGSCC____: attributes #[[ATTR7]] = { nounwind willreturn writeonly }