[llvm] [Aarch64] [ISel] Don't save vaargs registers if vaargs are unused (PR #126780)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 14 10:07:01 PDT 2025


mstorsjo wrote:

> I actually don't know the win64 arm vararg convention, but historically Microsoft has taken an approach much more similar to Apple, where variadic arguments all get pass in memory on the stack, for simplicity, if that helps explain the failures.

On Windows/arm64, normally floats are passed in vector registers and ints in GPRs, but for vararg functions, both floats and ints are passed in GPRs. Normally, up to 8 arguments are passed in registers. For vararg functions, the prologue dumps all non-fixed argument registers on the stack, so that it lines up with the following arguments on the stack. (E.g. for a function with 3 fixed parameters, passed in x0, x1, x2, the function dumps x3, x4, ... x7 on the stack, so that varargs can iterate over them plus any following arguments on the stack in one sequence.)

I presume the purpose of this patch is to skip the couple of instructions for dumping these registers on the stack, if nobody actually is going to use the varargs (no `va_start` etc). Sounds like a reasonable idea (and a quick test with one case seems like it roughly does what it's supposed to), but apparently it does break something somewhere.

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


More information about the llvm-commits mailing list