[PATCH] D106444: X86: fix frame offset calculation with mandatory tail calls

Tim Northover via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 21 07:22:01 PDT 2021


t.p.northover created this revision.
Herald added subscribers: pengfei, hiraditya, mcrosier.
t.p.northover requested review of this revision.
Herald added a project: LLVM.

If there's a region of the stack reserved for potential tail call arguments (only the case when we guarantee tail calls will be honoured), this is right next to the incoming stored return address, not necessarily next to the callee-saved area, so combining the two into a single figure leads to incorrect offsets in some edge cases.

This keeps the two concepts split and (hopefully) updates all users of `getCalleeSavedFrameSize` that need it. The notable exceptions are the stack-realignment code in `emitEpilogue` (~line 2117) which is where the bug came from, and Windows-ABI functions, because they don't guarantee tail calls so it should always be zero there.

Similarly, the code in `getFrameIndexReference` that dealt with this delta wasn't present on the realigned stack branch so I refactored it so that wasn't possible any more.


https://reviews.llvm.org/D106444

Files:
  llvm/lib/Target/X86/X86FrameLowering.cpp
  llvm/test/CodeGen/X86/swifttail-realign.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106444.360445.patch
Type: text/x-patch
Size: 7639 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210721/4384b19e/attachment.bin>


More information about the llvm-commits mailing list