[PATCH] D154051: [LangRef] Always allow getelementptr inbounds with zero offset

Ralf via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 29 03:17:34 PDT 2023


RalfJung added a comment.

For Rust this would be a great change, since we'd like to  allow offset-by-0 for arbitrary pointers in the language and are currently blocked on how to best lower such an operation to LLVM. :)



================
Comment at: llvm/docs/LangRef.rst:10931
 *  The base pointer has an *in bounds* address of an allocated object, which
-   means that it points into an allocated object, or to its end. The only
-   *in bounds* address for a null pointer in the default address-space is the
-   null pointer itself.
+   means that it points into an allocated object, or to its end.
 *  If the type of an index is larger than the pointer index type, the
----------------
This might be a good opportunity to clarify that the allocated objects does not have to be live.


================
Comment at: llvm/docs/LangRef.rst:10946
 
+Note that ``getelementptr`` with all-zero indices is always considered to be
+``inbounds``, even if the base pointer does not point to an allocated object.
----------------
Are negative indices supported? If yes, is it possible that multiple indices "cancel" to leave the total effective offset as 0 despite there being non-0 indices?


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

https://reviews.llvm.org/D154051



More information about the llvm-commits mailing list