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

The verifier was unconditionally accessing the body block terminator,
but it's not guaranteed that the block has one in general.
This commit is contained in:
Oleksandr "Alex" Zinenko 2023-09-19 13:28:53 +02:00 committed by GitHub
parent 73c2cb5999
commit a2a1dbb518
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -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()

View File

@ -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}}