[Mlir-commits] [mlir] Use reportFatalInternalError in DialectConversion (PR #178612)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sun Feb 1 12:29:47 PST 2026


https://github.com/sladyn98 updated https://github.com/llvm/llvm-project/pull/178612

>From 30781aa15dbe8478cde1f8756fa26514e7c1f9de Mon Sep 17 00:00:00 2001
From: sladynnunes <snunes at usc.edu>
Date: Wed, 28 Jan 2026 22:32:03 -0800
Subject: [PATCH 1/2] mlir: use reportFatalInternalError in DialectConversion

Migrate from deprecated report_fatal_error to reportFatalInternalError
in DialectConversion.cpp. All 6 instances are internal consistency
checks in MLIR's dialect conversion system, so reportFatalInternalError
is the appropriate replacement.

Part of #138914
---
 mlir/lib/Transforms/Utils/DialectConversion.cpp | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index 52067f1b95ad4..f246033576012 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -21,6 +21,7 @@
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/DebugLog.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/SaveAndRestore.h"
 #include "llvm/Support/ScopedPrinter.h"
@@ -1596,7 +1597,7 @@ Block *ConversionPatternRewriterImpl::applySignatureConversion(
 #if MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS
   // A block cannot be converted multiple times.
   if (hasRewrite<BlockTypeConversionRewrite>(rewrites, block))
-    llvm::report_fatal_error("block was already converted");
+    llvm::reportFatalInternalError("block was already converted");
 #endif // MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS
 
   OpBuilder::InsertionGuard g(rewriter);
@@ -2027,7 +2028,7 @@ void ConversionPatternRewriterImpl::replaceValueUses(
 #endif // NDEBUG
 
   if (functor)
-    llvm::report_fatal_error(
+    llvm::reportFatalInternalError(
         "conditional value replacement is not supported in rollback mode");
   mapping.map(from, to);
   appendRewrite<ReplaceValueRewrite>(from, converter);
@@ -2687,7 +2688,7 @@ LogicalResult OperationLegalizer::legalizeWithFold(Operation *op) {
                             newOp->getName()));
       if (!rewriter.getConfig().allowPatternRollback) {
         // Rolling back a folder is like rolling back a pattern.
-        llvm::report_fatal_error(
+        llvm::reportFatalInternalError(
             "op '" + opName +
             "' folder rollback of IR modifications requested");
       }
@@ -2711,7 +2712,7 @@ reportNewIrLegalizationFatalError(const Pattern &pattern,
       newOps, [](Operation *op) { return op->getName().getStringRef(); });
   auto modifiedOpNames = llvm::map_range(
       modifiedOps, [](Operation *op) { return op->getName().getStringRef(); });
-  llvm::report_fatal_error("pattern '" + pattern.getDebugName() +
+  llvm::reportFatalInternalError("pattern '" + pattern.getDebugName() +
                            "' produced IR that could not be legalized. " +
                            "new ops: {" + llvm::join(newOpNames, ", ") + "}, " +
                            "modified ops: {" +
@@ -2772,7 +2773,7 @@ LogicalResult OperationLegalizer::legalizeWithPattern(Operation *op) {
       if (checkOp && topLevelFingerPrint) {
         OperationFingerPrint fingerPrintAfterPattern(checkOp);
         if (fingerPrintAfterPattern != *topLevelFingerPrint)
-          llvm::report_fatal_error("pattern '" + pattern.getDebugName() +
+          llvm::reportFatalInternalError("pattern '" + pattern.getDebugName() +
                                    "' returned failure but IR did change");
       }
 #endif // MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS
@@ -2870,7 +2871,7 @@ LogicalResult OperationLegalizer::legalizePatternResult(
       return hasRewrite<ModifyOperationRewrite>(newRewrites, op);
     };
     if (!replacedRoot() && !updatedRootInPlace())
-      llvm::report_fatal_error("expected pattern to replace the root operation "
+      llvm::reportFatalInternalError("expected pattern to replace the root operation "
                                "or modify it in place");
   }
 #endif // MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS

>From 5bea8050164aedd91e94726b1dadb29d4e79bc0a Mon Sep 17 00:00:00 2001
From: sladynnunes <snunes at usc.edu>
Date: Sun, 1 Feb 2026 12:29:34 -0800
Subject: [PATCH 2/2] mlir: fix clang-format issues in DialectConversion

Fix formatting issues reported by clang-format bot:
- Adjust indentation for string concatenation
- Split long function calls across multiple lines
---
 .../lib/Transforms/Utils/DialectConversion.cpp | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index f246033576012..c5facc32e4461 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -2713,10 +2713,10 @@ reportNewIrLegalizationFatalError(const Pattern &pattern,
   auto modifiedOpNames = llvm::map_range(
       modifiedOps, [](Operation *op) { return op->getName().getStringRef(); });
   llvm::reportFatalInternalError("pattern '" + pattern.getDebugName() +
-                           "' produced IR that could not be legalized. " +
-                           "new ops: {" + llvm::join(newOpNames, ", ") + "}, " +
-                           "modified ops: {" +
-                           llvm::join(modifiedOpNames, ", ") + "}");
+                                 "' produced IR that could not be legalized. " +
+                                 "new ops: {" + llvm::join(newOpNames, ", ") +
+                                 "}, " + "modified ops: {" +
+                                 llvm::join(modifiedOpNames, ", ") + "}");
 }
 
 LogicalResult OperationLegalizer::legalizeWithPattern(Operation *op) {
@@ -2773,8 +2773,9 @@ LogicalResult OperationLegalizer::legalizeWithPattern(Operation *op) {
       if (checkOp && topLevelFingerPrint) {
         OperationFingerPrint fingerPrintAfterPattern(checkOp);
         if (fingerPrintAfterPattern != *topLevelFingerPrint)
-          llvm::reportFatalInternalError("pattern '" + pattern.getDebugName() +
-                                   "' returned failure but IR did change");
+          llvm::reportFatalInternalError(
+              "pattern '" + pattern.getDebugName() +
+              "' returned failure but IR did change");
       }
 #endif // MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS
     }
@@ -2871,8 +2872,9 @@ LogicalResult OperationLegalizer::legalizePatternResult(
       return hasRewrite<ModifyOperationRewrite>(newRewrites, op);
     };
     if (!replacedRoot() && !updatedRootInPlace())
-      llvm::reportFatalInternalError("expected pattern to replace the root operation "
-                               "or modify it in place");
+      llvm::reportFatalInternalError(
+          "expected pattern to replace the root operation "
+          "or modify it in place");
   }
 #endif // MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS
 



More information about the Mlir-commits mailing list