Skip to content

Commit 158568c

Browse files
committed
Mention null capture semantics
1 parent ec80b2a commit 158568c

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
@@ -3421,6 +3421,19 @@ function, provenance capture refers exclusively to the ability to perform
34213421
accesses *after* the function returns. Memory accesses within the function
34223422
itself are not considered pointer captures.
34233423

3424+
Comparison of a pointer with a null pointer is generally also considered an
3425+
address capture. As an exception, if the pointer is known to be either null
3426+
or in bounds of an allocated object, it is not considered an address capture.
3427+
As such, the following example does not capture the pointer argument due to
3428+
the presence of the ``dereferenceable_or_null`` attribute:
3429+
3430+
.. code-block:: llvm
3431+
3432+
define i1 @f(ptr dereferenceable_or_null(4) %a) {
3433+
%c = icmp eq ptr %a, null
3434+
ret i1 %c
3435+
}
3436+
34243437
We can further say that the capture only occurs through a specific location.
34253438
In the following example, the pointer (both address and provenance) is captured
34263439
through the return value only:

0 commit comments

Comments
 (0)