1; RUN: opt < %s -simplifycfg -S | FileCheck %s 2 3declare void @bar() 4 5; This testcase checks to see if the simplifycfg pass is converting invoke 6; instructions to call instructions if the handler just rethrows the exception. 7define i32 @test1() personality i32 (...)* @__gxx_personality_v0 { 8; CHECK-LABEL: @test1( 9; CHECK-NEXT: call void @bar() 10; CHECK-NOT: !prof 11; CHECK-NEXT: ret i32 0 12 invoke void @bar( ) 13 to label %1 unwind label %Rethrow, !prof !0 14 ret i32 0 15Rethrow: 16 %exn = landingpad {i8*, i32} 17 catch i8* null 18 resume { i8*, i32 } %exn 19} 20 21!0 = !{!"branch_weights", i32 369, i32 0} 22 23define i32 @test2() personality i32 (...)* @__gxx_personality_v0 { 24; CHECK-LABEL: @test2( 25; CHECK-NEXT: call void @bar() [ "foo"(i32 100) ] 26; CHECK-NEXT: ret i32 0 27 invoke void @bar( ) [ "foo"(i32 100) ] 28 to label %1 unwind label %Rethrow 29 ret i32 0 30Rethrow: 31 %exn = landingpad {i8*, i32} 32 catch i8* null 33 resume { i8*, i32 } %exn 34} 35 36declare i64 @dummy1() 37declare i64 @dummy2() 38 39; This testcase checks to see if simplifycfg pass can convert two invoke 40; instructions to call instructions if they share a common trivial unwind 41; block. 42define i64 @test3(i1 %cond) personality i32 (...)* @__gxx_personality_v0 { 43entry: 44; CHECK-LABEL: @test3( 45; CHECK: %call1 = call i64 @dummy1() 46; CHECK: %call2 = call i64 @dummy2() 47; CHECK-NOT: resume { i8*, i32 } %lp 48 br i1 %cond, label %br1, label %br2 49 50br1: 51 %call1 = invoke i64 @dummy1() 52 to label %invoke.cont unwind label %lpad1 53 54br2: 55 %call2 = invoke i64 @dummy2() 56 to label %invoke.cont unwind label %lpad2 57 58invoke.cont: 59 %c = phi i64 [%call1, %br1], [%call2, %br2] 60 ret i64 %c 61 62 63lpad1: 64 %0 = landingpad { i8*, i32 } 65 cleanup 66 br label %rethrow 67 68rethrow: 69 %lp = phi { i8*, i32 } [%0, %lpad1], [%1, %lpad2] 70 resume { i8*, i32 } %lp 71 72lpad2: 73 %1 = landingpad { i8*, i32 } 74 cleanup 75 br label %rethrow 76} 77 78declare i32 @__gxx_personality_v0(...) 79