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