[llvm] getelementptr inbounds clarifications (PR #65478)

Ralf Jung via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 7 09:12:53 PDT 2023


https://github.com/RalfJung updated https://github.com/llvm/llvm-project/pull/65478:

>From d0b7a36b9db500d6bfac27766ac30bc1d01a4e80 Mon Sep 17 00:00:00 2001
From: Ralf Jung <post at ralfj.de>
Date: Wed, 6 Sep 2023 11:55:40 +0200
Subject: [PATCH 1/2] getelementptr inbounds clarifications

---
 llvm/docs/LangRef.rst | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index d7fde35f63a3ee9..bd691f1f528d2ff 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -10955,15 +10955,17 @@ If the ``inbounds`` keyword is present, the result value of a
 :ref:`poison value <poisonvalues>` if one of the following rules is violated:
 
 *  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.
+   means that it points into an allocated object, or to its end. Note that the
+   object does not have to be live any more; being in-bounds of a deallocated
+   object is sufficient.
 *  If the type of an index is larger than the pointer index type, the
    truncation to the pointer index type preserves the signed value.
 *  The multiplication of an index by the type size does not wrap the pointer
    index type in a signed sense (``nsw``).
-*  The successive addition of offsets (without adding the base address) does
+*  The successive addition each offset (without adding the base address) does
    not wrap the pointer index type in a signed sense (``nsw``).
 *  The successive addition of the current address, interpreted as an unsigned
-   number, and an offset, interpreted as a signed number, does not wrap the
+   number, and each offset, interpreted as a signed number, does not wrap the
    unsigned address space and remains *in bounds* of the allocated object.
    As a corollary, if the added offset is non-negative, the addition does not
    wrap in an unsigned sense (``nuw``).

>From 31e138e3a2c689e91f8beec31c4844069a41be9f Mon Sep 17 00:00:00 2001
From: Ralf Jung <post at ralfj.de>
Date: Thu, 7 Sep 2023 18:12:48 +0200
Subject: [PATCH 2/2] fix typo

---
 llvm/docs/LangRef.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index bd691f1f528d2ff..c405b84440b97f0 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -10962,7 +10962,7 @@ If the ``inbounds`` keyword is present, the result value of a
    truncation to the pointer index type preserves the signed value.
 *  The multiplication of an index by the type size does not wrap the pointer
    index type in a signed sense (``nsw``).
-*  The successive addition each offset (without adding the base address) does
+*  The successive addition of each offset (without adding the base address) does
    not wrap the pointer index type in a signed sense (``nsw``).
 *  The successive addition of the current address, interpreted as an unsigned
    number, and each offset, interpreted as a signed number, does not wrap the



More information about the llvm-commits mailing list