From 87b63c1726e24214272cd6c04825c585635d1cdc Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 2 Oct 2020 21:47:03 +0200 Subject: [PATCH] [MemCpyOpt] Avoid double invalidation (NFCI) The removal of the cpy instruction is left to the caller of performCallSlotOptzn(), including the invalidation of MD. Both call-sites already do this. Also handle incrementation of NumMemCpyInstr consistently at the call-site. One of the call-site was already doing this, which ended up incrementing the statistic twice. This fix was part of D26739. --- llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp index 01f3c32..4d30804 100644 --- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp @@ -953,10 +953,6 @@ bool MemCpyOptPass::performCallSlotOptzn(Instruction *cpy, Value *cpyDest, LLVMContext::MD_access_group}; combineMetadata(C, cpy, KnownIDs, true); - // Remove the memcpy. - MD->removeInstruction(cpy); - ++NumMemCpyInstr; - return true; } @@ -1272,6 +1268,7 @@ bool MemCpyOptPass::processMemCpy(MemCpyInst *M, BasicBlock::iterator &BBI) { MD->removeInstruction(M); M->eraseFromParent(); + ++NumMemCpyInstr; return true; } } -- 2.7.4