[PATCH] D135687: [AArch64] Fix aligning the stack after calling __chkstk

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 14 02:16:43 PDT 2022


mstorsjo updated this revision to Diff 467717.
mstorsjo added a comment.

Added a testcase for one case where things broke in practice with the previous form.

Since the previous version, I moved the setting of `NeedsRealignment` further down in the function. Previously I initialized this variable early in the function, before the first call to `windowsRequiresStackProbe`. However, `NumBytes` may be nonzero at this point (making `NeedsRealignment` true), even if `NumBytes` would be zero at the point when realignment is done later in the function, prior to the patch.

We don't need to include `RealignmentPadding` in the first initial check with `windowsRequiresStackProbe`, since if we're actually going to realign the stack, we do have a stack frame anyway.

Additionally, don't set `RealignmentPadding` to a nonzero value, if the requested alignment is less than 16. In the added testcase, `MFI.getMaxAlign()` is 8. (Curiously, for non-Windows OSes, this input actually does result in generating code for ANDing the stack pointer to align it to 8 bytes though.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135687/new/

https://reviews.llvm.org/D135687

Files:
  llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
  llvm/test/CodeGen/AArch64/win-align-chkstk.ll
  llvm/test/CodeGen/AArch64/win-realign.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135687.467717.patch
Type: text/x-patch
Size: 4181 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221014/4c7fb7d1/attachment.bin>


More information about the llvm-commits mailing list