brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.2 KiB · 0d58156 Raw
121 lines · plain
1; Test the allocation of frames in cases where we do not need to save2; registers in the prologue.3;4; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s5 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, -16812; CHECK: .cfi_def_cfa_offset 32813; CHECK: stg %r2, 160(%r15)14; CHECK: aghi %r15, 16815; CHECK: br %r1416  %y = alloca i64, align 817  store volatile i64 %x, ptr %y18  ret void19}20 21; Check frames of size 32760, which is the largest size that can be both22; allocated and freed using AGHI.  This size is big enough to require23; two emergency spill slots at 160(%r15), for instructions with unsigned24; 12-bit offsets that end up being out of range.  Fill the remaining25; 32760 - 176 bytes by allocating (32760 - 176) / 8 = 4073 doublewords.26define void @f2(i64 %x) {27; CHECK-LABEL: f2:28; CHECK: aghi %r15, -3276029; CHECK: .cfi_def_cfa_offset 3292030; CHECK: stg %r2, 176(%r15)31; CHECK: aghi %r15, 3276032; CHECK: br %r1433  %y = alloca [4073 x i64], align 834  store volatile i64 %x, ptr %y35  ret void36}37 38; Allocate one more doubleword.  This is the one frame size that we can39; allocate using AGHI but must free using AGFI.40define void @f3(i64 %x) {41; CHECK-LABEL: f3:42; CHECK: aghi %r15, -3276843; CHECK: .cfi_def_cfa_offset 3292844; CHECK: stg %r2, 176(%r15)45; CHECK: agfi %r15, 3276846; CHECK: br %r1447  %y = alloca [4074 x i64], align 848  store volatile i64 %x, ptr %y49  ret void50}51 52; Allocate another doubleword on top of that.  The allocation and free53; must both use AGFI.54define void @f4(i64 %x) {55; CHECK-LABEL: f4:56; CHECK: agfi %r15, -3277657; CHECK: .cfi_def_cfa_offset 3293658; CHECK: stg %r2, 176(%r15)59; CHECK: agfi %r15, 3277660; CHECK: br %r1461  %y = alloca [4075 x i64], align 862  store volatile i64 %x, ptr %y63  ret void64}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, -214748364071; CHECK: stg %r2, 176(%r15)72; CHECK: agfi %r15, 214748364073; CHECK: br %r1474  %y = alloca [268435433 x i64], align 875  store volatile i64 %x, ptr %y76  ret void77}78 79; The only frame size that can be allocated using a single AGFI but which80; must be freed using two instructions.81define void @f6(i64 %x) {82; CHECK-LABEL: f6:83; CHECK: agfi %r15, -214748364884; CHECK: stg %r2, 176(%r15)85; CHECK: agfi %r15, 214748364086; CHECK: aghi %r15, 887; CHECK: br %r1488  %y = alloca [268435434 x i64], align 889  store volatile i64 %x, ptr %y90  ret void91}92 93; The smallest frame size that needs two instructions to both allocate94; and free the frame.95define void @f7(i64 %x) {96; CHECK-LABEL: f7:97; CHECK: agfi %r15, -214748364898; CHECK: aghi %r15, -899; CHECK: stg %r2, 176(%r15)100; CHECK: agfi %r15, 2147483640101; CHECK: aghi %r15, 16102; CHECK: br %r14103  %y = alloca [268435435 x i64], align 8104  store volatile i64 %x, ptr %y105  ret void106}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@PLT113; CHECK: la %r2, 164(%r15)114; CHECK: brasl %r14, foo@PLT115; CHECK: br %r14116  %ptr = alloca i32117  call void @foo(ptr %ptr)118  call void @foo(ptr %ptr)119  ret void120}121