Skip to content

[mlir] avoid crash in transform.sequence verifier #66756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mlir/lib/Dialect/Transform/IR/TransformOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2188,6 +2188,9 @@ LogicalResult transform::SequenceOp::verify() {
}
}

if (!getBodyBlock()->hasTerminator())
return emitOpError() << "expects to have a terminator in the body";

if (getBodyBlock()->getTerminator()->getOperandTypes() !=
getOperation()->getResultTypes()) {
InFlightDiagnostic diag = emitOpError()
Expand Down
10 changes: 10 additions & 0 deletions mlir/test/Dialect/Transform/ops-invalid.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ transform.sequence failures(propagate) {
}
}

// -----

// expected-error @below {{expects to have a terminator in the body}}
"transform.sequence"() <{failure_propagation_mode = 1 : i32, operandSegmentSizes = array<i32: 0, 0>}> ({
^bb0(%arg0: !transform.any_op):
transform.apply_patterns to %arg0 {
} : !transform.any_op
}) : () -> ()


// -----

// expected-error @below {{'transform.sequence' op expects trailing entry block arguments to be of type implementing TransformHandleTypeInterface, TransformValueHandleTypeInterface or TransformParamTypeInterface}}
Expand Down