• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
4
5; Check function without prolog
6define void @foo0() uwtable {
7entry:
8  ret void
9}
10; WIN64-LABEL: foo0:
11; WIN64-NOT: .seh_proc foo0
12; WIN64-NOT: .seh_endprologue
13; WIN64: ret
14; WIN64-NOT: .seh_endproc
15
16; Checks a small stack allocation
17define void @foo1() uwtable {
18entry:
19  %baz = alloca [2000 x i16], align 2
20  ret void
21}
22; WIN64-LABEL: foo1:
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
29; WIN64: ret
30; WIN64: .seh_endproc
31
32; Checks a stack allocation requiring call to __chkstk/___chkstk_ms
33define void @foo2() uwtable {
34entry:
35  %baz = alloca [4000 x i16], align 2
36  ret void
37}
38; WIN64-LABEL: foo2:
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
46; WIN64: ret
47; WIN64: .seh_endproc
48
49
50define i32 @foo3(i32 %f_arg, i32 %e_arg, i32 %d_arg, i32 %c_arg, i32 %b_arg, i32 %a_arg) uwtable {
51entry:
52  %a = alloca i32
53  %b = alloca i32
54  %c = alloca i32
55  %d = alloca i32
56  %e = alloca i32
57  %f = alloca i32
58  store i32 %a_arg, i32* %a
59  store i32 %b_arg, i32* %b
60  store i32 %c_arg, i32* %c
61  store i32 %d_arg, i32* %d
62  store i32 %e_arg, i32* %e
63  store i32 %f_arg, i32* %f
64  %tmp = load i32, i32* %a
65  %tmp1 = mul i32 %tmp, 2
66  %tmp2 = load i32, i32* %b
67  %tmp3 = mul i32 %tmp2, 3
68  %tmp4 = add i32 %tmp1, %tmp3
69  %tmp5 = load i32, i32* %c
70  %tmp6 = mul i32 %tmp5, 5
71  %tmp7 = add i32 %tmp4, %tmp6
72  %tmp8 = load i32, i32* %d
73  %tmp9 = mul i32 %tmp8, 7
74  %tmp10 = add i32 %tmp7, %tmp9
75  %tmp11 = load i32, i32* %e
76  %tmp12 = mul i32 %tmp11, 11
77  %tmp13 = add i32 %tmp10, %tmp12
78  %tmp14 = load i32, i32* %f
79  %tmp15 = mul i32 %tmp14, 13
80  %tmp16 = add i32 %tmp13, %tmp15
81  ret i32 %tmp16
82}
83; WIN64-LABEL: foo3:
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
90; WIN64: ret
91; WIN64: .seh_endproc
92
93
94; Check emission of eh handler and handler data
95declare i32 @_d_eh_personality(i32, i32, i64, i8*, i8*)
96declare void @_d_eh_resume_unwind(i8*)
97
98declare i32 @bar()
99
100define i32 @foo4() #0 personality i32 (i32, i32, i64, i8*, i8*)* @_d_eh_personality {
101entry:
102  %step = alloca i32, align 4
103  store i32 0, i32* %step
104  %tmp = load i32, i32* %step
105
106  %tmp1 = invoke i32 @bar()
107          to label %finally unwind label %landingpad
108
109finally:
110  store i32 1, i32* %step
111  br label %endtryfinally
112
113landingpad:
114  %landing_pad = landingpad { i8*, i32 }
115          cleanup
116  %tmp3 = extractvalue { i8*, i32 } %landing_pad, 0
117  store i32 2, i32* %step
118  call void @_d_eh_resume_unwind(i8* %tmp3)
119  unreachable
120
121endtryfinally:
122  %tmp10 = load i32, i32* %step
123  ret i32 %tmp10
124}
125; WIN64-LABEL: foo4:
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
133; WIN64: ret
134; WIN64: .seh_handlerdata
135; WIN64: .seh_endproc
136
137
138; Check stack re-alignment and xmm spilling
139define void @foo5() uwtable {
140entry:
141  %s = alloca i32, align 64
142  call void asm sideeffect "", "~{rbx},~{rdi},~{xmm6},~{xmm7}"()
143  ret void
144}
145; WIN64-LABEL: foo5:
146; WIN64: .seh_proc foo5
147; WIN64: pushq %rbp
148; WIN64: .seh_pushreg %rbp
149; WIN64: pushq %rdi
150; WIN64: .seh_pushreg %rdi
151; WIN64: pushq %rbx
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
167; WIN64: popq  %rbx
168; WIN64: popq  %rdi
169; WIN64: popq  %rbp
170; WIN64: retq
171; WIN64: .seh_endproc
172