[DSE,MSSA] Treat passed by value args as invisible to caller.
authorFlorian Hahn <flo@fhahn.com>
Tue, 23 Jun 2020 07:58:51 +0000 (08:58 +0100)
committerFlorian Hahn <flo@fhahn.com>
Tue, 23 Jun 2020 07:58:51 +0000 (08:58 +0100)
This updates the MemorySSA backed implementation to treat arguments
passed by value similar to allocas: in they are assumed to be invisible
in the caller. This is similar to how they are treated in legacy DSE.

Reviewers: efriedma, asbirlea, george.burgess.iv

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D82222

llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp

index c6f579b..469c879 100644 (file)
@@ -1563,8 +1563,13 @@ struct DSEState {
     // Treat byval or inalloca arguments the same as Allocas, stores to them are
     // dead at the end of the function.
     for (Argument &AI : F.args())
-      if (AI.hasPassPointeeByValueAttr())
-        State.InvisibleToCallerBeforeRet.insert(&AI);
+      if (AI.hasPassPointeeByValueAttr()) {
+        // For byval, the caller doesn't know the address of the allocation.
+        if (AI.hasByValAttr())
+          State.InvisibleToCallerBeforeRet.insert(&AI);
+        State.InvisibleToCallerAfterRet.insert(&AI);
+      }
+
     return State;
   }