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

Aiden Grossman via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 22 12:58:27 PST 2025


================
@@ -1017,7 +1017,9 @@ struct DSEState {
     // Treat byval, inalloca or dead on return arguments the same as Allocas,
     // stores to them are dead at the end of the function.
     for (Argument &AI : F.args())
-      if (AI.hasPassPointeeByValueCopyAttr() || AI.hasDeadOnReturnAttr())
+      if (AI.hasPassPointeeByValueCopyAttr() ||
+          (AI.getType()->isPointerTy() &&
+           !AI.getDeadOnReturnBytes().has_value()))
----------------
boomanaiden154 wrote:

Good point. I've updated the patch to change the getter to `getDeadOnReturnInfo` that returns a struct wrapping the optional to appropriately name functions. So now we can just query `coversAllRechableMemory()` which should be self-documenting. Name bike-shedding is welcome since I'm not super confident that is a great name.

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


More information about the cfe-commits mailing list