Skip to content

Commit 3250301

Browse files
authored
[mlir] harden transform.test_emit_remark_and_erase (#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.
1 parent 4091f4d commit 3250301

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mlir/test/lib/Dialect/Transform/TestTransformDialectExtension.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,11 @@ DiagnosedSilenceableFailure mlir::test::TestEmitRemarkAndEraseOperandOp::apply(
346346
transform::TransformRewriter &rewriter,
347347
transform::TransformResults &results, transform::TransformState &state) {
348348
emitRemark() << getRemark();
349-
for (Operation *op : state.getPayloadOps(getTarget()))
349+
for (Operation *op : state.getPayloadOps(getTarget())) {
350+
if (!op->getUses().empty())
351+
return emitSilenceableError() << "cannot erase an op that has uses";
350352
rewriter.eraseOp(op);
353+
}
351354

352355
if (getFailAfterErase())
353356
return emitSilenceableError() << "silenceable error";

0 commit comments

Comments
 (0)