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

Keshav Vinayak Jha via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 8 19:52:26 PST 2026


================
@@ -2769,6 +2772,8 @@ class CodeGenFunction : public CodeGenTypeCache {
 
   LValue MakeAddrLValue(Address Addr, QualType T, LValueBaseInfo BaseInfo,
                         TBAAAccessInfo TBAAInfo) {
+    if (CGM.isInvariantAddressSpace(T.getAddressSpace()))
----------------
keshavvinayak01 wrote:

This checks the access type, which covers OpenCL/HLSL. CUDA is handled in `EmitGlobalVarDeclLValue(): isGlobalVarInvariant(VD)` classifies the declaration via `GetGlobalVarAddressSpace()`.

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


More information about the cfe-commits mailing list