[Mlir-commits] [mlir] Fix ownership based deallocation pass crash (PR #179357)

Artemiy Bulavin llvmlistbot at llvm.org
Tue Feb 3 01:49:57 PST 2026


================
@@ -248,7 +248,12 @@ bool ValueComparator::operator()(const Value &lhs, const Value &rhs) const {
     lhsRegion = lhs.getDefiningOp()->getParentRegion();
     rhsRegion = rhs.getDefiningOp()->getParentRegion();
     if (lhsRegion == rhsRegion) {
-      return lhs.getDefiningOp()->isBeforeInBlock(rhs.getDefiningOp());
+      Block *lhsBlock = lhs.getDefiningOp()->getBlock();
+      Block *rhsBlock = rhs.getDefiningOp()->getBlock();
+      if (lhsBlock == rhsBlock) {
+        return lhs.getDefiningOp()->isBeforeInBlock(rhs.getDefiningOp());
+      }
+      return lhsBlock->computeBlockNumber() < rhsBlock->computeBlockNumber();
----------------
abulavin wrote:

I agree. Judging by the fact that only a few cases seems to hit this path already, hopefully there's not a lot of impact on downstream users.

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


More information about the Mlir-commits mailing list