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

Tim Northover via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 22 01:22:03 PDT 2021


t.p.northover added inline comments.


================
Comment at: llvm/lib/Target/X86/X86FrameLowering.cpp:2028
     uint64_t FrameSize = StackSize - SlotSize;
-    NumBytes = FrameSize - CSSize;
+    NumBytes = FrameSize - CSSize - TailCallArgReserveSize;
 
----------------
Gerolf wrote:
> It seems here the  code assume TailCallArgReserveSize is positive? This looks inconsistent to (X86FI->getCalleeSavedFrameSize() + TailCallArgReserveSize) in the NumBytes calculation in the function above. 
It is positive in both cases. Schematically the previous function has `A - (B + C)` but this one is `A - B - C`. I can switch to the first style here for consistency?


================
Comment at: llvm/test/CodeGen/X86/swifttail-realign.ll:1
+; RUN: llc -mtriple=x86_64-linux-gnu %s -o - | FileCheck %s
+
----------------
Gerolf wrote:
> Does this need more tests for the paths modified? 
I think this actually covers both of the actual changes I made (the `leaq` offset and the `[[RETADDR]]` moves).

The frame lowering suggests you can get a base pointer without stack realignment, but it actually only seems to happen in one really obscure case with something called a "preallocated call". I think it's something to do with MSVC compatibility.


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

https://reviews.llvm.org/D106444



More information about the llvm-commits mailing list