Skip to content

Commit 7caad3a

Browse files
committed
LangRef: allocated objects can grow
1 parent ffb9bbf commit 7caad3a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

llvm/docs/LangRef.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3327,6 +3327,15 @@ behavior is undefined:
33273327
- the size of all allocated objects must be non-negative and not exceed the
33283328
largest signed integer that fits into the index type.
33293329

3330+
Allocated objects that are created with operations recognized by LLVM (such as
3331+
:ref:`alloca <i_alloca>`, heap allocation functions marked as such, and global
3332+
variables) may *not* change their size. However, allocated objects can also be
3333+
created by means not recognized by LLVM, e.g. by directly calling ``mmap``.
3334+
Those allocated objects are allowed to grow to the right (i.e., keeping the same
3335+
base address, but changing their size), as long as they always satisfy the
3336+
properties described above. Currently, allocated objects are not permitted to
3337+
grow to the left or to shrink, nor can they have holes.
3338+
33303339
.. _objectlifetime:
33313340

33323341
Object Lifetime
@@ -11870,6 +11879,8 @@ if the ``getelementptr`` has any non-zero indices, the following rules apply:
1187011879
:ref:`based <pointeraliasing>` on. This means that it points into that
1187111880
allocated object, or to its end. Note that the object does not have to be
1187211881
live anymore; being in-bounds of a deallocated object is sufficient.
11882+
If the allocated object can grow, then the relevant size for being *in
11883+
bounds* is the maximal size the object will ever have, not its current size.
1187311884
* During the successive addition of offsets to the address, the resulting
1187411885
pointer must remain *in bounds* of the allocated object at each step.
1187511886

0 commit comments

Comments
 (0)