[clang] [llvm] [InstCombine] remove dead loads, such as memcpy from undef (PR #143958)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 16 06:33:52 PDT 2025
================
@@ -3382,6 +3422,17 @@ Instruction *InstCombinerImpl::visitAllocSite(Instruction &MI) {
eraseInstFromFunction(*I);
Users[i] = nullptr; // Skip examining in the next loop.
}
+ if (auto *MTI = dyn_cast<MemTransferInst>(I)) {
+ if (KnowInitZero && getUnderlyingObject(MTI->getRawDest()) != &MI) {
----------------
nikic wrote:
I think this check isn't entirely right, in case we can't see through to the underlying object (e.g. a very long gep chain). In that case even though we're writing to the alloca, we'd leave a memset here.
I think it would be more robust if isAllocSiteRemovable returned the ModRefInfo and then you made the decision here on whether this is a Mod or Ref alloca.
https://github.com/llvm/llvm-project/pull/143958
More information about the llvm-commits
mailing list