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 -code-model=large -verify-machineinstrs | FileCheck %s -check-prefix=X64-Linux-Large
4 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux-gnux32 -verify-machineinstrs | FileCheck %s -check-prefix=X32ABI
5 ; RUN: llc < %s -mcpu=generic -mtriple=i686-darwin -verify-machineinstrs | FileCheck %s -check-prefix=X32-Darwin
6 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-darwin -verify-machineinstrs | FileCheck %s -check-prefix=X64-Darwin
7 ; RUN: llc < %s -mcpu=generic -mtriple=i686-mingw32 -verify-machineinstrs | FileCheck %s -check-prefix=X32-MinGW
8 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-freebsd -verify-machineinstrs | FileCheck %s -check-prefix=X64-FreeBSD
9 ; RUN: llc < %s -mcpu=generic -mtriple=i686-dragonfly -verify-machineinstrs | FileCheck %s -check-prefix=X32-DFlyBSD
10 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-dragonfly -verify-machineinstrs | FileCheck %s -check-prefix=X64-DFlyBSD
11 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-mingw32 -verify-machineinstrs | FileCheck %s -check-prefix=X64-MinGW
13 ; We used to crash with filetype=obj
14 ; RUN: llc < %s -mcpu=generic -mtriple=i686-linux -filetype=obj -o /dev/null
15 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux -filetype=obj -o /dev/null
16 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux-gnux32 -filetype=obj -o /dev/null
17 ; RUN: llc < %s -mcpu=generic -mtriple=i686-darwin -filetype=obj -o /dev/null
18 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-darwin -filetype=obj -o /dev/null
19 ; RUN: llc < %s -mcpu=generic -mtriple=i686-mingw32 -filetype=obj -o /dev/null
20 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-freebsd -filetype=obj -o /dev/null
21 ; RUN: llc < %s -mcpu=generic -mtriple=i686-dragonfly -filetype=obj -o /dev/null
22 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-dragonfly -filetype=obj -o /dev/null
23 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-mingw32 -filetype=obj -o /dev/null
25 ; RUN: not llc < %s -mcpu=generic -mtriple=x86_64-solaris 2> %t.log
26 ; RUN: FileCheck %s -input-file=%t.log -check-prefix=X64-Solaris
27 ; RUN: not llc < %s -mcpu=generic -mtriple=i686-freebsd 2> %t.log
28 ; RUN: FileCheck %s -input-file=%t.log -check-prefix=X32-FreeBSD
30 ; X64-Solaris: Segmented stacks not supported on this platform
31 ; X32-FreeBSD: Segmented stacks not supported on FreeBSD i386
33 ; Just to prevent the alloca from being optimized away
34 declare void @dummy_use(i32*, i32)
36 define void @test_basic() #0 {
37 %mem = alloca i32, i32 10
38 call void @dummy_use (i32* %mem, i32 10)
41 ; X32-Linux-LABEL: test_basic:
43 ; X32-Linux: cmpl %gs:48, %esp
44 ; X32-Linux-NEXT: jbe .LBB0_1
47 ; X32-Linux-NEXT: pushl $44
48 ; X32-Linux-NEXT: calll __morestack
51 ; X64-Linux-LABEL: test_basic:
53 ; X64-Linux: cmpq %fs:112, %rsp
54 ; X64-Linux-NEXT: jbe .LBB0_1
56 ; X64-Linux: movabsq $40, %r10
57 ; X64-Linux-NEXT: movabsq $0, %r11
58 ; X64-Linux-NEXT: callq __morestack
61 ; X64-Linux-Large-LABEL: test_basic:
63 ; X64-Linux-Large: cmpq %fs:112, %rsp
64 ; X64-Linux-Large-NEXT: jbe .LBB0_1
66 ; X64-Linux-Large: movabsq $40, %r10
67 ; X64-Linux-Large-NEXT: movabsq $0, %r11
68 ; X64-Linux-Large-NEXT: callq *__morestack_addr(%rip)
69 ; X64-Linux-Large-NEXT: ret
71 ; X32ABI-LABEL: test_basic:
73 ; X32ABI: cmpl %fs:64, %esp
74 ; X32ABI-NEXT: jbe .LBB0_1
76 ; X32ABI: movl $40, %r10d
77 ; X32ABI-NEXT: movl $0, %r11d
78 ; X32ABI-NEXT: callq __morestack
81 ; X32-Darwin-LABEL: test_basic:
83 ; X32-Darwin: movl $432, %ecx
84 ; X32-Darwin-NEXT: cmpl %gs:(%ecx), %esp
85 ; X32-Darwin-NEXT: jbe LBB0_1
87 ; X32-Darwin: pushl $0
88 ; X32-Darwin-NEXT: pushl $60
89 ; X32-Darwin-NEXT: calll ___morestack
90 ; X32-Darwin-NEXT: ret
92 ; X64-Darwin-LABEL: test_basic:
94 ; X64-Darwin: cmpq %gs:816, %rsp
95 ; X64-Darwin-NEXT: jbe LBB0_1
97 ; X64-Darwin: movabsq $40, %r10
98 ; X64-Darwin-NEXT: movabsq $0, %r11
99 ; X64-Darwin-NEXT: callq ___morestack
100 ; X64-Darwin-NEXT: ret
102 ; X32-MinGW-LABEL: test_basic:
104 ; X32-MinGW: cmpl %fs:20, %esp
105 ; X32-MinGW-NEXT: jbe LBB0_1
107 ; X32-MinGW: pushl $0
108 ; X32-MinGW-NEXT: pushl $40
109 ; X32-MinGW-NEXT: calll ___morestack
110 ; X32-MinGW-NEXT: ret
112 ; X64-MinGW-LABEL: test_basic:
114 ; X64-MinGW: cmpq %gs:40, %rsp
115 ; X64-MinGW-NEXT: jbe .LBB0_1
117 ; X64-MinGW: movabsq $72, %r10
118 ; X64-MinGW-NEXT: movabsq $32, %r11
119 ; X64-MinGW-NEXT: callq __morestack
120 ; X64-MinGW-NEXT: retq
122 ; X64-FreeBSD-LABEL: test_basic:
124 ; X64-FreeBSD: cmpq %fs:24, %rsp
125 ; X64-FreeBSD-NEXT: jbe .LBB0_1
127 ; X64-FreeBSD: movabsq $40, %r10
128 ; X64-FreeBSD-NEXT: movabsq $0, %r11
129 ; X64-FreeBSD-NEXT: callq __morestack
130 ; X64-FreeBSD-NEXT: ret
132 ; X32-DFlyBSD-LABEL: test_basic:
134 ; X32-DFlyBSD: cmpl %fs:16, %esp
135 ; X32-DFlyBSD-NEXT: jbe .LBB0_1
137 ; X32-DFlyBSD: pushl $0
138 ; X32-DFlyBSD-NEXT: pushl $40
139 ; X32-DFlyBSD-NEXT: calll __morestack
140 ; X32-DFlyBSD-NEXT: ret
142 ; X64-DFlyBSD-LABEL: test_basic:
144 ; X64-DFlyBSD: cmpq %fs:32, %rsp
145 ; X64-DFlyBSD-NEXT: jbe .LBB0_1
147 ; X64-DFlyBSD: movabsq $40, %r10
148 ; X64-DFlyBSD-NEXT: movabsq $0, %r11
149 ; X64-DFlyBSD-NEXT: callq __morestack
150 ; X64-DFlyBSD-NEXT: ret
154 define i32 @test_nested(i32 * nest %closure, i32 %other) #0 {
155 %addend = load i32 , i32 * %closure
156 %result = add i32 %other, %addend
157 %mem = alloca i32, i32 10
158 call void @dummy_use (i32* %mem, i32 10)
161 ; X32-Linux: cmpl %gs:48, %esp
162 ; X32-Linux-NEXT: jbe .LBB1_1
164 ; X32-Linux: pushl $4
165 ; X32-Linux-NEXT: pushl $44
166 ; X32-Linux-NEXT: calll __morestack
167 ; X32-Linux-NEXT: ret
169 ; X64-Linux: cmpq %fs:112, %rsp
170 ; X64-Linux-NEXT: jbe .LBB1_1
172 ; X64-Linux: movq %r10, %rax
173 ; X64-Linux-NEXT: movabsq $56, %r10
174 ; X64-Linux-NEXT: movabsq $0, %r11
175 ; X64-Linux-NEXT: callq __morestack
176 ; X64-Linux-NEXT: ret
177 ; X64-Linux-NEXT: movq %rax, %r10
179 ; X32ABI: cmpl %fs:64, %esp
180 ; X32ABI-NEXT: jbe .LBB1_1
182 ; X32ABI: movl %r10d, %eax
183 ; X32ABI-NEXT: movl $56, %r10d
184 ; X32ABI-NEXT: movl $0, %r11d
185 ; X32ABI-NEXT: callq __morestack
187 ; X32ABI-NEXT: movq %rax, %r10
189 ; X32-Darwin: movl $432, %edx
190 ; X32-Darwin-NEXT: cmpl %gs:(%edx), %esp
191 ; X32-Darwin-NEXT: jbe LBB1_1
193 ; X32-Darwin: pushl $4
194 ; X32-Darwin-NEXT: pushl $60
195 ; X32-Darwin-NEXT: calll ___morestack
196 ; X32-Darwin-NEXT: ret
198 ; X64-Darwin: cmpq %gs:816, %rsp
199 ; X64-Darwin-NEXT: jbe LBB1_1
201 ; X64-Darwin: movq %r10, %rax
202 ; X64-Darwin-NEXT: movabsq $56, %r10
203 ; X64-Darwin-NEXT: movabsq $0, %r11
204 ; X64-Darwin-NEXT: callq ___morestack
205 ; X64-Darwin-NEXT: ret
206 ; X64-Darwin-NEXT: movq %rax, %r10
208 ; X32-MinGW: cmpl %fs:20, %esp
209 ; X32-MinGW-NEXT: jbe LBB1_1
211 ; X32-MinGW: pushl $4
212 ; X32-MinGW-NEXT: pushl $44
213 ; X32-MinGW-NEXT: calll ___morestack
214 ; X32-MinGW-NEXT: ret
216 ; X64-MinGW-LABEL: test_nested:
217 ; X64-MinGW: cmpq %gs:40, %rsp
218 ; X64-MinGW-NEXT: jbe .LBB1_1
220 ; X64-MinGW: movq %r10, %rax
221 ; X64-MinGW-NEXT: movabsq $88, %r10
222 ; X64-MinGW-NEXT: movabsq $32, %r11
223 ; X64-MinGW-NEXT: callq __morestack
224 ; X64-MinGW-NEXT: retq
225 ; X64-MinGW-NEXT: movq %rax, %r10
227 ; X64-FreeBSD: cmpq %fs:24, %rsp
228 ; X64-FreeBSD-NEXT: jbe .LBB1_1
230 ; X64-FreeBSD: movq %r10, %rax
231 ; X64-FreeBSD-NEXT: movabsq $56, %r10
232 ; X64-FreeBSD-NEXT: movabsq $0, %r11
233 ; X64-FreeBSD-NEXT: callq __morestack
234 ; X64-FreeBSD-NEXT: ret
235 ; X64-FreeBSD-NEXT: movq %rax, %r10
237 ; X32-DFlyBSD: cmpl %fs:16, %esp
238 ; X32-DFlyBSD-NEXT: jbe .LBB1_1
240 ; X32-DFlyBSD: pushl $4
241 ; X32-DFlyBSD-NEXT: pushl $44
242 ; X32-DFlyBSD-NEXT: calll __morestack
243 ; X32-DFlyBSD-NEXT: ret
245 ; X64-DFlyBSD: cmpq %fs:32, %rsp
246 ; X64-DFlyBSD-NEXT: jbe .LBB1_1
248 ; X64-DFlyBSD: movq %r10, %rax
249 ; X64-DFlyBSD-NEXT: movabsq $56, %r10
250 ; X64-DFlyBSD-NEXT: movabsq $0, %r11
251 ; X64-DFlyBSD-NEXT: callq __morestack
252 ; X64-DFlyBSD-NEXT: ret
253 ; X64-DFlyBSD-NEXT: movq %rax, %r10
257 define void @test_large() #0 {
258 %mem = alloca i32, i32 10000
259 call void @dummy_use (i32* %mem, i32 3)
262 ; X32-Linux-LABEL: test_large:
264 ; X32-Linux: leal -40012(%esp), %ecx
265 ; X32-Linux-NEXT: cmpl %gs:48, %ecx
266 ; X32-Linux-NEXT: jbe .LBB2_1
268 ; X32-Linux: pushl $0
269 ; X32-Linux-NEXT: pushl $40012
270 ; X32-Linux-NEXT: calll __morestack
271 ; X32-Linux-NEXT: ret
273 ; X64-Linux: leaq -40008(%rsp), %r11
274 ; X64-Linux-NEXT: cmpq %fs:112, %r11
275 ; X64-Linux-NEXT: jbe .LBB2_1
277 ; X64-Linux: movabsq $40008, %r10
278 ; X64-Linux-NEXT: movabsq $0, %r11
279 ; X64-Linux-NEXT: callq __morestack
280 ; X64-Linux-NEXT: ret
282 ; X32ABI: leal -40008(%rsp), %r11d
283 ; X32ABI-NEXT: cmpl %fs:64, %r11d
284 ; X32ABI-NEXT: jbe .LBB2_1
286 ; X32ABI: movl $40008, %r10d
287 ; X32ABI-NEXT: movl $0, %r11d
288 ; X32ABI-NEXT: callq __morestack
291 ; X32-Darwin: leal -40012(%esp), %ecx
292 ; X32-Darwin-NEXT: movl $432, %eax
293 ; X32-Darwin-NEXT: cmpl %gs:(%eax), %ecx
294 ; X32-Darwin-NEXT: jbe LBB2_1
296 ; X32-Darwin: pushl $0
297 ; X32-Darwin-NEXT: pushl $40012
298 ; X32-Darwin-NEXT: calll ___morestack
299 ; X32-Darwin-NEXT: ret
301 ; X64-Darwin: leaq -40008(%rsp), %r11
302 ; X64-Darwin-NEXT: cmpq %gs:816, %r11
303 ; X64-Darwin-NEXT: jbe LBB2_1
305 ; X64-Darwin: movabsq $40008, %r10
306 ; X64-Darwin-NEXT: movabsq $0, %r11
307 ; X64-Darwin-NEXT: callq ___morestack
308 ; X64-Darwin-NEXT: ret
310 ; X32-MinGW: leal -40000(%esp), %ecx
311 ; X32-MinGW-NEXT: cmpl %fs:20, %ecx
312 ; X32-MinGW-NEXT: jbe LBB2_1
314 ; X32-MinGW: pushl $0
315 ; X32-MinGW-NEXT: pushl $40000
316 ; X32-MinGW-NEXT: calll ___morestack
317 ; X32-MinGW-NEXT: ret
319 ; X64-MinGW-LABEL: test_large:
320 ; X64-MinGW: leaq -40040(%rsp), %r11
321 ; X64-MinGW-NEXT: cmpq %gs:40, %r11
322 ; X64-MinGW-NEXT: jbe .LBB2_1
324 ; X64-MinGW: movabsq $40040, %r10
325 ; X64-MinGW-NEXT: movabsq $32, %r11
326 ; X64-MinGW-NEXT: callq __morestack
327 ; X64-MinGW-NEXT: retq
329 ; X64-FreeBSD: leaq -40008(%rsp), %r11
330 ; X64-FreeBSD-NEXT: cmpq %fs:24, %r11
331 ; X64-FreeBSD-NEXT: jbe .LBB2_1
333 ; X64-FreeBSD: movabsq $40008, %r10
334 ; X64-FreeBSD-NEXT: movabsq $0, %r11
335 ; X64-FreeBSD-NEXT: callq __morestack
336 ; X64-FreeBSD-NEXT: ret
338 ; X32-DFlyBSD: leal -40000(%esp), %ecx
339 ; X32-DFlyBSD-NEXT: cmpl %fs:16, %ecx
340 ; X32-DFlyBSD-NEXT: jbe .LBB2_1
342 ; X32-DFlyBSD: pushl $0
343 ; X32-DFlyBSD-NEXT: pushl $40000
344 ; X32-DFlyBSD-NEXT: calll __morestack
345 ; X32-DFlyBSD-NEXT: ret
347 ; X64-DFlyBSD: leaq -40008(%rsp), %r11
348 ; X64-DFlyBSD-NEXT: cmpq %fs:32, %r11
349 ; X64-DFlyBSD-NEXT: jbe .LBB2_1
351 ; X64-DFlyBSD: movabsq $40008, %r10
352 ; X64-DFlyBSD-NEXT: movabsq $0, %r11
353 ; X64-DFlyBSD-NEXT: callq __morestack
354 ; X64-DFlyBSD-NEXT: ret
358 define fastcc void @test_fastcc() #0 {
359 %mem = alloca i32, i32 10
360 call void @dummy_use (i32* %mem, i32 10)
363 ; X32-Linux-LABEL: test_fastcc:
365 ; X32-Linux: cmpl %gs:48, %esp
366 ; X32-Linux-NEXT: jbe .LBB3_1
368 ; X32-Linux: pushl $0
369 ; X32-Linux-NEXT: pushl $44
370 ; X32-Linux-NEXT: calll __morestack
371 ; X32-Linux-NEXT: ret
373 ; X64-Linux-LABEL: test_fastcc:
375 ; X64-Linux: cmpq %fs:112, %rsp
376 ; X64-Linux-NEXT: jbe .LBB3_1
378 ; X64-Linux: movabsq $40, %r10
379 ; X64-Linux-NEXT: movabsq $0, %r11
380 ; X64-Linux-NEXT: callq __morestack
381 ; X64-Linux-NEXT: ret
383 ; X32ABI-LABEL: test_fastcc:
385 ; X32ABI: cmpl %fs:64, %esp
386 ; X32ABI-NEXT: jbe .LBB3_1
388 ; X32ABI: movl $40, %r10d
389 ; X32ABI-NEXT: movl $0, %r11d
390 ; X32ABI-NEXT: callq __morestack
393 ; X32-Darwin-LABEL: test_fastcc:
395 ; X32-Darwin: movl $432, %eax
396 ; X32-Darwin-NEXT: cmpl %gs:(%eax), %esp
397 ; X32-Darwin-NEXT: jbe LBB3_1
399 ; X32-Darwin: pushl $0
400 ; X32-Darwin-NEXT: pushl $60
401 ; X32-Darwin-NEXT: calll ___morestack
402 ; X32-Darwin-NEXT: ret
404 ; X64-Darwin-LABEL: test_fastcc:
406 ; X64-Darwin: cmpq %gs:816, %rsp
407 ; X64-Darwin-NEXT: jbe LBB3_1
409 ; X64-Darwin: movabsq $40, %r10
410 ; X64-Darwin-NEXT: movabsq $0, %r11
411 ; X64-Darwin-NEXT: callq ___morestack
412 ; X64-Darwin-NEXT: ret
414 ; X32-MinGW-LABEL: test_fastcc:
416 ; X32-MinGW: cmpl %fs:20, %esp
417 ; X32-MinGW-NEXT: jbe LBB3_1
419 ; X32-MinGW: pushl $0
420 ; X32-MinGW-NEXT: pushl $40
421 ; X32-MinGW-NEXT: calll ___morestack
422 ; X32-MinGW-NEXT: ret
424 ; X64-MinGW-LABEL: test_fastcc:
426 ; X64-MinGW: cmpq %gs:40, %rsp
427 ; X64-MinGW-NEXT: jbe .LBB3_1
429 ; X64-MinGW: movabsq $72, %r10
430 ; X64-MinGW-NEXT: movabsq $32, %r11
431 ; X64-MinGW-NEXT: callq __morestack
432 ; X64-MinGW-NEXT: retq
434 ; X64-FreeBSD-LABEL: test_fastcc:
436 ; X64-FreeBSD: cmpq %fs:24, %rsp
437 ; X64-FreeBSD-NEXT: jbe .LBB3_1
439 ; X64-FreeBSD: movabsq $40, %r10
440 ; X64-FreeBSD-NEXT: movabsq $0, %r11
441 ; X64-FreeBSD-NEXT: callq __morestack
442 ; X64-FreeBSD-NEXT: ret
444 ; X32-DFlyBSD-LABEL: test_fastcc:
446 ; X32-DFlyBSD: cmpl %fs:16, %esp
447 ; X32-DFlyBSD-NEXT: jbe .LBB3_1
449 ; X32-DFlyBSD: pushl $0
450 ; X32-DFlyBSD-NEXT: pushl $40
451 ; X32-DFlyBSD-NEXT: calll __morestack
452 ; X32-DFlyBSD-NEXT: ret
454 ; X64-DFlyBSD-LABEL: test_fastcc:
456 ; X64-DFlyBSD: cmpq %fs:32, %rsp
457 ; X64-DFlyBSD-NEXT: jbe .LBB3_1
459 ; X64-DFlyBSD: movabsq $40, %r10
460 ; X64-DFlyBSD-NEXT: movabsq $0, %r11
461 ; X64-DFlyBSD-NEXT: callq __morestack
462 ; X64-DFlyBSD-NEXT: ret
466 define fastcc void @test_fastcc_large() #0 {
467 %mem = alloca i32, i32 10000
468 call void @dummy_use (i32* %mem, i32 3)
471 ; X32-Linux-LABEL: test_fastcc_large:
473 ; X32-Linux: leal -40012(%esp), %eax
474 ; X32-Linux-NEXT: cmpl %gs:48, %eax
475 ; X32-Linux-NEXT: jbe .LBB4_1
477 ; X32-Linux: pushl $0
478 ; X32-Linux-NEXT: pushl $40012
479 ; X32-Linux-NEXT: calll __morestack
480 ; X32-Linux-NEXT: ret
482 ; X64-Linux-LABEL: test_fastcc_large:
484 ; X64-Linux: leaq -40008(%rsp), %r11
485 ; X64-Linux-NEXT: cmpq %fs:112, %r11
486 ; X64-Linux-NEXT: jbe .LBB4_1
488 ; X64-Linux: movabsq $40008, %r10
489 ; X64-Linux-NEXT: movabsq $0, %r11
490 ; X64-Linux-NEXT: callq __morestack
491 ; X64-Linux-NEXT: ret
493 ; X32ABI-LABEL: test_fastcc_large:
495 ; X32ABI: leal -40008(%rsp), %r11d
496 ; X32ABI-NEXT: cmpl %fs:64, %r11d
497 ; X32ABI-NEXT: jbe .LBB4_1
499 ; X32ABI: movl $40008, %r10d
500 ; X32ABI-NEXT: movl $0, %r11d
501 ; X32ABI-NEXT: callq __morestack
504 ; X32-Darwin-LABEL: test_fastcc_large:
506 ; X32-Darwin: leal -40012(%esp), %eax
507 ; X32-Darwin-NEXT: movl $432, %ecx
508 ; X32-Darwin-NEXT: cmpl %gs:(%ecx), %eax
509 ; X32-Darwin-NEXT: jbe LBB4_1
511 ; X32-Darwin: pushl $0
512 ; X32-Darwin-NEXT: pushl $40012
513 ; X32-Darwin-NEXT: calll ___morestack
514 ; X32-Darwin-NEXT: ret
516 ; X64-Darwin-LABEL: test_fastcc_large:
518 ; X64-Darwin: leaq -40008(%rsp), %r11
519 ; X64-Darwin-NEXT: cmpq %gs:816, %r11
520 ; X64-Darwin-NEXT: jbe LBB4_1
522 ; X64-Darwin: movabsq $40008, %r10
523 ; X64-Darwin-NEXT: movabsq $0, %r11
524 ; X64-Darwin-NEXT: callq ___morestack
525 ; X64-Darwin-NEXT: ret
527 ; X32-MinGW-LABEL: test_fastcc_large:
529 ; X32-MinGW: leal -40000(%esp), %eax
530 ; X32-MinGW-NEXT: cmpl %fs:20, %eax
531 ; X32-MinGW-NEXT: jbe LBB4_1
533 ; X32-MinGW: pushl $0
534 ; X32-MinGW-NEXT: pushl $40000
535 ; X32-MinGW-NEXT: calll ___morestack
536 ; X32-MinGW-NEXT: ret
538 ; X64-MinGW-LABEL: test_fastcc_large:
540 ; X64-MinGW: leaq -40040(%rsp), %r11
541 ; X64-MinGW-NEXT: cmpq %gs:40, %r11
542 ; X64-MinGW-NEXT: jbe .LBB4_1
544 ; X64-MinGW: movabsq $40040, %r10
545 ; X64-MinGW-NEXT: movabsq $32, %r11
546 ; X64-MinGW-NEXT: callq __morestack
547 ; X64-MinGW-NEXT: retq
549 ; X64-FreeBSD-LABEL: test_fastcc_large:
551 ; X64-FreeBSD: leaq -40008(%rsp), %r11
552 ; X64-FreeBSD-NEXT: cmpq %fs:24, %r11
553 ; X64-FreeBSD-NEXT: jbe .LBB4_1
555 ; X64-FreeBSD: movabsq $40008, %r10
556 ; X64-FreeBSD-NEXT: movabsq $0, %r11
557 ; X64-FreeBSD-NEXT: callq __morestack
558 ; X64-FreeBSD-NEXT: ret
560 ; X32-DFlyBSD-LABEL: test_fastcc_large:
562 ; X32-DFlyBSD: leal -40000(%esp), %eax
563 ; X32-DFlyBSD-NEXT: cmpl %fs:16, %eax
564 ; X32-DFlyBSD-NEXT: jbe .LBB4_1
566 ; X32-DFlyBSD: pushl $0
567 ; X32-DFlyBSD-NEXT: pushl $40000
568 ; X32-DFlyBSD-NEXT: calll __morestack
569 ; X32-DFlyBSD-NEXT: ret
571 ; X64-DFlyBSD-LABEL: test_fastcc_large:
573 ; X64-DFlyBSD: leaq -40008(%rsp), %r11
574 ; X64-DFlyBSD-NEXT: cmpq %fs:32, %r11
575 ; X64-DFlyBSD-NEXT: jbe .LBB4_1
577 ; X64-DFlyBSD: movabsq $40008, %r10
578 ; X64-DFlyBSD-NEXT: movabsq $0, %r11
579 ; X64-DFlyBSD-NEXT: callq __morestack
580 ; X64-DFlyBSD-NEXT: ret
584 define fastcc void @test_fastcc_large_with_ecx_arg(i32 %a) #0 {
585 %mem = alloca i32, i32 10000
586 call void @dummy_use (i32* %mem, i32 %a)
589 ; This is testing that the Mac implementation preserves ecx
591 ; X32-Darwin-LABEL: test_fastcc_large_with_ecx_arg:
593 ; X32-Darwin: leal -40012(%esp), %eax
594 ; X32-Darwin-NEXT: pushl %ecx
595 ; X32-Darwin-NEXT: movl $432, %ecx
596 ; X32-Darwin-NEXT: cmpl %gs:(%ecx), %eax
597 ; X32-Darwin-NEXT: popl %ecx
598 ; X32-Darwin-NEXT: jbe LBB5_1
600 ; X32-Darwin: pushl $0
601 ; X32-Darwin-NEXT: pushl $40012
602 ; X32-Darwin-NEXT: calll ___morestack
603 ; X32-Darwin-NEXT: ret
607 define void @test_nostack() #0 {
610 ; X32-Linux-LABEL: test_nostack:
611 ; X32-Linux-NOT: calll __morestack
613 ; X64-Linux-LABEL: test_nostack:
614 ; X64-Linux-NOT: callq __morestack
616 ; X32ABI-LABEL: test_nostack:
617 ; X32ABI-NOT: callq __morestack
619 ; X32-Darwin-LABEL: test_nostack:
620 ; X32-Darwin-NOT: calll __morestack
622 ; X64-Darwin-LABEL: test_nostack:
623 ; X64-Darwin-NOT: callq __morestack
625 ; X32-MinGW-LABEL: test_nostack:
626 ; X32-MinGW-NOT: calll __morestack
628 ; X64-MinGW-LABEL: test_nostack:
629 ; X64-MinGW-NOT: callq __morestack
631 ; X64-FreeBSD-LABEL: test_nostack:
632 ; X64-FreeBSD-NOT: callq __morestack
634 ; X32-DFlyBSD-LABEL: test_nostack:
635 ; X32-DFlyBSD-NOT: calll __morestack
637 ; X64-DFlyBSD-LABEL: test_nostack:
638 ; X64-DFlyBSD-NOT: callq __morestack
641 define void @test_nosplitstck() {
645 ; Test to make sure that a morestack call is generated if there is a
646 ; sibling call, even if the function in question has no stack frame
649 declare i32 @callee(i32)
651 define i32 @test_sibling_call_empty_frame(i32 %x) #0 {
652 %call = tail call i32 @callee(i32 %x) #0
655 ; X32-Linux-LABEL: test_sibling_call_empty_frame:
656 ; X32-Linux: calll __morestack
658 ; X64-Linux-LABEL: test_sibling_call_empty_frame:
659 ; X64-Linux: callq __morestack
661 ; X64-Linux-Large-LABEL: test_sibling_call_empty_frame:
662 ; X64-Linux-Large: callq *__morestack_addr(%rip)
664 ; X32ABI-LABEL: test_sibling_call_empty_frame:
665 ; X32ABI: callq __morestack
667 ; X32-Darwin-LABEL: test_sibling_call_empty_frame:
668 ; X32-Darwin: calll ___morestack
670 ; X64-Darwin-LABEL: test_sibling_call_empty_frame:
671 ; X64-Darwin: callq ___morestack
673 ; X32-MinGW-LABEL: test_sibling_call_empty_frame:
674 ; X32-MinGW: calll ___morestack
676 ; X64-MinGW-LABEL: test_sibling_call_empty_frame:
677 ; X64-MinGW: callq __morestack
679 ; X64-FreeBSD-LABEL: test_sibling_call_empty_frame:
680 ; X64-FreeBSD: callq __morestack
682 ; X32-DFlyBSD-LABEL: test_sibling_call_empty_frame:
683 ; X32-DFlyBSD: calll __morestack
684 ; X32-DFlyBSD-NEXT: ret
686 ; X64-DFlyBSD-LABEL: test_sibling_call_empty_frame:
687 ; X64-DFlyBSD: callq __morestack
691 ; Test that unused nested argument doesn't need saving/restoring.
693 define i32 @test_nested_unused(i32 * nest %unused) #0 {
694 %mem = alloca i32, i32 10
695 call void @dummy_use (i32* %mem, i32 10)
698 ; X64-Linux-LABEL: test_nested_unused:
699 ; X64-Linux-NOT: movq %r10, %rax
700 ; X64-Linux: callq __morestack
701 ; X64-Linux-NOT: movq %rax, %r10
703 ; X64-Darwin-LABEL: test_nested_unused:
704 ; X64-Darwin-NOT: movq %r10, %rax
705 ; X64-Darwin: callq ___morestack
706 ; X64-Darwin-NOT: movq %rax, %r10
708 ; X64-FreeBSD-LABEL: test_nested_unused:
709 ; X64-FreeBSD-NOT: movq %r10, %rax
710 ; X64-FreeBSD: callq __morestack
711 ; X64-FreeBSD-NOT: movq %rax, %r10
713 ; X64-DFlyBSD-LABEL: test_nested_unused:
714 ; X64-DFlyBSD-NOT: movq %r10, %rax
715 ; X64-DFlyBSD: callq __morestack
716 ; X64-DFlyBSD-NOT: movq %rax, %r10
718 ; X64-MinGW-LABEL: test_nested_unused:
719 ; X64-MinGW-NOT: movq %r10, %rax
720 ; X64-MinGW: callq __morestack
721 ; X64-MinGW-NOT: movq %rax, %r10
723 ; X32ABI-LABEL: test_nested_unused:
724 ; X32ABI-NOT: movl %r10d, %eax
725 ; X32ABI: callq __morestack
726 ; X32ABI-NOT: movq %rax, %r10
730 attributes #0 = { "split-stack" }
732 ; X64-Linux-Large: .rodata
733 ; X64-Linux-Large-NEXT: __morestack_addr:
734 ; X64-Linux-Large-NEXT: .quad __morestack
736 ; X32-Linux: .section ".note.GNU-split-stack","",@progbits
737 ; X32-Linux: .section ".note.GNU-no-split-stack","",@progbits
739 ; X64-Linux: .section ".note.GNU-split-stack","",@progbits
740 ; X64-Linux: .section ".note.GNU-no-split-stack","",@progbits
742 ; X64-FreeBSD: .section ".note.GNU-split-stack","",@progbits
743 ; X64-FreeBSD: .section ".note.GNU-no-split-stack","",@progbits
745 ; X32-DFlyBSD: .section ".note.GNU-split-stack","",@progbits
746 ; X32-DFlyBSD: .section ".note.GNU-no-split-stack","",@progbits
748 ; X64-DFlyBSD: .section ".note.GNU-split-stack","",@progbits
749 ; X64-DFlyBSD: .section ".note.GNU-no-split-stack","",@progbits