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

Matthias Springer llvmlistbot at llvm.org
Mon Feb 2 23:53:06 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();
----------------
matthias-springer wrote:

This works but could have a significant runtime overhead. Every time you compute the block number, there's a linear scan over the blocks in the region. But I don't see a better way to do this today.


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


More information about the Mlir-commits mailing list