================ @@ -3382,6 +3418,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) { + IRBuilderBase::InsertPointGuard Guard(Builder); + Builder.SetInsertPoint(MTI); + auto *M = Builder.CreateMemSet(MTI->getRawDest(), + ConstantInt::get(Type::getInt8Ty(MI.getContext()), 0), + MTI->getLength(), + MTI->getDestAlign()); + M->copyMetadata(*MTI, LLVMContext::MD_DIAssignID); ---------------- nikic wrote:
This depends a lot on the specific transform. Dropping or adjusting metadata is often required when we're merging operations in some way (e.g. memcpy to memcpy forwarding). However, I believe that for this specific case where we're converting memcpy to memset, preserving metadata should be fine. (We're only *removing* a read from a location.) https://github.com/llvm/llvm-project/pull/143958 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits