[llvm] LangRef: allocated objects can grow (PR #141338)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sat May 24 02:28:23 PDT 2025


================
@@ -3327,6 +3327,14 @@ 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, as long as they always satisfy the
+properties described above. Currently, allocated objects are not permitted to
+ever shrink, nor can they have holes.
----------------
nikic wrote:

I think that would complicate the inbounds semantics, at least from an operational point of view. If we only allow growth to the right we can always make inbounds work with the maximal possible size that still satisfies the above constraints (without knowledge of how large the allocation will *actually* grow). If we allow growth in both directions, this no longer works.

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


More information about the llvm-commits mailing list