[clang] [Clang][CUDA] Preserve addresses of scalar grid-constant parameters (PR #231567)

Artem Belevich via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 8 08:59:54 PST 2026


Artem-B wrote:

I don't think `byval` for scalars is the right thing to do here.

Scalars are already passed by value, and `nvvm.grid_constant` already marks the ones we care about. This patch turns them into pseudo-aggregates so they happen to reach the copy-avoiding paths in NVPTX lowering. It happens to work, but it works around the gap in the current implementation instead of fixing it, IMO.

I'd prefer to keep these arguments direct and teach the NVPTX back-end to handle `nvvm.grid_constant` on scalars: use `cvta.param` when the target supports it, and fall back to a copy otherwise. That would probably address the underlying issue. 

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


More information about the cfe-commits mailing list