1 ; RUN: llc < %s -O0 -mcpu=corei7 -mtriple=x86_64-pc-win32 | FileCheck %s -check-prefix=WIN64
2 ; RUN: llc < %s -O0 -mcpu=corei7 -mtriple=x86_64-pc-mingw32 | FileCheck %s -check-prefix=WIN64
4 ; Check function without prolog
5 define void @foo0() uwtable {
10 ; WIN64: .seh_proc foo0
11 ; WIN64: .seh_endprologue
15 ; Checks a small stack allocation
16 define void @foo1() uwtable {
18 %baz = alloca [2000 x i16], align 2
22 ; WIN64: .seh_proc foo1
23 ; WIN64: subq $4000, %rsp
24 ; WIN64: .seh_stackalloc 4000
25 ; WIN64: .seh_endprologue
26 ; WIN64: addq $4000, %rsp
30 ; Checks a stack allocation requiring call to __chkstk/___chkstk_ms
31 define void @foo2() uwtable {
33 %baz = alloca [4000 x i16], align 2
37 ; WIN64: .seh_proc foo2
38 ; WIN64: movabsq $8000, %rax
39 ; WIN64: callq {{__chkstk|___chkstk_ms}}
40 ; WIN64: subq %rax, %rsp
41 ; WIN64: .seh_stackalloc 8000
42 ; WIN64: .seh_endprologue
43 ; WIN64: addq $8000, %rsp
49 define i32 @foo3(i32 %f_arg, i32 %e_arg, i32 %d_arg, i32 %c_arg, i32 %b_arg, i32 %a_arg) uwtable {
57 store i32 %a_arg, i32* %a
58 store i32 %b_arg, i32* %b
59 store i32 %c_arg, i32* %c
60 store i32 %d_arg, i32* %d
61 store i32 %e_arg, i32* %e
62 store i32 %f_arg, i32* %f
64 %tmp1 = mul i32 %tmp, 2
66 %tmp3 = mul i32 %tmp2, 3
67 %tmp4 = add i32 %tmp1, %tmp3
69 %tmp6 = mul i32 %tmp5, 5
70 %tmp7 = add i32 %tmp4, %tmp6
72 %tmp9 = mul i32 %tmp8, 7
73 %tmp10 = add i32 %tmp7, %tmp9
75 %tmp12 = mul i32 %tmp11, 11
76 %tmp13 = add i32 %tmp10, %tmp12
78 %tmp15 = mul i32 %tmp14, 13
79 %tmp16 = add i32 %tmp13, %tmp15
83 ; WIN64: .seh_proc foo3
85 ; WIN64: .seh_pushreg 6
86 ; WIN64: subq $24, %rsp
87 ; WIN64: .seh_stackalloc 24
88 ; WIN64: .seh_endprologue
89 ; WIN64: addq $24, %rsp
95 ; Check emission of eh handler and handler data
96 declare i32 @_d_eh_personality(i32, i32, i64, i8*, i8*)
97 declare void @_d_eh_resume_unwind(i8*)
101 define i32 @foo4() #0 {
103 %step = alloca i32, align 4
104 store i32 0, i32* %step
105 %tmp = load i32* %step
107 %tmp1 = invoke i32 @bar()
108 to label %finally unwind label %landingpad
111 store i32 1, i32* %step
112 br label %endtryfinally
115 %landing_pad = landingpad { i8*, i32 } personality i32 (i32, i32, i64, i8*, i8*)* @_d_eh_personality
117 %tmp3 = extractvalue { i8*, i32 } %landing_pad, 0
118 store i32 2, i32* %step
119 call void @_d_eh_resume_unwind(i8* %tmp3)
123 %tmp10 = load i32* %step
127 ; WIN64: .seh_proc foo4
128 ; WIN64: .seh_handler _d_eh_personality, @unwind, @except
129 ; WIN64: subq $56, %rsp
130 ; WIN64: .seh_stackalloc 56
131 ; WIN64: .seh_endprologue
132 ; WIN64: addq $56, %rsp
134 ; WIN64: .seh_handlerdata
135 ; WIN64: .seh_endproc
138 ; Check stack re-alignment and xmm spilling
139 define void @foo5() uwtable {
141 %s = alloca i32, align 64
142 call void asm sideeffect "", "~{rbx},~{rdi},~{xmm6},~{xmm7}"()
146 ; WIN64: .seh_proc foo5
148 ; WIN64: .seh_pushreg 5
149 ; WIN64: movq %rsp, %rbp
151 ; WIN64: .seh_pushreg 7
153 ; WIN64: .seh_pushreg 3
154 ; WIN64: andq $-64, %rsp
155 ; WIN64: subq $128, %rsp
156 ; WIN64: .seh_stackalloc 48
157 ; WIN64: .seh_setframe 5, 64
158 ; WIN64: movaps %xmm7, -32(%rbp) # 16-byte Spill
159 ; WIN64: movaps %xmm6, -48(%rbp) # 16-byte Spill
160 ; WIN64: .seh_savexmm 6, 16
161 ; WIN64: .seh_savexmm 7, 32
162 ; WIN64: .seh_endprologue
163 ; WIN64: movaps -48(%rbp), %xmm6 # 16-byte Reload
164 ; WIN64: movaps -32(%rbp), %xmm7 # 16-byte Reload
165 ; WIN64: leaq -16(%rbp), %rsp
170 ; WIN64: .seh_endproc