[PATCH] D63525: LangRef: Attempt to formulate some rules for addrspacecast

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 27 09:20:14 PDT 2019


arsenm marked an inline comment as done.
arsenm added inline comments.


================
Comment at: docs/LangRef.rst:2713
+space. In general pointers with the bit-value 0 are assumed to be
+dereferencable in non-0 address spaces.
+
----------------
theraven wrote:
> jdoerfert wrote:
> > I'd change the last sentence, maybe as shown below, but the meaning is fine.
> > 
> > "In general, "null-pointers" have to be assumed dereferenceable in non-zero address spaces."
> > 
> > 
> > dereferencable -> dereferenceable
> I am also unhappy with this as a claim.  null pointers should always be non-dereferenceable. The semantics of inttoptr of 0 may not yield null for a given address space and the semantics of ptrtoint of null may not yield the integer 0, but the definition of a null pointer is a guaranteed non-dereferenceable pointer.
I'm unhappy with the claim, but I'm also unhappy with the state of null in llvm. "i8 addrspace(N)* null" is always interpreted as bit pattern 0. I would like to fix this by defining the invalid pointer value in the datalayout, and remove all special treatment of addrspace(0). As-is I don't think there is a way to describe a constant, known-invalid/null pointer in the IR.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63525/new/

https://reviews.llvm.org/D63525





More information about the llvm-commits mailing list