Skip to content

Commit c3cd872

Browse files
author
git apple-llvm automerger
committed
Merge commit 'f22d5884b284' from llvm.org/main into next
2 parents 56f2900 + f22d588 commit c3cd872

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

mlir/lib/Transforms/Utils/DialectConversion.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2856,17 +2856,19 @@ LogicalResult OperationLegalizer::legalizePatternResult(
28562856
assert(impl.pendingRootUpdates.empty() && "dangling root updates");
28572857

28582858
#if MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS
2859-
// Check that the root was either replaced or updated in place.
2860-
auto newRewrites = llvm::drop_begin(impl.rewrites, curState.numRewrites);
2861-
auto replacedRoot = [&] {
2862-
return hasRewrite<ReplaceOperationRewrite>(newRewrites, op);
2863-
};
2864-
auto updatedRootInPlace = [&] {
2865-
return hasRewrite<ModifyOperationRewrite>(newRewrites, op);
2866-
};
2867-
if (!replacedRoot() && !updatedRootInPlace())
2868-
llvm::report_fatal_error(
2869-
"expected pattern to replace the root operation or modify it in place");
2859+
if (impl.config.allowPatternRollback) {
2860+
// Check that the root was either replaced or updated in place.
2861+
auto newRewrites = llvm::drop_begin(impl.rewrites, curState.numRewrites);
2862+
auto replacedRoot = [&] {
2863+
return hasRewrite<ReplaceOperationRewrite>(newRewrites, op);
2864+
};
2865+
auto updatedRootInPlace = [&] {
2866+
return hasRewrite<ModifyOperationRewrite>(newRewrites, op);
2867+
};
2868+
if (!replacedRoot() && !updatedRootInPlace())
2869+
llvm::report_fatal_error("expected pattern to replace the root operation "
2870+
"or modify it in place");
2871+
}
28702872
#endif // MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS
28712873

28722874
// Legalize each of the actions registered during application.

0 commit comments

Comments
 (0)