Skip to content

[mlir][Transforms][NFC] Dialect Conversion: Simplify finalize signature #110419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

matthias-springer
Copy link
Member

@matthias-springer matthias-springer commented Sep 29, 2024

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).

@llvmbot llvmbot added mlir:core MLIR Core Infrastructure mlir labels Sep 29, 2024
@llvmbot
Copy link
Member

llvmbot commented Sep 29, 2024

@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-core

Author: Matthias Springer (matthias-springer)

Changes

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).

Depends on #110414.


Full diff: https://github.com/llvm/llvm-project/pull/110419.diff

1 Files Affected:

  • (modified) mlir/lib/Transforms/Utils/DialectConversion.cpp (+3-7)
diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index b5aab2416c3eb9..a5872cd3d30696 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -2340,7 +2340,7 @@ struct OperationConverter {
 
   /// This method is called after the conversion process to legalize any
   /// remaining artifacts and complete the conversion.
-  LogicalResult finalize(ConversionPatternRewriter &rewriter);
+  void finalize(ConversionPatternRewriter &rewriter);
 
   /// Dialect conversion configuration.
   ConversionConfig config;
@@ -2464,8 +2464,7 @@ LogicalResult OperationConverter::convertOperations(ArrayRef<Operation *> ops) {
   // Now that all of the operations have been converted, finalize the conversion
   // process to ensure any lingering conversion artifacts are cleaned up and
   // legalized.
-  if (failed(finalize(rewriter)))
-    return rewriterImpl.undoRewrites(), failure();
+  finalize(rewriter);
 
   // After a successful conversion, apply rewrites if this is not an analysis
   // conversion.
@@ -2542,8 +2541,7 @@ getReplacedValues(IRRewrite *rewrite) {
   return {};
 }
 
-LogicalResult
-OperationConverter::finalize(ConversionPatternRewriter &rewriter) {
+void OperationConverter::finalize(ConversionPatternRewriter &rewriter) {
   ConversionPatternRewriterImpl &rewriterImpl = rewriter.getImpl();
   DenseMap<Value, SmallVector<Value>> inverseMapping =
       rewriterImpl.mapping.getInverse();
@@ -2578,8 +2576,6 @@ OperationConverter::finalize(ConversionPatternRewriter &rewriter) {
       llvm::erase(inverseMapping[newValue], originalValue);
     }
   }
-
-  return success();
 }
 
 //===----------------------------------------------------------------------===//

Base automatically changed from users/matthias-springer/remap_values_docs to main September 30, 2024 19:19
…ture

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`).
@matthias-springer matthias-springer force-pushed the users/matthias-springer/finalize_signature branch from 95a23ba to b0e2a3a Compare October 1, 2024 07:06
@matthias-springer matthias-springer merged commit 8897dd6 into main Oct 1, 2024
5 of 7 checks passed
@matthias-springer matthias-springer deleted the users/matthias-springer/finalize_signature branch October 1, 2024 07:06
Sterling-Augustine pushed a commit to Sterling-Augustine/llvm-project that referenced this pull request Oct 3, 2024
…ture (llvm#110419)

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`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mlir:core MLIR Core Infrastructure mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants