brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.5 KiB · 73917a6 Raw
130 lines · plain
1; Test the invoke reduction standalone, dead blocks are not removed2; 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.03; RUN: FileCheck --check-prefixes=CHECK,RESULT,RESULT-SINGLE %s < %t.04 5; Test the full reduction pipeline, which cleans up unreachable blocks6; 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.17; RUN: FileCheck --check-prefixes=CHECK,RESULT,RESULT-FULL %s < %t.18 9 10define i32 @maybe_throwing_callee(i32 %arg) {11  call void @thrown()12  ret i32 %arg13}14 15declare void @did_not_throw(i32)16 17declare void @thrown()18 19; CHECK-LABEL: define void @invoke_keep_landingpad_block(i32 %arg) personality ptr @__gxx_personality_v0 {20; INTERESTING: i32 @maybe_throwing_callee(21 22; RESULT-SINGLE: %i0 = call i32 @maybe_throwing_callee(i32 %arg), !some.metadata !023; RESULT-SINGLE-NEXT: br label %bb324 25; RESULT-FULL: %i0 = call i32 @maybe_throwing_callee()26; RESULT-FULL-NEXT: br label %bb427 28 29; RESULT-SINGLE: bb1:  ; No predecessors!30; RESULT-SINGLE-NEXT: %landing = landingpad { ptr, i32 }31; RESULT-SINGLE-NEXT: catch ptr null32; RESULT-SINGLE-NEXT: call void @thrown()33define void @invoke_keep_landingpad_block(i32 %arg) personality ptr @__gxx_personality_v0 {34bb:35  %i0 = invoke i32 @maybe_throwing_callee(i32 %arg)36          to label %bb3 unwind label %bb1, !some.metadata !037 38bb1:                                              ; preds = %bb39  %landing = landingpad { ptr, i32 }40          catch ptr null41  ; INTERESTING: call void @thrown()42  call void @thrown()43  br label %bb444 45bb3:                                              ; preds = %bb46  call void @did_not_throw(i32 %i0)47  br label %bb448 49bb4:                                              ; preds = %bb3, %bb150  ret void51}52 53; CHECK-LABEL: define void @invoke_drop_landingpad_block(i32 %arg) personality ptr @__gxx_personality_v0 {54; INTERESTING: i32 @maybe_throwing_callee(55 56; RESULT-SINGLE: %i0 = call i32 @maybe_throwing_callee(i32 %arg), !some.metadata !057; RESULT-SINGLE-NEXT: br label %bb358 59; RESULT-SINGLE: bb1:  ; No predecessors!60; RESULT-SINGLE-NEXT: %landing = landingpad { ptr, i32 }61 62; RESULT-SINGLE: bb3:63; RESULT-SINGLE-NEXT: call void @did_not_throw(i32 %i0)64 65; RESULT-FULL: %i0 = call i32 @maybe_throwing_callee()66; RESULT-FULL-NEXT: call void @did_not_throw()67; RESULT-FULL-NEXT: ret void68define void @invoke_drop_landingpad_block(i32 %arg) personality ptr @__gxx_personality_v0 {69bb:70  %i0 = invoke i32 @maybe_throwing_callee(i32 %arg)71          to label %bb3 unwind label %bb1, !some.metadata !072 73bb1:                                              ; preds = %bb74  %landing = landingpad { ptr, i32 }75          catch ptr null76  call void @thrown()77  br label %bb478 79bb3:                                              ; preds = %bb80  ; INTERESTING: call void @did_not_throw(81  call void @did_not_throw(i32 %i0)82  br label %bb483 84bb4:                                              ; preds = %bb3, %bb185  ret void86}87 88declare i32 @another_maybe_throwing_callee(i32 %arg)89 90; Test the same landing pad block is used by multiple invokes91; CHECK-LABEL: define i32 @multi_invoke_caller(i32 %arg) personality ptr @__gxx_personality_v0 {92define i32 @multi_invoke_caller(i32 %arg) personality ptr @__gxx_personality_v0 {93bb:94  %i0 = invoke i32 @maybe_throwing_callee(i32 %arg)95          to label %bb3 unwind label %bb1, !some.metadata !096 97; RESULT: bb1:                                              ; preds = %bb498; RESULT-NEXT: %landing = landingpad { ptr, i32 }99; RESULT-NEXT:   catch ptr null100bb1:                                              ; preds = %bb101  %landing = landingpad { ptr, i32 }102          catch ptr null103  ; INTERESTING: call void @thrown()104  call void @thrown()105  br label %bb4106 107bb3:                                              ; preds = %bb108  call void @did_not_throw(i32 %i0)109  br label %bb4110 111bb4:                                              ; preds = %bb3, %bb1112  ; INTERESTING: invoke i32 @another_maybe_throwing_callee(113 114  ; RESULT-SINGLE:   %i1 = invoke i32 @another_maybe_throwing_callee(i32 %arg)115  ; RESULT-SINGLE-NEXT: to label %bb5 unwind label %bb1, !some.metadata !1116 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 !1121 122bb5:123  ret i32 %i1124}125 126declare i32 @__gxx_personality_v0(...)127 128!0 = !{!"arst"}129!1 = !{!"arstarst"}130