1*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple=i686-pc-windows-msvc < %s | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Workerdeclare void @may_throw_or_crash() 4*9880d681SAndroid Build Coastguard Workerdeclare i32 @_except_handler3(...) 5*9880d681SAndroid Build Coastguard Workerdeclare i32 @_except_handler4(...) 6*9880d681SAndroid Build Coastguard Workerdeclare i32 @__CxxFrameHandler3(...) 7*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.eh.begincatch(i8*, i8*) 8*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.eh.endcatch() 9*9880d681SAndroid Build Coastguard Workerdeclare i32 @llvm.eh.typeid.for(i8*) 10*9880d681SAndroid Build Coastguard Worker 11*9880d681SAndroid Build Coastguard Workerdefine internal i32 @catchall_filt() { 12*9880d681SAndroid Build Coastguard Worker ret i32 1 13*9880d681SAndroid Build Coastguard Worker} 14*9880d681SAndroid Build Coastguard Worker 15*9880d681SAndroid Build Coastguard Workerdefine void @use_except_handler3() personality i32 (...)* @_except_handler3 { 16*9880d681SAndroid Build Coastguard Workerentry: 17*9880d681SAndroid Build Coastguard Worker invoke void @may_throw_or_crash() 18*9880d681SAndroid Build Coastguard Worker to label %cont unwind label %lpad 19*9880d681SAndroid Build Coastguard Workercont: 20*9880d681SAndroid Build Coastguard Worker ret void 21*9880d681SAndroid Build Coastguard Workerlpad: 22*9880d681SAndroid Build Coastguard Worker %cs = catchswitch within none [label %catch] unwind to caller 23*9880d681SAndroid Build Coastguard Workercatch: 24*9880d681SAndroid Build Coastguard Worker %p = catchpad within %cs [i8* bitcast (i32 ()* @catchall_filt to i8*)] 25*9880d681SAndroid Build Coastguard Worker catchret from %p to label %cont 26*9880d681SAndroid Build Coastguard Worker} 27*9880d681SAndroid Build Coastguard Worker 28*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: _use_except_handler3: 29*9880d681SAndroid Build Coastguard Worker; CHECK: pushl %ebp 30*9880d681SAndroid Build Coastguard Worker; CHECK: movl %esp, %ebp 31*9880d681SAndroid Build Coastguard Worker; CHECK: pushl %ebx 32*9880d681SAndroid Build Coastguard Worker; CHECK: pushl %edi 33*9880d681SAndroid Build Coastguard Worker; CHECK: pushl %esi 34*9880d681SAndroid Build Coastguard Worker; CHECK: subl ${{[0-9]+}}, %esp 35*9880d681SAndroid Build Coastguard Worker; CHECK: movl $-1, -16(%ebp) 36*9880d681SAndroid Build Coastguard Worker; CHECK: movl $L__ehtable$use_except_handler3, -20(%ebp) 37*9880d681SAndroid Build Coastguard Worker; CHECK: leal -28(%ebp), %[[node:[^ ,]*]] 38*9880d681SAndroid Build Coastguard Worker; CHECK: movl $__except_handler3, -24(%ebp) 39*9880d681SAndroid Build Coastguard Worker; CHECK: movl %fs:0, %[[next:[^ ,]*]] 40*9880d681SAndroid Build Coastguard Worker; CHECK: movl %[[next]], -28(%ebp) 41*9880d681SAndroid Build Coastguard Worker; CHECK: movl %[[node]], %fs:0 42*9880d681SAndroid Build Coastguard Worker; CHECK: calll _may_throw_or_crash 43*9880d681SAndroid Build Coastguard Worker; CHECK: movl -28(%ebp), %[[next:[^ ,]*]] 44*9880d681SAndroid Build Coastguard Worker; CHECK: movl %[[next]], %fs:0 45*9880d681SAndroid Build Coastguard Worker; CHECK: retl 46*9880d681SAndroid Build Coastguard Worker; CHECK: LBB1_2: # %catch{{$}} 47*9880d681SAndroid Build Coastguard Worker 48*9880d681SAndroid Build Coastguard Worker; CHECK: .section .xdata,"dr" 49*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: L__ehtable$use_except_handler3: 50*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long -1 51*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long _catchall_filt 52*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long LBB1_2 53*9880d681SAndroid Build Coastguard Worker 54*9880d681SAndroid Build Coastguard Workerdefine void @use_except_handler4() personality i32 (...)* @_except_handler4 { 55*9880d681SAndroid Build Coastguard Workerentry: 56*9880d681SAndroid Build Coastguard Worker invoke void @may_throw_or_crash() 57*9880d681SAndroid Build Coastguard Worker to label %cont unwind label %lpad 58*9880d681SAndroid Build Coastguard Workercont: 59*9880d681SAndroid Build Coastguard Worker ret void 60*9880d681SAndroid Build Coastguard Workerlpad: 61*9880d681SAndroid Build Coastguard Worker %cs = catchswitch within none [label %catch] unwind to caller 62*9880d681SAndroid Build Coastguard Workercatch: 63*9880d681SAndroid Build Coastguard Worker %p = catchpad within %cs [i8* bitcast (i32 ()* @catchall_filt to i8*)] 64*9880d681SAndroid Build Coastguard Worker catchret from %p to label %cont 65*9880d681SAndroid Build Coastguard Worker} 66*9880d681SAndroid Build Coastguard Worker 67*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: _use_except_handler4: 68*9880d681SAndroid Build Coastguard Worker; CHECK: pushl %ebp 69*9880d681SAndroid Build Coastguard Worker; CHECK: movl %esp, %ebp 70*9880d681SAndroid Build Coastguard Worker; CHECK: subl ${{[0-9]+}}, %esp 71*9880d681SAndroid Build Coastguard Worker; CHECK: movl %esp, -36(%ebp) 72*9880d681SAndroid Build Coastguard Worker; CHECK: movl $-2, -16(%ebp) 73*9880d681SAndroid Build Coastguard Worker; CHECK: movl $L__ehtable$use_except_handler4, %[[lsda:[^ ,]*]] 74*9880d681SAndroid Build Coastguard Worker; CHECK: xorl ___security_cookie, %[[lsda]] 75*9880d681SAndroid Build Coastguard Worker; CHECK: movl %[[lsda]], -20(%ebp) 76*9880d681SAndroid Build Coastguard Worker; CHECK: leal -28(%ebp), %[[node:[^ ,]*]] 77*9880d681SAndroid Build Coastguard Worker; CHECK: movl $__except_handler4, -24(%ebp) 78*9880d681SAndroid Build Coastguard Worker; CHECK: movl %fs:0, %[[next:[^ ,]*]] 79*9880d681SAndroid Build Coastguard Worker; CHECK: movl %[[next]], -28(%ebp) 80*9880d681SAndroid Build Coastguard Worker; CHECK: movl %[[node]], %fs:0 81*9880d681SAndroid Build Coastguard Worker; CHECK: calll _may_throw_or_crash 82*9880d681SAndroid Build Coastguard Worker; CHECK: movl -28(%ebp), %[[next:[^ ,]*]] 83*9880d681SAndroid Build Coastguard Worker; CHECK: movl %[[next]], %fs:0 84*9880d681SAndroid Build Coastguard Worker; CHECK: retl 85*9880d681SAndroid Build Coastguard Worker; CHECK: LBB2_2: # %catch{{$}} 86*9880d681SAndroid Build Coastguard Worker 87*9880d681SAndroid Build Coastguard Worker; CHECK: .section .xdata,"dr" 88*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: L__ehtable$use_except_handler4: 89*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long -2 90*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 0 91*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long -40 92*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 0 93*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long -2 94*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long _catchall_filt 95*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long LBB2_2 96*9880d681SAndroid Build Coastguard Worker 97*9880d681SAndroid Build Coastguard Workerdefine void @use_except_handler4_ssp() sspstrong personality i32 (...)* @_except_handler4 { 98*9880d681SAndroid Build Coastguard Workerentry: 99*9880d681SAndroid Build Coastguard Worker invoke void @may_throw_or_crash() 100*9880d681SAndroid Build Coastguard Worker to label %cont unwind label %lpad 101*9880d681SAndroid Build Coastguard Workercont: 102*9880d681SAndroid Build Coastguard Worker ret void 103*9880d681SAndroid Build Coastguard Workerlpad: 104*9880d681SAndroid Build Coastguard Worker %cs = catchswitch within none [label %catch] unwind to caller 105*9880d681SAndroid Build Coastguard Workercatch: 106*9880d681SAndroid Build Coastguard Worker %p = catchpad within %cs [i8* bitcast (i32 ()* @catchall_filt to i8*)] 107*9880d681SAndroid Build Coastguard Worker catchret from %p to label %cont 108*9880d681SAndroid Build Coastguard Worker} 109*9880d681SAndroid Build Coastguard Worker 110*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: _use_except_handler4_ssp: 111*9880d681SAndroid Build Coastguard Worker; CHECK: pushl %ebp 112*9880d681SAndroid Build Coastguard Worker; CHECK: movl %esp, %ebp 113*9880d681SAndroid Build Coastguard Worker; CHECK: subl ${{[0-9]+}}, %esp 114*9880d681SAndroid Build Coastguard Worker; CHECK: movl %ebp, %[[ehguard:[^ ,]*]] 115*9880d681SAndroid Build Coastguard Worker; CHECK: movl %esp, -36(%ebp) 116*9880d681SAndroid Build Coastguard Worker; CHECK: movl $-2, -16(%ebp) 117*9880d681SAndroid Build Coastguard Worker; CHECK: movl $L__ehtable$use_except_handler4_ssp, %[[lsda:[^ ,]*]] 118*9880d681SAndroid Build Coastguard Worker; CHECK: xorl ___security_cookie, %[[lsda]] 119*9880d681SAndroid Build Coastguard Worker; CHECK: movl %[[lsda]], -20(%ebp) 120*9880d681SAndroid Build Coastguard Worker; CHECK: xorl ___security_cookie, %[[ehguard]] 121*9880d681SAndroid Build Coastguard Worker; CHECK: movl %[[ehguard]], -40(%ebp) 122*9880d681SAndroid Build Coastguard Worker; CHECK: leal -28(%ebp), %[[node:[^ ,]*]] 123*9880d681SAndroid Build Coastguard Worker; CHECK: movl $__except_handler4, -24(%ebp) 124*9880d681SAndroid Build Coastguard Worker; CHECK: movl %fs:0, %[[next:[^ ,]*]] 125*9880d681SAndroid Build Coastguard Worker; CHECK: movl %[[next]], -28(%ebp) 126*9880d681SAndroid Build Coastguard Worker; CHECK: movl %[[node]], %fs:0 127*9880d681SAndroid Build Coastguard Worker; CHECK: calll _may_throw_or_crash 128*9880d681SAndroid Build Coastguard Worker; CHECK: movl -28(%ebp), %[[next:[^ ,]*]] 129*9880d681SAndroid Build Coastguard Worker; CHECK: movl %[[next]], %fs:0 130*9880d681SAndroid Build Coastguard Worker; CHECK: retl 131*9880d681SAndroid Build Coastguard Worker; CHECK: [[catch:[^ ,]*]]: # %catch{{$}} 132*9880d681SAndroid Build Coastguard Worker 133*9880d681SAndroid Build Coastguard Worker; CHECK: .section .xdata,"dr" 134*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: L__ehtable$use_except_handler4_ssp: 135*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long -2 136*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 0 137*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long -40 138*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 0 139*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long -2 140*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long _catchall_filt 141*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long [[catch]] 142*9880d681SAndroid Build Coastguard Worker 143*9880d681SAndroid Build Coastguard Workerdefine void @use_CxxFrameHandler3() personality i32 (...)* @__CxxFrameHandler3 { 144*9880d681SAndroid Build Coastguard Worker invoke void @may_throw_or_crash() 145*9880d681SAndroid Build Coastguard Worker to label %cont unwind label %catchall 146*9880d681SAndroid Build Coastguard Workercont: 147*9880d681SAndroid Build Coastguard Worker ret void 148*9880d681SAndroid Build Coastguard Worker 149*9880d681SAndroid Build Coastguard Workercatchall: 150*9880d681SAndroid Build Coastguard Worker %cs = catchswitch within none [label %catch] unwind to caller 151*9880d681SAndroid Build Coastguard Workercatch: 152*9880d681SAndroid Build Coastguard Worker %p = catchpad within %cs [i8* null, i32 64, i8* null] 153*9880d681SAndroid Build Coastguard Worker catchret from %p to label %cont 154*9880d681SAndroid Build Coastguard Worker} 155*9880d681SAndroid Build Coastguard Worker 156*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: _use_CxxFrameHandler3: 157*9880d681SAndroid Build Coastguard Worker; CHECK: pushl %ebp 158*9880d681SAndroid Build Coastguard Worker; CHECK: movl %esp, %ebp 159*9880d681SAndroid Build Coastguard Worker; CHECK: subl ${{[0-9]+}}, %esp 160*9880d681SAndroid Build Coastguard Worker; CHECK: movl %esp, -28(%ebp) 161*9880d681SAndroid Build Coastguard Worker; CHECK: movl $-1, -16(%ebp) 162*9880d681SAndroid Build Coastguard Worker; CHECK: leal -24(%ebp), %[[node:[^ ,]*]] 163*9880d681SAndroid Build Coastguard Worker; CHECK: movl $___ehhandler$use_CxxFrameHandler3, -20(%ebp) 164*9880d681SAndroid Build Coastguard Worker; CHECK: movl %fs:0, %[[next:[^ ,]*]] 165*9880d681SAndroid Build Coastguard Worker; CHECK: movl %[[next]], -24(%ebp) 166*9880d681SAndroid Build Coastguard Worker; CHECK: movl %[[node]], %fs:0 167*9880d681SAndroid Build Coastguard Worker; CHECK: movl $0, -16(%ebp) 168*9880d681SAndroid Build Coastguard Worker; CHECK: calll _may_throw_or_crash 169*9880d681SAndroid Build Coastguard Worker; CHECK: movl -24(%ebp), %[[next:[^ ,]*]] 170*9880d681SAndroid Build Coastguard Worker; CHECK: movl %[[next]], %fs:0 171*9880d681SAndroid Build Coastguard Worker; CHECK: retl 172*9880d681SAndroid Build Coastguard Worker 173*9880d681SAndroid Build Coastguard Worker; CHECK: .section .xdata,"dr" 174*9880d681SAndroid Build Coastguard Worker; CHECK: .p2align 2 175*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: L__ehtable$use_CxxFrameHandler3: 176*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 429065506 177*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 2 178*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long ($stateUnwindMap$use_CxxFrameHandler3) 179*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 1 180*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long ($tryMap$use_CxxFrameHandler3) 181*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 0 182*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 0 183*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 0 184*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 1 185*9880d681SAndroid Build Coastguard Worker 186*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: ___ehhandler$use_CxxFrameHandler3: 187*9880d681SAndroid Build Coastguard Worker; CHECK: movl $L__ehtable$use_CxxFrameHandler3, %eax 188*9880d681SAndroid Build Coastguard Worker; CHECK: jmp ___CxxFrameHandler3 # TAILCALL 189*9880d681SAndroid Build Coastguard Worker 190*9880d681SAndroid Build Coastguard Worker; CHECK: .safeseh __except_handler3 191*9880d681SAndroid Build Coastguard Worker; CHECK: .safeseh __except_handler4 192*9880d681SAndroid Build Coastguard Worker; CHECK: .safeseh ___ehhandler$use_CxxFrameHandler3 193