[PATCH] D31042: Allow DataLayout to specify addrspace for allocas.

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 27 15:09:12 PDT 2017


arsenm added a comment.

In https://reviews.llvm.org/D31042#711627, @rjmccall wrote:

>




> You keep talking about LLVM having a "generic address space".  I'm trying to figure out what you mean by that, because in LLVM, global values can be declared in an arbitrary address space, pointer values all carry an address space, instructions work on arbitrary address spaces, the memory intrinsics are generally overloaded by pointer address spaces, etc.  And in general, the idea that there exists a generic address space which subsumes every other address space is just wrong.  As an example, on x86-64 we use address spaces as a way of requesting segmented addressing; even if the memory there was addressable in the standard segment (which is not guaranteed), AFAIK there's no way to actually perform that conversion.
> 
> Given that, there's nothing wrong with LLVM deciding to hard-code a specific address space index as the address space of the stack.  That's worth doing if it significantly simplifies the IR, e.g. by not requiring a data layout to be passed to CreateAlloca.  It just means that frontends that *do* assume there's a generic address space may need to insert addrspace conversions in some cases.
> 
> it's okay to call out some specific address space, like addrspace 0, and say that it's always the address space of the stack.
> 
> I certainly hope that nothing in LLVM is ever implicitly inserting addrspace conversions or assuming anything about them without target-specific information.  In general, it is not true that there exists an address space that subsumes all others.

LLVM treats 0 as the "generic" address space. This is how the LangRef refers to it. In the AMDGPU sense this is a pointer that can be used to access any memory. For AMDGPU, globals declared without an address space are invalid. All objects must have a definite address space.

There have been bugs in the past from random places inserting addrspacecasts but I don't think I've seen one recently


https://reviews.llvm.org/D31042





More information about the llvm-commits mailing list