@@ -729,8 +729,8 @@ units that do not include the definition.
729
729
As SSA values, global variables define pointer values that are in scope
730
730
(i.e. they dominate) all basic blocks in the program. Global variables
731
731
always 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.
734
734
735
735
Global variables can be marked with ``unnamed_addr`` which indicates
736
736
that the address is not significant, only the content. Constants marked
@@ -2169,7 +2169,8 @@ For example:
2169
2169
A ``nofree`` function is explicitly allowed to free memory which it
2170
2170
allocated or (if not ``nosync``) arrange for another thread to free
2171
2171
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>`.
2173
2174
``noimplicitfloat``
2174
2175
Disallows implicit floating-point code. This inhibits optimizations that
2175
2176
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
3280
3281
code for the proper architecture. It's possible to override this on the
3281
3282
command line with the ``-mtriple`` command line option.
3282
3283
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
+
3283
3305
.. _objectlifetime:
3284
3306
3285
3307
Object Lifetime
3286
3308
----------------------
3287
3309
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
3308
3319
:ref:`llvm.lifetime.end <int_lifeend>` intrinsic function calls.
3309
3320
3310
3321
.. _pointeraliasing:
@@ -4484,11 +4495,10 @@ Here are some examples of multidimensional arrays:
4484
4495
4485
4496
There is no restriction on indexing beyond the end of the array implied
4486
4497
by 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.
4492
4502
4493
4503
.. _t_struct:
4494
4504
@@ -11720,10 +11730,8 @@ Note that ``getelementptr`` with all-zero indices is always considered to be
11720
11730
As a corollary, the only pointer in bounds of the null pointer in the default
11721
11731
address space is the null pointer itself.
11722
11732
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>`.
11727
11735
11728
11736
If ``inbounds`` is present on a ``getelementptr`` instruction, the ``nusw``
11729
11737
attribute will be automatically set as well. For this reason, the ``nusw``
@@ -26319,7 +26327,7 @@ Memory Use Markers
26319
26327
------------------
26320
26328
26321
26329
This 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
26323
26331
are immutable.
26324
26332
26325
26333
.. _int_lifestart:
@@ -26387,8 +26395,8 @@ Syntax:
26387
26395
Overview:
26388
26396
"""""""""
26389
26397
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>` .
26392
26400
26393
26401
Arguments:
26394
26402
""""""""""
@@ -26418,7 +26426,8 @@ with ``poison``.
26418
26426
26419
26427
Syntax:
26420
26428
"""""""
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.
26422
26431
26423
26432
::
26424
26433
@@ -26428,7 +26437,7 @@ Overview:
26428
26437
"""""""""
26429
26438
26430
26439
The '``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.
26432
26441
26433
26442
Arguments:
26434
26443
""""""""""
@@ -26449,7 +26458,8 @@ unchanging.
26449
26458
26450
26459
Syntax:
26451
26460
"""""""
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.
26453
26463
26454
26464
::
26455
26465
@@ -26459,7 +26469,7 @@ Overview:
26459
26469
"""""""""
26460
26470
26461
26471
The '``llvm.invariant.end``' intrinsic specifies that the contents of a
26462
- memory object are mutable.
26472
+ :ref:`allocated object<allocatedobjects>` are mutable.
26463
26473
26464
26474
Arguments:
26465
26475
""""""""""
@@ -26479,9 +26489,9 @@ This intrinsic indicates that the memory is mutable again.
26479
26489
26480
26490
Syntax:
26481
26491
"""""""
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.
26485
26495
26486
26496
::
26487
26497
@@ -26515,9 +26525,9 @@ It does not read any accessible memory and the execution can be speculated.
26515
26525
26516
26526
Syntax:
26517
26527
"""""""
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.
26521
26531
26522
26532
::
26523
26533
0 commit comments