blob: a2988a3059e7d4010a993eddc528df242d8e96de [file] [log] [blame]
Reid Klecknercfaeb422015-10-21 19:54:40 +00001; RUN: llc -mtriple=x86_64-windows-msvc < %s | FileCheck %s --check-prefix=X64
2; RUN: llc -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 %0 = catchpad [i8* null, i32 64, i8* null]
17 to label %catch unwind label %catchendblock
18
19catch: ; preds = %catch.dispatch
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 %0 to label %return
27
28catchendblock: ; preds = %catch.dispatch
29 catchendpad unwind to caller
30
31return: ; preds = %entry, %catch
32 %retval.0 = phi i32 [ %arg2, %catch ], [ -1, %entry ]
33 ret i32 %retval.0
34}
35
36; X64-LABEL: .seh_proc f
37; X64: pushq %rbp
Reid Klecknercc2f6c32015-11-19 23:23:33 +000038; X64: subq $64, %rsp
39; X64: leaq 64(%rsp), %rbp
40; X64: movq $-2, -8(%rbp)
41; X64: movl $-1, -20(%rbp) # 4-byte Folded Spill
Reid Klecknercfaeb422015-10-21 19:54:40 +000042; X64: callq g
Reid Klecknercc2f6c32015-11-19 23:23:33 +000043; X64: .LBB0_1
44; X64: movl -20(%rbp), %eax # 4-byte Reload
45; X64: addq $64, %rsp
Reid Klecknercfaeb422015-10-21 19:54:40 +000046; X64: popq %rbp
47
Reid Klecknercc2f6c32015-11-19 23:23:33 +000048; X64-LABEL: "?catch${{[0-9]}}@?0?f@4HA":
49; X64: .seh_proc "?catch${{[0-9]}}@?0?f@4HA"
Reid Klecknercfaeb422015-10-21 19:54:40 +000050; X64: movq %rdx, 16(%rsp)
51; X64: pushq %rbp
Reid Klecknercc2f6c32015-11-19 23:23:33 +000052; X64: subq $32, %rsp
53; X64: leaq 64(%rdx), %rbp
Reid Klecknercfaeb422015-10-21 19:54:40 +000054; arg2 is at RBP+40:
55; start at arg2
56; + 8 for arg1
57; + 8 for retaddr
58; + 8 for RBP
Reid Klecknercc2f6c32015-11-19 23:23:33 +000059; + 64 for stackalloc
60; - 64 for setframe
Reid Klecknercfaeb422015-10-21 19:54:40 +000061; = 40
Reid Klecknercc2f6c32015-11-19 23:23:33 +000062; X64: movl 24(%rbp), %eax
63; X64: movl %eax, -20(%rbp) # 4-byte Spill
64; X64: leaq .LBB0_1(%rip), %rax
65; X64: addq $32, %rsp
Reid Klecknercfaeb422015-10-21 19:54:40 +000066; X64: popq %rbp
67; X64: retq # CATCHRET
68
69; X86-LABEL: _f: # @f
70; X86: pushl %ebp
71; X86: movl %esp, %ebp
72; X86: pushl %ebx
73; X86: pushl %edi
74; X86: pushl %esi
Reid Klecknercc2f6c32015-11-19 23:23:33 +000075; X86: subl $24, %esp
76; X86: movl $-1, -36(%ebp)
Reid Klecknercfaeb422015-10-21 19:54:40 +000077; X86: calll _g
Reid Klecknercc2f6c32015-11-19 23:23:33 +000078; X86: LBB0_[[retbb:[0-9]+]]:
79; X86: movl -36(%ebp), %eax
80; X86: addl $24, %esp
Reid Klecknercfaeb422015-10-21 19:54:40 +000081; X86: popl %esi
82; X86: popl %edi
83; X86: popl %ebx
84; X86: popl %ebp
85; X86: retl
86
Reid Klecknercc2f6c32015-11-19 23:23:33 +000087; X86: LBB0_[[restorebb:[0-9]+]]: # Block address taken
88; X86: addl $12, %ebp
Reid Klecknercfaeb422015-10-21 19:54:40 +000089; arg2 is at EBP offset 12:
90; + 4 for arg1
91; + 4 for retaddr
92; + 4 for EBP
Reid Klecknercc2f6c32015-11-19 23:23:33 +000093; X86: movl 12(%ebp), %eax
94; X86: movl %eax, -36(%ebp)
95; X86: jmp LBB0_[[retbb]]
96
97; X86-LABEL: "?catch${{[0-9]}}@?0?f@4HA":
98; X86: pushl %ebp
99; X86: addl $12, %ebp
Reid Klecknercfaeb422015-10-21 19:54:40 +0000100; Done due to mov %esp, %ebp
Reid Klecknercc2f6c32015-11-19 23:23:33 +0000101; X86: leal 12(%ebp), %eax
102; X86: movl $LBB0_[[restorebb]], %eax
Reid Klecknercfaeb422015-10-21 19:54:40 +0000103; X86: popl %ebp
104; X86: retl # CATCHRET