1 ; Test the invoke reduction standalone, dead blocks are not removed
2 ; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=invokes --test FileCheck --test-arg --check-prefixes=CHECK,INTERESTING --test-arg %s --test-arg --input-file %s -o %t.0
3 ; RUN: FileCheck --check-prefixes=CHECK,RESULT,RESULT-SINGLE %s < %t.0
5 ; Test the full reduction pipeline, which cleans up unreachable blocks
6 ; RUN: llvm-reduce --abort-on-invalid-reduction --test FileCheck --test-arg --check-prefixes=CHECK,INTERESTING --test-arg %s --test-arg --input-file %s -o %t.1
7 ; RUN: FileCheck --check-prefixes=CHECK,RESULT,RESULT-FULL %s < %t.1
10 define i32 @maybe_throwing_callee(i32 %arg) {
15 declare void @did_not_throw(i32)
17 declare void @thrown()
19 ; CHECK-LABEL: define void @invoke_keep_landingpad_block(i32 %arg) personality ptr @__gxx_personality_v0 {
20 ; INTERESTING: i32 @maybe_throwing_callee(
22 ; RESULT-SINGLE: %i0 = call i32 @maybe_throwing_callee(i32 %arg), !some.metadata !0
23 ; RESULT-SINGLE-NEXT: br label %bb3
25 ; RESULT-FULL: %i0 = call i32 @maybe_throwing_callee()
26 ; RESULT-FULL-NEXT: br label %bb4
29 ; RESULT-SINGLE: bb1: ; No predecessors!
30 ; RESULT-SINGLE-NEXT: %landing = landingpad { ptr, i32 }
31 ; RESULT-SINGLE-NEXT: catch ptr null
32 ; RESULT-SINGLE-NEXT: call void @thrown()
33 define void @invoke_keep_landingpad_block(i32 %arg) personality ptr @__gxx_personality_v0 {
35 %i0 = invoke i32 @maybe_throwing_callee(i32 %arg)
36 to label %bb3 unwind label %bb1, !some.metadata !0
39 %landing = landingpad { ptr, i32 }
41 ; INTERESTING: call void @thrown()
46 call void @did_not_throw(i32 %i0)
49 bb4: ; preds = %bb3, %bb1
53 ; CHECK-LABEL: define void @invoke_drop_landingpad_block(i32 %arg) personality ptr @__gxx_personality_v0 {
54 ; INTERESTING: i32 @maybe_throwing_callee(
56 ; RESULT-SINGLE: %i0 = call i32 @maybe_throwing_callee(i32 %arg), !some.metadata !0
57 ; RESULT-SINGLE-NEXT: br label %bb3
59 ; RESULT-SINGLE: bb1: ; No predecessors!
60 ; RESULT-SINGLE-NEXT: %landing = landingpad { ptr, i32 }
63 ; RESULT-SINGLE-NEXT: call void @did_not_throw(i32 %i0)
65 ; RESULT-FULL: %i0 = call i32 @maybe_throwing_callee()
66 ; RESULT-FULL-NEXT: call void @did_not_throw()
67 ; RESULT-FULL-NEXT: ret void
68 define void @invoke_drop_landingpad_block(i32 %arg) personality ptr @__gxx_personality_v0 {
70 %i0 = invoke i32 @maybe_throwing_callee(i32 %arg)
71 to label %bb3 unwind label %bb1, !some.metadata !0
74 %landing = landingpad { ptr, i32 }
80 ; INTERESTING: call void @did_not_throw(
81 call void @did_not_throw(i32 %i0)
84 bb4: ; preds = %bb3, %bb1
88 declare i32 @another_maybe_throwing_callee(i32 %arg)
90 ; Test the same landing pad block is used by multiple invokes
91 ; CHECK-LABEL: define i32 @multi_invoke_caller(i32 %arg) personality ptr @__gxx_personality_v0 {
92 define i32 @multi_invoke_caller(i32 %arg) personality ptr @__gxx_personality_v0 {
94 %i0 = invoke i32 @maybe_throwing_callee(i32 %arg)
95 to label %bb3 unwind label %bb1, !some.metadata !0
97 ; RESULT: bb1: ; preds = %bb4
98 ; RESULT-NEXT: %landing = landingpad { ptr, i32 }
99 ; RESULT-NEXT: catch ptr null
101 %landing = landingpad { ptr, i32 }
103 ; INTERESTING: call void @thrown()
108 call void @did_not_throw(i32 %i0)
111 bb4: ; preds = %bb3, %bb1
112 ; INTERESTING: invoke i32 @another_maybe_throwing_callee(
114 ; RESULT-SINGLE: %i1 = invoke i32 @another_maybe_throwing_callee(i32 %arg)
115 ; RESULT-SINGLE-NEXT: to label %bb5 unwind label %bb1, !some.metadata !1
117 ; RESULT-FULL: %i1 = invoke i32 @another_maybe_throwing_callee(i32 0)
118 ; RESULT-FULL-NEXT: to label %bb5 unwind label %bb1{{$}}
119 %i1 = invoke i32 @another_maybe_throwing_callee(i32 %arg)
120 to label %bb5 unwind label %bb1, !some.metadata !1
126 declare i32 @__gxx_personality_v0(...)