Skip to content

Commit a2a1dbb

Browse files
authored
[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.
1 parent 73c2cb5 commit a2a1dbb

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

mlir/lib/Dialect/Transform/IR/TransformOps.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -2188,6 +2188,9 @@ LogicalResult transform::SequenceOp::verify() {
21882188
}
21892189
}
21902190

2191+
if (!getBodyBlock()->hasTerminator())
2192+
return emitOpError() << "expects to have a terminator in the body";
2193+
21912194
if (getBodyBlock()->getTerminator()->getOperandTypes() !=
21922195
getOperation()->getResultTypes()) {
21932196
InFlightDiagnostic diag = emitOpError()

mlir/test/Dialect/Transform/ops-invalid.mlir

+10
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ transform.sequence failures(propagate) {
2222
}
2323
}
2424

25+
// -----
26+
27+
// expected-error @below {{expects to have a terminator in the body}}
28+
"transform.sequence"() <{failure_propagation_mode = 1 : i32, operandSegmentSizes = array<i32: 0, 0>}> ({
29+
^bb0(%arg0: !transform.any_op):
30+
transform.apply_patterns to %arg0 {
31+
} : !transform.any_op
32+
}) : () -> ()
33+
34+
2535
// -----
2636

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

0 commit comments

Comments
 (0)