1 ; FIXME: Fix machine verifier issues and remove -verify-machineinstrs=0. PR38376.
2 ; RUN: llc < %s -mtriple=x86_64-pc-win32-coreclr -verify-machineinstrs=0 | FileCheck %s -check-prefix=WIN_X64
3 ; RUN: llc < %s -mtriple=x86_64-pc-linux | FileCheck %s -check-prefix=LINUX
5 ; By default, windows CoreCLR requires an inline prologue stack expansion check
6 ; if more than 4096 bytes are allocated on the stack.
8 ; Prolog stack allocation >= 4096 bytes will require the probe sequence
9 define i32 @main4k() nounwind {
11 ; WIN_X64-LABEL:main4k:
13 ; WIN_X64: movl $4096, %eax
14 ; WIN_X64: xorq %rcx, %rcx
15 ; WIN_X64: movq %rsp, %rdx
16 ; WIN_X64: subq %rax, %rdx
17 ; WIN_X64: cmovbq %rcx, %rdx
18 ; WIN_X64: movq %gs:16, %rcx
19 ; WIN_X64: cmpq %rcx, %rdx
20 ; WIN_X64: jae .LBB0_3
22 ; WIN_X64: andq $-4096, %rdx
24 ; WIN_X64: addq $-4096, %rcx
25 ; WIN_X64: movb $0, (%rcx)
26 ; WIN_X64: cmpq %rcx, %rdx
27 ; WIN_X64: jne .LBB0_2
29 ; WIN_X64: subq %rax, %rsp
30 ; WIN_X64: xorl %eax, %eax
31 ; WIN_X64: addq $4096, %rsp
34 ; LINUX-NOT: movq %gs:16, %rcx
36 %a = alloca [4096 x i8]
40 ; Prolog stack allocation >= 4096 bytes will require the probe sequence
41 ; Case with frame pointer
42 define i32 @main4k_frame() nounwind "frame-pointer"="all" {
44 ; WIN_X64-LABEL:main4k_frame:
45 ; WIN_X64: movq %gs:16, %rcx
46 ; LINUX-LABEL:main4k_frame:
47 ; LINUX-NOT: movq %gs:16, %rcx
49 %a = alloca [4096 x i8]
53 ; Prolog stack allocation >= 4096 bytes will require the probe sequence
55 define i32 @main4k_intargs(i32 %x, i32 %y) nounwind {
57 ; WIN_X64: movq %gs:16, %rcx
58 ; LINUX-NOT: movq %gs:16, %rcx
60 %a = alloca [4096 x i8]
65 ; Prolog stack allocation >= 4096 bytes will require the probe sequence
67 define i32 @main4k_fpargs(double %x, double %y) nounwind {
69 ; WIN_X64: movq %gs:16, %rcx
70 ; LINUX-NOT: movq %gs:16, %rcx
72 %a = alloca [4096 x i8]
76 ; Prolog stack allocation >= 4096 bytes will require the probe sequence
77 ; Case with mixed regs
78 define i32 @main4k_mixargs(double %x, i32 %y) nounwind {
80 ; WIN_X64: movq %gs:16, %rcx
81 ; LINUX-NOT: movq %gs:16, %rcx
83 %a = alloca [4096 x i8]
87 ; Make sure we don't emit the probe for a smaller prolog stack allocation.
88 define i32 @main128() nounwind {
90 ; WIN_X64-NOT: movq %gs:16, %rcx
92 ; LINUX-NOT: movq %gs:16, %rcx
94 %a = alloca [128 x i8]
98 ; Make sure we don't emit the probe sequence if not on windows even if the
99 ; caller has the Win64 calling convention.
100 define win64cc i32 @main4k_win64() nounwind {
102 ; WIN_X64: movq %gs:16, %rcx
103 ; LINUX-NOT: movq %gs:16, %rcx
105 %a = alloca [4096 x i8]
109 declare i32 @bar(ptr) nounwind
111 ; Within-body inline probe expansion
112 define win64cc i32 @main4k_alloca(i64 %n) nounwind {
115 ; WIN_X64: movq %gs:16, [[R:%r.*]]
118 ; LINUX-NOT: movq %gs:16, [[R:%r.*]]
120 %a = alloca i8, i64 1024
121 %ra = call i32 @bar(ptr %a) nounwind
122 %b = alloca i8, i64 %n
123 %rb = call i32 @bar(ptr %b) nounwind
124 %r = add i32 %ra, %rb
128 ; Influence of stack-probe-size attribute
129 ; Note this is not exposed in coreclr
130 define i32 @test_probe_size() "stack-probe-size"="8192" nounwind {
131 ; WIN_X64-NOT: movq %gs:16, %rcx
133 ; LINUX-NOT: movq %gs:16, %rcx
135 %a = alloca [4096 x i8]