198 lines · plain
1; RUN: llc < %s | FileCheck %s2 3; Based on the source:4; extern "C" int puts(const char *);5; extern "C" int printf(const char *, ...);6; extern "C" int do_div(int a, int b) { return a / b; }7; extern "C" int filt();8; int main() {9; __try {10; __try {11; do_div(1, 0);12; } __except (1) {13; __try {14; do_div(1, 0);15; } __finally {16; puts("finally");17; }18; }19; } __except (filt()) {20; puts("caught");21; }22; return 0;23; }24 25; ModuleID = 't.cpp'26target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"27target triple = "x86_64-pc-windows-msvc"28 29$"\01??_C@_07MKBLAIAL@finally?$AA@" = comdat any30 31$"\01??_C@_06IBDBCMGJ@caught?$AA@" = comdat any32 33@"\01??_C@_07MKBLAIAL@finally?$AA@" = linkonce_odr unnamed_addr constant [8 x i8] c"finally\00", comdat, align 134@"\01??_C@_06IBDBCMGJ@caught?$AA@" = linkonce_odr unnamed_addr constant [7 x i8] c"caught\00", comdat, align 135 36; Function Attrs: nounwind readnone37define i32 @do_div(i32 %a, i32 %b) #0 {38entry:39 %div = sdiv i32 %a, %b40 ret i32 %div41}42 43define i32 @main() #1 personality ptr @__C_specific_handler {44entry:45 %call = invoke i32 @do_div(i32 1, i32 0) #446 to label %__try.cont.12 unwind label %catch.dispatch47 48__except.2: ; preds = %__except49 %call4 = invoke i32 @do_div(i32 1, i32 0) #450 to label %invoke.cont.3 unwind label %ehcleanup51 52invoke.cont.3: ; preds = %__except.253 invoke fastcc void @"\01?fin$0@0@main@@"() #454 to label %__try.cont.12 unwind label %catch.dispatch.755 56__except.9: ; preds = %__except.ret57 %call11 = tail call i32 @puts(ptr nonnull @"\01??_C@_06IBDBCMGJ@caught?$AA@")58 br label %__try.cont.1259 60__try.cont.12: ; preds = %invoke.cont.3, %entry, %__except.961 ret i32 062 63catch.dispatch: ; preds = %entry64 %cs1 = catchswitch within none [label %__except] unwind label %catch.dispatch.765 66__except: ; preds = %catch.dispatch67 %cp1 = catchpad within %cs1 [ptr null]68 catchret from %cp1 to label %__except.269 70ehcleanup: ; preds = %__except.271 %cp2 = cleanuppad within none []72 invoke fastcc void @"\01?fin$0@0@main@@"() #4 [ "funclet"(token %cp2) ]73 to label %invoke.cont.6 unwind label %catch.dispatch.774 75invoke.cont.6: ; preds = %ehcleanup76 cleanupret from %cp2 unwind label %catch.dispatch.777 78catch.dispatch.7:79 %cs2 = catchswitch within none [label %__except.ret] unwind to caller80 81__except.ret: ; preds = %catch.dispatch.782 %cp3 = catchpad within %cs2 [ptr @"\01?filt$0@0@main@@"]83 catchret from %cp3 to label %__except.984}85 86; CHECK: main: # @main87; CHECK: .seh_proc main88; CHECK: .seh_handler __C_specific_handler, @unwind, @except89; CHECK: pushq %rbp90; CHECK: .seh_pushreg %rbp91; CHECK: subq $32, %rsp92; CHECK: .seh_stackalloc 3293; CHECK: leaq 32(%rsp), %rbp94; CHECK: .seh_setframe %rbp, 3295; CHECK: .seh_endprologue96; CHECK: .Ltmp0:97; CHECK: movl $1, %ecx98; CHECK: xorl %edx, %edx99; CHECK: callq do_div100; CHECK: .Ltmp1:101; CHECK: .LBB1_[[epilogue:[0-9]+]]: # %__try.cont.12102; CHECK: xorl %eax, %eax103; CHECK: .seh_startepilogue104; CHECK: addq $32, %rsp105; CHECK: popq %rbp106; CHECK: .seh_endepilogue107; CHECK: retq108; CHECK: .LBB1_[[except1bb:[0-9]+]]: # %__except109; CHECK: .Ltmp2:110; CHECK: movl $1, %ecx111; CHECK: xorl %edx, %edx112; CHECK: callq do_div113; CHECK: .Ltmp3:114; CHECK: callq "?fin$0@0@main@@"115; CHECK: jmp .LBB1_[[epilogue]]116; CHECK: .LBB1_[[except2bb:[0-9]+]]: # %__except.ret117; CHECK: leaq "??_C@_06IBDBCMGJ@caught?$AA@"(%rip), %rcx118; CHECK: callq puts119; CHECK: jmp .LBB1_[[epilogue]]120 121; CHECK: .seh_handlerdata122; CHECK-NEXT: .Lmain$parent_frame_offset = 32123; CHECK-NEXT: .long (.Llsda_end0-.Llsda_begin0)/16124; CHECK-NEXT: .Llsda_begin0:125; CHECK-NEXT: .long .Ltmp0@IMGREL126; CHECK-NEXT: .long .Ltmp1@IMGREL127; CHECK-NEXT: .long 1128; CHECK-NEXT: .long .LBB1_[[except1bb]]@IMGREL129; CHECK-NEXT: .long .Ltmp0@IMGREL130; CHECK-NEXT: .long .Ltmp1@IMGREL131; CHECK-NEXT: .long "?filt$0@0@main@@"@IMGREL132; CHECK-NEXT: .long .LBB1_[[except2bb]]@IMGREL133; CHECK-NEXT: .long .Ltmp2@IMGREL134; CHECK-NEXT: .long .Ltmp3@IMGREL135; CHECK-NEXT: .long "?dtor$[[finbb:[0-9]+]]@?0?main@4HA"@IMGREL136; CHECK-NEXT: .long 0137; CHECK-NEXT: .long .Ltmp2@IMGREL138; CHECK-NEXT: .long .Ltmp3@IMGREL139; CHECK-NEXT: .long "?filt$0@0@main@@"@IMGREL140; CHECK-NEXT: .long .LBB1_3@IMGREL141; CHECK-NEXT: .long .Ltmp6@IMGREL142; CHECK-NEXT: .long .Ltmp7@IMGREL143; CHECK-NEXT: .long "?filt$0@0@main@@"@IMGREL144; CHECK-NEXT: .long .LBB1_3@IMGREL145; CHECK-NEXT: .Llsda_end0:146 147; CHECK: .text148; CHECK: .seh_endproc149 150; CHECK: "?dtor$[[finbb]]@?0?main@4HA":151; CHECK: .seh_proc "?dtor$[[finbb]]@?0?main@4HA"152; CHECK-NOT: .seh_handler153; CHECK: .LBB1_[[finbb]]: # %ehcleanup154; CHECK: movq %rdx, 16(%rsp)155; CHECK: pushq %rbp156; CHECK: .seh_pushreg %rbp157; CHECK: subq $32, %rsp158; CHECK: .seh_stackalloc 32159; CHECK: leaq 32(%rdx), %rbp160; CHECK: .seh_endprologue161; CHECK: callq "?fin$0@0@main@@"162; CHECK: nop163; CHECK: addq $32, %rsp164; CHECK: popq %rbp165; CHECK: retq166; CHECK: .seh_handlerdata167; CHECK: .seh_endproc168 169define internal i32 @"\01?filt$0@0@main@@"(ptr nocapture readnone %exception_pointers, ptr nocapture readnone %frame_pointer) #1 {170entry:171 %call = tail call i32 @filt()172 ret i32 %call173}174 175; CHECK: "?filt$0@0@main@@": # @"\01?filt$0@0@main@@"176; CHECK: jmp filt # TAILCALL177 178declare i32 @filt() #1179 180declare i32 @__C_specific_handler(...)181 182; Function Attrs: noinline nounwind183define internal fastcc void @"\01?fin$0@0@main@@"() #2 {184entry:185 %call = tail call i32 @puts(ptr @"\01??_C@_07MKBLAIAL@finally?$AA@") #5186 ret void187}188 189; Function Attrs: nounwind190declare i32 @puts(ptr nocapture readonly) #3191 192attributes #0 = { nounwind readnone "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-features"="+sse,+sse2" "use-soft-float"="false" }193attributes #1 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-features"="+sse,+sse2" "use-soft-float"="false" }194attributes #2 = { noinline nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-features"="+sse,+sse2" "use-soft-float"="false" }195attributes #3 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-features"="+sse,+sse2" "use-soft-float"="false" }196attributes #4 = { noinline }197attributes #5 = { nounwind }198