1 ; RUN: opt < %s -instcombine -S | FileCheck %s 2 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" 3 target triple = "x86_64-pc-windows-msvc18.0.0" 4 5 declare i32 @__CxxFrameHandler3(...) 6 7 define void @test1() personality i32 (...)* @__CxxFrameHandler3 { 8 bb: 9 unreachable 10 11 unreachable: 12 %cl = cleanuppad within none [] 13 cleanupret from %cl unwind to caller 14 } 15 16 ; CHECK-LABEL: define void @test1( 17 ; CHECK: unreachable: 18 ; CHECK: %cl = cleanuppad within none [] 19 ; CHECK: cleanupret from %cl unwind to caller 20 21 define void @test2(i8 %A, i8 %B) personality i32 (...)* @__CxxFrameHandler3 { 22 bb: 23 %X = zext i8 %A to i32 24 invoke void @g(i32 0) 25 to label %cont 26 unwind label %catch 27 28 cont: 29 %Y = zext i8 %B to i32 30 invoke void @g(i32 0) 31 to label %unreachable 32 unwind label %catch 33 34 catch: 35 %phi = phi i32 [ %X, %bb ], [ %Y, %cont ] 36 %cs = catchswitch within none [label %doit] unwind to caller 37 38 doit: 39 %cl = catchpad within %cs [] 40 call void @g(i32 %phi) 41 unreachable 42 43 unreachable: 44 unreachable 45 } 46 47 ; CHECK-LABEL: define void @test2( 48 ; CHECK: %X = zext i8 %A to i32 49 ; CHECK: %Y = zext i8 %B to i32 50 ; CHECK: %phi = phi i32 [ %X, %bb ], [ %Y, %cont ] 51 52 define void @test3(i8 %A, i8 %B) personality i32 (...)* @__CxxFrameHandler3 { 53 bb: 54 %X = zext i8 %A to i32 55 invoke void @g(i32 0) 56 to label %cont 57 unwind label %catch 58 59 cont: 60 %Y = zext i8 %B to i32 61 invoke void @g(i32 0) 62 to label %cont2 63 unwind label %catch 64 65 cont2: 66 invoke void @g(i32 0) 67 to label %unreachable 68 unwind label %catch 69 70 catch: 71 %phi = phi i32 [ %X, %bb ], [ %Y, %cont ], [ %Y, %cont2 ] 72 %cs = catchswitch within none [label %doit] unwind to caller 73 74 doit: 75 %cl = catchpad within %cs [] 76 call void @g(i32 %phi) 77 unreachable 78 79 unreachable: 80 unreachable 81 } 82 83 ; CHECK-LABEL: define void @test3( 84 ; CHECK: %X = zext i8 %A to i32 85 ; CHECK: %Y = zext i8 %B to i32 86 ; CHECK: %phi = phi i32 [ %X, %bb ], [ %Y, %cont ], [ %Y, %cont2 ] 87 88 declare void @foo() 89 declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) 90 91 define void @test4(i8 addrspace(1)* %obj) gc "statepoint-example" { 92 bb: 93 unreachable 94 95 unreachable: 96 call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @foo, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0) 97 ret void 98 } 99 100 ; CHECK-LABEL: define void @test4( 101 ; CHECK: unreachable: 102 ; CHECK: call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @foo, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0) 103 ; CHECK: ret void 104 105 106 declare void @g(i32) 107