[llvm] [AArch64] Skip over shadow space for ARM64EC entry thunk variadic calls (PR #80994)

Billy Laws via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 13 07:01:02 PST 2024


bylaws wrote:

> In general, I attempted to keep the meaning of IR inside the thunks as close as possible to "normal" IR: following the same semantics, just with a slightly exotic calling convention. So someone who doesn't understand the rules here can just ignore the calling convention stuff, and understand what the IR is doing.
> 
> Here, you're violating that rule: you're making a vararg function argument passing work the wrong way. Outside of musttail calls, vararg lists don't normally get forwarded from the caller to the callee. The vararg list of a call consists of arguments explicitly passed beyond the end of the fixed argument list.
> 
> I see two ways to solve this:
> 
> * We try to add some way to model "vararg list forwarding" to LLVM IR.  This doesn't currently exist, so a bit complicated to add.
> * We don't model the caller or the callee as "varargs"; instead, we pass x4 and x5 explicitly.  Basically, add "inreg" markings (or something like that) to the arguments representing x4 and x5, then mess with CC_AArch64_Arm64EC_Thunk using CCIfInReg to pass those values in registers instead of memory.

I'm conflicted on this, it would surely be the easiest but I don't think it makes much sense to break the 1-1 mapping between x86 args and entry thunk args, modelling x4 as an argument when it isn't. Using the regular CC to call a varargs CC call also feels quite counter-intuitive. The former seems like a better idea, but modelling both zeroing x5 and offsetting x4 in a generic way seems like it would need something beyond just basic forwarding. Did you have any concrete ideas for handling that?

https://github.com/llvm/llvm-project/pull/80994


More information about the llvm-commits mailing list