mirror of
https://github.com/intel/llvm.git
synced 2026-02-09 01:52:26 +08:00
[mlir][Transform] Fix transform.sequence crash in the presence of propagated silenceable errors and yield operations
Differential Revision: https://reviews.llvm.org/D137708
This commit is contained in:
@@ -155,6 +155,12 @@ void transform::AlternativesOp::getRegionInvocationBounds(
|
||||
bounds.resize(getNumRegions(), InvocationBounds(0, 1));
|
||||
}
|
||||
|
||||
static void forwardEmptyOperands(Block *block, transform::TransformState &state,
|
||||
transform::TransformResults &results) {
|
||||
for (const auto &res : block->getParentOp()->getOpResults())
|
||||
results.set(res, {});
|
||||
}
|
||||
|
||||
static void forwardTerminatorOperands(Block *block,
|
||||
transform::TransformState &state,
|
||||
transform::TransformResults &results) {
|
||||
@@ -594,8 +600,11 @@ transform::SequenceOp::apply(transform::TransformResults &results,
|
||||
return result;
|
||||
|
||||
if (result.isSilenceableFailure()) {
|
||||
if (getFailurePropagationMode() == FailurePropagationMode::Propagate)
|
||||
if (getFailurePropagationMode() == FailurePropagationMode::Propagate) {
|
||||
// Propagate empty results in case of early exit.
|
||||
forwardEmptyOperands(getBodyBlock(), state, results);
|
||||
return result;
|
||||
}
|
||||
(void)result.silence();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -920,3 +920,20 @@ transform.with_pdl_patterns {
|
||||
}
|
||||
|
||||
"test.some_op"() : () -> ()
|
||||
// -----
|
||||
|
||||
func.func @split_handles(%a: index, %b: index, %c: index) {
|
||||
%0 = arith.muli %a, %b : index
|
||||
%1 = arith.muli %a, %c : index
|
||||
return
|
||||
}
|
||||
|
||||
transform.sequence -> !pdl.operation failures(propagate) {
|
||||
^bb1(%fun: !pdl.operation):
|
||||
%muli = transform.structured.match ops{["arith.muli"]} in %fun
|
||||
// expected-error @below {{expected to contain 3 operation handles but it only 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.
|
||||
yield %fun : !pdl.operation
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user