1; Test the allocation of frames in cases where we do not need to save 2; registers in the prologue. 3; 4; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s 5 6declare void @foo(ptr) 7 8; The CFA offset is 160 (the caller-allocated part of the frame) + 168. 9define void @f1(i64 %x) { 10; CHECK-LABEL: f1: 11; CHECK: aghi %r15, -168 12; CHECK: .cfi_def_cfa_offset 328 13; CHECK: stg %r2, 160(%r15) 14; CHECK: aghi %r15, 168 15; CHECK: br %r14 16 %y = alloca i64, align 8 17 store volatile i64 %x, ptr %y 18 ret void 19} 20 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. 26define void @f2(i64 %x) { 27; CHECK-LABEL: f2: 28; CHECK: aghi %r15, -32760 29; CHECK: .cfi_def_cfa_offset 32920 30; CHECK: stg %r2, 176(%r15) 31; CHECK: aghi %r15, 32760 32; CHECK: br %r14 33 %y = alloca [4073 x i64], align 8 34 store volatile i64 %x, ptr %y 35 ret void 36} 37 38; Allocate one more doubleword. This is the one frame size that we can 39; allocate using AGHI but must free using AGFI. 40define void @f3(i64 %x) { 41; CHECK-LABEL: f3: 42; CHECK: aghi %r15, -32768 43; CHECK: .cfi_def_cfa_offset 32928 44; CHECK: stg %r2, 176(%r15) 45; CHECK: agfi %r15, 32768 46; CHECK: br %r14 47 %y = alloca [4074 x i64], align 8 48 store volatile i64 %x, ptr %y 49 ret void 50} 51 52; Allocate another doubleword on top of that. The allocation and free 53; must both use AGFI. 54define void @f4(i64 %x) { 55; CHECK-LABEL: f4: 56; CHECK: agfi %r15, -32776 57; CHECK: .cfi_def_cfa_offset 32936 58; CHECK: stg %r2, 176(%r15) 59; CHECK: agfi %r15, 32776 60; CHECK: br %r14 61 %y = alloca [4075 x i64], align 8 62 store volatile i64 %x, ptr %y 63 ret void 64} 65 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. 68define void @f5(i64 %x) { 69; CHECK-LABEL: f5: 70; CHECK: agfi %r15, -2147483640 71; CHECK: stg %r2, 176(%r15) 72; CHECK: agfi %r15, 2147483640 73; CHECK: br %r14 74 %y = alloca [268435433 x i64], align 8 75 store volatile i64 %x, ptr %y 76 ret void 77} 78 79; The only frame size that can be allocated using a single AGFI but which 80; must be freed using two instructions. 81define void @f6(i64 %x) { 82; CHECK-LABEL: f6: 83; CHECK: agfi %r15, -2147483648 84; CHECK: stg %r2, 176(%r15) 85; CHECK: agfi %r15, 2147483640 86; CHECK: aghi %r15, 8 87; CHECK: br %r14 88 %y = alloca [268435434 x i64], align 8 89 store volatile i64 %x, ptr %y 90 ret void 91} 92 93; The smallest frame size that needs two instructions to both allocate 94; and free the frame. 95define void @f7(i64 %x) { 96; CHECK-LABEL: f7: 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 102; CHECK: br %r14 103 %y = alloca [268435435 x i64], align 8 104 store volatile i64 %x, ptr %y 105 ret void 106} 107 108; Make sure that LA can be rematerialized. 109define void @f8() { 110; CHECK-LABEL: f8: 111; CHECK: la %r2, 164(%r15) 112; CHECK: brasl %r14, foo@PLT 113; CHECK: la %r2, 164(%r15) 114; CHECK: brasl %r14, foo@PLT 115; CHECK: br %r14 116 %ptr = alloca i32 117 call void @foo(ptr %ptr) 118 call void @foo(ptr %ptr) 119 ret void 120} 121