[Mlir-commits] [mlir] fa1b807 - [mlir] fix crash in transform.print verification (#86679)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Mar 26 18:58:09 PDT 2024
Author: Oleksandr "Alex" Zinenko
Date: 2024-03-27T02:58:06+01:00
New Revision: fa1b807befdc7b31b1c0e0ab625170924f7b4951
URL: https://github.com/llvm/llvm-project/commit/fa1b807befdc7b31b1c0e0ab625170924f7b4951
DIFF: https://github.com/llvm/llvm-project/commit/fa1b807befdc7b31b1c0e0ab625170924f7b4951.diff
LOG: [mlir] fix crash in transform.print verification (#86679)
Transform op trait verification calls `getEffects`, and since trait
verification runs before op verification, this call cannot assume the op
to be valid. However, the operand getters now return a `TypedValue` that
unconditionally casts the value to the expected type, leading to an
assertion failure. Use the untyped mechanism instead.
Fixes #84701.
Added:
Modified:
mlir/lib/Dialect/Transform/IR/TransformOps.cpp
mlir/test/Dialect/Transform/ops-invalid.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
index 8d2ed8f6d73714..abd557a508a103 100644
--- a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
+++ b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
@@ -2628,7 +2628,11 @@ transform::PrintOp::apply(transform::TransformRewriter &rewriter,
void transform::PrintOp::getEffects(
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) {
- onlyReadsHandle(getTarget(), effects);
+ // We don't really care about mutability here, but `getTarget` now
+ // unconditionally casts to a specific type before verification could run
+ // here.
+ if (!getTargetMutable().empty())
+ onlyReadsHandle(getTargetMutable()[0].get(), effects);
onlyReadsPayload(effects);
// There is no resource for stderr file descriptor, so just declare print
diff --git a/mlir/test/Dialect/Transform/ops-invalid.mlir b/mlir/test/Dialect/Transform/ops-invalid.mlir
index 73a5f36af92952..cc04e65420c5b7 100644
--- a/mlir/test/Dialect/Transform/ops-invalid.mlir
+++ b/mlir/test/Dialect/Transform/ops-invalid.mlir
@@ -771,3 +771,14 @@ module attributes { transform.with_named_sequence } {
transform.yield %arg0 : !transform.any_op
}
}
+
+// -----
+
+module attributes { transform.with_named_sequence } {
+ transform.named_sequence @match_matmul(%entry: !transform.any_op) -> () {
+ %c3 = transform.param.constant 1 : i64 -> !transform.param<i64>
+ // expected-error @below {{op operand #0 must be TransformHandleTypeInterface instance}}
+ transform.print %c3 : !transform.param<i64>
+ transform.yield
+ }
+}
More information about the Mlir-commits
mailing list