[PATCH] D158246: [amdgpu] WIP variadics

Jon Chesterfield via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 18 13:27:04 PDT 2023


JonChesterfield removed subscribers: kristof.beyls, wangpc, jdoerfert.
JonChesterfield added inline comments.


================
Comment at: llvm/lib/CodeGen/ExpandVAIntrinsics.cpp:215-217
+    auto alloced = Builder.Insert(
+        new AllocaInst(VarargsTy, DL.getAllocaAddrSpace(), nullptr,
+                       std::max(MaxFieldAlign, assumedStructAlignment(DL))),
----------------
arsenm wrote:
> What's wrong with just Builder.CreateAlloca?
I want to mark the callee parameter with alignment metadata so the pointer alignment can constant fold (todo, said folding isn't currently working very well).

The struct contains whatever the caller was passing which we don't know much about. If we call CreateAlloca, it gets whatever alignment suffices for those fields.

If those two don't line up nicely, you get bad times. I'm using the stack alignment from the target string as a heuristic for a reasonable alignment to use for things on the stack. For amdgpu that's 4, which means passing a double gets an dynamic realignment which doesn't optimise out, but otherwise it seems reasonable.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158246



More information about the cfe-commits mailing list