1 ; Test the allocation of frames in cases where we do not need to save
2 ; registers in the prologue.
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
6 ; The CFA offset is 160 (the caller-allocated part of the frame) + 168.
7 define void @f1(i64 %x) {
9 ; CHECK: aghi %r15, -168
10 ; CHECK: .cfi_def_cfa_offset 328
11 ; CHECK: stg %r2, 160(%r15)
12 ; CHECK: aghi %r15, 168
14 %y = alloca i64, align 8
15 store volatile i64 %x, i64* %y
19 ; Check frames of size 32760, which is the largest size that can be both
20 ; allocated and freed using AGHI. This size is big enough to require
21 ; an emergency spill slot at 160(%r15), for instructions with unsigned
22 ; 12-bit offsets that end up being out of range. Fill the remaining
23 ; 32760 - 168 bytes by allocating (32760 - 168) / 8 = 4074 doublewords.
24 define void @f2(i64 %x) {
26 ; CHECK: aghi %r15, -32760
27 ; CHECK: .cfi_def_cfa_offset 32920
28 ; CHECK: stg %r2, 168(%r15)
29 ; CHECK: aghi %r15, 32760
31 %y = alloca [4074 x i64], align 8
32 %ptr = getelementptr inbounds [4074 x i64]* %y, i64 0, i64 0
33 store volatile i64 %x, i64* %ptr
37 ; Allocate one more doubleword. This is the one frame size that we can
38 ; allocate using AGHI but must free using AGFI.
39 define void @f3(i64 %x) {
41 ; CHECK: aghi %r15, -32768
42 ; CHECK: .cfi_def_cfa_offset 32928
43 ; CHECK: stg %r2, 168(%r15)
44 ; CHECK: agfi %r15, 32768
46 %y = alloca [4075 x i64], align 8
47 %ptr = getelementptr inbounds [4075 x i64]* %y, i64 0, i64 0
48 store volatile i64 %x, i64* %ptr
52 ; Allocate another doubleword on top of that. The allocation and free
54 define void @f4(i64 %x) {
56 ; CHECK: agfi %r15, -32776
57 ; CHECK: .cfi_def_cfa_offset 32936
58 ; CHECK: stg %r2, 168(%r15)
59 ; CHECK: agfi %r15, 32776
61 %y = alloca [4076 x i64], align 8
62 %ptr = getelementptr inbounds [4076 x i64]* %y, i64 0, i64 0
63 store volatile i64 %x, i64* %ptr
67 ; The largest size that can be both allocated and freed using AGFI.
68 ; At this point the frame is too big to represent properly in the CFI.
69 define void @f5(i64 %x) {
71 ; CHECK: agfi %r15, -2147483640
72 ; CHECK: stg %r2, 168(%r15)
73 ; CHECK: agfi %r15, 2147483640
75 %y = alloca [268435434 x i64], align 8
76 %ptr = getelementptr inbounds [268435434 x i64]* %y, i64 0, i64 0
77 store volatile i64 %x, i64* %ptr
81 ; The only frame size that can be allocated using a single AGFI but which
82 ; must be freed using two instructions.
83 define void @f6(i64 %x) {
85 ; CHECK: agfi %r15, -2147483648
86 ; CHECK: stg %r2, 168(%r15)
87 ; CHECK: agfi %r15, 2147483640
90 %y = alloca [268435435 x i64], align 8
91 %ptr = getelementptr inbounds [268435435 x i64]* %y, i64 0, i64 0
92 store volatile i64 %x, i64* %ptr
96 ; The smallest frame size that needs two instructions to both allocate
98 define void @f7(i64 %x) {
100 ; CHECK: agfi %r15, -2147483648
101 ; CHECK: aghi %r15, -8
102 ; CHECK: stg %r2, 168(%r15)
103 ; CHECK: agfi %r15, 2147483640
104 ; CHECK: aghi %r15, 16
106 %y = alloca [268435436 x i64], align 8
107 %ptr = getelementptr inbounds [268435436 x i64]* %y, i64 0, i64 0
108 store volatile i64 %x, i64* %ptr