1 ; RUN: opt -S -simplifycfg < %s | FileCheck %s 2 3 declare void @Personality() 4 declare void @f() 5 6 ; CHECK-LABEL: define void @test1() 7 define void @test1() personality i8* bitcast (void ()* @Personality to i8*) { 8 entry: 9 ; CHECK: call void @f() 10 invoke void @f() 11 to label %exit unwind label %unreachable.unwind 12 exit: 13 ret void 14 unreachable.unwind: 15 cleanuppad within none [] 16 unreachable 17 } 18 19 ; CHECK-LABEL: define void @test2() 20 define void @test2() personality i8* bitcast (void ()* @Personality to i8*) { 21 entry: 22 invoke void @f() 23 to label %exit unwind label %catch.pad 24 catch.pad: 25 %cs1 = catchswitch within none [label %catch.body] unwind label %unreachable.unwind 26 ; CHECK: catch.pad: 27 ; CHECK-NEXT: catchswitch within none [label %catch.body] unwind to caller 28 catch.body: 29 ; CHECK: catch.body: 30 ; CHECK-NEXT: catchpad within %cs1 31 ; CHECK-NEXT: call void @f() 32 ; CHECK-NEXT: unreachable 33 %catch = catchpad within %cs1 [] 34 call void @f() 35 catchret from %catch to label %unreachable 36 exit: 37 ret void 38 unreachable.unwind: 39 cleanuppad within none [] 40 unreachable 41 unreachable: 42 unreachable 43 } 44 45 ; CHECK-LABEL: define void @test3() 46 define void @test3() personality i8* bitcast (void ()* @Personality to i8*) { 47 entry: 48 invoke void @f() 49 to label %exit unwind label %cleanup.pad 50 cleanup.pad: 51 ; CHECK: %cleanup = cleanuppad within none [] 52 ; CHECK-NEXT: call void @f() 53 ; CHECK-NEXT: unreachable 54 %cleanup = cleanuppad within none [] 55 invoke void @f() 56 to label %cleanup.ret unwind label %unreachable.unwind 57 cleanup.ret: 58 ; This cleanupret should be rewritten to unreachable, 59 ; and merged into the pred block. 60 cleanupret from %cleanup unwind label %unreachable.unwind 61 exit: 62 ret void 63 unreachable.unwind: 64 cleanuppad within none [] 65 unreachable 66 } 67 68 ; CHECK-LABEL: define void @test5() 69 define void @test5() personality i8* bitcast (void ()* @Personality to i8*) { 70 entry: 71 invoke void @f() 72 to label %exit unwind label %catch.pad 73 74 catch.pad: 75 %cs1 = catchswitch within none [label %catch.body] unwind to caller 76 77 catch.body: 78 %catch = catchpad within %cs1 [] 79 catchret from %catch to label %exit 80 81 exit: 82 unreachable 83 } 84