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

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 15 13:47:08 PDT 2020


arsenm updated this revision to Diff 270850.
arsenm marked 2 inline comments as done.
arsenm added a comment.
Herald added a project: LLVM.

Apply phrasing suggestions


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

https://reviews.llvm.org/D63525

Files:
  llvm/docs/LangRef.rst


Index: llvm/docs/LangRef.rst
===================================================================
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -2543,6 +2543,11 @@
 may not modify any other memory accessible by the module being compiled.
 A volatile operation may not call any code in the current module.
 
+In general (without target specific context), the address space of a
+volatile operation may not be changed. Different address spaces may
+have different trapping behavior when dereferencing an invalid
+pointer.
+
 The compiler may assume execution will continue after a volatile operation,
 so operations which modify memory or may have undefined behavior can be
 hoisted past a volatile operation.
@@ -3035,10 +3040,17 @@
 The pointer type is used to specify memory locations. Pointers are
 commonly used to reference objects in memory.
 
-Pointer types may have an optional address space attribute defining the
-numbered address space where the pointed-to object resides. The default
-address space is number zero. The semantics of non-zero address spaces
-are target-specific.
+Pointer types may have an optional address space attribute defining
+the numbered address space where the pointed-to object resides. The
+default address space is number zero. The semantics of non-zero
+address spaces are target-specific. Memory access through an invalid,
+non-dereferenceable "null" pointer is undefined behavior in any address
+space. Pointers with the bit-value 0 are only assumed to be
+non-dereferenceable in address space 0.
+
+If an object can be proven accessible through a pointer with a
+different address space, the access may be modified to use that
+address space. Exceptions apply if the operation is ``volatile``.
 
 Note that LLVM does not permit pointers to void (``void*``) nor does it
 permit pointers to labels (``label*``). Use ``i8*`` instead.
@@ -10250,9 +10262,19 @@
 ``ptrval`` to type ``pty2``. It can be a *no-op cast* or a complex
 value modification, depending on the target and the address space
 pair. Pointer conversions within the same address space must be
-performed with the ``bitcast`` instruction. Note that if the address space
-conversion is legal then both result and operand refer to the same memory
-location.
+performed with the ``bitcast`` instruction. Note that if the address
+space conversion produces a dereferenceable result then both result and
+operand refer to the same memory location. The conversion must have no
+side effects, or capture the value of the pointer.
+
+If the source is :ref:`poison <poisonvalues>`, the result is
+:ref:`poison <poisonvalues>`.
+
+If the source is not :ref:`poison <poisonvalues>`, and both source and
+destination are :ref:`integral pointers <nointptrtype>`, and the
+result pointer is dereferenceable, the cast is assumed to be
+reversible (i.e. casting the result back to the original address space
+should yield the original bit pattern).
 
 Example:
 """"""""


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63525.270850.patch
Type: text/x-patch
Size: 2967 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200615/381f3fd3/attachment.bin>


More information about the llvm-commits mailing list