[clang] [llvm] [LLVM] Fix incorrect alignment on AMDGPU variadics (PR #96370)

Joseph Huber via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 25 05:14:29 PDT 2024


jhuber6 wrote:

> > Hm, that's what I'm doing in the `printf` implementation and it doesn't work without that patch. When I look at the varargs struct it didn't have any padding, which explained why `alignTo(ptr + size, align)` was wrong. So, I was trying to do the following, `printf("%d%ld", 1, 1l)`. With this patch I get the following,
> 
> For what IR? Is the small struct getting expanded into individual scalar pieces?

The implementation intentionally states that the alignment is always `4` in this case, which results in there being no padding between the four byte and eight byte values when put into a `void *` buffer for varargs. You should be able to see it in the changes to the tests. Unfortunately, @JonChesterfield is on vacation so I can't ask about this as it seems to be a deliberate choice, but I don't know how it's correct.

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


More information about the cfe-commits mailing list