[PATCH] D90708: [LangRef] Clarify GEP inbounds wrapping semantics
Nuno Lopes via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 11 11:41:15 PST 2020
nlopes added inline comments.
================
Comment at: llvm/docs/LangRef.rst:9782
+ means that it points into an allocated object, or to its end (which is one
+ byte past the last byte contained in the object). The only *in bounds*
+ address for a null pointer in the default address-space is the null pointer
----------------
I still don't like the current writing. I would need to see some evidence from language standards that they require pointers past the end of objects.
================
Comment at: llvm/docs/LangRef.rst:9785
+ itself.
+* If the type of an index is larger than than the pointer index type, the
+ truncation to the pointer index type preserves the signed value.
----------------
than than
================
Comment at: llvm/docs/LangRef.rst:9789
+ index type in a signed sense (``nsw``).
+* The successive addition of offsets (without adding the base address) does
+ not wrap the pointer index type in a signed sense (``nsw``).
----------------
It's a bit stronger than that. The addition of each offset to the preceding pointer should not overflow. You can't do e.g.:
gep inbounds %p, -1, 1
because %p-1 is OOB, even though the result is in bounds (because %p must be in bounds).
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D90708/new/
https://reviews.llvm.org/D90708
More information about the llvm-commits
mailing list