[Mlir-commits] [mlir] [mlir][CSE] fix use-after-free (PR #203849)

Stefan Schuermans llvmlistbot at llvm.org
Mon Jun 15 04:01:18 PDT 2026


================
@@ -162,6 +162,11 @@ void CSEDriver::replaceUsesAndDelete(ScopedMapTy &knownValues, Operation *op,
   if (isa<UnknownLoc>(existing->getLoc()) && !isa<UnknownLoc>(op->getLoc()))
     existing->setLoc(op->getLoc());
 
+  // Deletion of the dead current op can only be done here, and not before,
+  // because the its location is still read above.
+  if (opIsDead)
+    eraseDeadOp(op);
+
----------------
schuermans-roofline wrote:

Okay, I can restructure it like this.

https://github.com/llvm/llvm-project/pull/203849


More information about the Mlir-commits mailing list