Skip to content

Commit fa1b807

Browse files
authored
[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.
1 parent 10b07f2 commit fa1b807

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2628,7 +2628,11 @@ transform::PrintOp::apply(transform::TransformRewriter &rewriter,
26282628

26292629
void transform::PrintOp::getEffects(
26302630
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) {
2631-
onlyReadsHandle(getTarget(), effects);
2631+
// We don't really care about mutability here, but `getTarget` now
2632+
// unconditionally casts to a specific type before verification could run
2633+
// here.
2634+
if (!getTargetMutable().empty())
2635+
onlyReadsHandle(getTargetMutable()[0].get(), effects);
26322636
onlyReadsPayload(effects);
26332637

26342638
// There is no resource for stderr file descriptor, so just declare print

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,3 +771,14 @@ module attributes { transform.with_named_sequence } {
771771
transform.yield %arg0 : !transform.any_op
772772
}
773773
}
774+
775+
// -----
776+
777+
module attributes { transform.with_named_sequence } {
778+
transform.named_sequence @match_matmul(%entry: !transform.any_op) -> () {
779+
%c3 = transform.param.constant 1 : i64 -> !transform.param<i64>
780+
// expected-error @below {{op operand #0 must be TransformHandleTypeInterface instance}}
781+
transform.print %c3 : !transform.param<i64>
782+
transform.yield
783+
}
784+
}

0 commit comments

Comments
 (0)