[PATCH] D22488: [IR] Introduce a non-integral pointer type

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 26 12:23:47 PDT 2016


sanjoy added inline comments.

================
Comment at: docs/LangRef.rst:559-561
@@ +558,5 @@
+via the :ref:```datalayout`` string<langref_datalayout>`.  Values of the
+non-integral pointer type represent pointers that don't have a *stable* bitwise
+representation; that is at runtime they may not be backed by a fixed unchanging
+pointer-width integer.
+
----------------
arsenm wrote:
> sanjoy wrote:
> > arsenm wrote:
> > > What consequence does the changing pointer value have on the optimizer? I'm interested in this for fat pointers which will not change value during runtime
> > That is the justification for disallowing integer <-> pointer conversions (directly via cast instructions or via memory).  If fat pointers have a stable bitwise representation, then why not represent them as normal pointers?
> > 
> The pointer arithmetic does not behave exactly like a 128-bit integer. Doing pointer arithmetic such as a 128-bit add would be incorrect, and we don't want CodeGenPrepare etc. to be allowed to decompose it into integer operations.
> 
> The high 64-bits are constant "metadata" bits for the memory operation. The low 64-bits behave like a pointer. I think what we need is something that would only ever have the pointer manipulated through GEP, and then special addressing mode matching in the backend (since the fat pointer should almost always be treated as a constant with a separate index operand)
Okay, that sounds reasonable.  We have a similar restriction, in that GEPs have to stay GEPs and can't be decomposed into integer arithmetic.  However, we also want to allow things like alignment, which only really make sense if the pointer has an integral representation.   What do you think of changing the language to say "does not have a useful integral representation"?  "useful" is deliberately vague here, with the understanding that we disallow some integer-like operations / properties, but allow others.


https://reviews.llvm.org/D22488





More information about the llvm-commits mailing list