1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Worker; Based on the source: 4*9880d681SAndroid Build Coastguard Worker; extern "C" int puts(const char *); 5*9880d681SAndroid Build Coastguard Worker; extern "C" int printf(const char *, ...); 6*9880d681SAndroid Build Coastguard Worker; extern "C" int do_div(int a, int b) { return a / b; } 7*9880d681SAndroid Build Coastguard Worker; extern "C" int filt(); 8*9880d681SAndroid Build Coastguard Worker; int main() { 9*9880d681SAndroid Build Coastguard Worker; __try { 10*9880d681SAndroid Build Coastguard Worker; __try { 11*9880d681SAndroid Build Coastguard Worker; do_div(1, 0); 12*9880d681SAndroid Build Coastguard Worker; } __except (1) { 13*9880d681SAndroid Build Coastguard Worker; __try { 14*9880d681SAndroid Build Coastguard Worker; do_div(1, 0); 15*9880d681SAndroid Build Coastguard Worker; } __finally { 16*9880d681SAndroid Build Coastguard Worker; puts("finally"); 17*9880d681SAndroid Build Coastguard Worker; } 18*9880d681SAndroid Build Coastguard Worker; } 19*9880d681SAndroid Build Coastguard Worker; } __except (filt()) { 20*9880d681SAndroid Build Coastguard Worker; puts("caught"); 21*9880d681SAndroid Build Coastguard Worker; } 22*9880d681SAndroid Build Coastguard Worker; return 0; 23*9880d681SAndroid Build Coastguard Worker; } 24*9880d681SAndroid Build Coastguard Worker 25*9880d681SAndroid Build Coastguard Worker; ModuleID = 't.cpp' 26*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" 27*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64-pc-windows-msvc" 28*9880d681SAndroid Build Coastguard Worker 29*9880d681SAndroid Build Coastguard Worker$"\01??_C@_07MKBLAIAL@finally?$AA@" = comdat any 30*9880d681SAndroid Build Coastguard Worker 31*9880d681SAndroid Build Coastguard Worker$"\01??_C@_06IBDBCMGJ@caught?$AA@" = comdat any 32*9880d681SAndroid Build Coastguard Worker 33*9880d681SAndroid Build Coastguard Worker@"\01??_C@_07MKBLAIAL@finally?$AA@" = linkonce_odr unnamed_addr constant [8 x i8] c"finally\00", comdat, align 1 34*9880d681SAndroid Build Coastguard Worker@"\01??_C@_06IBDBCMGJ@caught?$AA@" = linkonce_odr unnamed_addr constant [7 x i8] c"caught\00", comdat, align 1 35*9880d681SAndroid Build Coastguard Worker 36*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind readnone 37*9880d681SAndroid Build Coastguard Workerdefine i32 @do_div(i32 %a, i32 %b) #0 { 38*9880d681SAndroid Build Coastguard Workerentry: 39*9880d681SAndroid Build Coastguard Worker %div = sdiv i32 %a, %b 40*9880d681SAndroid Build Coastguard Worker ret i32 %div 41*9880d681SAndroid Build Coastguard Worker} 42*9880d681SAndroid Build Coastguard Worker 43*9880d681SAndroid Build Coastguard Workerdefine i32 @main() #1 personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) { 44*9880d681SAndroid Build Coastguard Workerentry: 45*9880d681SAndroid Build Coastguard Worker %call = invoke i32 @do_div(i32 1, i32 0) #4 46*9880d681SAndroid Build Coastguard Worker to label %__try.cont.12 unwind label %catch.dispatch 47*9880d681SAndroid Build Coastguard Worker 48*9880d681SAndroid Build Coastguard Worker__except.2: ; preds = %__except 49*9880d681SAndroid Build Coastguard Worker %call4 = invoke i32 @do_div(i32 1, i32 0) #4 50*9880d681SAndroid Build Coastguard Worker to label %invoke.cont.3 unwind label %ehcleanup 51*9880d681SAndroid Build Coastguard Worker 52*9880d681SAndroid Build Coastguard Workerinvoke.cont.3: ; preds = %__except.2 53*9880d681SAndroid Build Coastguard Worker invoke fastcc void @"\01?fin$0@0@main@@"() #4 54*9880d681SAndroid Build Coastguard Worker to label %__try.cont.12 unwind label %catch.dispatch.7 55*9880d681SAndroid Build Coastguard Worker 56*9880d681SAndroid Build Coastguard Worker__except.9: ; preds = %__except.ret 57*9880d681SAndroid Build Coastguard Worker %call11 = tail call i32 @puts(i8* nonnull getelementptr inbounds ([7 x i8], [7 x i8]* @"\01??_C@_06IBDBCMGJ@caught?$AA@", i64 0, i64 0)) 58*9880d681SAndroid Build Coastguard Worker br label %__try.cont.12 59*9880d681SAndroid Build Coastguard Worker 60*9880d681SAndroid Build Coastguard Worker__try.cont.12: ; preds = %invoke.cont.3, %entry, %__except.9 61*9880d681SAndroid Build Coastguard Worker ret i32 0 62*9880d681SAndroid Build Coastguard Worker 63*9880d681SAndroid Build Coastguard Workercatch.dispatch: ; preds = %entry 64*9880d681SAndroid Build Coastguard Worker %cs1 = catchswitch within none [label %__except] unwind label %catch.dispatch.7 65*9880d681SAndroid Build Coastguard Worker 66*9880d681SAndroid Build Coastguard Worker__except: ; preds = %catch.dispatch 67*9880d681SAndroid Build Coastguard Worker %cp1 = catchpad within %cs1 [i8* null] 68*9880d681SAndroid Build Coastguard Worker catchret from %cp1 to label %__except.2 69*9880d681SAndroid Build Coastguard Worker 70*9880d681SAndroid Build Coastguard Workerehcleanup: ; preds = %__except.2 71*9880d681SAndroid Build Coastguard Worker %cp2 = cleanuppad within none [] 72*9880d681SAndroid Build Coastguard Worker invoke fastcc void @"\01?fin$0@0@main@@"() #4 [ "funclet"(token %cp2) ] 73*9880d681SAndroid Build Coastguard Worker to label %invoke.cont.6 unwind label %catch.dispatch.7 74*9880d681SAndroid Build Coastguard Worker 75*9880d681SAndroid Build Coastguard Workerinvoke.cont.6: ; preds = %ehcleanup 76*9880d681SAndroid Build Coastguard Worker cleanupret from %cp2 unwind label %catch.dispatch.7 77*9880d681SAndroid Build Coastguard Worker 78*9880d681SAndroid Build Coastguard Workercatch.dispatch.7: 79*9880d681SAndroid Build Coastguard Worker %cs2 = catchswitch within none [label %__except.ret] unwind to caller 80*9880d681SAndroid Build Coastguard Worker 81*9880d681SAndroid Build Coastguard Worker__except.ret: ; preds = %catch.dispatch.7 82*9880d681SAndroid Build Coastguard Worker %cp3 = catchpad within %cs2 [i8* bitcast (i32 (i8*, i8*)* @"\01?filt$0@0@main@@" to i8*)] 83*9880d681SAndroid Build Coastguard Worker catchret from %cp3 to label %__except.9 84*9880d681SAndroid Build Coastguard Worker} 85*9880d681SAndroid Build Coastguard Worker 86*9880d681SAndroid Build Coastguard Worker; CHECK: main: # @main 87*9880d681SAndroid Build Coastguard Worker; CHECK: .seh_proc main 88*9880d681SAndroid Build Coastguard Worker; CHECK: .seh_handler __C_specific_handler, @unwind, @except 89*9880d681SAndroid Build Coastguard Worker; CHECK: pushq %rbp 90*9880d681SAndroid Build Coastguard Worker; CHECK: .seh_pushreg 5 91*9880d681SAndroid Build Coastguard Worker; CHECK: subq $32, %rsp 92*9880d681SAndroid Build Coastguard Worker; CHECK: .seh_stackalloc 32 93*9880d681SAndroid Build Coastguard Worker; CHECK: leaq 32(%rsp), %rbp 94*9880d681SAndroid Build Coastguard Worker; CHECK: .seh_setframe 5, 32 95*9880d681SAndroid Build Coastguard Worker; CHECK: .seh_endprologue 96*9880d681SAndroid Build Coastguard Worker; CHECK: .Ltmp0: 97*9880d681SAndroid Build Coastguard Worker; CHECK: movl $1, %ecx 98*9880d681SAndroid Build Coastguard Worker; CHECK: xorl %edx, %edx 99*9880d681SAndroid Build Coastguard Worker; CHECK: callq do_div 100*9880d681SAndroid Build Coastguard Worker; CHECK: .Ltmp1: 101*9880d681SAndroid Build Coastguard Worker; CHECK: .LBB1_[[epilogue:[0-9]+]]: # %__try.cont.12 102*9880d681SAndroid Build Coastguard Worker; CHECK: xorl %eax, %eax 103*9880d681SAndroid Build Coastguard Worker; CHECK: addq $32, %rsp 104*9880d681SAndroid Build Coastguard Worker; CHECK: popq %rbp 105*9880d681SAndroid Build Coastguard Worker; CHECK: retq 106*9880d681SAndroid Build Coastguard Worker; CHECK: .LBB1_[[except1bb:[0-9]+]]: # %__except 107*9880d681SAndroid Build Coastguard Worker; CHECK: .Ltmp2: 108*9880d681SAndroid Build Coastguard Worker; CHECK: movl $1, %ecx 109*9880d681SAndroid Build Coastguard Worker; CHECK: xorl %edx, %edx 110*9880d681SAndroid Build Coastguard Worker; CHECK: callq do_div 111*9880d681SAndroid Build Coastguard Worker; CHECK: .Ltmp3: 112*9880d681SAndroid Build Coastguard Worker; CHECK: callq "?fin$0@0@main@@" 113*9880d681SAndroid Build Coastguard Worker; CHECK: jmp .LBB1_[[epilogue]] 114*9880d681SAndroid Build Coastguard Worker; CHECK: .LBB1_[[except2bb:[0-9]+]]: # %__except.ret 115*9880d681SAndroid Build Coastguard Worker; CHECK: leaq "??_C@_06IBDBCMGJ@caught?$AA@"(%rip), %rcx 116*9880d681SAndroid Build Coastguard Worker; CHECK: callq puts 117*9880d681SAndroid Build Coastguard Worker; CHECK: jmp .LBB1_[[epilogue]] 118*9880d681SAndroid Build Coastguard Worker 119*9880d681SAndroid Build Coastguard Worker; CHECK: .seh_handlerdata 120*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .Lmain$parent_frame_offset = 32 121*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long (.Llsda_end0-.Llsda_begin0)/16 122*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .Llsda_begin0: 123*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long .Ltmp0@IMGREL+1 124*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long .Ltmp1@IMGREL+1 125*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 1 126*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long .LBB1_[[except1bb]]@IMGREL 127*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long .Ltmp0@IMGREL+1 128*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long .Ltmp1@IMGREL+1 129*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long "?filt$0@0@main@@"@IMGREL 130*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long .LBB1_[[except2bb]]@IMGREL 131*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long .Ltmp2@IMGREL+1 132*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long .Ltmp3@IMGREL+1 133*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long "?dtor$[[finbb:[0-9]+]]@?0?main@4HA"@IMGREL 134*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long 0 135*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long .Ltmp2@IMGREL+1 136*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long .Ltmp3@IMGREL+1 137*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long "?filt$0@0@main@@"@IMGREL 138*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long .LBB1_3@IMGREL 139*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long .Ltmp6@IMGREL+1 140*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long .Ltmp7@IMGREL+1 141*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long "?filt$0@0@main@@"@IMGREL 142*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long .LBB1_3@IMGREL 143*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .Llsda_end0: 144*9880d681SAndroid Build Coastguard Worker 145*9880d681SAndroid Build Coastguard Worker; CHECK: .text 146*9880d681SAndroid Build Coastguard Worker; CHECK: .seh_endproc 147*9880d681SAndroid Build Coastguard Worker 148*9880d681SAndroid Build Coastguard Worker; CHECK: "?dtor$[[finbb]]@?0?main@4HA": 149*9880d681SAndroid Build Coastguard Worker; CHECK: .seh_proc "?dtor$[[finbb]]@?0?main@4HA" 150*9880d681SAndroid Build Coastguard Worker; CHECK: .seh_handler __C_specific_handler, @unwind, @except 151*9880d681SAndroid Build Coastguard Worker; CHECK: .LBB1_[[finbb]]: # %ehcleanup 152*9880d681SAndroid Build Coastguard Worker; CHECK: movq %rdx, 16(%rsp) 153*9880d681SAndroid Build Coastguard Worker; CHECK: pushq %rbp 154*9880d681SAndroid Build Coastguard Worker; CHECK: .seh_pushreg 5 155*9880d681SAndroid Build Coastguard Worker; CHECK: subq $32, %rsp 156*9880d681SAndroid Build Coastguard Worker; CHECK: .seh_stackalloc 32 157*9880d681SAndroid Build Coastguard Worker; CHECK: leaq 32(%rdx), %rbp 158*9880d681SAndroid Build Coastguard Worker; CHECK: .seh_endprologue 159*9880d681SAndroid Build Coastguard Worker; CHECK: callq "?fin$0@0@main@@" 160*9880d681SAndroid Build Coastguard Worker; CHECK: nop 161*9880d681SAndroid Build Coastguard Worker; CHECK: addq $32, %rsp 162*9880d681SAndroid Build Coastguard Worker; CHECK: popq %rbp 163*9880d681SAndroid Build Coastguard Worker; CHECK: retq 164*9880d681SAndroid Build Coastguard Worker; CHECK: .seh_handlerdata 165*9880d681SAndroid Build Coastguard Worker; CHECK: .seh_endproc 166*9880d681SAndroid Build Coastguard Worker 167*9880d681SAndroid Build Coastguard Workerdefine internal i32 @"\01?filt$0@0@main@@"(i8* nocapture readnone %exception_pointers, i8* nocapture readnone %frame_pointer) #1 { 168*9880d681SAndroid Build Coastguard Workerentry: 169*9880d681SAndroid Build Coastguard Worker %call = tail call i32 @filt() 170*9880d681SAndroid Build Coastguard Worker ret i32 %call 171*9880d681SAndroid Build Coastguard Worker} 172*9880d681SAndroid Build Coastguard Worker 173*9880d681SAndroid Build Coastguard Worker; CHECK: "?filt$0@0@main@@": # @"\01?filt$0@0@main@@" 174*9880d681SAndroid Build Coastguard Worker; CHECK: .seh_proc "?filt$0@0@main@@" 175*9880d681SAndroid Build Coastguard Worker; CHECK: .seh_endprologue 176*9880d681SAndroid Build Coastguard Worker; CHECK: rex64 jmp filt # TAILCALL 177*9880d681SAndroid Build Coastguard Worker; CHECK: .seh_handlerdata 178*9880d681SAndroid Build Coastguard Worker 179*9880d681SAndroid Build Coastguard Workerdeclare i32 @filt() #1 180*9880d681SAndroid Build Coastguard Worker 181*9880d681SAndroid Build Coastguard Workerdeclare i32 @__C_specific_handler(...) 182*9880d681SAndroid Build Coastguard Worker 183*9880d681SAndroid Build Coastguard Worker; Function Attrs: noinline nounwind 184*9880d681SAndroid Build Coastguard Workerdefine internal fastcc void @"\01?fin$0@0@main@@"() #2 { 185*9880d681SAndroid Build Coastguard Workerentry: 186*9880d681SAndroid Build Coastguard Worker %call = tail call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @"\01??_C@_07MKBLAIAL@finally?$AA@", i64 0, i64 0)) #5 187*9880d681SAndroid Build Coastguard Worker ret void 188*9880d681SAndroid Build Coastguard Worker} 189*9880d681SAndroid Build Coastguard Worker 190*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind 191*9880d681SAndroid Build Coastguard Workerdeclare i32 @puts(i8* nocapture readonly) #3 192*9880d681SAndroid Build Coastguard Worker 193*9880d681SAndroid Build Coastguard Workerattributes #0 = { nounwind readnone "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" } 194*9880d681SAndroid Build Coastguard Workerattributes #1 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" } 195*9880d681SAndroid Build Coastguard Workerattributes #2 = { noinline nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" } 196*9880d681SAndroid Build Coastguard Workerattributes #3 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" } 197*9880d681SAndroid Build Coastguard Workerattributes #4 = { noinline } 198*9880d681SAndroid Build Coastguard Workerattributes #5 = { nounwind } 199