[llvm] [IR] Add `dead_on_return` attribute (PR #143271)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 10 05:53:33 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.
----------------
nikic wrote:
This is just an unavoidable consequence of the incoherence around uninitialized memory and poison memory. If we write "undef" here instead, someone is going to complain that this makes eliminating "store poison" incorrect, which is not UB per LangRef. I don't care which word is being used here. "poison" is consistent with the dead_on_unwind wording.
https://github.com/llvm/llvm-project/pull/143271
More information about the llvm-commits
mailing list