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

Ralf Jung via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 10 04:47:53 PDT 2025


================
@@ -1741,6 +1741,23 @@ 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, meaning that the caller will not depend on its
+    contents. Stores that would only be observable on the normal return path may
+    be elided.
+
+    Specifically, the behavior is as-if any memory written through the pointer
+    during the execution of the function is overwritten with a poison value
+    upon normal function return. The caller may access the memory, but any load
+    not preceded by a store will return poison.
----------------
RalfJung wrote:

@nikic has opinions on poison in memory (namely, that there can't be poison in memory) that seem to contradict what this paragraph says.

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


More information about the llvm-commits mailing list