[PATCH] D86099: [AArch64][SVE] Fix calculation restore point for SVE callee saves.
Sander de Smalen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 17 12:19:32 PDT 2020
sdesmalen created this revision.
sdesmalen added reviewers: paulwalker-arm, efriedma, david-arm.
Herald added subscribers: danielkiss, psnobl, hiraditya, kristof.beyls, tschuett.
Herald added a project: LLVM.
sdesmalen requested review of this revision.
This fixes an issue where the restore point of callee-saves in the
function epilogues was incorrectly calculated when the basic block
consisted of only a RET instruction. This caused dealloc instructions
to be inserted in between the block of callee-save restore instructions,
rather than before it.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D86099
Files:
llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
llvm/test/CodeGen/AArch64/framelayout-sve-calleesaves-fix.mir
Index: llvm/test/CodeGen/AArch64/framelayout-sve-calleesaves-fix.mir
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/AArch64/framelayout-sve-calleesaves-fix.mir
@@ -0,0 +1,36 @@
+# NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+# RUN: llc -mattr=+sve -mtriple=aarch64-none-linux-gnu -start-before=prologepilog %s -o - | FileCheck %s
+
+--- |
+ define aarch64_sve_vector_pcs void @fix_restorepoint_p4() { entry: unreachable }
+ ; CHECK-LABEL: fix_restorepoint_p4:
+ ; CHECK: // %bb.0: // %entry
+ ; CHECK-NEXT: str x29, [sp, #-16]! // 8-byte Folded Spill
+ ; CHECK-NEXT: addvl sp, sp, #-2
+ ; CHECK-NEXT: str p4, [sp, #7, mul vl] // 2-byte Folded Spill
+ ; CHECK-NEXT: str z8, [sp, #1, mul vl] // 16-byte Folded Spill
+ ; CHECK-NEXT: addvl sp, sp, #-1
+ ; CHECK-NEXT: .cfi_escape 0x0f, 0x0c, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0x18, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 24 * VG
+ ; CHECK-NEXT: .cfi_escape 0x10, 0x48, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x78, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d8 @ cfa - 16 - 8 * VG
+ ; CHECK-NEXT: .cfi_offset w29, -16
+ ; CHECK-NEXT: // implicit-def: $z8
+ ; CHECK-NEXT: // implicit-def: $p4
+ ; CHECK-NEXT: addvl sp, sp, #1
+ ; CHECK-NEXT: ldr p4, [sp, #7, mul vl] // 2-byte Folded Reload
+ ; CHECK-NEXT: ldr z8, [sp, #1, mul vl] // 16-byte Folded Reload
+ ; CHECK-NEXT: addvl sp, sp, #2
+ ; CHECK-NEXT: ldr x29, [sp], #16 // 8-byte Folded Reload
+ ; CHECK-NEXT: ret
+...
+name: fix_restorepoint_p4
+stack:
+ - { id: 0, stack-id: sve-vec, size: 16, alignment: 16 }
+body: |
+ bb.0.entry:
+ $z8 = IMPLICIT_DEF
+ $p4 = IMPLICIT_DEF
+ B %bb.1
+
+ bb.1.entry:
+ RET_ReallyLR
+---
Index: llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
@@ -1698,7 +1698,9 @@
while (IsSVECalleeSave(RestoreBegin) &&
RestoreBegin != MBB.begin())
--RestoreBegin;
- ++RestoreBegin;
+
+ if (!IsSVECalleeSave(RestoreBegin))
+ ++RestoreBegin;
assert(IsSVECalleeSave(RestoreBegin) &&
IsSVECalleeSave(std::prev(RestoreEnd)) && "Unexpected instruction");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86099.286104.patch
Type: text/x-patch
Size: 2373 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200817/81e15eea/attachment.bin>
More information about the llvm-commits
mailing list