1; RUN: llc -mtriple=x86_64-windows-msvc < %s | FileCheck %s 2 3target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" 4target triple = "x86_64-pc-windows-msvc" 5 6define void @"\01?f@@YAXXZ"(i1 %B) personality i32 (...)* @__CxxFrameHandler3 { 7entry: 8 invoke void @g() 9 to label %unreachable unwind label %cleanupblock 10 11cleanupblock: 12 %cleanp = cleanuppad within none [] 13 call void @g() [ "funclet"(token %cleanp) ] 14 cleanupret from %cleanp unwind label %catch.dispatch 15 16catch.dispatch: 17 %cs1 = catchswitch within none [label %catch] unwind to caller 18 19catch: 20 %cp = catchpad within %cs1 [i8* null, i32 64, i8* null] 21 call void @g() [ "funclet"(token %cp) ] 22 catchret from %cp to label %try.cont 23 24try.cont: 25 ret void 26 27unreachable: 28 unreachable 29} 30 31 32declare void @g() 33 34declare i32 @__CxxFrameHandler3(...) 35 36; Destructors need CFI but they shouldn't use the .seh_handler directive. 37; CHECK: "?dtor$[[cleanup:[0-9]+]]@?0??f@@YAXXZ@4HA": 38; CHECK: .seh_proc "?dtor$[[cleanup]]@?0??f@@YAXXZ@4HA" 39; CHECK-NOT: .seh_handler __CxxFrameHandler3 40; CHECK: LBB0_[[cleanup]]: # %cleanupblock{{$}} 41 42; Emit CFI for pushing RBP. 43; CHECK: movq %rdx, 16(%rsp) 44; CHECK: pushq %rbp 45; CHECK: .seh_pushreg 5 46 47; Emit CFI for allocating from the stack pointer. 48; CHECK: subq $32, %rsp 49; CHECK: .seh_stackalloc 32 50 51; CHECK: leaq 48(%rdx), %rbp 52; CHECK-NOT: .seh_setframe 53 54; Prologue is done, emit the .seh_endprologue directive. 55; CHECK: .seh_endprologue 56 57; Make sure there is a nop after a call if the call precedes the epilogue. 58; CHECK: callq g 59; CHECK-NEXT: nop 60 61; Don't emit a reference to the LSDA. 62; CHECK: .seh_handlerdata 63; CHECK-NOT: .long ("$cppxdata$?f@@YAXXZ")@IMGREL 64; CHECK-NEXT: .text 65; CHECK: .seh_endproc 66 67; CHECK: "?catch$[[catch:[0-9]+]]@?0??f@@YAXXZ@4HA": 68; CHECK: .seh_proc "?catch$[[catch]]@?0??f@@YAXXZ@4HA" 69; CHECK-NEXT: .seh_handler __CxxFrameHandler3, @unwind, @except 70; CHECK: LBB0_[[catch]]: # %catch{{$}} 71 72; Emit CFI for pushing RBP. 73; CHECK: movq %rdx, 16(%rsp) 74; CHECK: pushq %rbp 75; CHECK: .seh_pushreg 5 76 77; Emit CFI for allocating from the stack pointer. 78; CHECK: subq $32, %rsp 79; CHECK: .seh_stackalloc 32 80 81; CHECK: leaq 48(%rdx), %rbp 82; CHECK-NOT: .seh_setframe 83 84; Prologue is done, emit the .seh_endprologue directive. 85; CHECK: .seh_endprologue 86 87; Make sure there is at least one instruction after a call before the epilogue. 88; CHECK: callq g 89; CHECK-NEXT: leaq .LBB0_{{[0-9]+}}(%rip), %rax 90 91; Emit a reference to the LSDA. 92; CHECK: .seh_handlerdata 93; CHECK-NEXT: .long ("$cppxdata$?f@@YAXXZ")@IMGREL 94; CHECK-NEXT: .text 95; CHECK: .seh_endproc 96