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
8 ; The CFA offset is 160 (the caller-allocated part of the frame) + 168.
9 define void @f1(i64 %x) {
11 ; CHECK: aghi %r15, -168
12 ; CHECK: .cfi_def_cfa_offset 328
13 ; CHECK: stg %r2, 160(%r15)
14 ; CHECK: aghi %r15, 168
16 %y = alloca i64, align 8
17 store volatile i64 %x, ptr %y
21 ; Check frames of size 32760, which is the largest size that can be both
22 ; allocated and freed using AGHI. This size is big enough to require
23 ; two emergency spill slots at 160(%r15), for instructions with unsigned
24 ; 12-bit offsets that end up being out of range. Fill the remaining
25 ; 32760 - 176 bytes by allocating (32760 - 176) / 8 = 4073 doublewords.
26 define void @f2(i64 %x) {
28 ; CHECK: aghi %r15, -32760
29 ; CHECK: .cfi_def_cfa_offset 32920
30 ; CHECK: stg %r2, 176(%r15)
31 ; CHECK: aghi %r15, 32760
33 %y = alloca [4073 x i64], align 8
34 store volatile i64 %x, ptr %y
38 ; Allocate one more doubleword. This is the one frame size that we can
39 ; allocate using AGHI but must free using AGFI.
40 define void @f3(i64 %x) {
42 ; CHECK: aghi %r15, -32768
43 ; CHECK: .cfi_def_cfa_offset 32928
44 ; CHECK: stg %r2, 176(%r15)
45 ; CHECK: agfi %r15, 32768
47 %y = alloca [4074 x i64], align 8
48 store volatile i64 %x, ptr %y
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, 176(%r15)
59 ; CHECK: agfi %r15, 32776
61 %y = alloca [4075 x i64], align 8
62 store volatile i64 %x, ptr %y
66 ; The largest size that can be both allocated and freed using AGFI.
67 ; At this point the frame is too big to represent properly in the CFI.
68 define void @f5(i64 %x) {
70 ; CHECK: agfi %r15, -2147483640
71 ; CHECK: stg %r2, 176(%r15)
72 ; CHECK: agfi %r15, 2147483640
74 %y = alloca [268435433 x i64], align 8
75 store volatile i64 %x, ptr %y
79 ; The only frame size that can be allocated using a single AGFI but which
80 ; must be freed using two instructions.
81 define void @f6(i64 %x) {
83 ; CHECK: agfi %r15, -2147483648
84 ; CHECK: stg %r2, 176(%r15)
85 ; CHECK: agfi %r15, 2147483640
88 %y = alloca [268435434 x i64], align 8
89 store volatile i64 %x, ptr %y
93 ; The smallest frame size that needs two instructions to both allocate
95 define void @f7(i64 %x) {
97 ; CHECK: agfi %r15, -2147483648
98 ; CHECK: aghi %r15, -8
99 ; CHECK: stg %r2, 176(%r15)
100 ; CHECK: agfi %r15, 2147483640
101 ; CHECK: aghi %r15, 16
103 %y = alloca [268435435 x i64], align 8
104 store volatile i64 %x, ptr %y
108 ; Make sure that LA can be rematerialized.
111 ; CHECK: la %r2, 164(%r15)
112 ; CHECK: brasl %r14, foo@PLT
113 ; CHECK: la %r2, 164(%r15)
114 ; CHECK: brasl %r14, foo@PLT
117 call void @foo(ptr %ptr)
118 call void @foo(ptr %ptr)