[llvm] LangRef: getelementptr: inbounds is about the object the pointer is 'based on' (PR #95650)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 15 01:58:12 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-ir

Author: Ralf Jung (RalfJung)

<details>
<summary>Changes</summary>

As discussed [here](https://discourse.llvm.org/t/getelementptr-inbounds-inbounds-of-which-allocation/79024), we need the pointer to be inbounds of *the* allocated object the pointer is based on, not just any allocated object.

---
Full diff: https://github.com/llvm/llvm-project/pull/95650.diff


1 Files Affected:

- (modified) llvm/docs/LangRef.rst (+4-4) 


``````````diff
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 6935ccdfc9196..fcf6d310d03de 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -11390,10 +11390,10 @@ For ``nuw`` (no unsigned wrap):
 For ``inbounds`` all rules of the ``nusw`` attribute apply. Additionally,
 if the ``getelementptr`` has any non-zero indices, the following rules apply:
 
- * 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. Note that the
-   object does not have to be live anymore; being in-bounds of a deallocated
-   object is sufficient.
+ * The base pointer has an *in bounds* address of the allocated object that it
+   is :ref:`based <pointeraliasing>` on. This means that it points into that
+   allocated object, or to its end. Note that the object does not have to be
+   live anymore; being in-bounds of a deallocated object is sufficient.
  * During the successive addition of offsets to the address, the resulting
    pointer must remain *in bounds* of the allocated object at each step.
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/95650


More information about the llvm-commits mailing list