xref: /llvm-project/llvm/test/CodeGen/X86/huge-stack-offset.ll (revision 86705eb6242b5e2d6153708ddedffbfc95491756)
1; RUN: llc < %s -mtriple=x86_64-linux-unknown -verify-machineinstrs | FileCheck %s --check-prefix=CHECK-64
2; RUN: llc < %s -mtriple=i386-linux-unknown -verify-machineinstrs | FileCheck %s --check-prefix=CHECK-32
3; RUN: llc < %s -mtriple=x86_64-linux-gnux32 -verify-machineinstrs | FileCheck %s -check-prefix=CHECK-32
4
5; Test that a large stack offset uses a single add/sub instruction to
6; adjust the stack pointer.
7
8define void @foo() nounwind {
9; CHECK-64-LABEL: foo:
10; CHECK-64:      movabsq $50000000{{..}}, %rax
11; CHECK-64-NEXT: subq    %rax, %rsp
12; CHECK-64-NOT:  subq    $2147483647, %rsp
13; CHECK-64:      movabsq $50000000{{..}}, [[RAX:%r..]]
14; CHECK-64-NEXT: addq    [[RAX]], %rsp
15;
16; CHECK-32-LABEL: foo:
17; CHECK-32:      ud2
18; CHECK-32-NOT:  subl    $2147483647, %esp
19; CHECK-32:      ud2
20  %1 = alloca [5000000000 x i8], align 16
21  call void @bar(ptr %1)
22  ret void
23}
24
25; Verify that we do not clobber the return value.
26
27define i32 @foo2() nounwind {
28; CHECK-64-LABEL: foo2:
29; CHECK-64:     movl    $10, %eax
30; CHECK-64-NOT: movabsq ${{.*}}, %rax
31;
32; CHECK-32-LABEL: foo2:
33; CHECK-32:     movl    $10, %eax
34; CHECK-32-NOT: movl    ${{.*}}, %eax
35  %1 = alloca [5000000000 x i8], align 16
36  call void @bar(ptr %1)
37  ret i32 10
38}
39
40; Verify that we do not clobber EAX when using inreg attribute
41
42define i32 @foo3(i32 inreg %x) nounwind {
43; CHECK-64-LABEL: foo3:
44; CHECK-64:      movabsq $50000000{{..}}, %rax
45; CHECK-64-NEXT: subq    %rax, %rsp
46;
47; CHECK-32-LABEL: foo3:
48; CHECK-32:      ud2
49; CHECK-32-NOT:  movl ${{.*}}, %eax
50  %1 = alloca [5000000000 x i8], align 16
51  call void @bar(ptr %1)
52  ret i32 %x
53}
54
55declare void @bar(ptr)
56