[PATCH] D154051: [LangRef] Always allow getelementptr inbounds with zero offset
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 29 04:04:31 PDT 2023
nikic added inline comments.
================
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
----------------
RalfJung wrote:
> This might be a good opportunity to clarify that the allocated objects does not have to be live.
That seems orthogonal to the change here, so I'd rather not include it. Properly specifying the notion of a dead allocated object seems pretty tricky.
================
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.
----------------
RalfJung wrote:
> 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?
Multiple indices are not allowed to cancel. The "any non-zero" and "all-zero" wordings here are intentional. This is consistent with usual inbounds semantics, which also do not allow "temporarily" going out of bounds.
(We do have optimizations that depend on this.)
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154051/new/
https://reviews.llvm.org/D154051
More information about the llvm-commits
mailing list