[llvm] [DSE] Delay deleting non-memory-defs until end of DSE. (PR #83411)
Alina Sbirlea via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 1 08:19:12 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();
----------------
alinas wrote:
At this time I'm inclined to say this cannot happen. So let's have this fix in for the existing issue.
https://github.com/llvm/llvm-project/pull/83411
More information about the llvm-commits
mailing list