[Mlir-commits] [mlir] [mlir][dc] Fix dialect conversion drop uses (PR #86991)

Rob Suderman llvmlistbot at llvm.org
Thu Mar 28 11:59:54 PDT 2024


https://github.com/rsuderman created https://github.com/llvm/llvm-project/pull/86991

Before deleting the block we need to drop uses to the surrounding args. If this is not performed dialect conversion failures can result in a failure to remove args (despite the block having no remaining uses).

>From fbdc5b8eaedee30b871caf263f6444aeff2b343c Mon Sep 17 00:00:00 2001
From: Rob Suderman <rob.suderman at gmail.com>
Date: Thu, 28 Mar 2024 11:58:34 -0700
Subject: [PATCH] [mlir][dc] Fix dialect conversion drop uses

Before deleting the block we need to drop uses to the surrounding args.
If this is not performed dialect conversion failures can result in a
failure to remove args (despite the block having no remaining uses).
---
 mlir/lib/Transforms/Utils/DialectConversion.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index f967e8352bf4c8..2460ddf4ef4078 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -277,8 +277,10 @@ class CreateBlockRewrite : public BlockRewrite {
       blockOps.remove(blockOps.begin());
     if (block->getParent())
       eraseBlock(block);
-    else
+    else {
+      block->dropAllDefinedValueUses();
       delete block;
+    }
   }
 };
 



More information about the Mlir-commits mailing list