[llvm] [IR] Add `dead_on_return` attribute (PR #143271)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 7 12:33:52 PDT 2025


================
@@ -1741,6 +1741,20 @@ Currently, only the following parameter attributes are defined:
 
     This attribute cannot be applied to return values.
 
+``dead_on_return``
+    This attribute indicates that the memory pointed to by the argument is dead
+    upon normal function return.
+
+    It is similar to ``byval`` in the regard that it is generally used to pass
+    structs and arrays by value, and the memory is caller-invisible when the
+    function returns. However, unlike ``byval``, it is intended for ABIs where the
+    *callee* explicitly allocates the temporary copy. Stores that would only be
+    visible on the normal return path may be optimized out. Likewise,
+    optimizations may assume that the pointer does not alias any memory that
+    outlives the call.
----------------
nikic wrote:

I'm not sure I understand what this last sentence means, but I don't think dead_on_return should have effects on aliasing. I'd expect that typically dead_on_return would be combined with the noalias attribute.

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


More information about the llvm-commits mailing list