1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s
6 ; This testcase checks to see if the simplifycfg pass is converting invoke
7 ; instructions to call instructions if the handler just rethrows the exception.
8 define i32 @test1() personality i32 (...)* @__gxx_personality_v0 {
10 ; CHECK-NEXT: call void @bar(), !prof !0
11 ; CHECK-NEXT: ret i32 0
14 to label %1 unwind label %Rethrow, !prof !0
17 %exn = landingpad {i8*, i32}
19 resume { i8*, i32 } %exn
22 !0 = !{!"branch_weights", i32 369, i32 2}
24 define i32 @test2() personality i32 (...)* @__gxx_personality_v0 {
25 ; CHECK-LABEL: @test2(
26 ; CHECK-NEXT: call void @bar() [ "foo"(i32 100) ]
27 ; CHECK-NEXT: ret i32 0
29 invoke void @bar( ) [ "foo"(i32 100) ]
30 to label %1 unwind label %Rethrow
33 %exn = landingpad {i8*, i32}
35 resume { i8*, i32 } %exn
41 ; This testcase checks to see if simplifycfg pass can convert two invoke
42 ; instructions to call instructions if they share a common trivial unwind
44 define i64 @test3(i1 %cond) personality i32 (...)* @__gxx_personality_v0 {
45 ; CHECK-LABEL: @test3(
47 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[BR1:%.*]], label [[BR2:%.*]]
49 ; CHECK-NEXT: [[CALL1:%.*]] = call i64 @dummy1()
50 ; CHECK-NEXT: br label [[INVOKE_CONT:%.*]]
52 ; CHECK-NEXT: [[CALL2:%.*]] = call i64 @dummy2()
53 ; CHECK-NEXT: br label [[INVOKE_CONT]]
55 ; CHECK-NEXT: [[C:%.*]] = phi i64 [ [[CALL1]], [[BR1]] ], [ [[CALL2]], [[BR2]] ]
56 ; CHECK-NEXT: ret i64 [[C]]
59 br i1 %cond, label %br1, label %br2
62 %call1 = invoke i64 @dummy1()
63 to label %invoke.cont unwind label %lpad1
66 %call2 = invoke i64 @dummy2()
67 to label %invoke.cont unwind label %lpad2
70 %c = phi i64 [%call1, %br1], [%call2, %br2]
75 %0 = landingpad { i8*, i32 }
80 %lp = phi { i8*, i32 } [%0, %lpad1], [%1, %lpad2]
81 resume { i8*, i32 } %lp
84 %1 = landingpad { i8*, i32 }
89 declare i32 @__gxx_personality_v0(...)