[llvm] LangRef: allocated objects can grow (PR #141338)
Ralf Jung via llvm-commits
llvm-commits at lists.llvm.org
Sat May 24 02:43:02 PDT 2025
https://github.com/RalfJung updated https://github.com/llvm/llvm-project/pull/141338
>From 18f4a90642a7ca9a2bbdf8de1440ddeebe9a66f7 Mon Sep 17 00:00:00 2001
From: Ralf Jung <post at ralfj.de>
Date: Sat, 24 May 2025 10:58:02 +0200
Subject: [PATCH] LangRef: allocated objects can grow
---
llvm/docs/LangRef.rst | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 343ca743c74f8..84fa7f3476904 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -3327,6 +3327,15 @@ behavior is undefined:
- the size of all allocated objects must be non-negative and not exceed the
largest signed integer that fits into the index type.
+Allocated objects that are created with operations recognized by LLVM (such as
+:ref:`alloca <i_alloca>`, heap allocation functions marked as such, and global
+variables) may *not* change their size. However, allocated objects can also be
+created by means not recognized by LLVM, e.g. by directly calling ``mmap``.
+Those allocated objects are allowed to grow to the right (i.e., keeping the same
+base address, but increasing their size), as long as they always satisfy the
+properties described above. Currently, allocated objects are not permitted to
+grow to the left or to shrink, nor can they have holes.
+
.. _objectlifetime:
Object Lifetime
@@ -11870,6 +11879,8 @@ if the ``getelementptr`` has any non-zero indices, the following rules apply:
: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.
+ If the allocated object can grow, then the relevant size for being *in
+ bounds* is the maximal size the object will ever have, not its current size.
* During the successive addition of offsets to the address, the resulting
pointer must remain *in bounds* of the allocated object at each step.
More information about the llvm-commits
mailing list