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