[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
Tue Sep 15 00:58:25 PDT 2026
================
@@ -1085,6 +1085,14 @@ class CodeGenModule : public CodeGenTypeCache {
/// space, target-specific global or constant address space may be returned.
LangAS GetGlobalVarAddressSpace(const VarDecl *D);
+ /// Return whether loads from an address space are invariant.
+ bool isInvariantAddressSpace(LangAS AS) const {
+ return AS == LangAS::opencl_constant || AS == LangAS::cuda_constant;
+ }
+
+ /// Return whether loads from a global variable are invariant.
+ bool isGlobalVarInvariant(const VarDecl *D);
+
----------------
keshavvinayak01 wrote:
@arsenm `isGlobalVarInvariant` keeps address-space recovery and classification out of the CodeGen call site.
https://github.com/llvm/llvm-project/pull/218356
More information about the cfe-commits
mailing list