[PATCH] D133338: [clang][PowerPC] PPC64 VAArg use coerced integer type for direct aggregate fits in register

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 11 19:48:51 PDT 2022


rjmccall added a reviewer: t.p.northover.
rjmccall added inline comments.


================
Comment at: clang/lib/CodeGen/TargetInfo.cpp:5461
 
   // Otherwise, just use the general rule.
+  // TODO: a better approach may refer to SystemZABI use same logic for caller
----------------
Please add this comment explaining the use of ForceRightAdjust:

> The PPC64 ABI passes some arguments in integer registers, even to variadic functions.  To allow `va_list` to use the simple "`void*`" representation, variadic calls allocate space in the argument area for the integer argument registers, and variadic functions spill their integer argument registers to this area in their prologues.  When aggregates smaller than a register are passed this way, they are passed in the least significant bits of the register, which means that after spilling on big-endian targets they will be right-aligned in their argument slot.  This is uncommon; for a variety of reasons, other big-endian targets don't end up right-aligning aggregate types this way, and so right-alignment only applies to fundamental types.  So on PPC64, we must force the use of right-alignment even for aggregates.

I'm not sure what your TODO is hoping for.  You'd like to re-use logic between the frontend's va_arg emission and the backend's variadic argument emission?  That would be very tricky.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133338



More information about the cfe-commits mailing list