[Mlir-commits] [mlir] [mlir] avoid crash in transform.sequence verifier (PR #66756)
Oleksandr Alex Zinenko
llvmlistbot at llvm.org
Tue Sep 19 02:47:20 PDT 2023
https://github.com/ftynse created https://github.com/llvm/llvm-project/pull/66756
The verifier was unconditionally accessing the body block terminator, but it's not guaranteed that the block has one in general.
>From 249d53f1d4d89f991946b2f6ee6574480fba66c7 Mon Sep 17 00:00:00 2001
From: Alex Zinenko <zinenko at google.com>
Date: Tue, 19 Sep 2023 09:44:08 +0000
Subject: [PATCH] [mlir] avoid crash in transform.sequence verifier
The verifier was unconditionally accessing the body block terminator,
but it's not guaranteed that the block has one in general.
---
mlir/lib/Dialect/Transform/IR/TransformOps.cpp | 3 +++
mlir/test/Dialect/Transform/ops-invalid.mlir | 10 ++++++++++
2 files changed, 13 insertions(+)
diff --git a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
index f1d07b85adb7576..dc004cd14dc0fbf 100644
--- a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
+++ b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
@@ -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()
diff --git a/mlir/test/Dialect/Transform/ops-invalid.mlir b/mlir/test/Dialect/Transform/ops-invalid.mlir
index 3e30947769eb403..096416158879812 100644
--- a/mlir/test/Dialect/Transform/ops-invalid.mlir
+++ b/mlir/test/Dialect/Transform/ops-invalid.mlir
@@ -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}}
More information about the Mlir-commits
mailing list