[clang] [llvm] [IR] Make dead_on_return attribute optionally sized (PR #171712)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 20 03:45:17 PST 2026


================
@@ -1842,11 +1842,15 @@ Currently, only the following parameter attributes are defined:
 
     This attribute cannot be applied to return values.
 
-``dead_on_return``
+``dead_on_return`` or ``dead_on_return(<n>)``
     This attribute indicates that the memory pointed to by the argument is dead
     upon function return, both upon normal return and if the calls unwinds, meaning
     that the caller will not depend on its contents. Stores that would be observable
-    either on the return path or on the unwind path may be elided.
+    either on the return path or on the unwind path may be elided. A number of
+    bytes known to be dead may optionally be provided in parentheses. It is legal
+    for the number of bytes to be less than the size of the pointee type. If a number
+    of bytes is not specified, all memory reachable through the pointer is marked as
+    dead on return.
----------------
nikic wrote:

This "all reachable memory" wording isn't entirely correct when taken together with the next paragraph. Only written memory is dead. There are two possibilities for the interaction with the byte count. We can either say that if a byte count is specified, then that entire range is overwritten with poison on return. Or we can say that it just limits what's said in the next paragraph to writes within the byte count.

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


More information about the llvm-commits mailing list