1 ; RUN: llc < %s -mtriple=x86_64-pc-win32-coreclr | FileCheck %s -check-prefix=WIN_X64
2 ; RUN: llc < %s -mtriple=x86_64-pc-linux | FileCheck %s -check-prefix=LINUX
4 ; By default, windows CoreCLR requires an inline prologue stack expansion check
5 ; if more than 4096 bytes are allocated on the stack.
7 ; Prolog stack allocation >= 4096 bytes will require the probe sequence
8 define i32 @main4k() nounwind {
10 ; WIN_X64-LABEL:main4k:
12 ; WIN_X64: movl $4096, %eax
13 ; WIN_X64: movq %rcx, 8(%rsp)
14 ; WIN_X64: movq %rdx, 16(%rsp)
15 ; WIN_X64: xorq %rcx, %rcx
16 ; WIN_X64: movq %rsp, %rdx
17 ; WIN_X64: subq %rax, %rdx
18 ; WIN_X64: cmovbq %rcx, %rdx
19 ; WIN_X64: movq %gs:16, %rcx
20 ; WIN_X64: cmpq %rcx, %rdx
21 ; WIN_X64: jae .LBB0_3
23 ; WIN_X64: andq $-4096, %rdx
25 ; WIN_X64: leaq -4096(%rcx), %rcx
26 ; WIN_X64: movb $0, (%rcx)
27 ; WIN_X64: cmpq %rcx, %rdx
28 ; WIN_X64: jne .LBB0_2
30 ; WIN_X64: movq 8(%rsp), %rcx
31 ; WIN_X64: movq 16(%rsp), %rdx
32 ; WIN_X64: subq %rax, %rsp
33 ; WIN_X64: xorl %eax, %eax
34 ; WIN_X64: addq $4096, %rsp
37 ; LINUX-NOT: movq %gs:16, %rcx
39 %a = alloca [4096 x i8]
43 ; Prolog stack allocation >= 4096 bytes will require the probe sequence
44 ; Case with frame pointer
45 define i32 @main4k_frame() nounwind "no-frame-pointer-elim"="true" {
47 ; WIN_X64-LABEL:main4k_frame:
48 ; WIN_X64: movq %rcx, 16(%rsp)
49 ; WIN_X64: movq %gs:16, %rcx
50 ; LINUX-LABEL:main4k_frame:
51 ; LINUX-NOT: movq %gs:16, %rcx
53 %a = alloca [4096 x i8]
57 ; Prolog stack allocation >= 4096 bytes will require the probe sequence
59 define i32 @main4k_intargs(i32 %x, i32 %y) nounwind {
61 ; WIN_X64: movq %rcx, 8(%rsp)
62 ; WIN_X64: movq %gs:16, %rcx
63 ; LINUX-NOT: movq %gs:16, %rcx
65 %a = alloca [4096 x i8]
70 ; Prolog stack allocation >= 4096 bytes will require the probe sequence
72 define i32 @main4k_fpargs(double %x, double %y) nounwind {
74 ; WIN_X64: movq %rcx, 8(%rsp)
75 ; WIN_X64: movq %gs:16, %rcx
76 ; LINUX-NOT: movq %gs:16, %rcx
78 %a = alloca [4096 x i8]
82 ; Prolog stack allocation >= 4096 bytes will require the probe sequence
83 ; Case with mixed regs
84 define i32 @main4k_mixargs(double %x, i32 %y) nounwind {
86 ; WIN_X64: movq %gs:16, %rcx
87 ; LINUX-NOT: movq %gs:16, %rcx
89 %a = alloca [4096 x i8]
93 ; Make sure we don't emit the probe for a smaller prolog stack allocation.
94 define i32 @main128() nounwind {
96 ; WIN_X64-NOT: movq %gs:16, %rcx
98 ; LINUX-NOT: movq %gs:16, %rcx
100 %a = alloca [128 x i8]
104 ; Make sure we don't emit the probe sequence if not on windows even if the
105 ; caller has the Win64 calling convention.
106 define x86_64_win64cc i32 @main4k_win64() nounwind {
108 ; WIN_X64: movq %gs:16, %rcx
109 ; LINUX-NOT: movq %gs:16, %rcx
111 %a = alloca [4096 x i8]
115 declare i32 @bar(i8*) nounwind
117 ; Within-body inline probe expansion
118 define x86_64_win64cc i32 @main4k_alloca(i64 %n) nounwind {
121 ; WIN_X64: movq %gs:16, [[R:%r.*]]
124 ; LINUX-NOT: movq %gs:16, [[R:%r.*]]
126 %a = alloca i8, i64 1024
127 %ra = call i32 @bar(i8* %a) nounwind
128 %b = alloca i8, i64 %n
129 %rb = call i32 @bar(i8* %b) nounwind
130 %r = add i32 %ra, %rb
134 ; Influence of stack-probe-size attribute
135 ; Note this is not exposed in coreclr
136 define i32 @test_probe_size() "stack-probe-size"="8192" nounwind {
137 ; WIN_X64-NOT: movq %gs:16, %rcx
139 ; LINUX-NOT: movq %gs:16, %rcx
141 %a = alloca [4096 x i8]