[clang] [Clang][OpenCL] Mark scalar loads from constant address space invariant (PR #218356)
Matt Arsenault via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 10 04:28:40 PDT 2026
================
@@ -3500,10 +3503,14 @@ static LValue EmitGlobalVarDeclLValue(CodeGenFunction &CGF,
return EmitThreadPrivateVarDeclLValue(CGF, VD, T, Addr, RealVarTy,
E->getExprLoc());
}
- LValue LV = VD->getType()->isReferenceType() ?
- CGF.EmitLoadOfReferenceLValue(Addr, VD->getType(),
- AlignmentSource::Decl) :
- CGF.MakeAddrLValue(Addr, T, AlignmentSource::Decl);
+ const bool IsReference = VD->getType()->isReferenceType();
+ LValue LV = IsReference ? CGF.EmitLoadOfReferenceLValue(Addr, VD->getType(),
+ AlignmentSource::Decl)
+ : CGF.MakeAddrLValue(Addr, T, AlignmentSource::Decl);
+ // Preserve CUDA constant storage information from the AST declaration.
+ if (!IsReference && CGF.getLangOpts().CUDAIsDevice &&
+ CGF.CGM.GetGlobalVarAddressSpace(VD) == LangAS::cuda_constant)
----------------
arsenm wrote:
Special casing an address space, there should be some predicate function that tells you the global is invariant, not spread the language and address space check here
https://github.com/llvm/llvm-project/pull/218356
More information about the cfe-commits
mailing list