[llvm] [DSE] Delay deleting non-memory-defs until end of DSE. (PR #83411)
David Li via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 29 10:18:51 PST 2024
================
@@ -1730,13 +1736,21 @@ struct DSEState {
// Remove its operands
for (Use &O : DeadInst->operands())
if (Instruction *OpI = dyn_cast<Instruction>(O)) {
- O = nullptr;
+ O.set(PoisonValue::get(O->getType()));
if (isInstructionTriviallyDead(OpI, &TLI))
NowDeadInsts.push_back(OpI);
}
EI.removeInstruction(DeadInst);
- DeadInst->eraseFromParent();
+ // Remove memory defs directly, but only queue other dead instructions for
+ // later removal. They may have been used as memory locations that have
+ // been cached by BatchAA. Removing them here may lead to newly created
+ // instructions to be allocated at the same address, yielding stale cache
+ // entries.
+ if (IsMemDef)
+ DeadInst->eraseFromParent();
----------------
david-xl wrote:
Is it safer to just delay the deletion for them too?
https://github.com/llvm/llvm-project/pull/83411
More information about the llvm-commits
mailing list