[clang] [clang] Allow overriding any global variable address space (PR #195612)

Pierre van Houtryve via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 3 02:11:35 PDT 2026


Pierre-vh wrote:

> mapping LangAS to LangAS is a fundamentally dodgy operation.

This is not the goal of this patch (and #195613 does not do that at any point either), but the added TargetInfo hook could be abused for that indeed.
This patch just changes the flow from conditionally calling TargetInfo to determine the AS of a GV to always calling it.

> Make GetGlobalVarAddressSpace return that address space for barrier globals

This patch is simply trying to enable that. I did not think it was okay to check an AMDGPU-specific type in the middle of `lib/CodeGen/CodeGenModule.cpp`. Is it the recommended approach? Then this patch can just be closed and I can do that directly in #195613 indeed.

> Define a LangAS::hip_barrier language-level address space

That's fine if we want to avoid the `getLangASFromTargetAS(llvm::AMDGPUAS::BARRIER)` call later, but it's orthogonal to this patch. It's a concern for #195613

Suggestion: How about I do a very targeted hook instead, something like `getCUDADeviceGlobalVarAddressSpace` that'd always be called? Seems like that'd be less abuse-able. I can do it directly in #195613 as well.

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


More information about the cfe-commits mailing list