• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s --check-prefix=CHECK
2
3; Test how we handle pathologically large stack frames when RAX is live through
4; the prologue and epilogue.
5
6declare void @bar(i8*)
7declare void @llvm.va_start(i8*)
8
9; For stack frames between 2GB and 16GB, do multiple adjustments.
10
11define 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
18; CHECK:      callq bar
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
24; CHECK:      retq
25  %1 = alloca [u0x200000000 x i8]
26  %va = alloca i8, i32 24
27  call void @llvm.va_start(i8* %va)
28  %2 = getelementptr inbounds [u0x200000000 x i8], [u0x200000000 x i8]* %1, i32 0, i32 0
29  call void @bar(i8* %2)
30  ret i32 %x
31}
32
33; For stack frames larger than 16GB, spill EAX instead of doing a linear number
34; of adjustments.
35
36; This function should have a frame size of 0x4000000D0. The 0xD0 is 208 bytes
37; from 24 bytes of va_list, 176 bytes of spilled varargs regparms, and 8 bytes
38; of alignment. We subtract 8 less and add 8 more in the prologue and epilogue
39; respectively to account for the PUSH.
40
41define i32 @stack_frame_16gb(i32 %x, ...) nounwind {
42; CHECK-LABEL: stack_frame_16gb:
43; CHECK:      pushq %rax
44; CHECK-NEXT: movabsq ${{.*}}, %rax # imm = 0xFFFFFFFBFFFFFF38
45; CHECK-NEXT: addq %rsp, %rax
46; CHECK-NEXT: xchgq %rax, (%rsp)
47; CHECK-NEXT: movq (%rsp), %rsp
48; CHECK:      callq bar
49; CHECK:      pushq %rax
50; CHECK-NEXT: movabsq ${{.*}}, %rax # imm = 0x4000000D8
51; CHECK-NEXT: addq %rsp, %rax
52; CHECK-NEXT: xchgq %rax, (%rsp)
53; CHECK-NEXT: movq (%rsp), %rsp
54; CHECK:      retq
55  %1 = alloca [u0x400000000 x i8]
56  %va = alloca i8, i32 24
57  call void @llvm.va_start(i8* %va)
58  %2 = getelementptr inbounds [u0x400000000 x i8], [u0x400000000 x i8]* %1, i32 0, i32 0
59  call void @bar(i8* %2)
60  ret i32 %x
61}
62
63