[PATCH] D100365: [AArch64] Fix windows vararg functions with floats in the fixed args

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 13 00:40:14 PDT 2021


mstorsjo created this revision.
mstorsjo added reviewers: rnk, efriedma, TomTan, maxim-kuvyrkov, aemerson.
Herald added subscribers: danielkiss, pengfei, hiraditya, kristof.beyls.
mstorsjo requested review of this revision.
Herald added a project: LLVM.

On Windows, float arguments are normally passed in float registers
in the calling convention for regular functions. For variable
argument functions, floats are passed in integer registers. This
already was done correctly since many years.

However, the surprising bit was that floats among the fixed arguments
also are supposed to be passed in integer registers, contrary to regular
functions. (This also seems to be the behaviour on ARM though, both
on Windows, but also on e.g. hardfloat linux.)

In the calling convention, don't promote shorter floats to f64, but
convert them to integers of the same length. (Floats passed as part of
the actual variable arguments are promoted to double already on the
C/Clang level; the LLVM vararg calling convention doesn't do any
extra promotion of f32 to f64 - this matches how it works on X86 too.)

Technically, this is an ABI break compared to older LLVM versions,
but it fixes compatibility with the official platform ABI. (In practice,
floats among the fixed arguments in variable argument functions is
a pretty rare construct.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100365

Files:
  llvm/lib/Target/AArch64/AArch64CallingConvention.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp
  llvm/test/CodeGen/AArch64/GlobalISel/call-translator-tail-call.ll
  llvm/test/CodeGen/AArch64/win64_vararg_float.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100365.337056.patch
Type: text/x-patch
Size: 11692 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210413/ecf393a2/attachment-0001.bin>


More information about the llvm-commits mailing list