Skip to content

Commit 23d6cc9

Browse files
committed
Mention null capture semantics
1 parent 5249baa commit 23d6cc9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

llvm/docs/LangRef.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3400,6 +3400,19 @@ function, provenance capture refers exclusively to the ability to perform
34003400
accesses *after* the function returns. Memory accesses within the function
34013401
itself are not considered pointer captures.
34023402

3403+
Comparison of a pointer with a null pointer is generally also considered an
3404+
address capture. As an exception, if the pointer is known to be either null
3405+
or in bounds of an allocated object, it is not considered an address capture.
3406+
As such, the following example does not capture the pointer argument due to
3407+
the presence of the ``dereferenceable_or_null`` attribute:
3408+
3409+
.. code-block:: llvm
3410+
3411+
define i1 @f(ptr dereferenceable_or_null(4) %a) {
3412+
%c = icmp eq ptr %a, null
3413+
ret i1 %c
3414+
}
3415+
34033416
We can further say that the capture only occurs through a specific location.
34043417
In the following example, the pointer (both address and provenance) is captured
34053418
through the return value only:

0 commit comments

Comments
 (0)