[llvm] [MemCpyOpt] Drop dead `memmove` calls on `memset`'d source data (PR #101930)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 29 08:16:30 PST 2024
================
@@ -1841,12 +1842,87 @@ bool MemCpyOptPass::processMemCpy(MemCpyInst *M, BasicBlock::iterator &BBI) {
return false;
}
+/// Memmove calls with overlapping src/dest buffers that come after a memset may
+/// be removed.
+bool MemCpyOptPass::isMemMoveMemSetDependency(MemMoveInst *M) {
+ const auto &DL = M->getDataLayout();
+ MemoryUseOrDef *MemMoveAccess = MSSA->getMemoryAccess(M);
+ if (!MemMoveAccess)
+ return false;
+
+ // The memmove is of form memmove(x, x + A, B).
+ MemoryLocation SourceLoc = MemoryLocation::getForSource(M);
+ auto *MemMoveSourceOp = M->getSource();
+ auto *Source = dyn_cast<GetElementPtrInst>(MemMoveSourceOp);
----------------
antoniofrighetto wrote:
Thanks, updated.
https://github.com/llvm/llvm-project/pull/101930
More information about the llvm-commits
mailing list