1*9880d681SAndroid Build Coastguard Worker; RUN: opt -mtriple=i686-pc-windows-msvc -S -x86-winehstate < %s | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" 4*9880d681SAndroid Build Coastguard Workertarget triple = "i686-pc-windows-msvc" 5*9880d681SAndroid Build Coastguard Worker 6*9880d681SAndroid Build Coastguard Worker%rtti.TypeDescriptor2 = type { i8**, i8*, [3 x i8] } 7*9880d681SAndroid Build Coastguard Worker%eh.CatchableType = type { i32, i8*, i32, i32, i32, i32, i8* } 8*9880d681SAndroid Build Coastguard Worker%eh.CatchableTypeArray.1 = type { i32, [1 x %eh.CatchableType*] } 9*9880d681SAndroid Build Coastguard Worker%eh.ThrowInfo = type { i32, i8*, i8*, i8* } 10*9880d681SAndroid Build Coastguard Worker 11*9880d681SAndroid Build Coastguard Worker$"\01??_R0H@8" = comdat any 12*9880d681SAndroid Build Coastguard Worker 13*9880d681SAndroid Build Coastguard Worker$"_CT??_R0H@84" = comdat any 14*9880d681SAndroid Build Coastguard Worker 15*9880d681SAndroid Build Coastguard Worker$_CTA1H = comdat any 16*9880d681SAndroid Build Coastguard Worker 17*9880d681SAndroid Build Coastguard Worker$_TI1H = comdat any 18*9880d681SAndroid Build Coastguard Worker 19*9880d681SAndroid Build Coastguard Worker@"\01??_7type_info@@6B@" = external constant i8* 20*9880d681SAndroid Build Coastguard Worker@"\01??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { i8** @"\01??_7type_info@@6B@", i8* null, [3 x i8] c".H\00" }, comdat 21*9880d681SAndroid Build Coastguard Worker@"_CT??_R0H@84" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 1, i8* bitcast (%rtti.TypeDescriptor2* @"\01??_R0H@8" to i8*), i32 0, i32 -1, i32 0, i32 4, i8* null }, section ".xdata", comdat 22*9880d681SAndroid Build Coastguard Worker@_CTA1H = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.1 { i32 1, [1 x %eh.CatchableType*] [%eh.CatchableType* @"_CT??_R0H@84"] }, section ".xdata", comdat 23*9880d681SAndroid Build Coastguard Worker@_TI1H = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 0, i8* null, i8* null, i8* bitcast (%eh.CatchableTypeArray.1* @_CTA1H to i8*) }, section ".xdata", comdat 24*9880d681SAndroid Build Coastguard Worker 25*9880d681SAndroid Build Coastguard Workerdefine i32 @main() #0 personality i32 (...)* @__CxxFrameHandler3 { 26*9880d681SAndroid Build Coastguard Workerentry: 27*9880d681SAndroid Build Coastguard Worker %tmp = alloca i32, align 4 28*9880d681SAndroid Build Coastguard Worker ; CHECK: entry: 29*9880d681SAndroid Build Coastguard Worker ; CHECK: store i32 -1 30*9880d681SAndroid Build Coastguard Worker ; CHECK: call void @g(i32 3) 31*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: call void @g(i32 4) 32*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: call void @g(i32 5) 33*9880d681SAndroid Build Coastguard Worker call void @g(i32 3) 34*9880d681SAndroid Build Coastguard Worker call void @g(i32 4) 35*9880d681SAndroid Build Coastguard Worker call void @g(i32 5) 36*9880d681SAndroid Build Coastguard Worker store i32 0, i32* %tmp, align 4 37*9880d681SAndroid Build Coastguard Worker %0 = bitcast i32* %tmp to i8* 38*9880d681SAndroid Build Coastguard Worker ; CHECK: store i32 0 39*9880d681SAndroid Build Coastguard Worker ; CHECK: invoke void @_CxxThrowException( 40*9880d681SAndroid Build Coastguard Worker invoke void @_CxxThrowException(i8* %0, %eh.ThrowInfo* nonnull @_TI1H) #1 41*9880d681SAndroid Build Coastguard Worker to label %unreachable.for.entry unwind label %catch.dispatch 42*9880d681SAndroid Build Coastguard Worker 43*9880d681SAndroid Build Coastguard Workercatch.dispatch: ; preds = %entry 44*9880d681SAndroid Build Coastguard Worker %cs1 = catchswitch within none [label %catch] unwind to caller 45*9880d681SAndroid Build Coastguard Worker 46*9880d681SAndroid Build Coastguard Workercatch: ; preds = %catch.dispatch 47*9880d681SAndroid Build Coastguard Worker %1 = catchpad within %cs1 [i8* null, i32 u0x40, i8* null] 48*9880d681SAndroid Build Coastguard Worker ; CHECK: catch: 49*9880d681SAndroid Build Coastguard Worker ; CHECK: store i32 2 50*9880d681SAndroid Build Coastguard Worker ; CHECK: invoke void @_CxxThrowException( 51*9880d681SAndroid Build Coastguard Worker invoke void @_CxxThrowException(i8* null, %eh.ThrowInfo* null) [ "funclet"(token %1) ] 52*9880d681SAndroid Build Coastguard Worker to label %unreachable unwind label %catch.dispatch.1 53*9880d681SAndroid Build Coastguard Worker 54*9880d681SAndroid Build Coastguard Workercatch.dispatch.1: ; preds = %catch 55*9880d681SAndroid Build Coastguard Worker %cs2 = catchswitch within %1 [label %catch.3] unwind to caller 56*9880d681SAndroid Build Coastguard Workercatch.3: ; preds = %catch.dispatch.1 57*9880d681SAndroid Build Coastguard Worker %2 = catchpad within %cs2 [i8* null, i32 u0x40, i8* null] 58*9880d681SAndroid Build Coastguard Worker ; CHECK: catch.3: 59*9880d681SAndroid Build Coastguard Worker ; CHECK: store i32 3 60*9880d681SAndroid Build Coastguard Worker ; CHECK: call void @g(i32 1) 61*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: call void @g(i32 2) 62*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: call void @g(i32 3) 63*9880d681SAndroid Build Coastguard Worker call void @g(i32 1) 64*9880d681SAndroid Build Coastguard Worker call void @g(i32 2) 65*9880d681SAndroid Build Coastguard Worker call void @g(i32 3) 66*9880d681SAndroid Build Coastguard Worker catchret from %2 to label %try.cont 67*9880d681SAndroid Build Coastguard Worker 68*9880d681SAndroid Build Coastguard Workertry.cont: ; preds = %catch.3 69*9880d681SAndroid Build Coastguard Worker ; CHECK: try.cont: 70*9880d681SAndroid Build Coastguard Worker ; CHECK: store i32 1 71*9880d681SAndroid Build Coastguard Worker ; CHECK: call void @g(i32 2) 72*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: call void @g(i32 3) 73*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: call void @g(i32 4) 74*9880d681SAndroid Build Coastguard Worker call void @g(i32 2) 75*9880d681SAndroid Build Coastguard Worker call void @g(i32 3) 76*9880d681SAndroid Build Coastguard Worker call void @g(i32 4) 77*9880d681SAndroid Build Coastguard Worker unreachable 78*9880d681SAndroid Build Coastguard Worker 79*9880d681SAndroid Build Coastguard Workerunreachable: ; preds = %catch 80*9880d681SAndroid Build Coastguard Worker unreachable 81*9880d681SAndroid Build Coastguard Worker 82*9880d681SAndroid Build Coastguard Workerunreachable.for.entry: ; preds = %entry 83*9880d681SAndroid Build Coastguard Worker unreachable 84*9880d681SAndroid Build Coastguard Worker} 85*9880d681SAndroid Build Coastguard Worker 86*9880d681SAndroid Build Coastguard Workerdefine i32 @nopads() #0 personality i32 (...)* @__CxxFrameHandler3 { 87*9880d681SAndroid Build Coastguard Worker ret i32 0 88*9880d681SAndroid Build Coastguard Worker} 89*9880d681SAndroid Build Coastguard Worker 90*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: define i32 @nopads() 91*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: ret i32 0 92*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: __ehhandler$nopads 93*9880d681SAndroid Build Coastguard Worker 94*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: define void @PR25926() 95*9880d681SAndroid Build Coastguard Workerdefine void @PR25926() personality i32 (...)* @__CxxFrameHandler3 { 96*9880d681SAndroid Build Coastguard Workerentry: 97*9880d681SAndroid Build Coastguard Worker ; CHECK: entry: 98*9880d681SAndroid Build Coastguard Worker ; CHECK: store i32 -1 99*9880d681SAndroid Build Coastguard Worker ; CHECK: store i32 0 100*9880d681SAndroid Build Coastguard Worker ; CHECK: invoke void @_CxxThrowException( 101*9880d681SAndroid Build Coastguard Worker invoke void @_CxxThrowException(i8* null, %eh.ThrowInfo* null) 102*9880d681SAndroid Build Coastguard Worker to label %unreachable unwind label %catch.dispatch 103*9880d681SAndroid Build Coastguard Worker 104*9880d681SAndroid Build Coastguard Workercatch.dispatch: ; preds = %entry 105*9880d681SAndroid Build Coastguard Worker %0 = catchswitch within none [label %catch] unwind to caller 106*9880d681SAndroid Build Coastguard Worker 107*9880d681SAndroid Build Coastguard Workercatch: ; preds = %catch.dispatch 108*9880d681SAndroid Build Coastguard Worker %1 = catchpad within %0 [i8* null, i32 64, i8* null] 109*9880d681SAndroid Build Coastguard Worker ; CHECK: catch: 110*9880d681SAndroid Build Coastguard Worker ; CHECK: store i32 3 111*9880d681SAndroid Build Coastguard Worker ; CHECK: invoke void @_CxxThrowException( 112*9880d681SAndroid Build Coastguard Worker invoke void @_CxxThrowException(i8* null, %eh.ThrowInfo* null) [ "funclet"(token %1) ] 113*9880d681SAndroid Build Coastguard Worker to label %unreachable1 unwind label %catch.dispatch1 114*9880d681SAndroid Build Coastguard Worker 115*9880d681SAndroid Build Coastguard Workercatch.dispatch1: ; preds = %catch 116*9880d681SAndroid Build Coastguard Worker %2 = catchswitch within %1 [label %catch2] unwind label %ehcleanup 117*9880d681SAndroid Build Coastguard Worker 118*9880d681SAndroid Build Coastguard Workercatch2: ; preds = %catch.dispatch1 119*9880d681SAndroid Build Coastguard Worker %3 = catchpad within %2 [i8* null, i32 64, i8* null] 120*9880d681SAndroid Build Coastguard Worker catchret from %3 to label %try.cont 121*9880d681SAndroid Build Coastguard Worker 122*9880d681SAndroid Build Coastguard Workertry.cont: ; preds = %catch2 123*9880d681SAndroid Build Coastguard Worker ; CHECK: try.cont: 124*9880d681SAndroid Build Coastguard Worker ; CHECK: store i32 1 125*9880d681SAndroid Build Coastguard Worker ; CHECK: call void @dtor() 126*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: call void @dtor() 127*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: call void @dtor() 128*9880d681SAndroid Build Coastguard Worker call void @dtor() #3 [ "funclet"(token %1) ] 129*9880d681SAndroid Build Coastguard Worker call void @dtor() #3 [ "funclet"(token %1) ] 130*9880d681SAndroid Build Coastguard Worker call void @dtor() #3 [ "funclet"(token %1) ] 131*9880d681SAndroid Build Coastguard Worker catchret from %1 to label %try.cont4 132*9880d681SAndroid Build Coastguard Worker 133*9880d681SAndroid Build Coastguard Workertry.cont4: ; preds = %try.cont 134*9880d681SAndroid Build Coastguard Worker ret void 135*9880d681SAndroid Build Coastguard Worker 136*9880d681SAndroid Build Coastguard Workerehcleanup: ; preds = %catch.dispatch1 137*9880d681SAndroid Build Coastguard Worker %4 = cleanuppad within %1 [] 138*9880d681SAndroid Build Coastguard Worker ; CHECK: ehcleanup: 139*9880d681SAndroid Build Coastguard Worker ; CHECK: call void @dtor() 140*9880d681SAndroid Build Coastguard Worker call void @dtor() #3 [ "funclet"(token %4) ] 141*9880d681SAndroid Build Coastguard Worker cleanupret from %4 unwind to caller 142*9880d681SAndroid Build Coastguard Worker 143*9880d681SAndroid Build Coastguard Workerunreachable: ; preds = %entry 144*9880d681SAndroid Build Coastguard Worker unreachable 145*9880d681SAndroid Build Coastguard Worker 146*9880d681SAndroid Build Coastguard Workerunreachable1: ; preds = %catch 147*9880d681SAndroid Build Coastguard Worker unreachable 148*9880d681SAndroid Build Coastguard Worker} 149*9880d681SAndroid Build Coastguard Worker 150*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: define void @required_state_store( 151*9880d681SAndroid Build Coastguard Workerdefine void @required_state_store(i1 zeroext %cond) personality i32 (...)* @_except_handler3 { 152*9880d681SAndroid Build Coastguard Workerentry: 153*9880d681SAndroid Build Coastguard Worker %__exception_code = alloca i32, align 4 154*9880d681SAndroid Build Coastguard Worker call void (...) @llvm.localescape(i32* nonnull %__exception_code) 155*9880d681SAndroid Build Coastguard Worker; CHECK: store i32 -1 156*9880d681SAndroid Build Coastguard Worker; CHECK: call void @g(i32 0) 157*9880d681SAndroid Build Coastguard Worker call void @g(i32 0) 158*9880d681SAndroid Build Coastguard Worker br i1 %cond, label %if.then, label %if.end 159*9880d681SAndroid Build Coastguard Worker 160*9880d681SAndroid Build Coastguard Workerif.then: ; preds = %entry 161*9880d681SAndroid Build Coastguard Worker; CHECK: store i32 0 162*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: invoke void @g(i32 1) 163*9880d681SAndroid Build Coastguard Worker invoke void @g(i32 1) 164*9880d681SAndroid Build Coastguard Worker to label %if.end unwind label %catch.dispatch 165*9880d681SAndroid Build Coastguard Worker 166*9880d681SAndroid Build Coastguard Workercatch.dispatch: ; preds = %if.then 167*9880d681SAndroid Build Coastguard Worker %0 = catchswitch within none [label %__except.ret] unwind to caller 168*9880d681SAndroid Build Coastguard Worker 169*9880d681SAndroid Build Coastguard Worker__except.ret: ; preds = %catch.dispatch 170*9880d681SAndroid Build Coastguard Worker %1 = catchpad within %0 [i8* bitcast (i32 ()* @"\01?filt$0@0@required_state_store@@" to i8*)] 171*9880d681SAndroid Build Coastguard Worker catchret from %1 to label %if.end 172*9880d681SAndroid Build Coastguard Worker 173*9880d681SAndroid Build Coastguard Workerif.end: ; preds = %if.then, %__except.ret, %entry 174*9880d681SAndroid Build Coastguard Worker; CHECK: store i32 -1 175*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: call void @dtor() 176*9880d681SAndroid Build Coastguard Worker call void @dtor() 177*9880d681SAndroid Build Coastguard Worker ret void 178*9880d681SAndroid Build Coastguard Worker} 179*9880d681SAndroid Build Coastguard Worker 180*9880d681SAndroid Build Coastguard Workerdefine internal i32 @"\01?filt$0@0@required_state_store@@"() { 181*9880d681SAndroid Build Coastguard Workerentry: 182*9880d681SAndroid Build Coastguard Worker %0 = tail call i8* @llvm.frameaddress(i32 1) 183*9880d681SAndroid Build Coastguard Worker %1 = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (void (i1)* @required_state_store to i8*), i8* %0) 184*9880d681SAndroid Build Coastguard Worker %2 = tail call i8* @llvm.localrecover(i8* bitcast (void (i1)* @required_state_store to i8*), i8* %1, i32 0) 185*9880d681SAndroid Build Coastguard Worker %__exception_code = bitcast i8* %2 to i32* 186*9880d681SAndroid Build Coastguard Worker %3 = getelementptr inbounds i8, i8* %0, i32 -20 187*9880d681SAndroid Build Coastguard Worker %4 = bitcast i8* %3 to { i32*, i8* }** 188*9880d681SAndroid Build Coastguard Worker %5 = load { i32*, i8* }*, { i32*, i8* }** %4, align 4 189*9880d681SAndroid Build Coastguard Worker %6 = getelementptr inbounds { i32*, i8* }, { i32*, i8* }* %5, i32 0, i32 0 190*9880d681SAndroid Build Coastguard Worker %7 = load i32*, i32** %6, align 4 191*9880d681SAndroid Build Coastguard Worker %8 = load i32, i32* %7, align 4 192*9880d681SAndroid Build Coastguard Worker store i32 %8, i32* %__exception_code, align 4 193*9880d681SAndroid Build Coastguard Worker ret i32 1 194*9880d681SAndroid Build Coastguard Worker} 195*9880d681SAndroid Build Coastguard Worker 196*9880d681SAndroid Build Coastguard Workerdeclare void @g(i32) #0 197*9880d681SAndroid Build Coastguard Worker 198*9880d681SAndroid Build Coastguard Workerdeclare void @dtor() 199*9880d681SAndroid Build Coastguard Worker 200*9880d681SAndroid Build Coastguard Workerdeclare x86_stdcallcc void @_CxxThrowException(i8*, %eh.ThrowInfo*) 201*9880d681SAndroid Build Coastguard Worker 202*9880d681SAndroid Build Coastguard Workerdeclare i32 @__CxxFrameHandler3(...) 203*9880d681SAndroid Build Coastguard Worker 204*9880d681SAndroid Build Coastguard Workerdeclare i8* @llvm.frameaddress(i32) 205*9880d681SAndroid Build Coastguard Worker 206*9880d681SAndroid Build Coastguard Workerdeclare i8* @llvm.x86.seh.recoverfp(i8*, i8*) 207*9880d681SAndroid Build Coastguard Worker 208*9880d681SAndroid Build Coastguard Workerdeclare i8* @llvm.localrecover(i8*, i8*, i32) 209*9880d681SAndroid Build Coastguard Worker 210*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.localescape(...) 211*9880d681SAndroid Build Coastguard Worker 212*9880d681SAndroid Build Coastguard Workerdeclare i32 @_except_handler3(...) 213*9880d681SAndroid Build Coastguard Worker 214*9880d681SAndroid Build Coastguard Workerattributes #0 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } 215*9880d681SAndroid Build Coastguard Workerattributes #1 = { noreturn } 216*9880d681SAndroid Build Coastguard Worker 217*9880d681SAndroid Build Coastguard Worker!llvm.ident = !{!0} 218*9880d681SAndroid Build Coastguard Worker 219*9880d681SAndroid Build Coastguard Worker!0 = !{!"clang version 3.8.0 (trunk 245153) (llvm/trunk 245238)"} 220