1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes='dse' -S %s | FileCheck %s
4 target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
6 ; Test case from PR50220.
7 define i32 @other_value_escapes_before_call() {
8 ; CHECK-LABEL: @other_value_escapes_before_call(
10 ; CHECK-NEXT: [[V1:%.*]] = alloca i32, align 4
11 ; CHECK-NEXT: [[V2:%.*]] = alloca i32, align 4
12 ; CHECK-NEXT: store i32 0, ptr [[V1]], align 4
13 ; CHECK-NEXT: call void @escape(ptr nonnull [[V1]])
14 ; CHECK-NEXT: [[CALL:%.*]] = call i32 @getval()
15 ; CHECK-NEXT: store i32 [[CALL]], ptr [[V2]], align 4
16 ; CHECK-NEXT: call void @escape(ptr nonnull [[V2]])
17 ; CHECK-NEXT: [[LOAD_V2:%.*]] = load i32, ptr [[V2]], align 4
18 ; CHECK-NEXT: [[LOAD_V1:%.*]] = load i32, ptr [[V1]], align 4
19 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[LOAD_V2]], [[LOAD_V1]]
20 ; CHECK-NEXT: ret i32 [[ADD]]
23 %v1 = alloca i32, align 4
24 %v2 = alloca i32, align 4
25 store i32 0, ptr %v1, align 4
26 call void @escape(ptr nonnull %v1)
27 store i32 55555, ptr %v2, align 4
28 %call = call i32 @getval()
29 store i32 %call, ptr %v2, align 4
30 call void @escape(ptr nonnull %v2)
31 %load.v2 = load i32, ptr %v2, align 4
32 %load.v1 = load i32, ptr %v1, align 4
33 %add = add nsw i32 %load.v2, %load.v1
37 declare void @escape(ptr)
41 declare void @escape_and_clobber(ptr)
42 declare void @escape_writeonly(ptr) writeonly
43 declare void @clobber()
45 define i32 @test_not_captured_before_call_same_bb() {
46 ; CHECK-LABEL: @test_not_captured_before_call_same_bb(
47 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
48 ; CHECK-NEXT: [[R:%.*]] = call i32 @getval()
49 ; CHECK-NEXT: store i32 99, ptr [[A]], align 4
50 ; CHECK-NEXT: call void @escape_and_clobber(ptr [[A]])
51 ; CHECK-NEXT: ret i32 [[R]]
53 %a = alloca i32, align 4
55 %r = call i32 @getval()
56 store i32 99, ptr %a, align 4
57 call void @escape_and_clobber(ptr %a)
61 define i32 @test_not_captured_before_call_same_bb_escape_unreachable_block() {
62 ; CHECK-LABEL: @test_not_captured_before_call_same_bb_escape_unreachable_block(
63 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
64 ; CHECK-NEXT: [[R:%.*]] = call i32 @getval()
65 ; CHECK-NEXT: store i32 99, ptr [[A]], align 4
66 ; CHECK-NEXT: call void @escape_and_clobber(ptr [[A]])
67 ; CHECK-NEXT: ret i32 [[R]]
69 ; CHECK-NEXT: call void @escape_and_clobber(ptr [[A]])
70 ; CHECK-NEXT: ret i32 0
72 %a = alloca i32, align 4
74 %r = call i32 @getval()
75 store i32 99, ptr %a, align 4
76 call void @escape_and_clobber(ptr %a)
80 call void @escape_and_clobber(ptr %a)
84 define i32 @test_captured_and_clobbered_after_load_same_bb_2() {
85 ; CHECK-LABEL: @test_captured_and_clobbered_after_load_same_bb_2(
86 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
87 ; CHECK-NEXT: store i32 55, ptr [[A]], align 4
88 ; CHECK-NEXT: [[R:%.*]] = call i32 @getval()
89 ; CHECK-NEXT: call void @escape_and_clobber(ptr [[A]])
90 ; CHECK-NEXT: store i32 99, ptr [[A]], align 4
91 ; CHECK-NEXT: call void @clobber()
92 ; CHECK-NEXT: ret i32 [[R]]
94 %a = alloca i32, align 4
96 %r = call i32 @getval()
97 call void @escape_and_clobber(ptr %a)
98 store i32 99, ptr %a, align 4
103 define i32 @test_captured_after_call_same_bb_2_clobbered_later() {
104 ; CHECK-LABEL: @test_captured_after_call_same_bb_2_clobbered_later(
105 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
106 ; CHECK-NEXT: [[R:%.*]] = call i32 @getval()
107 ; CHECK-NEXT: call void @escape_writeonly(ptr [[A]])
108 ; CHECK-NEXT: store i32 99, ptr [[A]], align 4
109 ; CHECK-NEXT: call void @clobber()
110 ; CHECK-NEXT: ret i32 [[R]]
112 %a = alloca i32, align 4
114 %r = call i32 @getval()
115 call void @escape_writeonly(ptr %a)
116 store i32 99, ptr %a, align 4
121 define i32 @test_captured_sibling_path_to_call_other_blocks_1(i1 %c.1) {
122 ; CHECK-LABEL: @test_captured_sibling_path_to_call_other_blocks_1(
123 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
124 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
126 ; CHECK-NEXT: call void @escape_writeonly(ptr [[A]])
127 ; CHECK-NEXT: br label [[EXIT:%.*]]
129 ; CHECK-NEXT: [[R:%.*]] = call i32 @getval()
130 ; CHECK-NEXT: br label [[EXIT]]
132 ; CHECK-NEXT: [[P:%.*]] = phi i32 [ 0, [[THEN]] ], [ [[R]], [[ELSE]] ]
133 ; CHECK-NEXT: store i32 99, ptr [[A]], align 4
134 ; CHECK-NEXT: call void @clobber()
135 ; CHECK-NEXT: ret i32 [[P]]
137 %a = alloca i32, align 4
139 br i1 %c.1, label %then, label %else
142 call void @escape_writeonly(ptr %a)
146 %r = call i32 @getval()
150 %p = phi i32 [ 0, %then ], [ %r, %else ]
151 store i32 99, ptr %a, align 4
156 define i32 @test_captured_before_call_other_blocks_2(i1 %c.1) {
157 ; CHECK-LABEL: @test_captured_before_call_other_blocks_2(
158 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
159 ; CHECK-NEXT: store i32 55, ptr [[A]], align 4
160 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
162 ; CHECK-NEXT: br label [[EXIT:%.*]]
164 ; CHECK-NEXT: call void @escape_and_clobber(ptr [[A]])
165 ; CHECK-NEXT: [[R:%.*]] = call i32 @getval()
166 ; CHECK-NEXT: br label [[EXIT]]
168 ; CHECK-NEXT: [[P:%.*]] = phi i32 [ 0, [[THEN]] ], [ [[R]], [[ELSE]] ]
169 ; CHECK-NEXT: store i32 99, ptr [[A]], align 4
170 ; CHECK-NEXT: call void @clobber()
171 ; CHECK-NEXT: ret i32 [[P]]
173 %a = alloca i32, align 4
175 br i1 %c.1, label %then, label %else
181 call void @escape_and_clobber(ptr %a)
182 %r = call i32 @getval()
186 %p = phi i32 [ 0, %then ], [ %r, %else ]
187 store i32 99, ptr %a, align 4
192 define i32 @test_captured_before_call_other_blocks_4(i1 %c.1) {
193 ; CHECK-LABEL: @test_captured_before_call_other_blocks_4(
195 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
196 ; CHECK-NEXT: store i32 55, ptr [[A]], align 4
197 ; CHECK-NEXT: call void @escape_writeonly(ptr [[A]])
198 ; CHECK-NEXT: [[R:%.*]] = call i32 @getval()
199 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[THEN:%.*]], label [[EXIT:%.*]]
201 ; CHECK-NEXT: call void @escape_writeonly(ptr [[A]])
202 ; CHECK-NEXT: br label [[EXIT]]
204 ; CHECK-NEXT: [[P:%.*]] = phi i32 [ 0, [[THEN]] ], [ [[R]], [[ENTRY:%.*]] ]
205 ; CHECK-NEXT: store i32 99, ptr [[A]], align 4
206 ; CHECK-NEXT: call void @clobber()
207 ; CHECK-NEXT: ret i32 [[P]]
210 %a = alloca i32, align 4
212 call void @escape_writeonly(ptr %a)
213 %r = call i32 @getval()
214 br i1 %c.1, label %then, label %exit
217 call void @escape_writeonly(ptr %a)
221 %p = phi i32 [ 0, %then ], [ %r, %entry ]
222 store i32 99, ptr %a, align 4
227 define i32 @test_captured_before_call_other_blocks_5(i1 %c.1) {
228 ; CHECK-LABEL: @test_captured_before_call_other_blocks_5(
230 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
231 ; CHECK-NEXT: store i32 55, ptr [[A]], align 4
232 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[THEN:%.*]], label [[EXIT:%.*]]
234 ; CHECK-NEXT: call void @escape_writeonly(ptr [[A]])
235 ; CHECK-NEXT: br label [[EXIT]]
237 ; CHECK-NEXT: [[R:%.*]] = call i32 @getval()
238 ; CHECK-NEXT: store i32 99, ptr [[A]], align 4
239 ; CHECK-NEXT: call void @clobber()
240 ; CHECK-NEXT: ret i32 [[R]]
243 %a = alloca i32, align 4
245 br i1 %c.1, label %then, label %exit
248 call void @escape_writeonly(ptr %a)
252 %r = call i32 @getval()
253 store i32 99, ptr %a, align 4
258 define i32 @test_captured_before_call_other_blocks_6(i1 %c.1) {
259 ; CHECK-LABEL: @test_captured_before_call_other_blocks_6(
261 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
262 ; CHECK-NEXT: store i32 55, ptr [[A]], align 4
263 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[THEN:%.*]], label [[EXIT:%.*]]
265 ; CHECK-NEXT: call void @escape_writeonly(ptr [[A]])
266 ; CHECK-NEXT: br label [[EXIT]]
268 ; CHECK-NEXT: [[R:%.*]] = call i32 @getval()
269 ; CHECK-NEXT: store i32 99, ptr [[A]], align 4
270 ; CHECK-NEXT: call void @escape_writeonly(ptr [[A]])
271 ; CHECK-NEXT: call void @clobber()
272 ; CHECK-NEXT: ret i32 [[R]]
275 %a = alloca i32, align 4
277 br i1 %c.1, label %then, label %exit
280 call void @escape_writeonly(ptr %a)
284 %r = call i32 @getval()
285 store i32 99, ptr %a, align 4
286 call void @escape_writeonly(ptr %a)
291 define i32 @test_not_captured_before_call_other_blocks_1(i1 %c.1) {
292 ; CHECK-LABEL: @test_not_captured_before_call_other_blocks_1(
293 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
294 ; CHECK-NEXT: [[R:%.*]] = call i32 @getval()
295 ; CHECK-NEXT: store i32 99, ptr [[A]], align 4
296 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
298 ; CHECK-NEXT: br label [[EXIT:%.*]]
300 ; CHECK-NEXT: br label [[EXIT]]
302 ; CHECK-NEXT: call void @escape_and_clobber(ptr [[A]])
303 ; CHECK-NEXT: ret i32 [[R]]
305 %a = alloca i32, align 4
307 %r = call i32 @getval()
308 store i32 99, ptr %a, align 4
309 br i1 %c.1, label %then, label %else
318 call void @escape_and_clobber(ptr %a)
322 define i32 @test_not_captured_before_call_other_blocks_2(i1 %c.1) {
323 ; CHECK-LABEL: @test_not_captured_before_call_other_blocks_2(
324 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
325 ; CHECK-NEXT: [[R:%.*]] = call i32 @getval()
326 ; CHECK-NEXT: store i32 99, ptr [[A]], align 4
327 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
329 ; CHECK-NEXT: call void @escape_and_clobber(ptr [[A]])
330 ; CHECK-NEXT: br label [[EXIT:%.*]]
332 ; CHECK-NEXT: call void @escape_and_clobber(ptr [[A]])
333 ; CHECK-NEXT: br label [[EXIT]]
335 ; CHECK-NEXT: ret i32 [[R]]
337 %a = alloca i32, align 4
339 %r = call i32 @getval()
340 store i32 99, ptr %a, align 4
341 br i1 %c.1, label %then, label %else
344 call void @escape_and_clobber(ptr %a)
348 call void @escape_and_clobber(ptr %a)
355 define i32 @test_not_captured_before_call_other_blocks_3(i1 %c.1) {
356 ; CHECK-LABEL: @test_not_captured_before_call_other_blocks_3(
357 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
358 ; CHECK-NEXT: [[R:%.*]] = call i32 @getval()
359 ; CHECK-NEXT: store i32 99, ptr [[A]], align 4
360 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
362 ; CHECK-NEXT: call void @escape_and_clobber(ptr [[A]])
363 ; CHECK-NEXT: br label [[EXIT:%.*]]
365 ; CHECK-NEXT: br label [[EXIT]]
367 ; CHECK-NEXT: ret i32 [[R]]
369 %a = alloca i32, align 4
371 %r = call i32 @getval()
372 store i32 99, ptr %a, align 4
373 br i1 %c.1, label %then, label %else
376 call void @escape_and_clobber(ptr %a)
386 define i32 @test_not_captured_before_call_other_blocks_4(i1 %c.1) {
387 ; CHECK-LABEL: @test_not_captured_before_call_other_blocks_4(
388 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
389 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
391 ; CHECK-NEXT: br label [[EXIT:%.*]]
393 ; CHECK-NEXT: [[R:%.*]] = call i32 @getval()
394 ; CHECK-NEXT: call void @escape_writeonly(ptr [[A]])
395 ; CHECK-NEXT: br label [[EXIT]]
397 ; CHECK-NEXT: [[P:%.*]] = phi i32 [ 0, [[THEN]] ], [ [[R]], [[ELSE]] ]
398 ; CHECK-NEXT: store i32 99, ptr [[A]], align 4
399 ; CHECK-NEXT: call void @clobber()
400 ; CHECK-NEXT: ret i32 [[P]]
402 %a = alloca i32, align 4
404 br i1 %c.1, label %then, label %else
410 %r = call i32 @getval()
411 call void @escape_writeonly(ptr %a)
415 %p = phi i32 [ 0, %then ], [ %r, %else ]
416 store i32 99, ptr %a, align 4
421 define i32 @test_not_captured_before_call_other_blocks_5(i1 %c.1) {
422 ; CHECK-LABEL: @test_not_captured_before_call_other_blocks_5(
424 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
425 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[THEN:%.*]], label [[EXIT:%.*]]
427 ; CHECK-NEXT: [[R:%.*]] = call i32 @getval()
428 ; CHECK-NEXT: call void @escape_writeonly(ptr [[A]])
429 ; CHECK-NEXT: br label [[EXIT]]
431 ; CHECK-NEXT: [[P:%.*]] = phi i32 [ [[R]], [[THEN]] ], [ 0, [[ENTRY:%.*]] ]
432 ; CHECK-NEXT: store i32 99, ptr [[A]], align 4
433 ; CHECK-NEXT: call void @clobber()
434 ; CHECK-NEXT: ret i32 [[P]]
437 %a = alloca i32, align 4
439 br i1 %c.1, label %then, label %exit
442 %r = call i32 @getval()
443 call void @escape_writeonly(ptr %a)
447 %p = phi i32 [ %r, %then ], [ 0, %entry ]
448 store i32 99, ptr %a, align 4
453 define i32 @test_not_captured_before_call_other_blocks_6(i1 %c.1) {
454 ; CHECK-LABEL: @test_not_captured_before_call_other_blocks_6(
456 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
457 ; CHECK-NEXT: store i32 55, ptr [[A]], align 4
458 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[THEN:%.*]], label [[EXIT:%.*]]
460 ; CHECK-NEXT: [[R:%.*]] = call i32 @getval()
461 ; CHECK-NEXT: call void @escape_writeonly(ptr [[A]])
462 ; CHECK-NEXT: br label [[EXIT]]
464 ; CHECK-NEXT: [[P:%.*]] = phi i32 [ [[R]], [[THEN]] ], [ 0, [[ENTRY:%.*]] ]
465 ; CHECK-NEXT: store i32 99, ptr [[A]], align 4
466 ; CHECK-NEXT: call void @escape_writeonly(ptr [[A]])
467 ; CHECK-NEXT: call void @clobber()
468 ; CHECK-NEXT: ret i32 [[P]]
471 %a = alloca i32, align 4
473 br i1 %c.1, label %then, label %exit
476 %r = call i32 @getval()
477 call void @escape_writeonly(ptr %a)
481 %p = phi i32 [ %r, %then ], [ 0, %entry ]
482 store i32 99, ptr %a, align 4
483 call void @escape_writeonly(ptr %a)
488 define i32 @test_not_captured_before_call_other_blocks_7(i1 %c.1) {
489 ; CHECK-LABEL: @test_not_captured_before_call_other_blocks_7(
491 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
492 ; CHECK-NEXT: [[R:%.*]] = call i32 @getval()
493 ; CHECK-NEXT: call void @escape_writeonly(ptr [[A]])
494 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[THEN:%.*]], label [[EXIT:%.*]]
496 ; CHECK-NEXT: call void @escape_writeonly(ptr [[A]])
497 ; CHECK-NEXT: br label [[EXIT]]
499 ; CHECK-NEXT: [[P:%.*]] = phi i32 [ 0, [[THEN]] ], [ [[R]], [[ENTRY:%.*]] ]
500 ; CHECK-NEXT: store i32 99, ptr [[A]], align 4
501 ; CHECK-NEXT: call void @clobber()
502 ; CHECK-NEXT: ret i32 [[P]]
505 %a = alloca i32, align 4
507 %r = call i32 @getval()
508 call void @escape_writeonly(ptr %a)
509 br i1 %c.1, label %then, label %exit
512 call void @escape_writeonly(ptr %a)
516 %p = phi i32 [ 0, %then ], [ %r, %entry ]
517 store i32 99, ptr %a, align 4
522 define i32 @test_not_captured_before_call_same_bb_but_read() {
523 ; CHECK-LABEL: @test_not_captured_before_call_same_bb_but_read(
524 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
525 ; CHECK-NEXT: store i32 55, ptr [[A]], align 4
526 ; CHECK-NEXT: [[R:%.*]] = call i32 @getval()
527 ; CHECK-NEXT: [[LV:%.*]] = load i32, ptr [[A]], align 4
528 ; CHECK-NEXT: store i32 99, ptr [[A]], align 4
529 ; CHECK-NEXT: call void @escape_and_clobber(ptr [[A]])
530 ; CHECK-NEXT: [[RES:%.*]] = add i32 [[R]], [[LV]]
531 ; CHECK-NEXT: ret i32 [[RES]]
533 %a = alloca i32, align 4
535 %r = call i32 @getval()
536 %lv = load i32, ptr %a
537 store i32 99, ptr %a, align 4
538 call void @escape_and_clobber(ptr %a)
539 %res = add i32 %r, %lv
543 define i32 @test_captured_after_loop(i1 %c.1) {
544 ; CHECK-LABEL: @test_captured_after_loop(
545 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
546 ; CHECK-NEXT: br label [[LOOP:%.*]]
548 ; CHECK-NEXT: [[R:%.*]] = call i32 @getval()
549 ; CHECK-NEXT: store i32 99, ptr [[A]], align 4
550 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[LOOP]], label [[EXIT:%.*]]
552 ; CHECK-NEXT: call void @escape_and_clobber(ptr [[A]])
553 ; CHECK-NEXT: ret i32 [[R]]
555 %a = alloca i32, align 4
560 %r = call i32 @getval()
561 store i32 99, ptr %a, align 4
562 br i1 %c.1, label %loop, label %exit
565 call void @escape_and_clobber(ptr %a)
569 define i32 @test_captured_in_loop(i1 %c.1) {
570 ; CHECK-LABEL: @test_captured_in_loop(
571 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
572 ; CHECK-NEXT: store i32 55, ptr [[A]], align 4
573 ; CHECK-NEXT: br label [[LOOP:%.*]]
575 ; CHECK-NEXT: [[R:%.*]] = call i32 @getval()
576 ; CHECK-NEXT: call void @escape_writeonly(ptr [[A]])
577 ; CHECK-NEXT: store i32 99, ptr [[A]], align 4
578 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[LOOP]], label [[EXIT:%.*]]
580 ; CHECK-NEXT: call void @escape_and_clobber(ptr [[A]])
581 ; CHECK-NEXT: ret i32 [[R]]
583 %a = alloca i32, align 4
588 %r = call i32 @getval()
589 call void @escape_writeonly(ptr %a)
590 store i32 99, ptr %a, align 4
591 br i1 %c.1, label %loop, label %exit
594 call void @escape_and_clobber(ptr %a)
598 declare void @llvm.memcpy.p0.p0.i64(ptr, ptr, i64, i1)
599 define void @test_escaping_store_removed(ptr %src, ptr %escape) {
600 ; CHECK-LABEL: @test_escaping_store_removed(
602 ; CHECK-NEXT: [[A:%.*]] = alloca i64, align 8
603 ; CHECK-NEXT: call void @clobber()
604 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr [[A]], ptr [[SRC:%.*]], i64 8, i1 false)
605 ; CHECK-NEXT: store ptr [[A]], ptr [[ESCAPE:%.*]], align 8
606 ; CHECK-NEXT: call void @clobber()
607 ; CHECK-NEXT: store i64 99, ptr [[A]], align 8
608 ; CHECK-NEXT: call void @clobber()
609 ; CHECK-NEXT: ret void
612 %a = alloca i64, align 8
615 call void @llvm.memcpy.p0.p0.i64(ptr %a, ptr %src, i64 8, i1 false)
616 store ptr %a, ptr %escape, align 8
617 store ptr %a, ptr %escape, align 8
625 define void @test_invoke_captures() personality ptr undef {
626 ; CHECK-LABEL: @test_invoke_captures(
628 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
629 ; CHECK-NEXT: invoke void @clobber()
630 ; CHECK-NEXT: to label [[BB2:%.*]] unwind label [[BB5:%.*]]
632 ; CHECK-NEXT: store i32 0, ptr [[A]], align 8
633 ; CHECK-NEXT: invoke void @escape(ptr [[A]])
634 ; CHECK-NEXT: to label [[BB9:%.*]] unwind label [[BB10:%.*]]
636 ; CHECK-NEXT: ret void
638 ; CHECK-NEXT: [[LP_1:%.*]] = landingpad { ptr, i32 }
639 ; CHECK-NEXT: cleanup
640 ; CHECK-NEXT: ret void
642 ; CHECK-NEXT: ret void
644 ; CHECK-NEXT: [[LP_2:%.*]] = landingpad { ptr, i32 }
645 ; CHECK-NEXT: cleanup
646 ; CHECK-NEXT: unreachable
651 invoke void @clobber()
652 to label %bb2 unwind label %bb5
655 store i32 0, ptr %a, align 8
656 invoke void @escape(ptr %a)
657 to label %bb9 unwind label %bb10
663 %lp.1 = landingpad { ptr, i32 }
671 %lp.2 = landingpad { ptr, i32 }
676 declare noalias ptr @alloc() nounwind
677 declare i32 @getval_nounwind() nounwind
679 define i32 @test_not_captured_before_load_same_bb_noalias_call() {
680 ; CHECK-LABEL: @test_not_captured_before_load_same_bb_noalias_call(
681 ; CHECK-NEXT: [[A:%.*]] = call ptr @alloc()
682 ; CHECK-NEXT: [[R:%.*]] = call i32 @getval_nounwind()
683 ; CHECK-NEXT: store i32 99, ptr [[A]], align 4
684 ; CHECK-NEXT: call void @escape_and_clobber(ptr [[A]])
685 ; CHECK-NEXT: ret i32 [[R]]
687 %a = call ptr @alloc()
689 %r = call i32 @getval_nounwind()
690 store i32 99, ptr %a, align 4
691 call void @escape_and_clobber(ptr %a)
695 define i32 @test_not_captured_before_load_same_bb_noalias_arg(ptr noalias %a) {
696 ; CHECK-LABEL: @test_not_captured_before_load_same_bb_noalias_arg(
697 ; CHECK-NEXT: [[R:%.*]] = call i32 @getval_nounwind()
698 ; CHECK-NEXT: store i32 99, ptr [[A:%.*]], align 4
699 ; CHECK-NEXT: call void @escape_and_clobber(ptr [[A]])
700 ; CHECK-NEXT: ret i32 [[R]]
703 %r = call i32 @getval_nounwind()
704 store i32 99, ptr %a, align 4
705 call void @escape_and_clobber(ptr %a)