[clang] [Clang][OpenCL] Mark scalar loads from constant address space invariant (PR #218356)

Christudasan Devadasan via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 2 20:51:06 PST 2026


cdevadas wrote:

I guess the new information passed down by this new metadata is useful for SPIR-V, CPU OpenCL and HLSL. For AMDGPU, flat ptr is the one specific use case that benefits. If this patch is worth considering, you must do the following first:
Rewrite the description to clearly indicate the patch's scope.
Drop the AMDGPU example with `constant int *k`. I believe if you compile the source code given in the description with clang, it would produce IR with AS4 instead of AS1. Can you verify that once again? If that is true, this use case doesn't benefit from this metadata. AS4 itself is sufficient to hint at it. You better motivate with SPIR-V / CPU OpenCL / HLSL cbuffer, where the IR otherwise has no way to know.
Also, add a test where the metadata changes an optimization: x86 or SPIR-V OpenCL, `constant` vs `global const` reused across a call (yxsamliu's request).

@efriedma-quic do you have any thoughts on this reply to your question? https://github.com/llvm/llvm-project/pull/218356#pullrequestreview-6070066765

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


More information about the cfe-commits mailing list