[PATCH] D11242: Fix assert when inlining a constantexpr addrspacecast

hfinkel at anl.gov hfinkel at anl.gov
Sun Jul 26 09:50:49 PDT 2015


hfinkel accepted this revision.
hfinkel added a reviewer: hfinkel.
hfinkel added a comment.
This revision is now accepted and ready to land.

In http://reviews.llvm.org/D11242#212256, @arsenm wrote:

> In http://reviews.llvm.org/D11242#212156, @hfinkel wrote:
>
> > > Accumulating the offset through the addrspacecast doesn't make much sense
> >
> >
> > Why does it not make sense? It just means that the base object is in a different address space from the original derived pointer. The LangRef says:
> >
> > > Note that if the address space conversion is legal then both result and operand refer to the same memory location.
> >
> >
> > and so, unless the addresscast were somehow illegal (is that possible for a constant expression addresscast?) then it should have a well-defined meaning. Am I missing something?
>
>
> The addrspacecast can totally change the representation of the pointer. In the case I ran into, the original pointer is a 32-bit offset into special on chip memory being casted to a 64-bit address space. The pointer is converted to a full virtual 64-bit address which will resolve to the same location, but doesn't have a common base with the original pointer, so there isn't a simple add relationship between the two.


Ah, okay. So the problem is then that you can't subtract them (or something like that). Or more specifically, the address space is part of the type, and constant folding can't change the type.

LGTM.


http://reviews.llvm.org/D11242







More information about the llvm-commits mailing list