1 ; RUN: llc < %s -O0 -mattr=sse2 -mtriple=x86_64-pc-windows-itanium | FileCheck %s -check-prefix=WIN64 -check-prefix=NORM
2 ; RUN: llc < %s -O0 -mattr=sse2 -mtriple=x86_64-pc-mingw32 | FileCheck %s -check-prefix=WIN64 -check-prefix=NORM
3 ; RUN: llc < %s -O0 -mattr=sse2 -mtriple=x86_64-pc-mingw32 -mcpu=atom | FileCheck %s -check-prefix=WIN64 -check-prefix=ATOM
5 ; Check function without prolog
6 define void @foo0() uwtable {
11 ; WIN64: .seh_proc foo0
12 ; WIN64: .seh_endprologue
16 ; Checks a small stack allocation
17 define void @foo1() uwtable {
19 %baz = alloca [2000 x i16], align 2
23 ; WIN64: .seh_proc foo1
24 ; NORM: subq $4000, %rsp
25 ; ATOM: leaq -4000(%rsp), %rsp
26 ; WIN64: .seh_stackalloc 4000
27 ; WIN64: .seh_endprologue
28 ; WIN64: addq $4000, %rsp
32 ; Checks a stack allocation requiring call to __chkstk/___chkstk_ms
33 define void @foo2() uwtable {
35 %baz = alloca [4000 x i16], align 2
39 ; WIN64: .seh_proc foo2
40 ; WIN64: movl $8000, %eax
41 ; WIN64: callq {{__chkstk|___chkstk_ms}}
42 ; WIN64: subq %rax, %rsp
43 ; WIN64: .seh_stackalloc 8000
44 ; WIN64: .seh_endprologue
45 ; WIN64: addq $8000, %rsp
51 define i32 @foo3(i32 %f_arg, i32 %e_arg, i32 %d_arg, i32 %c_arg, i32 %b_arg, i32 %a_arg) uwtable {
59 store i32 %a_arg, i32* %a
60 store i32 %b_arg, i32* %b
61 store i32 %c_arg, i32* %c
62 store i32 %d_arg, i32* %d
63 store i32 %e_arg, i32* %e
64 store i32 %f_arg, i32* %f
65 %tmp = load i32, i32* %a
66 %tmp1 = mul i32 %tmp, 2
67 %tmp2 = load i32, i32* %b
68 %tmp3 = mul i32 %tmp2, 3
69 %tmp4 = add i32 %tmp1, %tmp3
70 %tmp5 = load i32, i32* %c
71 %tmp6 = mul i32 %tmp5, 5
72 %tmp7 = add i32 %tmp4, %tmp6
73 %tmp8 = load i32, i32* %d
74 %tmp9 = mul i32 %tmp8, 7
75 %tmp10 = add i32 %tmp7, %tmp9
76 %tmp11 = load i32, i32* %e
77 %tmp12 = mul i32 %tmp11, 11
78 %tmp13 = add i32 %tmp10, %tmp12
79 %tmp14 = load i32, i32* %f
80 %tmp15 = mul i32 %tmp14, 13
81 %tmp16 = add i32 %tmp13, %tmp15
85 ; WIN64: .seh_proc foo3
87 ; WIN64: .seh_pushreg 6
88 ; NORM: subq $24, %rsp
89 ; ATOM: leaq -24(%rsp), %rsp
90 ; WIN64: .seh_stackalloc 24
91 ; WIN64: .seh_endprologue
92 ; WIN64: addq $24, %rsp
98 ; Check emission of eh handler and handler data
99 declare i32 @_d_eh_personality(i32, i32, i64, i8*, i8*)
100 declare void @_d_eh_resume_unwind(i8*)
104 define i32 @foo4() #0 personality i32 (i32, i32, i64, i8*, i8*)* @_d_eh_personality {
106 %step = alloca i32, align 4
107 store i32 0, i32* %step
108 %tmp = load i32, i32* %step
110 %tmp1 = invoke i32 @bar()
111 to label %finally unwind label %landingpad
114 store i32 1, i32* %step
115 br label %endtryfinally
118 %landing_pad = landingpad { i8*, i32 }
120 %tmp3 = extractvalue { i8*, i32 } %landing_pad, 0
121 store i32 2, i32* %step
122 call void @_d_eh_resume_unwind(i8* %tmp3)
126 %tmp10 = load i32, i32* %step
130 ; WIN64: .seh_proc foo4
131 ; WIN64: .seh_handler _d_eh_personality, @unwind, @except
132 ; NORM: subq $56, %rsp
133 ; ATOM: leaq -56(%rsp), %rsp
134 ; WIN64: .seh_stackalloc 56
135 ; WIN64: .seh_endprologue
136 ; WIN64: addq $56, %rsp
138 ; WIN64: .seh_handlerdata
139 ; WIN64: .seh_endproc
142 ; Check stack re-alignment and xmm spilling
143 define void @foo5() uwtable {
145 %s = alloca i32, align 64
146 call void asm sideeffect "", "~{rbx},~{rdi},~{xmm6},~{xmm7}"()
150 ; WIN64: .seh_proc foo5
152 ; WIN64: .seh_pushreg 5
154 ; WIN64: .seh_pushreg 7
156 ; WIN64: .seh_pushreg 3
157 ; NORM: subq $96, %rsp
158 ; ATOM: leaq -96(%rsp), %rsp
159 ; WIN64: .seh_stackalloc 96
160 ; WIN64: leaq 96(%rsp), %rbp
161 ; WIN64: .seh_setframe 5, 96
162 ; WIN64: movaps %xmm7, -16(%rbp) # 16-byte Spill
163 ; WIN64: .seh_savexmm 7, 80
164 ; WIN64: movaps %xmm6, -32(%rbp) # 16-byte Spill
165 ; WIN64: .seh_savexmm 6, 64
166 ; WIN64: .seh_endprologue
167 ; WIN64: andq $-64, %rsp
168 ; WIN64: movaps -32(%rbp), %xmm6 # 16-byte Reload
169 ; WIN64: movaps -16(%rbp), %xmm7 # 16-byte Reload
170 ; WIN64: movq %rbp, %rsp
175 ; WIN64: .seh_endproc