@@ -729,8 +729,8 @@ units that do not include the definition.
729729As SSA values, global variables define pointer values that are in scope
730730(i.e. they dominate) all basic blocks in the program. Global variables
731731always define a pointer to their "content" type because they describe a
732- region of memory, and all memory objects in LLVM are accessed through
733- pointers.
732+ region of memory, and all :ref:`allocated object<allocatedobjects>` in LLVM are
733+ accessed through pointers.
734734
735735Global variables can be marked with ``unnamed_addr`` which indicates
736736that the address is not significant, only the content. Constants marked
@@ -2169,7 +2169,8 @@ For example:
21692169 A ``nofree`` function is explicitly allowed to free memory which it
21702170 allocated or (if not ``nosync``) arrange for another thread to free
21712171 memory on it's behalf. As a result, perhaps surprisingly, a ``nofree``
2172- function can return a pointer to a previously deallocated memory object.
2172+ function can return a pointer to a previously deallocated
2173+ :ref:`allocated object<allocatedobjects>`.
21732174``noimplicitfloat``
21742175 Disallows implicit floating-point code. This inhibits optimizations that
21752176 use floating-point code and floating-point registers for operations that are
@@ -3280,31 +3281,41 @@ This information is passed along to the backend so that it generates
32803281code for the proper architecture. It's possible to override this on the
32813282command line with the ``-mtriple`` command line option.
32823283
3284+
3285+ .. _allocatedobjects:
3286+
3287+ Allocated Objects
3288+ -----------------
3289+
3290+ An allocated object, memory object, or simply object, is a region of a memory
3291+ space that is reserved by a memory allocation such as :ref:`alloca <i_alloca>`,
3292+ heap allocation calls, and global variable definitions. Once it is allocated,
3293+ the bytes stored in the region can only be read or written through a pointer
3294+ that is :ref:`based on <pointeraliasing>` the allocation value. If a pointer
3295+ that is not based on the object tries to read or write to the object, it is
3296+ undefined behavior.
3297+
3298+ The following properties hold for all allocated objects:
3299+
3300+ - no allocated object may cross the unsigned address space boundary (including
3301+ the pointer after the end of the object),
3302+ - the size of all allocated objects must be non-negative and smaller than
3303+ the largest signed integer that fits into the index type,
3304+
32833305.. _objectlifetime:
32843306
32853307Object Lifetime
32863308----------------------
32873309
3288- A memory object, or simply object, is a region of a memory space that is
3289- reserved by a memory allocation such as :ref:`alloca <i_alloca>`, heap
3290- allocation calls, and global variable definitions.
3291- Once it is allocated, the bytes stored in the region can only be read or written
3292- through a pointer that is :ref:`based on <pointeraliasing>` the allocation
3293- value.
3294- If a pointer that is not based on the object tries to read or write to the
3295- object, it is undefined behavior.
3296-
3297- A lifetime of a memory object is a property that decides its accessibility.
3298- Unless stated otherwise, a memory object is alive since its allocation, and
3299- dead after its deallocation.
3300- It is undefined behavior to access a memory object that isn't alive, but
3301- operations that don't dereference it such as
3302- :ref:`getelementptr <i_getelementptr>`, :ref:`ptrtoint <i_ptrtoint>` and
3303- :ref:`icmp <i_icmp>` return a valid result.
3304- This explains code motion of these instructions across operations that
3305- impact the object's lifetime.
3306- A stack object's lifetime can be explicitly specified using
3307- :ref:`llvm.lifetime.start <int_lifestart>` and
3310+ A lifetime of an :ref:`allocated object<allocatedobjects>` is a property that
3311+ decides its accessibility. Unless stated otherwise, an allocated object is alive
3312+ since its allocation, and dead after its deallocation. It is undefined behavior
3313+ to access an allocated object that isn't alive, but operations that don't
3314+ dereference it such as :ref:`getelementptr <i_getelementptr>`,
3315+ :ref:`ptrtoint <i_ptrtoint>` and :ref:`icmp <i_icmp>` return a valid result.
3316+ This explains code motion of these instructions across operations that impact
3317+ the object's lifetime. A stack object's lifetime can be explicitly specified
3318+ using :ref:`llvm.lifetime.start <int_lifestart>` and
33083319:ref:`llvm.lifetime.end <int_lifeend>` intrinsic function calls.
33093320
33103321.. _pointeraliasing:
@@ -4484,11 +4495,10 @@ Here are some examples of multidimensional arrays:
44844495
44854496There is no restriction on indexing beyond the end of the array implied
44864497by a static type (though there are restrictions on indexing beyond the
4487- bounds of an allocated object in some cases). This means that
4488- single-dimension 'variable sized array' addressing can be implemented in
4489- LLVM with a zero length array type. An implementation of 'pascal style
4490- arrays' in LLVM could use the type "``{ i32, [0 x float]}``", for
4491- example.
4498+ bounds of an :ref:`allocated object<allocatedobjects>` in some cases). This
4499+ means that single-dimension 'variable sized array' addressing can be implemented
4500+ in LLVM with a zero length array type. An implementation of 'pascal style
4501+ arrays' in LLVM could use the type "``{ i32, [0 x float]}``", for example.
44924502
44934503.. _t_struct:
44944504
@@ -11720,10 +11730,8 @@ Note that ``getelementptr`` with all-zero indices is always considered to be
1172011730As a corollary, the only pointer in bounds of the null pointer in the default
1172111731address space is the null pointer itself.
1172211732
11723- These rules are based on the assumption that no allocated object may cross
11724- the unsigned address space boundary, the pointer after the object must be valid,
11725- and no allocated object may be larger than half the pointer index type space
11726- - 1.
11733+ These rules are based on the assumption for
11734+ :ref:`allocated object<allocatedobjects>`.
1172711735
1172811736If ``inbounds`` is present on a ``getelementptr`` instruction, the ``nusw``
1172911737attribute will be automatically set as well. For this reason, the ``nusw``
@@ -26319,7 +26327,7 @@ Memory Use Markers
2631926327------------------
2632026328
2632126329This class of intrinsics provides information about the
26322- :ref:`lifetime of memory objects <objectlifetime>` and ranges where variables
26330+ :ref:`lifetime of allocated objects <objectlifetime>` and ranges where variables
2632326331are immutable.
2632426332
2632526333.. _int_lifestart:
@@ -26387,8 +26395,8 @@ Syntax:
2638726395Overview:
2638826396"""""""""
2638926397
26390- The '``llvm.lifetime.end``' intrinsic specifies the end of a memory object's
26391- lifetime.
26398+ The '``llvm.lifetime.end``' intrinsic specifies the end of a
26399+ :ref:`allocated object's lifetime<objectlifetime>` .
2639226400
2639326401Arguments:
2639426402""""""""""
@@ -26418,7 +26426,8 @@ with ``poison``.
2641826426
2641926427Syntax:
2642026428"""""""
26421- This is an overloaded intrinsic. The memory object can belong to any address space.
26429+ This is an overloaded intrinsic. The :ref:`allocated object<allocatedobjects>`
26430+ can belong to any address space.
2642226431
2642326432::
2642426433
@@ -26428,7 +26437,7 @@ Overview:
2642826437"""""""""
2642926438
2643026439The '``llvm.invariant.start``' intrinsic specifies that the contents of
26431- a memory object will not change.
26440+ an :ref:`allocated object<allocatedobjects>` will not change.
2643226441
2643326442Arguments:
2643426443""""""""""
@@ -26449,7 +26458,8 @@ unchanging.
2644926458
2645026459Syntax:
2645126460"""""""
26452- This is an overloaded intrinsic. The memory object can belong to any address space.
26461+ This is an overloaded intrinsic. The :ref:`allocated object<allocatedobjects>`
26462+ can belong to any address space.
2645326463
2645426464::
2645526465
@@ -26459,7 +26469,7 @@ Overview:
2645926469"""""""""
2646026470
2646126471The '``llvm.invariant.end``' intrinsic specifies that the contents of a
26462- memory object are mutable.
26472+ :ref:`allocated object<allocatedobjects>` are mutable.
2646326473
2646426474Arguments:
2646526475""""""""""
@@ -26479,9 +26489,9 @@ This intrinsic indicates that the memory is mutable again.
2647926489
2648026490Syntax:
2648126491"""""""
26482- This is an overloaded intrinsic. The memory object can belong to any address
26483- space. The returned pointer must belong to the same address space as the
26484- argument.
26492+ This is an overloaded intrinsic. The :ref:`allocated object<allocatedobjects>`
26493+ can belong to any address space. The returned pointer must belong to the same
26494+ address space as the argument.
2648526495
2648626496::
2648726497
@@ -26515,9 +26525,9 @@ It does not read any accessible memory and the execution can be speculated.
2651526525
2651626526Syntax:
2651726527"""""""
26518- This is an overloaded intrinsic. The memory object can belong to any address
26519- space. The returned pointer must belong to the same address space as the
26520- argument.
26528+ This is an overloaded intrinsic. The :ref:`allocated object<allocatedobjects>`
26529+ can belong to any address space. The returned pointer must belong to the same
26530+ address space as the argument.
2652126531
2652226532::
2652326533
0 commit comments