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 declare void @foo(i32 *)
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, i64* %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 %ptr = getelementptr inbounds [4073 x i64], [4073 x i64]* %y, i64 0, i64 0
35 store volatile i64 %x, i64* %ptr
39 ; Allocate one more doubleword. This is the one frame size that we can
40 ; allocate using AGHI but must free using AGFI.
41 define void @f3(i64 %x) {
43 ; CHECK: aghi %r15, -32768
44 ; CHECK: .cfi_def_cfa_offset 32928
45 ; CHECK: stg %r2, 176(%r15)
46 ; CHECK: agfi %r15, 32768
48 %y = alloca [4074 x i64], align 8
49 %ptr = getelementptr inbounds [4074 x i64], [4074 x i64]* %y, i64 0, i64 0
50 store volatile i64 %x, i64* %ptr
54 ; Allocate another doubleword on top of that. The allocation and free
56 define void @f4(i64 %x) {
58 ; CHECK: agfi %r15, -32776
59 ; CHECK: .cfi_def_cfa_offset 32936
60 ; CHECK: stg %r2, 176(%r15)
61 ; CHECK: agfi %r15, 32776
63 %y = alloca [4075 x i64], align 8
64 %ptr = getelementptr inbounds [4075 x i64], [4075 x i64]* %y, i64 0, i64 0
65 store volatile i64 %x, i64* %ptr
69 ; The largest size that can be both allocated and freed using AGFI.
70 ; At this point the frame is too big to represent properly in the CFI.
71 define void @f5(i64 %x) {
73 ; CHECK: agfi %r15, -2147483640
74 ; CHECK: stg %r2, 176(%r15)
75 ; CHECK: agfi %r15, 2147483640
77 %y = alloca [268435433 x i64], align 8
78 %ptr = getelementptr inbounds [268435433 x i64], [268435433 x i64]* %y, i64 0, i64 0
79 store volatile i64 %x, i64* %ptr
83 ; The only frame size that can be allocated using a single AGFI but which
84 ; must be freed using two instructions.
85 define void @f6(i64 %x) {
87 ; CHECK: agfi %r15, -2147483648
88 ; CHECK: stg %r2, 176(%r15)
89 ; CHECK: agfi %r15, 2147483640
92 %y = alloca [268435434 x i64], align 8
93 %ptr = getelementptr inbounds [268435434 x i64], [268435434 x i64]* %y, i64 0, i64 0
94 store volatile i64 %x, i64* %ptr
98 ; The smallest frame size that needs two instructions to both allocate
100 define void @f7(i64 %x) {
102 ; CHECK: agfi %r15, -2147483648
103 ; CHECK: aghi %r15, -8
104 ; CHECK: stg %r2, 176(%r15)
105 ; CHECK: agfi %r15, 2147483640
106 ; CHECK: aghi %r15, 16
108 %y = alloca [268435435 x i64], align 8
109 %ptr = getelementptr inbounds [268435435 x i64], [268435435 x i64]* %y, i64 0, i64 0
110 store volatile i64 %x, i64* %ptr
114 ; Make sure that LA can be rematerialized.
117 ; CHECK: la %r2, 164(%r15)
118 ; CHECK: brasl %r14, foo@PLT
119 ; CHECK: la %r2, 164(%r15)
120 ; CHECK: brasl %r14, foo@PLT
123 call void @foo(i32 *%ptr)
124 call void @foo(i32 *%ptr)