[llvm] [IR] Introduce captures attribute (PR #116990)

Alexander Richardson via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 21 08:02:14 PST 2024


================
@@ -1379,6 +1379,36 @@ Currently, only the following parameter attributes are defined:
     function, returning a pointer to allocated storage disjoint from the
     storage for any other object accessible to the caller.
 
+``captures(...)``
+    This attributes restrict the ways in which the callee may capture the
+    pointer. This is not a valid attribute for return values. This attribute
+    applies only to the particular copy of the pointer passed in this argument.
+
+    The arguments of ``captures`` is a list of captured pointer components,
+    which may be ``none``, or a combination of:
+
+    - ``address``: The integral address of the pointer.
+    - ``provenance``: The ability to access the pointer for both read and write
+      after the function returns.
+    - ``read_provenance``: The ability to access the pointer only for reads
+      after the function returns.
+
+    Additionally, it is possible to specify that the pointer is captured via
+    the return value only, by using ``caputres(ret: ...)``.
----------------
arichardson wrote:

```suggestion
    the return value only, by using ``captures(ret: ...)``.
```

https://github.com/llvm/llvm-project/pull/116990


More information about the llvm-commits mailing list