Skip to content

Conversation

MacDue
Copy link
Member

@MacDue MacDue commented Sep 2, 2025

Previously, we would pop FixedObject-bytes after deallocating the SVE area, then again as part of the "AfterCSRPopSize". This could be seen in the tests @f6 and @f9.

This patch removes the erroneous pop, and refactors FPAfterSVECalleeSaves to reuse more of the existing GPR deallocation logic, which allows for post-decrements.

…Saves

Previously, we would pop `FixedObject`-bytes after deallocating the SVE
area, then again as part of the "AfterCSRPopSize". This could be seen
in the tests `@f6` and `@f9`.

This patch removes the erroneous pop, and refactors `FPAfterSVECalleeSaves`
to reuse more of the existing GPR deallocation logic, which allows for
post-decrements.
Comment on lines +2601 to +2607
// If not, and FPAfterSVECalleeSaves is enabled, deallocate callee-save
// non-SVE registers to move the stack pointer to the start of the SVE
// area.
emitFrameOffset(MBB, std::next(Pop), DL, AArch64::SP, AArch64::SP,
StackOffset::getFixed(ProloguePopSize), TII,
MachineInstr::FrameDestroy, false, NeedsWinCFI,
&HasWinCFI);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been unable to come up with a reasonable test for this case. With !FPAfterSVECalleeSaves we only get here if:

  • We have hazard padding (not applicable)
  • Or use some somewhat niche swiftcc or tailcc functionality, which I'm not sure works with SVE.

I wonder if it'd be okay to just do if (FPAfterSVECalleeSaves) reportFatalInternalError(...) instead?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't be surprised if tailcc handling doesn't work with SVE argument/return types, but it shouldn't interact with SVE spill slots outside of this code.

Copy link
Collaborator

@efriedma-quic efriedma-quic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic here makes sense.

Comment on lines +2601 to +2607
// If not, and FPAfterSVECalleeSaves is enabled, deallocate callee-save
// non-SVE registers to move the stack pointer to the start of the SVE
// area.
emitFrameOffset(MBB, std::next(Pop), DL, AArch64::SP, AArch64::SP,
StackOffset::getFixed(ProloguePopSize), TII,
MachineInstr::FrameDestroy, false, NeedsWinCFI,
&HasWinCFI);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't be surprised if tailcc handling doesn't work with SVE argument/return types, but it shouldn't interact with SVE spill slots outside of this code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants