[Mlir-commits] [mlir] [mlir] fix crash in transform.print verification (PR #86679)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Mar 26 08:17:37 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Oleksandr "Alex" Zinenko (ftynse)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/86679.diff
2 Files Affected:
- (modified) mlir/lib/Dialect/Transform/IR/TransformOps.cpp (+5-1)
- (modified) mlir/test/Dialect/Transform/ops-invalid.mlir (+11)
``````````diff
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
+ }
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/86679
More information about the Mlir-commits
mailing list