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-NOT: .seh_proc foo0
12 ; WIN64-NOT: .seh_endprologue
14 ; WIN64-NOT: .seh_endproc
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
50 define i32 @foo3(i32 %f_arg, i32 %e_arg, i32 %d_arg, i32 %c_arg, i32 %b_arg, i32 %a_arg) uwtable {
58 store i32 %a_arg, ptr %a
59 store i32 %b_arg, ptr %b
60 store i32 %c_arg, ptr %c
61 store i32 %d_arg, ptr %d
62 store i32 %e_arg, ptr %e
63 store i32 %f_arg, ptr %f
64 %tmp = load i32, ptr %a
65 %tmp1 = mul i32 %tmp, 2
66 %tmp2 = load i32, ptr %b
67 %tmp3 = mul i32 %tmp2, 3
68 %tmp4 = add i32 %tmp1, %tmp3
69 %tmp5 = load i32, ptr %c
70 %tmp6 = mul i32 %tmp5, 5
71 %tmp7 = add i32 %tmp4, %tmp6
72 %tmp8 = load i32, ptr %d
73 %tmp9 = mul i32 %tmp8, 7
74 %tmp10 = add i32 %tmp7, %tmp9
75 %tmp11 = load i32, ptr %e
76 %tmp12 = mul i32 %tmp11, 11
77 %tmp13 = add i32 %tmp10, %tmp12
78 %tmp14 = load i32, ptr %f
79 %tmp15 = mul i32 %tmp14, 13
80 %tmp16 = add i32 %tmp13, %tmp15
84 ; WIN64: .seh_proc foo3
85 ; NORM: subq $16, %rsp
86 ; ATOM: leaq -16(%rsp), %rsp
87 ; WIN64: .seh_stackalloc 16
88 ; WIN64: .seh_endprologue
89 ; WIN64: addq $16, %rsp
94 ; Check emission of eh handler and handler data
95 declare i32 @_d_eh_personality(i32, i32, i64, ptr, ptr)
96 declare void @_d_eh_resume_unwind(ptr)
100 define i32 @foo4() #0 personality ptr @_d_eh_personality {
102 %step = alloca i32, align 4
103 store i32 0, ptr %step
104 %tmp = load i32, ptr %step
106 %tmp1 = invoke i32 @bar()
107 to label %finally unwind label %landingpad
110 store i32 1, ptr %step
111 br label %endtryfinally
114 %landing_pad = landingpad { ptr, i32 }
116 %tmp3 = extractvalue { ptr, i32 } %landing_pad, 0
117 store i32 2, ptr %step
118 call void @_d_eh_resume_unwind(ptr %tmp3)
122 %tmp10 = load i32, ptr %step
126 ; WIN64: .seh_proc foo4
127 ; WIN64: .seh_handler _d_eh_personality, @unwind, @except
128 ; NORM: subq $40, %rsp
129 ; ATOM: leaq -40(%rsp), %rsp
130 ; WIN64: .seh_stackalloc 40
131 ; WIN64: .seh_endprologue
132 ; WIN64: addq $40, %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 %rbp
150 ; WIN64: .seh_pushreg %rdi
152 ; WIN64: .seh_pushreg %rbx
153 ; NORM: subq $96, %rsp
154 ; ATOM: leaq -96(%rsp), %rsp
155 ; WIN64: .seh_stackalloc 96
156 ; WIN64: leaq 96(%rsp), %rbp
157 ; WIN64: .seh_setframe %rbp, 96
158 ; WIN64: movaps %xmm7, -16(%rbp) # 16-byte Spill
159 ; WIN64: .seh_savexmm %xmm7, 80
160 ; WIN64: movaps %xmm6, -32(%rbp) # 16-byte Spill
161 ; WIN64: .seh_savexmm %xmm6, 64
162 ; WIN64: .seh_endprologue
163 ; WIN64: andq $-64, %rsp
164 ; WIN64: movaps -32(%rbp), %xmm6 # 16-byte Reload
165 ; WIN64: movaps -16(%rbp), %xmm7 # 16-byte Reload
166 ; WIN64: movq %rbp, %rsp
171 ; WIN64: .seh_endproc