[llvm-branch-commits] [clang] [NFCI][clang] Allow overriding any global variable address space (PR #195612)
Pierre van Houtryve via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed May 6 00:56:57 PDT 2026
================
@@ -312,13 +312,15 @@ class TargetCodeGenInfo {
virtual llvm::Constant *getNullPointer(const CodeGen::CodeGenModule &CGM,
llvm::PointerType *T, QualType QT) const;
- /// Get target favored AST address space of a global variable for languages
- /// other than OpenCL and CUDA.
- /// If \p D is nullptr, returns the default target favored address space
- /// for global variable.
- virtual LangAS getGlobalVarAddressSpace(CodeGenModule &CGM,
- const VarDecl *D) const;
-
+ /// Adjust the address space proposed by the code generator for \p D.
+ /// If \p AS is empty, it means language semantics did not specify any address
+ /// space for this \p D.
+ ///
+ /// Can be used by targets to further refine the chosen address space for a
+ /// declaration.
+ virtual LangAS adjustGlobalVarAddressSpace(CodeGenModule &CGM,
+ const VarDecl *D,
+ std::optional<LangAS> AS) const;
----------------
Pierre-vh wrote:
I could if I refactored a bit more and moved all the logic that determines the AS of a GV (from CodeGenModule) into the base TargetInfo method. I'd need to pass some more arguments though, like the OpenMPRuntime pointer
I just thought it was easier to keep CGM as-is, and just give more control to the TargetInfo hook.
https://github.com/llvm/llvm-project/pull/195612
More information about the llvm-branch-commits
mailing list