[Mlir-commits] [mlir] [mlir] harden transform.test_emit_remark_and_erase (PR #136307)
Oleksandr Alex Zinenko
llvmlistbot at llvm.org
Fri Apr 18 07:05:36 PDT 2025
https://github.com/ftynse created https://github.com/llvm/llvm-project/pull/136307
Executing this transform op may crash when the payload op is not erasable. Guard against that. Since this is a test op, no additional test is defined.
Fixes #128323.
>From 59432a7c72dde8a3f7aad6101861f534aea9b05a Mon Sep 17 00:00:00 2001
From: Alex Zinenko <git at ozinenko.com>
Date: Fri, 18 Apr 2025 16:04:19 +0200
Subject: [PATCH] [mlir] harden transform.test_emit_remark_and_erase
Executing this transform op may crash when the payload op is not erasable.
Guard against that. Since this is a test op, no additional test is defined.
Fixes #128323.
---
.../lib/Dialect/Transform/TestTransformDialectExtension.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp b/mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp
index face4de8e27d3..cdf44c2959d50 100644
--- a/mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp
+++ b/mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp
@@ -346,8 +346,11 @@ DiagnosedSilenceableFailure mlir::test::TestEmitRemarkAndEraseOperandOp::apply(
transform::TransformRewriter &rewriter,
transform::TransformResults &results, transform::TransformState &state) {
emitRemark() << getRemark();
- for (Operation *op : state.getPayloadOps(getTarget()))
+ for (Operation *op : state.getPayloadOps(getTarget())) {
+ if (!op->getUses().empty())
+ return emitSilenceableError() << "cannot erase an op that has uses";
rewriter.eraseOp(op);
+ }
if (getFailAfterErase())
return emitSilenceableError() << "silenceable error";
More information about the Mlir-commits
mailing list