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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 25 06:24:30 PDT 2026


AaronBallman wrote:

> > > I'm a little confused why want to do adjustments like this in CodeGen; shouldn't Sema know the address-space of variables?
> > 
> > 
> > I think it needs to be tracked in sema because of `constexpr` (which can happen at compile time or runtime) and AST matchers, etc.
> 
> To be clear, this patch just aims to adjust the emitted AS, not the user-facing AS (which remains `__shared__` for the time being). Does Sema need to be aware of the AS used by the IR at any point ? If so I'll of course look into fixing it, I just didn't think it was the case when I made this. I followed the breadcrumbs of how we do it for other similar cases and built from there

Sema needs to be able to catch undefined behaviors with constant expression evaluation. If the adjusted address space cannot introduce UB that isn't already present from the user-facing address space, then I think it's fine to do from codegen.

I don't think this is [NFC] because it's introducing new functionality that can be used; I'd prefer to drop that from the summary and add test coverage showing that the override actually happens. But in terms of the actual functionality, I leave it to @efriedma-quic and @asl to sign-off as codegen maintainers.

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


More information about the cfe-commits mailing list