Files
clang-p2996/mlir/test/Dialect/Transform/apply-foreach-nested.mlir
Oleksandr "Alex" Zinenko 71c17424b5 [mlir][TD] update more tests to use the "main" interpreter pass (#76963)
Update several tests under mlir/test/Dialect/Transform to use the "main"
transform interpreter pass with named entry points rather than the test
interpreter pass.

This helped discover a logic error in the expensive checks mechanism
that was exiting too early.
2024-01-04 21:33:51 +01:00

55 lines
1.8 KiB
MLIR

// RUN: mlir-opt %s --split-input-file --verify-diagnostics \
// RUN: --transform-interpreter
func.func private @bar()
func.func @foo() {
%c0 = arith.constant 0 : index
%c1 = arith.constant 1 : index
%c10 = arith.constant 10 : index
// expected-note @below {{ancestor payload op}}
scf.for %i = %c0 to %c1 step %c10 {
// expected-note @below {{descendant payload op}}
scf.for %j = %c0 to %c1 step %c10 {
func.call @bar() : () -> ()
}
}
return
}
module attributes {transform.with_named_sequence} {
transform.named_sequence @__transform_main(%arg0: !transform.any_op) {
%0 = transform.structured.match ops{["scf.for"]} in %arg0 : (!transform.any_op) -> !transform.op<"scf.for">
%1 = transform.test_reverse_payload_ops %0 : (!transform.op<"scf.for">) -> !transform.op<"scf.for">
// expected-error @below {{transform operation consumes a handle pointing to an ancestor payload operation before its descendant}}
// expected-note @below {{the ancestor is likely erased or rewritten before the descendant is accessed, leading to undefined behavior}}
transform.test_consume_operand_each %1 : !transform.op<"scf.for">
transform.yield
}
}
// -----
func.func private @bar()
func.func @foo() {
%c0 = arith.constant 0 : index
%c1 = arith.constant 1 : index
%c10 = arith.constant 10 : index
scf.for %i = %c0 to %c1 step %c10 {
scf.for %j = %c0 to %c1 step %c10 {
func.call @bar() : () -> ()
}
}
return
}
// No error here, processing ancestors before descendants.
module attributes {transform.with_named_sequence} {
transform.named_sequence @__transform_main(%arg0: !transform.any_op) {
%0 = transform.structured.match ops{["scf.for"]} in %arg0 : (!transform.any_op) -> !transform.op<"scf.for">
transform.test_consume_operand_each %0 : !transform.op<"scf.for">
transform.yield
}
}