[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:48:07 PDT 2024


AlexVlx wrote:

> > 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.
> 
> I'm just saying that I don't think it makes any sense to add a concept of a default AS to LLVM. The "default" AS is a frontend concept, not a middle-end / back-end concept. LLVM would only need a default AS if it were inventing a memory allocation/operation from whole cloth, which is generally not something LLVM should be doing except in local memory; the only legitimate counter-example I can think of would be something like materializing a constant into constant global memory, in which case LLVM needs to assign the new constant an AS.

Ah, ok, I was misreading what you said. I agree; however, I believe that it might make sense to enforce / enshrine that `0` has to be generic i.e. targets shouldn't use `0` creatively, precisely so as to make it a safe default for FEs. Otherwise, if a target uses `0` to refer to a peculiar memory space (say, addresses are of a different size, there are some very odd allocation constraints etc.), the sort of issues that motivated this patch, emerge. I don't know how feasible this is / how much retroactive churn it'd cause.

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


More information about the cfe-commits mailing list