1; RUN: opt < %s -simplifycfg -S | FileCheck %s 2target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" 3 4declare i32 @__gxx_personality_v0(...) 5declare void @__cxa_call_unexpected(i8*) 6declare void @purefn() nounwind readnone 7declare i32 @read_only() nounwind readonly 8declare i32 @nounwind_fn() nounwind 9declare i32 @fn() 10 11 12; CHECK-LABEL: @f1( 13define i8* @f1() nounwind uwtable ssp { 14entry: 15; CHECK: call void @llvm.trap() 16; CHECK: unreachable 17 %call = invoke noalias i8* undef() 18 to label %invoke.cont unwind label %lpad 19 20invoke.cont: 21 ret i8* %call 22 23lpad: 24 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) 25 filter [0 x i8*] zeroinitializer 26 %1 = extractvalue { i8*, i32 } %0, 0 27 tail call void @__cxa_call_unexpected(i8* %1) noreturn nounwind 28 unreachable 29} 30 31; CHECK-LABEL: @f2( 32define i8* @f2() nounwind uwtable ssp { 33entry: 34; CHECK: call void @llvm.trap() 35; CHECK: unreachable 36 %call = invoke noalias i8* null() 37 to label %invoke.cont unwind label %lpad 38 39invoke.cont: 40 ret i8* %call 41 42lpad: 43 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) 44 filter [0 x i8*] zeroinitializer 45 %1 = extractvalue { i8*, i32 } %0, 0 46 tail call void @__cxa_call_unexpected(i8* %1) noreturn nounwind 47 unreachable 48} 49 50; CHECK-LABEL: @f3( 51define i32 @f3() nounwind uwtable ssp { 52; CHECK-NEXT: entry 53entry: 54; CHECK-NEXT: ret i32 3 55 %call = invoke i32 @read_only() 56 to label %invoke.cont unwind label %lpad 57 58invoke.cont: 59 ret i32 3 60 61lpad: 62 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) 63 filter [0 x i8*] zeroinitializer 64 %1 = extractvalue { i8*, i32 } %0, 0 65 tail call void @__cxa_call_unexpected(i8* %1) noreturn nounwind 66 unreachable 67} 68 69; CHECK-LABEL: @f4( 70define i32 @f4() nounwind uwtable ssp { 71; CHECK-NEXT: entry 72entry: 73; CHECK-NEXT: call i32 @read_only() 74 %call = invoke i32 @read_only() 75 to label %invoke.cont unwind label %lpad 76 77invoke.cont: 78; CHECK-NEXT: ret i32 %call 79 ret i32 %call 80 81lpad: 82 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) 83 filter [0 x i8*] zeroinitializer 84 %1 = extractvalue { i8*, i32 } %0, 0 85 tail call void @__cxa_call_unexpected(i8* %1) noreturn nounwind 86 unreachable 87} 88 89; CHECK-LABEL: @f5( 90define i32 @f5(i1 %cond, i8* %a, i8* %b) { 91entry: 92 br i1 %cond, label %x, label %y 93 94x: 95; CHECK: invoke i32 @fn() 96 %call = invoke i32 @fn() 97 to label %cont unwind label %lpad 98 99y: 100; CHECK: call i32 @nounwind_fn() 101 %call2 = invoke i32 @nounwind_fn() 102 to label %cont unwind label %lpad 103 104cont: 105; CHECK: phi i32 106; CHECK: ret i32 %phi 107 %phi = phi i32 [%call, %x], [%call2, %y] 108 ret i32 %phi 109 110lpad: 111; CHECK-NOT: phi 112 %phi2 = phi i8* [%a, %x], [%b, %y] 113 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) 114 filter [0 x i8*] zeroinitializer 115; CHECK: __cxa_call_unexpected(i8* %a) 116 tail call void @__cxa_call_unexpected(i8* %phi2) noreturn nounwind 117 unreachable 118} 119 120; CHECK-LABEL: @f6( 121define void @f6() { 122entry: 123 invoke void @purefn() 124 to label %invoke.cont1 unwind label %lpad 125 126invoke.cont1: 127 %foo = invoke i32 @fn() 128 to label %invoke.cont2 unwind label %lpad 129 130invoke.cont2: 131 ret void 132 133lpad: 134; CHECK-NOT: phi 135 %tmp = phi i8* [ null, %invoke.cont1 ], [ null, %entry ] 136 landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) 137 cleanup 138 ret void 139} 140