Skip to content

Commit b0e2a3a

Browse files
[mlir][Transforms][NFC] Dialect Conversion: Simplify finalize signature
This commit simplifies the signature of `OperationConverter::finalize`. This function always returns "success", so the return value can be removed. Note: Previously, this function used to return "failure" if a materialization failed to legalize. This is now optional and happening at a later point of time (see `config.buildMaterializations`).
1 parent c26a522 commit b0e2a3a

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

mlir/lib/Transforms/Utils/DialectConversion.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2340,7 +2340,7 @@ struct OperationConverter {
23402340

23412341
/// This method is called after the conversion process to legalize any
23422342
/// remaining artifacts and complete the conversion.
2343-
LogicalResult finalize(ConversionPatternRewriter &rewriter);
2343+
void finalize(ConversionPatternRewriter &rewriter);
23442344

23452345
/// Dialect conversion configuration.
23462346
ConversionConfig config;
@@ -2464,8 +2464,7 @@ LogicalResult OperationConverter::convertOperations(ArrayRef<Operation *> ops) {
24642464
// Now that all of the operations have been converted, finalize the conversion
24652465
// process to ensure any lingering conversion artifacts are cleaned up and
24662466
// legalized.
2467-
if (failed(finalize(rewriter)))
2468-
return rewriterImpl.undoRewrites(), failure();
2467+
finalize(rewriter);
24692468

24702469
// After a successful conversion, apply rewrites if this is not an analysis
24712470
// conversion.
@@ -2542,8 +2541,7 @@ getReplacedValues(IRRewrite *rewrite) {
25422541
return {};
25432542
}
25442543

2545-
LogicalResult
2546-
OperationConverter::finalize(ConversionPatternRewriter &rewriter) {
2544+
void OperationConverter::finalize(ConversionPatternRewriter &rewriter) {
25472545
ConversionPatternRewriterImpl &rewriterImpl = rewriter.getImpl();
25482546
DenseMap<Value, SmallVector<Value>> inverseMapping =
25492547
rewriterImpl.mapping.getInverse();
@@ -2578,8 +2576,6 @@ OperationConverter::finalize(ConversionPatternRewriter &rewriter) {
25782576
llvm::erase(inverseMapping[newValue], originalValue);
25792577
}
25802578
}
2581-
2582-
return success();
25832579
}
25842580

25852581
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)