1; RUN: llc -stack-symbol-ordering=0 -mtriple=x86_64-windows-msvc < %s | FileCheck %s --check-prefix=X64 2; RUN: llc -stack-symbol-ordering=0 -mtriple=i686-windows-msvc < %s | FileCheck %s --check-prefix=X86 3 4declare void @llvm.va_start(i8*) 5declare void @llvm.va_end(i8*) 6declare i32 @__CxxFrameHandler3(...) 7declare void @g() 8 9define i32 @f(i32 %a, ...) personality i32 (...)* @__CxxFrameHandler3 { 10entry: 11 %ap = alloca i8* 12 invoke void @g() 13 to label %return unwind label %catch.dispatch 14 15catch.dispatch: ; preds = %entry 16 %cs1 = catchswitch within none [label %catch] unwind to caller 17 18catch: ; preds = %catch.dispatch 19 %0 = catchpad within %cs1 [i8* null, i32 64, i8* null] 20 %ap1 = bitcast i8** %ap to i8* 21 call void @llvm.va_start(i8* %ap1) 22 %argp.cur = load i8*, i8** %ap 23 %1 = bitcast i8* %argp.cur to i32* 24 %arg2 = load i32, i32* %1 25 call void @llvm.va_end(i8* %ap1) 26 catchret from %0 to label %return 27 28return: ; preds = %entry, %catch 29 %retval.0 = phi i32 [ %arg2, %catch ], [ -1, %entry ] 30 ret i32 %retval.0 31} 32 33; X64-LABEL: .seh_proc f 34; X64: pushq %rbp 35; X64: subq $64, %rsp 36; X64: leaq 64(%rsp), %rbp 37; X64: movq $-2, -8(%rbp) 38; X64: movl $-1, -20(%rbp) # 4-byte Folded Spill 39; X64: callq g 40; X64: .LBB0_1 41; X64: movl -20(%rbp), %eax # 4-byte Reload 42; X64: addq $64, %rsp 43; X64: popq %rbp 44 45; X64-LABEL: "?catch${{[0-9]}}@?0?f@4HA": 46; X64: .seh_proc "?catch${{[0-9]}}@?0?f@4HA" 47; X64: movq %rdx, 16(%rsp) 48; X64: pushq %rbp 49; X64: subq $32, %rsp 50; X64: leaq 64(%rdx), %rbp 51; arg2 is at RBP+40: 52; start at arg2 53; + 8 for arg1 54; + 8 for retaddr 55; + 8 for RBP 56; + 64 for stackalloc 57; - 64 for setframe 58; = 40 59; X64: movl 24(%rbp), %eax 60; X64: movl %eax, -20(%rbp) # 4-byte Spill 61; X64: leaq .LBB0_1(%rip), %rax 62; X64: addq $32, %rsp 63; X64: popq %rbp 64; X64: retq # CATCHRET 65 66; X86-LABEL: _f: # @f 67; X86: pushl %ebp 68; X86: movl %esp, %ebp 69; X86: pushl %ebx 70; X86: pushl %edi 71; X86: pushl %esi 72; X86: subl $24, %esp 73; X86: movl $-1, -36(%ebp) 74; X86: calll _g 75; X86: LBB0_[[retbb:[0-9]+]]: 76; X86: movl -36(%ebp), %eax 77; X86: addl $24, %esp 78; X86: popl %esi 79; X86: popl %edi 80; X86: popl %ebx 81; X86: popl %ebp 82; X86: retl 83 84; X86: LBB0_[[restorebb:[0-9]+]]: # Block address taken 85; X86: addl $12, %ebp 86; arg2 is at EBP offset 12: 87; + 4 for arg1 88; + 4 for retaddr 89; + 4 for EBP 90; X86: movl 12(%ebp), %eax 91; X86: movl %eax, -36(%ebp) 92; X86: jmp LBB0_[[retbb]] 93 94; X86-LABEL: "?catch${{[0-9]}}@?0?f@4HA": 95; X86: pushl %ebp 96; X86: addl $12, %ebp 97; Done due to mov %esp, %ebp 98; X86: leal 12(%ebp), %eax 99; X86: movl $LBB0_[[restorebb]], %eax 100; X86: popl %ebp 101; X86: retl # CATCHRET 102