[llvm] 87b63c1 - [MemCpyOpt] Avoid double invalidation (NFCI)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 2 12:51:01 PDT 2020


Author: Nikita Popov
Date: 2020-10-02T21:50:46+02:00
New Revision: 87b63c1726e24214272cd6c04825c585635d1cdc

URL: https://github.com/llvm/llvm-project/commit/87b63c1726e24214272cd6c04825c585635d1cdc
DIFF: https://github.com/llvm/llvm-project/commit/87b63c1726e24214272cd6c04825c585635d1cdc.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
index 01f3c322b1f4..4d30804f1680 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;
       }
     }


        


More information about the llvm-commits mailing list