[PATCH] D124615: [AArch64][SVE] Restore SP from FP when SVE CSRs and variable sized objects are present
Bradley Smith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 29 07:43:42 PDT 2022
bsmith updated this revision to Diff 426057.
bsmith retitled this revision from "[AArch64][SVE] Restore SP from base pointer when it and SVE frame are present" to "[AArch64][SVE] Restore SP from FP when SVE CSRs and variable sized objects are present".
bsmith edited the summary of this revision.
bsmith added a comment.
- Rework patch to use same mechanism as stack reaignment, rather than using base pointer.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124615/new/
https://reviews.llvm.org/D124615
Files:
llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
llvm/test/CodeGen/AArch64/framelayout-sve.mir
llvm/test/CodeGen/AArch64/sve-alloca.ll
Index: llvm/test/CodeGen/AArch64/sve-alloca.ll
===================================================================
--- llvm/test/CodeGen/AArch64/sve-alloca.ll
+++ llvm/test/CodeGen/AArch64/sve-alloca.ll
@@ -66,6 +66,7 @@
; CHECK-NEXT: st1d { z1.d }, p0, [x0, #1, mul vl]
; CHECK-NEXT: st1d { z0.d }, p0, [x0]
; CHECK-NEXT: bl bar
+; CHECK-NEXT: addvl sp, x29, #-18
; CHECK-NEXT: ldr p15, [sp, #4, mul vl] // 2-byte Folded Reload
; CHECK-NEXT: ldr p14, [sp, #5, mul vl] // 2-byte Folded Reload
; CHECK-NEXT: ldr p13, [sp, #6, mul vl] // 2-byte Folded Reload
@@ -94,7 +95,6 @@
; CHECK-NEXT: ldr z10, [sp, #15, mul vl] // 16-byte Folded Reload
; CHECK-NEXT: ldr z9, [sp, #16, mul vl] // 16-byte Folded Reload
; CHECK-NEXT: ldr z8, [sp, #17, mul vl] // 16-byte Folded Reload
-; CHECK-NEXT: addvl sp, sp, #18
; CHECK-NEXT: mov sp, x29
; CHECK-NEXT: ldp x28, x19, [sp, #16] // 16-byte Folded Reload
; CHECK-NEXT: ldp x29, x30, [sp], #32 // 16-byte Folded Reload
Index: llvm/test/CodeGen/AArch64/framelayout-sve.mir
===================================================================
--- llvm/test/CodeGen/AArch64/framelayout-sve.mir
+++ llvm/test/CodeGen/AArch64/framelayout-sve.mir
@@ -629,7 +629,6 @@
# CHECK-NEXT: $sp = frame-setup SUBXri $sp, 16, 0
# CHECK-NEXT: $x19 = ADDXri $sp, 0, 0
# CHECK-NEXT: STRXui $xzr, $x19, 0
-# CHECK-NEXT: $sp = frame-destroy ADDVL_XXI $sp, 1
# CHECK-NEXT: $sp = frame-destroy ADDXri $fp, 0, 0
# CHECK-NEXT: frame-destroy CFI_INSTRUCTION def_cfa $wsp, 32
# CHECK-NEXT: $x19 = frame-destroy LDRXui $sp, 2
Index: llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
@@ -1953,7 +1953,10 @@
// Deallocate the SVE area.
if (SVEStackSize) {
- if (AFI->isStackRealigned()) {
+ // If we have variable sized objects on the stack, we must also treat the
+ // stack as being realigned, so as to restore the stack pointer prior to
+ // SVE CSR restoration.
+ if (AFI->isStackRealigned() || MFI.hasVarSizedObjects()) {
if (int64_t CalleeSavedSize = AFI->getSVECalleeSavedStackSize()) {
// Set SP to start of SVE callee-save area from which they can
// be reloaded. The code below will deallocate the stack space
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124615.426057.patch
Type: text/x-patch
Size: 2406 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220429/e0f9c9e7/attachment.bin>
More information about the llvm-commits
mailing list