1 ; RUN: llc < %s -mtriple=x86_64-linux -verify-machineinstrs | FileCheck %s --check-prefix=CHECK
3 ; Test how we handle pathologically large stack frames when RAX is live through
4 ; the prologue and epilogue.
7 declare void @llvm.va_start(ptr)
9 ; For stack frames between 2GB and 16GB, do multiple adjustments.
11 define i32 @stack_frame_8gb(i32 %x, ...) nounwind {
12 ; CHECK-LABEL: stack_frame_8gb:
13 ; CHECK: subq ${{.*}}, %rsp # imm = 0x7FFFFFFF
14 ; CHECK: subq ${{.*}}, %rsp # imm = 0x7FFFFFFF
15 ; CHECK: subq ${{.*}}, %rsp # imm = 0x7FFFFFFF
16 ; CHECK: subq ${{.*}}, %rsp # imm = 0x7FFFFFFF
17 ; CHECK: subq ${{.*}}, %rsp
19 ; CHECK: addq ${{.*}}, %rsp # imm = 0x7FFFFFFF
20 ; CHECK: addq ${{.*}}, %rsp # imm = 0x7FFFFFFF
21 ; CHECK: addq ${{.*}}, %rsp # imm = 0x7FFFFFFF
22 ; CHECK: addq ${{.*}}, %rsp # imm = 0x7FFFFFFF
23 ; CHECK: addq ${{.*}}, %rsp
25 %1 = alloca [u0x200000000 x i8]
26 %va = alloca i8, i32 24
27 call void @llvm.va_start(ptr %va)
28 call void @bar(ptr %1)
32 ; For stack frames larger than 16GB, spill EAX instead of doing a linear number
35 ; This function should have a frame size of 0x4000000D0. The 0xD0 is 208 bytes
36 ; from 24 bytes of va_list, 176 bytes of spilled varargs regparms, and 8 bytes
37 ; of alignment. We subtract 8 less and add 8 more in the prologue and epilogue
38 ; respectively to account for the PUSH.
40 define i32 @stack_frame_16gb(i32 %x, ...) nounwind {
41 ; CHECK-LABEL: stack_frame_16gb:
43 ; CHECK-NEXT: movabsq ${{.*}}, %rax # imm = 0xFFFFFFFBFFFFFF38
44 ; CHECK-NEXT: addq %rsp, %rax
45 ; CHECK-NEXT: xchgq %rax, (%rsp)
46 ; CHECK-NEXT: movq (%rsp), %rsp
49 ; CHECK-NEXT: movabsq ${{.*}}, %rax # imm = 0x4000000D8
50 ; CHECK-NEXT: addq %rsp, %rax
51 ; CHECK-NEXT: xchgq %rax, (%rsp)
52 ; CHECK-NEXT: movq (%rsp), %rsp
54 %1 = alloca [u0x400000000 x i8]
55 %va = alloca i8, i32 24
56 call void @llvm.va_start(ptr %va)
57 call void @bar(ptr %1)