-
Notifications
You must be signed in to change notification settings - Fork 14.2k
[AArch64][SME] Fix restoring callee-saves from FP with hazard padding #143371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c965294
0cedfe5
f101ba2
b2144ed
903f3fd
7fc63d9
98ee22f
11b953a
d9c517b
698e146
edc8b5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2535,20 +2535,33 @@ void AArch64FrameLowering::emitEpilogue(MachineFunction &MF, | |
DeallocateAfter, TII, MachineInstr::FrameDestroy, false, | ||
NeedsWinCFI, &HasWinCFI); | ||
} else if (SVEStackSize) { | ||
// If we have stack realignment or variable sized objects on the stack, | ||
// restore the stack pointer from the frame 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 | ||
// space by moving FP -> SP. | ||
emitFrameOffset(MBB, RestoreBegin, DL, AArch64::SP, AArch64::FP, | ||
StackOffset::getScalable(-CalleeSavedSize), TII, | ||
int64_t SVECalleeSavedSize = AFI->getSVECalleeSavedStackSize(); | ||
// If we have stack realignment or variable-sized objects we must use the | ||
// FP to restore SVE callee saves (as there is an unknown amount of | ||
// data/padding between the SP and SVE CS area). | ||
Register BaseForSVEDealloc = | ||
(AFI->isStackRealigned() || MFI.hasVarSizedObjects()) ? AArch64::FP | ||
: AArch64::SP; | ||
if (SVECalleeSavedSize && BaseForSVEDealloc == AArch64::FP) { | ||
Register CalleeSaveBase = AArch64::FP; | ||
if (int64_t CalleeSaveBaseOffset = | ||
AFI->getCalleeSaveBaseToFrameRecordOffset()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For my own understanding, is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, later in |
||
// If we have have an non-zero offset to the non-SVE CS base we need to | ||
// compute the base address by subtracting the offest in a temporary | ||
// register first (to avoid briefly deallocating the SVE CS). | ||
CalleeSaveBase = MBB.getParent()->getRegInfo().createVirtualRegister( | ||
&AArch64::GPR64RegClass); | ||
emitFrameOffset(MBB, RestoreBegin, DL, CalleeSaveBase, AArch64::FP, | ||
StackOffset::getFixed(-CalleeSaveBaseOffset), TII, | ||
MachineInstr::FrameDestroy); | ||
} | ||
} else { | ||
if (AFI->getSVECalleeSavedStackSize()) { | ||
// The code below will deallocate the stack space space by moving the | ||
// SP to the start of the SVE callee-save area. | ||
emitFrameOffset(MBB, RestoreBegin, DL, AArch64::SP, CalleeSaveBase, | ||
StackOffset::getScalable(-SVECalleeSavedSize), TII, | ||
MachineInstr::FrameDestroy); | ||
} else if (BaseForSVEDealloc == AArch64::SP) { | ||
if (SVECalleeSavedSize) { | ||
// Deallocate the non-SVE locals first before we can deallocate (and | ||
// restore callee saves) from the SVE area. | ||
emitFrameOffset( | ||
|
Uh oh!
There was an error while loading. Please reload this page.