Index: docs/LangRef.rst =================================================================== --- docs/LangRef.rst +++ docs/LangRef.rst @@ -2704,10 +2704,20 @@ 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-dereferencable pointer is undefined behavior in any address +space. In general pointers with the bit-value 0 are assumed to be +dereferencable in non-0 address spaces. + +For a non-volatile access, 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. In general, it is not permitted to +change the address space of a volatile memory access. Different +address spaces may have different trapping behavior when dereferencing +an invalid pointer. Note that LLVM does not permit pointers to void (``void*``) nor does it permit pointers to labels (``label*``). Use ``i8*`` instead. @@ -9689,9 +9699,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 dereferencable 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 `, the result is +:ref:`poison `. + +If the source is not :ref:`poison `, and both source and +destination address spaces are :ref:`integral pointers +`, and the result pointer is dereferencable, 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: """"""""