[Mlir-commits] [mlir] [mlir][ExecutionEngine] propagate errors in mlirExecutionEngineCreate (PR #170592)

Maksim Levental llvmlistbot at llvm.org
Thu Dec 4 15:06:23 PST 2025


https://github.com/makslevental updated https://github.com/llvm/llvm-project/pull/170592

>From 61c4259f2e2727adf3b655ec16f832a14f4ef9a6 Mon Sep 17 00:00:00 2001
From: Maksim Levental <maksim.levental at gmail.com>
Date: Wed, 3 Dec 2025 18:03:14 -0800
Subject: [PATCH 1/3] [mlir][ExecutionEngine] propagate error from
 createTargetMachine

---
 mlir/lib/CAPI/ExecutionEngine/ExecutionEngine.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mlir/lib/CAPI/ExecutionEngine/ExecutionEngine.cpp b/mlir/lib/CAPI/ExecutionEngine/ExecutionEngine.cpp
index 2dbb993b1640f..2a63d09fe366b 100644
--- a/mlir/lib/CAPI/ExecutionEngine/ExecutionEngine.cpp
+++ b/mlir/lib/CAPI/ExecutionEngine/ExecutionEngine.cpp
@@ -43,7 +43,8 @@ mlirExecutionEngineCreate(MlirModule op, int optLevel, int numPaths,
   }
   auto tmOrError = tmBuilderOrError->createTargetMachine();
   if (!tmOrError) {
-    llvm::errs() << "Failed to create a TargetMachine for the host\n";
+    llvm::errs() << "Failed to create a TargetMachine for the host because: "
+                 << tmOrError.takeError();
     return MlirExecutionEngine{nullptr};
   }
 

>From bf85bfccce36e89aae39e480b8ea2c9c9d02ddb0 Mon Sep 17 00:00:00 2001
From: Maksim Levental <maksim.levental at gmail.com>
Date: Wed, 3 Dec 2025 18:05:16 -0800
Subject: [PATCH 2/3] [mlir][ExecutionEngine] propagate errors in
 mlirExecutionEngineCreate

---
 mlir/lib/CAPI/ExecutionEngine/ExecutionEngine.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/mlir/lib/CAPI/ExecutionEngine/ExecutionEngine.cpp b/mlir/lib/CAPI/ExecutionEngine/ExecutionEngine.cpp
index 2a63d09fe366b..6c97499b28fd9 100644
--- a/mlir/lib/CAPI/ExecutionEngine/ExecutionEngine.cpp
+++ b/mlir/lib/CAPI/ExecutionEngine/ExecutionEngine.cpp
@@ -38,13 +38,15 @@ mlirExecutionEngineCreate(MlirModule op, int optLevel, int numPaths,
 
   auto tmBuilderOrError = llvm::orc::JITTargetMachineBuilder::detectHost();
   if (!tmBuilderOrError) {
-    llvm::errs() << "Failed to create a JITTargetMachineBuilder for the host\n";
+    llvm::errs() << "Failed to create a JITTargetMachineBuilder for the host "
+                    "because: \n";
+    consumeError(tmBuilderOrError.takeError());
     return MlirExecutionEngine{nullptr};
   }
   auto tmOrError = tmBuilderOrError->createTargetMachine();
   if (!tmOrError) {
-    llvm::errs() << "Failed to create a TargetMachine for the host because: "
-                 << tmOrError.takeError();
+    llvm::errs() << "Failed to create a TargetMachine for the host because: \n";
+    consumeError(tmOrError.takeError());
     return MlirExecutionEngine{nullptr};
   }
 
@@ -63,6 +65,7 @@ mlirExecutionEngineCreate(MlirModule op, int optLevel, int numPaths,
   jitOptions.enableObjectDump = enableObjectDump;
   auto jitOrError = ExecutionEngine::create(unwrap(op), jitOptions);
   if (!jitOrError) {
+    llvm::errs() << "Failed to create an ExecutionEngine because: \n";
     consumeError(jitOrError.takeError());
     return MlirExecutionEngine{nullptr};
   }

>From f6a6798d50258361fac7c3275fea6f17604a9ff4 Mon Sep 17 00:00:00 2001
From: makslevental <maksim.levental at gmail.com>
Date: Thu, 4 Dec 2025 15:03:25 -0800
Subject: [PATCH 3/3] add check for specific error message

---
 mlir/test/python/execution_engine.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mlir/test/python/execution_engine.py b/mlir/test/python/execution_engine.py
index 146e213a9229e..005813d1788f5 100644
--- a/mlir/test/python/execution_engine.py
+++ b/mlir/test/python/execution_engine.py
@@ -71,6 +71,7 @@ def testInvalidModule():
     func.func @foo() { return }
     """
         )
+        # CHECK: error: cannot be converted to LLVM IR: missing `LLVMTranslationDialectInterface` registration for dialect for op: func.func
         # CHECK: Got RuntimeError:  Failure while creating the ExecutionEngine.
         try:
             execution_engine = ExecutionEngine(module)



More information about the Mlir-commits mailing list