[clang] [Clang][CodeGen] Start migrating away from assuming the Default AS is 0 (PR #88182)

Alex Voicu via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 9 13:19:57 PDT 2024


https://github.com/AlexVlx commented:

> It's very uncommon for LLVM to need to come up with an address space on its own, as opposed to just propagating the original address space of some memory / operation as chosen by the frontend.  LLVM occasionally creates new storage allocations, but usually they're (non-escaping) `alloca`s and therefore have to be in the `alloca` AS.  The only situation I can think of where LLVM might legitimately have to come with an address space is when LLVM decides to introduce new global constants.  (I can't think of any transformation that would introduce a *non-constant* global.)  So if you add a default AS to `DataLayout`, please focus on that specifically and call it something like a "preferred constant address space" rather than some sort of default AS.  The default AS for pointer types and so on is really a frontend issue that's none of LLVM's business to know about. 

I'm not quite sure how to parse this comment, could you explain what you have in mind here? The problem is precisely that the FE assumes 0 is fine / picks it by default, which ends up into dangerzones when e.g. a target happened to use 0 to point to private (stack). I feel as if I'm missing the core of your comment though, so apologies in advance.

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


More information about the cfe-commits mailing list