Skip to content

Commit 1ff11ee

Browse files
committed
Fixups
1 parent f9f1398 commit 1ff11ee

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

llvm/lib/Target/AArch64/AArch64PrologueEpilogue.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,20 +1530,20 @@ void AArch64EpilogueEmitter::emitEpilogue() {
15301530
(AFI->isStackRealigned() || MFI.hasVarSizedObjects()) ? AArch64::FP
15311531
: AArch64::SP;
15321532
if (SVECalleeSavesSize && BaseForSVEDealloc == AArch64::FP) {
1533-
// The offset from the frame-pointer to the start of the ZPR saves.
1534-
StackOffset FPOffsetZPR =
1535-
-SVECalleeSavesSize - PPR.LocalsSize -
1536-
StackOffset::getFixed(AFI->getCalleeSaveBaseToFrameRecordOffset());
1537-
// The offset from the frame-pointer to the start of the PPR saves.
1538-
StackOffset FPOffsetPPR = -PPR.CalleeSavesSize;
1539-
15401533
if (ZPR.CalleeSavesSize || SVELayout != SVEStackLayout::Split) {
1534+
// The offset from the frame-pointer to the start of the ZPR saves.
1535+
StackOffset FPOffsetZPR =
1536+
-SVECalleeSavesSize - PPR.LocalsSize -
1537+
StackOffset::getFixed(AFI->getCalleeSaveBaseToFrameRecordOffset());
15411538
// Deallocate the stack space space by moving the SP to the start of the
15421539
// ZPR/PPR callee-save area.
15431540
moveSPBelowFP(ZPRRange.Begin, FPOffsetZPR);
15441541
}
1545-
1542+
// With split SVE, the predicates are stored in a separate area above the
1543+
// ZPR saves, so we must adjust the stack to the start of the PPRs.
15461544
if (PPR.CalleeSavesSize && SVELayout == SVEStackLayout::Split) {
1545+
// The offset from the frame-pointer to the start of the PPR saves.
1546+
StackOffset FPOffsetPPR = -PPR.CalleeSavesSize;
15471547
// Move to the start of the PPR area.
15481548
assert(!FPOffsetPPR.getFixed() && "expected only scalable offset");
15491549
emitFrameOffset(MBB, ZPRRange.End, DL, AArch64::SP, AArch64::FP,

llvm/test/CodeGen/AArch64/split-sve-stack-frame-layout.ll

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,8 @@ define void @zpr_and_ppr_local_stack_probing(<vscale x 16 x i1> %pred, <vscale x
794794
}
795795

796796
; Only PPR callee-saves + a VLA
797+
; Expect: No hazard padding. Frame pointer (x29), p4-p6 callee saves allocated
798+
; with `addvl #-1`, PPR saves restored using frame pointer `addvl sp, x29, #-1`.
797799
define aarch64_sve_vector_pcs void @only_ppr_csr_vla(i64 %n) {
798800
; CHECK-LABEL: only_ppr_csr_vla:
799801
; CHECK: // %bb.0:
@@ -832,6 +834,8 @@ define aarch64_sve_vector_pcs void @only_ppr_csr_vla(i64 %n) {
832834
}
833835

834836
; Only ZPR callee-saves + a VLA
837+
; Expect: Hazard padding, Frame pointer (x29), z8-z10 callee saves allocated
838+
; with `addvl #-3`. ZPR saves restored from `FP - 1024 + addvl #-3`.
835839
define aarch64_sve_vector_pcs void @only_zpr_csr_vla(i64 %n) {
836840
; CHECK-LABEL: only_zpr_csr_vla:
837841
; CHECK: // %bb.0:
@@ -879,6 +883,10 @@ define aarch64_sve_vector_pcs void @only_zpr_csr_vla(i64 %n) {
879883
}
880884

881885
; PPR+ZPR callee-saves + a VLA
886+
; Expect: Hazard padding, Frame pointer (x29), PPR (p4-p6) and ZPR (z8-z10)
887+
; callee-saves allocated separately, with hazard padding of 1024 between the
888+
; areas. ZPR callee saves restored by `FP - 1024 + addvl #-4`, PPR callee saves
889+
; restored by `FP + addvl #-1`.
882890
define aarch64_sve_vector_pcs void @zpr_ppr_csr_vla(i64 %n) {
883891
; CHECK-LABEL: zpr_ppr_csr_vla:
884892
; CHECK: // %bb.0:
@@ -931,6 +939,10 @@ define aarch64_sve_vector_pcs void @zpr_ppr_csr_vla(i64 %n) {
931939
}
932940

933941
; Only PPR callee-saves (and ZPR/PPR locals) + a VLA
942+
; Expect: Hazard padding, Frame pointer (x29), PPR (p4-p6) callee-saves, with
943+
; hazard padding after the PPR callee saves (1024) and after the FPR local area
944+
; (1024) -- coeleased to 2048. Only PPRs restored by moving the SP to
945+
; `FP + addvl #-1`.
934946
define void @sve_locals_only_ppr_csr_vla(i64 %n, <vscale x 16 x i1> %pred, <vscale x 16 x i8> %vector) {
935947
; CHECK-LABEL: sve_locals_only_ppr_csr_vla:
936948
; CHECK: // %bb.0:
@@ -978,6 +990,9 @@ define void @sve_locals_only_ppr_csr_vla(i64 %n, <vscale x 16 x i1> %pred, <vsca
978990
}
979991

980992
; Only ZPR callee-saves (and ZPR/PPR locals) + a VLA
993+
; Expect: Hazard padding, Frame pointer (x29), ZPR (z8-z10) callee-saves, with
994+
; hazard padding before the ZPR callee saves (1024) and after the ZPR local area
995+
; (1024). Only ZPRs restored by moving the SP to `FP - 1024 + addvl #-4`.
981996
define void @sve_locals_only_zpr_csr_vla(i64 %n, <vscale x 16 x i1> %pred, <vscale x 16 x i8> %vector) {
982997
; CHECK-LABEL: sve_locals_only_zpr_csr_vla:
983998
; CHECK: // %bb.0:
@@ -1029,6 +1044,10 @@ define void @sve_locals_only_zpr_csr_vla(i64 %n, <vscale x 16 x i1> %pred, <vsca
10291044
}
10301045

10311046
; PPR+ZPR callee-saves (and ZPR/PPR locals) + a VLA
1047+
; Expect: Hazard padding, Frame pointer (x29), PPR (p4-p6) and ZPR (z8-z10)
1048+
; callee-saves, with hazard padding before the ZPR callee saves (1024) and after
1049+
; the ZPR local area (1024). ZPRs restored by moving the SP to
1050+
; `FP - 1024 + addvl #-5`, PPRs restored by moving SP to `FP + addvl #-1`.
10321051
define void @sve_locals_zpr_ppr_csr_vla(i64 %n, <vscale x 16 x i1> %pred, <vscale x 16 x i8> %vector) {
10331052
; CHECK-LABEL: sve_locals_zpr_ppr_csr_vla:
10341053
; CHECK: // %bb.0:

0 commit comments

Comments
 (0)