Skip to content

Conversation

@ftynse
Copy link
Member

@ftynse ftynse commented Apr 18, 2025

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.

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 llvm#128323.
@llvmbot llvmbot added the mlir label Apr 18, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 18, 2025

@llvm/pr-subscribers-mlir

Author: Oleksandr "Alex" Zinenko (ftynse)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/136307.diff

1 Files Affected:

  • (modified) mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp (+4-1)
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";

@ftynse ftynse merged commit 3250301 into llvm:main Apr 18, 2025
13 checks passed
@ftynse ftynse deleted the fix-transform-test branch April 18, 2025 18:56
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
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 llvm#128323.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MLIR]-transform-interpreter triggers Assertion Failure `op->use_empty() && "expected 'op' to have no uses"'

2 participants