diff --git a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp --- a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp +++ b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp @@ -1510,13 +1510,17 @@ if (numResultHandles != expectedNumResultHandles) { // Empty input handle corner case: always propagates empty handles in both // suppress and propagate modes. - if (numResultHandles == 0) + if (numResultHandles == 0) { + for (OpResult result : getResults()) + results.set(result, {}); return DiagnosedSilenceableFailure::success(); + } + // If the input handle was not empty and the number of result handles does // not match, this is a legit silenceable error. return emitSilenceableError() << getHandle() << " expected to contain " << expectedNumResultHandles - << " operation handles but it only contains " << numResultHandles + << " operation handles but it contains " << numResultHandles << " handles"; } // Normal successful case. diff --git a/mlir/test/Dialect/Transform/test-interpreter.mlir b/mlir/test/Dialect/Transform/test-interpreter.mlir --- a/mlir/test/Dialect/Transform/test-interpreter.mlir +++ b/mlir/test/Dialect/Transform/test-interpreter.mlir @@ -834,7 +834,7 @@ // expected-remark @below {{1}} transform.test_print_number_of_associated_payload_ir_ops %h#0 %muli_2 = transform.structured.match ops{["arith.muli"]} in %fun : (!pdl.operation) -> !pdl.operation - // expected-error @below {{expected to contain 3 operation handles but it only contains 2 handles}} + // expected-error @below {{expected to contain 3 operation handles but it contains 2 handles}} %h_2:3 = split_handles %muli_2 in [3] : (!pdl.operation) -> (!pdl.operation, !pdl.operation, !pdl.operation) } @@ -978,7 +978,7 @@ transform.sequence -> !pdl.operation failures(propagate) { ^bb1(%fun: !pdl.operation): %muli = transform.structured.match ops{["arith.muli"]} in %fun : (!pdl.operation) -> !pdl.operation - // expected-error @below {{expected to contain 3 operation handles but it only contains 2 handles}} + // expected-error @below {{expected to contain 3 operation handles but it contains 2 handles}} %h_2:3 = split_handles %muli in [3] : (!pdl.operation) -> (!pdl.operation, !pdl.operation, !pdl.operation) /// Test that yield does not crash in the presence of silenceable error in /// propagate mode. @@ -987,6 +987,17 @@ // ----- +transform.sequence -> !transform.any_op failures(suppress) { +^bb0(%arg0: !transform.any_op): + %muli = transform.structured.match ops{["arith.muli"]} in %arg0 : (!transform.any_op) -> !transform.any_op + // Edge case propagating empty handles in splitting. + %0:3 = split_handles %muli in [3] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op) + // Test does not crash when accessing the empty handle. + yield %0#0 : !transform.any_op +} + +// ----- + transform.sequence failures(propagate) { ^bb0(%arg0: !transform.any_op): %0 = transform.test_produce_integer_param_with_type i32 : !transform.test_dialect_param