1 ; RUN: llc < %s -mtriple=x86_64-pc-win32-coreclr -verify-machineinstrs | 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: xorq %rcx, %rcx
14 ; WIN_X64: movq %rsp, %rdx
15 ; WIN_X64: subq %rax, %rdx
16 ; WIN_X64: cmovbq %rcx, %rdx
17 ; WIN_X64: movq %gs:16, %rcx
18 ; WIN_X64: cmpq %rcx, %rdx
19 ; WIN_X64: jae .LBB0_3
21 ; WIN_X64: andq $-4096, %rdx
23 ; WIN_X64: addq $-4096, %rcx
24 ; WIN_X64: movb $0, (%rcx)
25 ; WIN_X64: cmpq %rcx, %rdx
26 ; WIN_X64: jne .LBB0_2
28 ; WIN_X64: subq %rax, %rsp
29 ; WIN_X64: xorl %eax, %eax
30 ; WIN_X64: addq $4096, %rsp
33 ; LINUX-NOT: movq %gs:16, %rcx
35 %a = alloca [4096 x i8]
39 ; Prolog stack allocation >= 4096 bytes will require the probe sequence
40 ; Case with frame pointer
41 define i32 @main4k_frame() nounwind "frame-pointer"="all" {
43 ; WIN_X64-LABEL:main4k_frame:
44 ; WIN_X64: movq %gs:16, %rcx
45 ; LINUX-LABEL:main4k_frame:
46 ; LINUX-NOT: movq %gs:16, %rcx
48 %a = alloca [4096 x i8]
52 ; Prolog stack allocation >= 4096 bytes will require the probe sequence
54 define i32 @main4k_intargs(i32 %x, i32 %y) nounwind {
56 ; WIN_X64: movq %gs:16, %rcx
57 ; LINUX-NOT: movq %gs:16, %rcx
59 %a = alloca [4096 x i8]
64 ; Prolog stack allocation >= 4096 bytes will require the probe sequence
66 define i32 @main4k_fpargs(double %x, double %y) nounwind {
68 ; WIN_X64: movq %gs:16, %rcx
69 ; LINUX-NOT: movq %gs:16, %rcx
71 %a = alloca [4096 x i8]
75 ; Prolog stack allocation >= 4096 bytes will require the probe sequence
76 ; Case with mixed regs
77 define i32 @main4k_mixargs(double %x, i32 %y) nounwind {
79 ; WIN_X64: movq %gs:16, %rcx
80 ; LINUX-NOT: movq %gs:16, %rcx
82 %a = alloca [4096 x i8]
86 ; Make sure we don't emit the probe for a smaller prolog stack allocation.
87 define i32 @main128() nounwind {
89 ; WIN_X64-NOT: movq %gs:16, %rcx
91 ; LINUX-NOT: movq %gs:16, %rcx
93 %a = alloca [128 x i8]
97 ; Make sure we don't emit the probe sequence if not on windows even if the
98 ; caller has the Win64 calling convention.
99 define win64cc i32 @main4k_win64() nounwind {
101 ; WIN_X64: movq %gs:16, %rcx
102 ; LINUX-NOT: movq %gs:16, %rcx
104 %a = alloca [4096 x i8]
108 declare i32 @bar(ptr) nounwind
110 ; Within-body inline probe expansion
111 define win64cc i32 @main4k_alloca(i64 %n) nounwind {
114 ; WIN_X64: movq %gs:16, [[R:%r.*]]
117 ; LINUX-NOT: movq %gs:16, [[R:%r.*]]
119 %a = alloca i8, i64 1024
120 %ra = call i32 @bar(ptr %a) nounwind
121 %b = alloca i8, i64 %n
122 %rb = call i32 @bar(ptr %b) nounwind
123 %r = add i32 %ra, %rb
127 ; Influence of stack-probe-size attribute
128 ; Note this is not exposed in coreclr
129 define i32 @test_probe_size() "stack-probe-size"="8192" nounwind {
130 ; WIN_X64-NOT: movq %gs:16, %rcx
132 ; LINUX-NOT: movq %gs:16, %rcx
134 %a = alloca [4096 x i8]