[llvm] [IR] Add nofreeobj parameter/return attribute (PR #206445)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 24 02:38:09 PDT 2026
================
@@ -1587,6 +1587,27 @@ Currently, only the following parameter attributes are defined:
This is not a valid attribute for return values.
+`nofreeobj`
+: On arguments, this indicates that the underlying object of the argument
+ cannot be freed during the execution of the function (where "during" is in
+ the same sense as for `nofree`).
+
+ On return values, this indicates that the underlying object of the return
+ value cannot be freed from this point forward, for the duration of the
+ program's execution.
+
+ Unlike `nofree`, it is not possible to free the underlying object through
+ a different pointer either.
----------------
antoniofrighetto wrote:
Maybe nit: a posteriori, I wonder if the nofree paragraph should have gone more explicit (mirroring the wording in noalias), with, e.g., "a free on another thread is permitted only if it happens-before function entry or the function return happens-before the free". Not sure whether an explicit wording could be relevant for the return value too (which may be extended similarly, e.g., "Formally, any free of the underlying object must happen-before the call returns").
https://github.com/llvm/llvm-project/pull/206445
More information about the llvm-commits
mailing list