Add segmented stack support for DragonFlyBSD.
[oota-llvm.git] / test / CodeGen / X86 / segmented-stacks.ll
1 ; RUN: llc < %s -mcpu=generic -mtriple=i686-linux -verify-machineinstrs | FileCheck %s -check-prefix=X32-Linux
2 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux  -verify-machineinstrs | FileCheck %s -check-prefix=X64-Linux
3 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux-gnux32 -verify-machineinstrs | FileCheck %s -check-prefix=X32ABI
4 ; RUN: llc < %s -mcpu=generic -mtriple=i686-darwin -verify-machineinstrs | FileCheck %s -check-prefix=X32-Darwin
5 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-darwin -verify-machineinstrs | FileCheck %s -check-prefix=X64-Darwin
6 ; RUN: llc < %s -mcpu=generic -mtriple=i686-mingw32 -verify-machineinstrs | FileCheck %s -check-prefix=X32-MinGW
7 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-freebsd -verify-machineinstrs | FileCheck %s -check-prefix=X64-FreeBSD
8 ; RUN: llc < %s -mcpu=generic -mtriple=i686-dragonfly -verify-machineinstrs | FileCheck %s -check-prefix=X32-DFlyBSD
9 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-dragonfly -verify-machineinstrs | FileCheck %s -check-prefix=X64-DFlyBSD
10 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-mingw32 -verify-machineinstrs | FileCheck %s -check-prefix=X64-MinGW
11
12 ; We used to crash with filetype=obj
13 ; RUN: llc < %s -mcpu=generic -mtriple=i686-linux -filetype=obj
14 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux -filetype=obj
15 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux-gnux32 -filetype=obj
16 ; RUN: llc < %s -mcpu=generic -mtriple=i686-darwin -filetype=obj
17 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-darwin -filetype=obj
18 ; RUN: llc < %s -mcpu=generic -mtriple=i686-mingw32 -filetype=obj
19 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-freebsd -filetype=obj
20 ; RUN: llc < %s -mcpu=generic -mtriple=i686-dragonfly -filetype=obj
21 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-dragonfly -filetype=obj
22 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-mingw32 -filetype=obj
23
24 ; RUN: not llc < %s -mcpu=generic -mtriple=x86_64-solaris 2> %t.log
25 ; RUN: FileCheck %s -input-file=%t.log -check-prefix=X64-Solaris
26 ; RUN: not llc < %s -mcpu=generic -mtriple=i686-freebsd 2> %t.log
27 ; RUN: FileCheck %s -input-file=%t.log -check-prefix=X32-FreeBSD
28
29 ; X64-Solaris: Segmented stacks not supported on this platform
30 ; X32-FreeBSD: Segmented stacks not supported on FreeBSD i386
31
32 ; Just to prevent the alloca from being optimized away
33 declare void @dummy_use(i32*, i32)
34
35 define void @test_basic() #0 {
36         %mem = alloca i32, i32 10
37         call void @dummy_use (i32* %mem, i32 10)
38         ret void
39
40 ; X32-Linux-LABEL:       test_basic:
41
42 ; X32-Linux:       cmpl %gs:48, %esp
43 ; X32-Linux-NEXT:  ja      .LBB0_2
44
45 ; X32-Linux:       pushl $0
46 ; X32-Linux-NEXT:  pushl $60
47 ; X32-Linux-NEXT:  calll __morestack
48 ; X32-Linux-NEXT:  ret
49
50 ; X64-Linux-LABEL:       test_basic:
51
52 ; X64-Linux:       cmpq %fs:112, %rsp
53 ; X64-Linux-NEXT:  ja      .LBB0_2
54
55 ; X64-Linux:       movabsq $40, %r10
56 ; X64-Linux-NEXT:  movabsq $0, %r11
57 ; X64-Linux-NEXT:  callq __morestack
58 ; X64-Linux-NEXT:  ret
59
60 ; X32ABI-LABEL:       test_basic:
61
62 ; X32ABI:       cmpl %fs:64, %esp
63 ; X32ABI-NEXT:  ja      .LBB0_2
64
65 ; X32ABI:       movl $40, %r10d
66 ; X32ABI-NEXT:  movl $0, %r11d
67 ; X32ABI-NEXT:  callq __morestack
68 ; X32ABI-NEXT:  ret
69
70 ; X32-Darwin-LABEL:      test_basic:
71
72 ; X32-Darwin:      movl $432, %ecx
73 ; X32-Darwin-NEXT: cmpl %gs:(%ecx), %esp
74 ; X32-Darwin-NEXT: ja      LBB0_2
75
76 ; X32-Darwin:      pushl $0
77 ; X32-Darwin-NEXT: pushl $60
78 ; X32-Darwin-NEXT: calll ___morestack
79 ; X32-Darwin-NEXT: ret
80
81 ; X64-Darwin-LABEL:      test_basic:
82
83 ; X64-Darwin:      cmpq %gs:816, %rsp
84 ; X64-Darwin-NEXT: ja      LBB0_2
85
86 ; X64-Darwin:      movabsq $40, %r10
87 ; X64-Darwin-NEXT: movabsq $0, %r11
88 ; X64-Darwin-NEXT: callq ___morestack
89 ; X64-Darwin-NEXT: ret
90
91 ; X32-MinGW-LABEL:       test_basic:
92
93 ; X32-MinGW:       cmpl %fs:20, %esp
94 ; X32-MinGW-NEXT:  ja      LBB0_2
95
96 ; X32-MinGW:       pushl $0
97 ; X32-MinGW-NEXT:  pushl $48
98 ; X32-MinGW-NEXT:  calll ___morestack
99 ; X32-MinGW-NEXT:  ret
100
101 ; X64-MinGW-LABEL:       test_basic:
102
103 ; X64-MinGW:       cmpq %gs:40, %rsp
104 ; X64-MinGW-NEXT:  ja      .LBB0_2
105
106 ; X64-MinGW:       movabsq $72, %r10
107 ; X64-MinGW-NEXT:  movabsq $32, %r11
108 ; X64-MinGW-NEXT:  callq __morestack
109 ; X64-MinGW-NEXT:  retq
110
111 ; X64-FreeBSD-LABEL:       test_basic:
112
113 ; X64-FreeBSD:       cmpq %fs:24, %rsp
114 ; X64-FreeBSD-NEXT:  ja      .LBB0_2
115
116 ; X64-FreeBSD:       movabsq $40, %r10
117 ; X64-FreeBSD-NEXT:  movabsq $0, %r11
118 ; X64-FreeBSD-NEXT:  callq __morestack
119 ; X64-FreeBSD-NEXT:  ret
120
121 ; X32-DFlyBSD-LABEL:       test_basic:
122
123 ; X32-DFlyBSD:       cmpl %fs:16, %esp
124 ; X32-DFlyBSD-NEXT:  ja      .LBB0_2
125
126 ; X32-DFlyBSD:       pushl $0
127 ; X32-DFlyBSD-NEXT:  pushl $48
128 ; X32-DFlyBSD-NEXT:  calll __morestack
129 ; X32-DFlyBSD-NEXT:  ret
130
131 ; X64-DFlyBSD-LABEL:       test_basic:
132
133 ; X64-DFlyBSD:       cmpq %fs:32, %rsp
134 ; X64-DFlyBSD-NEXT:  ja      .LBB0_2
135
136 ; X64-DFlyBSD:       movabsq $40, %r10
137 ; X64-DFlyBSD-NEXT:  movabsq $0, %r11
138 ; X64-DFlyBSD-NEXT:  callq __morestack
139 ; X64-DFlyBSD-NEXT:  ret
140
141 }
142
143 define i32 @test_nested(i32 * nest %closure, i32 %other) #0 {
144        %addend = load i32 * %closure
145        %result = add i32 %other, %addend
146        %mem = alloca i32, i32 10
147        call void @dummy_use (i32* %mem, i32 10)
148        ret i32 %result
149
150 ; X32-Linux:       cmpl %gs:48, %esp
151 ; X32-Linux-NEXT:  ja      .LBB1_2
152
153 ; X32-Linux:       pushl $4
154 ; X32-Linux-NEXT:  pushl $60
155 ; X32-Linux-NEXT:  calll __morestack
156 ; X32-Linux-NEXT:  ret
157
158 ; X64-Linux:       cmpq %fs:112, %rsp
159 ; X64-Linux-NEXT:  ja      .LBB1_2
160
161 ; X64-Linux:       movq %r10, %rax
162 ; X64-Linux-NEXT:  movabsq $56, %r10
163 ; X64-Linux-NEXT:  movabsq $0, %r11
164 ; X64-Linux-NEXT:  callq __morestack
165 ; X64-Linux-NEXT:  ret
166 ; X64-Linux-NEXT:  movq %rax, %r10
167
168 ; X32ABI:       cmpl %fs:64, %esp
169 ; X32ABI-NEXT:  ja      .LBB1_2
170
171 ; X32ABI:       movl %r10d, %eax
172 ; X32ABI-NEXT:  movl $56, %r10d
173 ; X32ABI-NEXT:  movl $0, %r11d
174 ; X32ABI-NEXT:  callq __morestack
175 ; X32ABI-NEXT:  ret
176 ; X32ABI-NEXT:  movq %rax, %r10
177
178 ; X32-Darwin:      movl $432, %edx
179 ; X32-Darwin-NEXT: cmpl %gs:(%edx), %esp
180 ; X32-Darwin-NEXT: ja      LBB1_2
181
182 ; X32-Darwin:      pushl $4
183 ; X32-Darwin-NEXT: pushl $60
184 ; X32-Darwin-NEXT: calll ___morestack
185 ; X32-Darwin-NEXT: ret
186
187 ; X64-Darwin:      cmpq %gs:816, %rsp
188 ; X64-Darwin-NEXT: ja      LBB1_2
189
190 ; X64-Darwin:      movq %r10, %rax
191 ; X64-Darwin-NEXT: movabsq $56, %r10
192 ; X64-Darwin-NEXT: movabsq $0, %r11
193 ; X64-Darwin-NEXT: callq ___morestack
194 ; X64-Darwin-NEXT: ret
195 ; X64-Darwin-NEXT: movq %rax, %r10
196
197 ; X32-MinGW:       cmpl %fs:20, %esp
198 ; X32-MinGW-NEXT:  ja      LBB1_2
199
200 ; X32-MinGW:       pushl $4
201 ; X32-MinGW-NEXT:  pushl $52
202 ; X32-MinGW-NEXT:  calll ___morestack
203 ; X32-MinGW-NEXT:  ret
204
205 ; X64-MinGW-LABEL: test_nested:
206 ; X64-MinGW:       cmpq %gs:40, %rsp
207 ; X64-MinGW-NEXT:  ja      .LBB1_2
208
209 ; X64-MinGW:       movq %r10, %rax
210 ; X64-MinGW-NEXT:  movabsq $88, %r10
211 ; X64-MinGW-NEXT:  movabsq $32, %r11
212 ; X64-MinGW-NEXT:  callq __morestack
213 ; X64-MinGW-NEXT:  retq
214 ; X64-MinGW-NEXT:  movq %rax, %r10
215
216 ; X64-FreeBSD:       cmpq %fs:24, %rsp
217 ; X64-FreeBSD-NEXT:  ja      .LBB1_2
218
219 ; X64-FreeBSD:       movq %r10, %rax
220 ; X64-FreeBSD-NEXT:  movabsq $56, %r10
221 ; X64-FreeBSD-NEXT:  movabsq $0, %r11
222 ; X64-FreeBSD-NEXT:  callq __morestack
223 ; X64-FreeBSD-NEXT:  ret
224 ; X64-FreeBSD-NEXT:  movq %rax, %r10
225
226 ; X32-DFlyBSD:       cmpl %fs:16, %esp
227 ; X32-DFlyBSD-NEXT:  ja      .LBB1_2
228
229 ; X32-DFlyBSD:       pushl $4
230 ; X32-DFlyBSD-NEXT:  pushl $52
231 ; X32-DFlyBSD-NEXT:  calll __morestack
232 ; X32-DFlyBSD-NEXT:  ret
233
234 ; X64-DFlyBSD:       cmpq %fs:32, %rsp
235 ; X64-DFlyBSD-NEXT:  ja      .LBB1_2
236
237 ; X64-DFlyBSD:       movq %r10, %rax
238 ; X64-DFlyBSD-NEXT:  movabsq $56, %r10
239 ; X64-DFlyBSD-NEXT:  movabsq $0, %r11
240 ; X64-DFlyBSD-NEXT:  callq __morestack
241 ; X64-DFlyBSD-NEXT:  ret
242 ; X64-DFlyBSD-NEXT:  movq %rax, %r10
243
244 }
245
246 define void @test_large() #0 {
247         %mem = alloca i32, i32 10000
248         call void @dummy_use (i32* %mem, i32 0)
249         ret void
250
251 ; X32-Linux:       leal -40012(%esp), %ecx
252 ; X32-Linux-NEXT:  cmpl %gs:48, %ecx
253 ; X32-Linux-NEXT:  ja      .LBB2_2
254
255 ; X32-Linux:       pushl $0
256 ; X32-Linux-NEXT:  pushl $40012
257 ; X32-Linux-NEXT:  calll __morestack
258 ; X32-Linux-NEXT:  ret
259
260 ; X64-Linux:       leaq -40008(%rsp), %r11
261 ; X64-Linux-NEXT:  cmpq %fs:112, %r11
262 ; X64-Linux-NEXT:  ja      .LBB2_2
263
264 ; X64-Linux:       movabsq $40008, %r10
265 ; X64-Linux-NEXT:  movabsq $0, %r11
266 ; X64-Linux-NEXT:  callq __morestack
267 ; X64-Linux-NEXT:  ret
268
269 ; X32ABI:       leal -40008(%rsp), %r11d
270 ; X32ABI-NEXT:  cmpl %fs:64, %r11d
271 ; X32ABI-NEXT:  ja      .LBB2_2
272
273 ; X32ABI:       movl $40008, %r10d
274 ; X32ABI-NEXT:  movl $0, %r11d
275 ; X32ABI-NEXT:  callq __morestack
276 ; X32ABI-NEXT:  ret
277
278 ; X32-Darwin:      leal -40012(%esp), %ecx
279 ; X32-Darwin-NEXT: movl $432, %eax
280 ; X32-Darwin-NEXT: cmpl %gs:(%eax), %ecx
281 ; X32-Darwin-NEXT: ja      LBB2_2
282
283 ; X32-Darwin:      pushl $0
284 ; X32-Darwin-NEXT: pushl $40012
285 ; X32-Darwin-NEXT: calll ___morestack
286 ; X32-Darwin-NEXT: ret
287
288 ; X64-Darwin:      leaq -40008(%rsp), %r11
289 ; X64-Darwin-NEXT: cmpq %gs:816, %r11
290 ; X64-Darwin-NEXT: ja      LBB2_2
291
292 ; X64-Darwin:      movabsq $40008, %r10
293 ; X64-Darwin-NEXT: movabsq $0, %r11
294 ; X64-Darwin-NEXT: callq ___morestack
295 ; X64-Darwin-NEXT: ret
296
297 ; X32-MinGW:       leal -40008(%esp), %ecx
298 ; X32-MinGW-NEXT:  cmpl %fs:20, %ecx
299 ; X32-MinGW-NEXT:  ja      LBB2_2
300
301 ; X32-MinGW:       pushl $0
302 ; X32-MinGW-NEXT:  pushl $40008
303 ; X32-MinGW-NEXT:  calll ___morestack
304 ; X32-MinGW-NEXT:  ret
305
306 ; X64-MinGW-LABEL: test_large:
307 ; X64-MinGW:       leaq -40040(%rsp), %r11
308 ; X64-MinGW-NEXT:  cmpq %gs:40, %r11
309 ; X64-MinGW-NEXT:  ja      .LBB2_2
310
311 ; X64-MinGW:       movabsq $40040, %r10
312 ; X64-MinGW-NEXT:  movabsq $32, %r11
313 ; X64-MinGW-NEXT:  callq __morestack
314 ; X64-MinGW-NEXT:  retq
315
316 ; X64-FreeBSD:       leaq -40008(%rsp), %r11
317 ; X64-FreeBSD-NEXT:  cmpq %fs:24, %r11
318 ; X64-FreeBSD-NEXT:  ja      .LBB2_2
319
320 ; X64-FreeBSD:       movabsq $40008, %r10
321 ; X64-FreeBSD-NEXT:  movabsq $0, %r11
322 ; X64-FreeBSD-NEXT:  callq __morestack
323 ; X64-FreeBSD-NEXT:  ret
324
325 ; X32-DFlyBSD:       leal -40008(%esp), %ecx
326 ; X32-DFlyBSD-NEXT:  cmpl %fs:16, %ecx
327 ; X32-DFlyBSD-NEXT:  ja      .LBB2_2
328
329 ; X32-DFlyBSD:       pushl $0
330 ; X32-DFlyBSD-NEXT:  pushl $40008
331 ; X32-DFlyBSD-NEXT:  calll __morestack
332 ; X32-DFlyBSD-NEXT:  ret
333
334 ; X64-DFlyBSD:       leaq -40008(%rsp), %r11
335 ; X64-DFlyBSD-NEXT:  cmpq %fs:32, %r11
336 ; X64-DFlyBSD-NEXT:  ja      .LBB2_2
337
338 ; X64-DFlyBSD:       movabsq $40008, %r10
339 ; X64-DFlyBSD-NEXT:  movabsq $0, %r11
340 ; X64-DFlyBSD-NEXT:  callq __morestack
341 ; X64-DFlyBSD-NEXT:  ret
342
343 }
344
345 define fastcc void @test_fastcc() #0 {
346         %mem = alloca i32, i32 10
347         call void @dummy_use (i32* %mem, i32 10)
348         ret void
349
350 ; X32-Linux-LABEL:       test_fastcc:
351
352 ; X32-Linux:       cmpl %gs:48, %esp
353 ; X32-Linux-NEXT:  ja      .LBB3_2
354
355 ; X32-Linux:       pushl $0
356 ; X32-Linux-NEXT:  pushl $60
357 ; X32-Linux-NEXT:  calll __morestack
358 ; X32-Linux-NEXT:  ret
359
360 ; X64-Linux-LABEL:       test_fastcc:
361
362 ; X64-Linux:       cmpq %fs:112, %rsp
363 ; X64-Linux-NEXT:  ja      .LBB3_2
364
365 ; X64-Linux:       movabsq $40, %r10
366 ; X64-Linux-NEXT:  movabsq $0, %r11
367 ; X64-Linux-NEXT:  callq __morestack
368 ; X64-Linux-NEXT:  ret
369
370 ; X32ABI-LABEL:       test_fastcc:
371
372 ; X32ABI:       cmpl %fs:64, %esp
373 ; X32ABI-NEXT:  ja      .LBB3_2
374
375 ; X32ABI:       movl $40, %r10d
376 ; X32ABI-NEXT:  movl $0, %r11d
377 ; X32ABI-NEXT:  callq __morestack
378 ; X32ABI-NEXT:  ret
379
380 ; X32-Darwin-LABEL:      test_fastcc:
381
382 ; X32-Darwin:      movl $432, %eax
383 ; X32-Darwin-NEXT: cmpl %gs:(%eax), %esp
384 ; X32-Darwin-NEXT: ja      LBB3_2
385
386 ; X32-Darwin:      pushl $0
387 ; X32-Darwin-NEXT: pushl $60
388 ; X32-Darwin-NEXT: calll ___morestack
389 ; X32-Darwin-NEXT: ret
390
391 ; X64-Darwin-LABEL:      test_fastcc:
392
393 ; X64-Darwin:      cmpq %gs:816, %rsp
394 ; X64-Darwin-NEXT: ja      LBB3_2
395
396 ; X64-Darwin:      movabsq $40, %r10
397 ; X64-Darwin-NEXT: movabsq $0, %r11
398 ; X64-Darwin-NEXT: callq ___morestack
399 ; X64-Darwin-NEXT: ret
400
401 ; X32-MinGW-LABEL:       test_fastcc:
402
403 ; X32-MinGW:       cmpl %fs:20, %esp
404 ; X32-MinGW-NEXT:  ja      LBB3_2
405
406 ; X32-MinGW:       pushl $0
407 ; X32-MinGW-NEXT:  pushl $48
408 ; X32-MinGW-NEXT:  calll ___morestack
409 ; X32-MinGW-NEXT:  ret
410
411 ; X64-MinGW-LABEL:       test_fastcc:
412
413 ; X64-MinGW:       cmpq %gs:40, %rsp
414 ; X64-MinGW-NEXT:  ja      .LBB3_2
415
416 ; X64-MinGW:       movabsq $72, %r10
417 ; X64-MinGW-NEXT:  movabsq $32, %r11
418 ; X64-MinGW-NEXT:  callq __morestack
419 ; X64-MinGW-NEXT:  retq
420
421 ; X64-FreeBSD-LABEL:       test_fastcc:
422
423 ; X64-FreeBSD:       cmpq %fs:24, %rsp
424 ; X64-FreeBSD-NEXT:  ja      .LBB3_2
425
426 ; X64-FreeBSD:       movabsq $40, %r10
427 ; X64-FreeBSD-NEXT:  movabsq $0, %r11
428 ; X64-FreeBSD-NEXT:  callq __morestack
429 ; X64-FreeBSD-NEXT:  ret
430
431 ; X32-DFlyBSD-LABEL:       test_fastcc:
432
433 ; X32-DFlyBSD:       cmpl %fs:16, %esp
434 ; X32-DFlyBSD-NEXT:  ja      .LBB3_2
435
436 ; X32-DFlyBSD:       pushl $0
437 ; X32-DFlyBSD-NEXT:  pushl $48
438 ; X32-DFlyBSD-NEXT:  calll __morestack
439 ; X32-DFlyBSD-NEXT:  ret
440
441 ; X64-DFlyBSD-LABEL:       test_fastcc:
442
443 ; X64-DFlyBSD:       cmpq %fs:32, %rsp
444 ; X64-DFlyBSD-NEXT:  ja      .LBB3_2
445
446 ; X64-DFlyBSD:       movabsq $40, %r10
447 ; X64-DFlyBSD-NEXT:  movabsq $0, %r11
448 ; X64-DFlyBSD-NEXT:  callq __morestack
449 ; X64-DFlyBSD-NEXT:  ret
450
451 }
452
453 define fastcc void @test_fastcc_large() #0 {
454         %mem = alloca i32, i32 10000
455         call void @dummy_use (i32* %mem, i32 0)
456         ret void
457
458 ; X32-Linux-LABEL:       test_fastcc_large:
459
460 ; X32-Linux:       leal -40012(%esp), %eax
461 ; X32-Linux-NEXT:  cmpl %gs:48, %eax
462 ; X32-Linux-NEXT:  ja      .LBB4_2
463
464 ; X32-Linux:       pushl $0
465 ; X32-Linux-NEXT:  pushl $40012
466 ; X32-Linux-NEXT:  calll __morestack
467 ; X32-Linux-NEXT:  ret
468
469 ; X64-Linux-LABEL:       test_fastcc_large:
470
471 ; X64-Linux:       leaq -40008(%rsp), %r11
472 ; X64-Linux-NEXT:  cmpq %fs:112, %r11
473 ; X64-Linux-NEXT:  ja      .LBB4_2
474
475 ; X64-Linux:       movabsq $40008, %r10
476 ; X64-Linux-NEXT:  movabsq $0, %r11
477 ; X64-Linux-NEXT:  callq __morestack
478 ; X64-Linux-NEXT:  ret
479
480 ; X32ABI-LABEL:       test_fastcc_large:
481
482 ; X32ABI:       leal -40008(%rsp), %r11d
483 ; X32ABI-NEXT:  cmpl %fs:64, %r11d
484 ; X32ABI-NEXT:  ja      .LBB4_2
485
486 ; X32ABI:       movl $40008, %r10d
487 ; X32ABI-NEXT:  movl $0, %r11d
488 ; X32ABI-NEXT:  callq __morestack
489 ; X32ABI-NEXT:  ret
490
491 ; X32-Darwin-LABEL:      test_fastcc_large:
492
493 ; X32-Darwin:      leal -40012(%esp), %eax
494 ; X32-Darwin-NEXT: movl $432, %ecx
495 ; X32-Darwin-NEXT: cmpl %gs:(%ecx), %eax
496 ; X32-Darwin-NEXT: ja      LBB4_2
497
498 ; X32-Darwin:      pushl $0
499 ; X32-Darwin-NEXT: pushl $40012
500 ; X32-Darwin-NEXT: calll ___morestack
501 ; X32-Darwin-NEXT: ret
502
503 ; X64-Darwin-LABEL:      test_fastcc_large:
504
505 ; X64-Darwin:      leaq -40008(%rsp), %r11
506 ; X64-Darwin-NEXT: cmpq %gs:816, %r11
507 ; X64-Darwin-NEXT: ja      LBB4_2
508
509 ; X64-Darwin:      movabsq $40008, %r10
510 ; X64-Darwin-NEXT: movabsq $0, %r11
511 ; X64-Darwin-NEXT: callq ___morestack
512 ; X64-Darwin-NEXT: ret
513
514 ; X32-MinGW-LABEL:       test_fastcc_large:
515
516 ; X32-MinGW:       leal -40008(%esp), %eax
517 ; X32-MinGW-NEXT:  cmpl %fs:20, %eax
518 ; X32-MinGW-NEXT:  ja      LBB4_2
519
520 ; X32-MinGW:       pushl $0
521 ; X32-MinGW-NEXT:  pushl $40008
522 ; X32-MinGW-NEXT:  calll ___morestack
523 ; X32-MinGW-NEXT:  ret
524
525 ; X64-MinGW-LABEL:       test_fastcc_large:
526
527 ; X64-MinGW:       leaq -40040(%rsp), %r11
528 ; X64-MinGW-NEXT:  cmpq %gs:40, %r11
529 ; X64-MinGW-NEXT:  ja      .LBB4_2
530
531 ; X64-MinGW:       movabsq $40040, %r10
532 ; X64-MinGW-NEXT:  movabsq $32, %r11
533 ; X64-MinGW-NEXT:  callq __morestack
534 ; X64-MinGW-NEXT:  retq
535
536 ; X64-FreeBSD-LABEL:       test_fastcc_large:
537
538 ; X64-FreeBSD:       leaq -40008(%rsp), %r11
539 ; X64-FreeBSD-NEXT:  cmpq %fs:24, %r11
540 ; X64-FreeBSD-NEXT:  ja      .LBB4_2
541
542 ; X64-FreeBSD:       movabsq $40008, %r10
543 ; X64-FreeBSD-NEXT:  movabsq $0, %r11
544 ; X64-FreeBSD-NEXT:  callq __morestack
545 ; X64-FreeBSD-NEXT:  ret
546
547 ; X32-DFlyBSD-LABEL:       test_fastcc_large:
548
549 ; X32-DFlyBSD:       leal -40008(%esp), %eax
550 ; X32-DFlyBSD-NEXT:  cmpl %fs:16, %eax
551 ; X32-DFlyBSD-NEXT:  ja      .LBB4_2
552
553 ; X32-DFlyBSD:       pushl $0
554 ; X32-DFlyBSD-NEXT:  pushl $40008
555 ; X32-DFlyBSD-NEXT:  calll __morestack
556 ; X32-DFlyBSD-NEXT:  ret
557
558 ; X64-DFlyBSD-LABEL:       test_fastcc_large:
559
560 ; X64-DFlyBSD:       leaq -40008(%rsp), %r11
561 ; X64-DFlyBSD-NEXT:  cmpq %fs:32, %r11
562 ; X64-DFlyBSD-NEXT:  ja      .LBB4_2
563
564 ; X64-DFlyBSD:       movabsq $40008, %r10
565 ; X64-DFlyBSD-NEXT:  movabsq $0, %r11
566 ; X64-DFlyBSD-NEXT:  callq __morestack
567 ; X64-DFlyBSD-NEXT:  ret
568
569 }
570
571 define fastcc void @test_fastcc_large_with_ecx_arg(i32 %a) #0 {
572         %mem = alloca i32, i32 10000
573         call void @dummy_use (i32* %mem, i32 %a)
574         ret void
575
576 ; This is testing that the Mac implementation preserves ecx
577
578 ; X32-Darwin-LABEL:      test_fastcc_large_with_ecx_arg:
579
580 ; X32-Darwin:      leal -40012(%esp), %eax
581 ; X32-Darwin-NEXT: pushl %ecx
582 ; X32-Darwin-NEXT: movl $432, %ecx
583 ; X32-Darwin-NEXT: cmpl %gs:(%ecx), %eax
584 ; X32-Darwin-NEXT: popl %ecx
585 ; X32-Darwin-NEXT: ja      LBB5_2
586
587 ; X32-Darwin:      pushl $0
588 ; X32-Darwin-NEXT: pushl $40012
589 ; X32-Darwin-NEXT: calll ___morestack
590 ; X32-Darwin-NEXT: ret
591
592 }
593
594 define void @test_nostack() #0 {
595         ret void
596
597 ; X32-Linux-LABEL: test_nostack:
598 ; X32-Linux-NOT:   calll __morestack
599
600 ; X64-Linux-LABEL: test_nostack:
601 ; X32-Linux-NOT:   callq __morestack
602
603 ; X32ABI-LABEL: test_nostack:
604 ; X32ABI-NOT:   callq __morestack
605
606 ; X32-Darwin-LABEL: test_nostack:
607 ; X32-Darwin-NOT:   calll __morestack
608
609 ; X64-Darwin-LABEL: test_nostack:
610 ; X64-Darwin-NOT:   callq __morestack
611
612 ; X32-MinGW-LABEL: test_nostack:
613 ; X32-MinGW-NOT:   calll __morestack
614
615 ; X64-MinGW-LABEL: test_nostack:
616 ; X64-MinGW-NOT:   callq __morestack
617
618 ; X64-FreeBSD-LABEL: test_nostack:
619 ; X64-FreeBSD-NOT:   callq __morestack
620
621 ; X32-DFlyBSD-LABEL: test_nostack:
622 ; X32-DFlyBSD-NOT:   calll __morestack
623
624 ; X64-DFlyBSD-LABEL: test_nostack:
625 ; X64-DFlyBSD-NOT:   callq __morestack
626 }
627
628 attributes #0 = { "split-stack" }