From a822ec75cc6044eae8dd99d1b78c1a7eb9ad40d7 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Tue, 23 Jun 2020 08:58:51 +0100 Subject: [PATCH] [DSE,MSSA] Treat passed by value args as invisible to caller. 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 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp index c6f579b..469c879 100644 --- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -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; } -- 2.7.4