[Mlir-commits] [mlir] [MLIR][ExecutionEngine] Restore internal _mlir_{*} builtins lookup (PR #159941)

Balint Cristian llvmlistbot at llvm.org
Mon Sep 22 14:52:48 PDT 2025


https://github.com/cbalint13 updated https://github.com/llvm/llvm-project/pull/159941

>From c7643f8c5220c074cbf4833ba0749c937dc9c1d7 Mon Sep 17 00:00:00 2001
From: Balint Cristian <cristian.balint at gmail.com>
Date: Tue, 23 Sep 2025 00:51:50 +0300
Subject: [PATCH] [MLIR][ExecutionEngine] Restore internal _mlir_{*} builtins

---
 mlir/lib/ExecutionEngine/CRunnerUtils.cpp | 12 ++++++++----
 mlir/test/python/execution_engine.py      | 10 +++++++---
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/mlir/lib/ExecutionEngine/CRunnerUtils.cpp b/mlir/lib/ExecutionEngine/CRunnerUtils.cpp
index 41c619566b55d..668b65d0801e3 100644
--- a/mlir/lib/ExecutionEngine/CRunnerUtils.cpp
+++ b/mlir/lib/ExecutionEngine/CRunnerUtils.cpp
@@ -147,9 +147,11 @@ extern "C" double rtclock() {
 #endif // _WIN32
 }
 
-extern "C" void *mlirAlloc(uint64_t size) { return malloc(size); }
+// NOLINTBEGIN(*-identifier-naming)
 
-extern "C" void *mlirAlignedAlloc(uint64_t alignment, uint64_t size) {
+extern "C" void *_mlir_alloc(uint64_t size) { return malloc(size); }
+extern "C" void *_mlir_malloc(uint64_t size) { return malloc(size); }
+extern "C" void *_mlir_aligned_alloc(uint64_t alignment, uint64_t size) {
 #ifdef _WIN32
   return _aligned_malloc(size, alignment);
 #elif defined(__APPLE__)
@@ -163,9 +165,9 @@ extern "C" void *mlirAlignedAlloc(uint64_t alignment, uint64_t size) {
 #endif
 }
 
-extern "C" void mlirFree(void *ptr) { free(ptr); }
+extern "C" void _mlir_free(void *ptr) { free(ptr); }
 
-extern "C" void mlirAlignedFree(void *ptr) {
+extern "C" void _mlir_aligned_free(void *ptr) {
 #ifdef _WIN32
   _aligned_free(ptr);
 #else
@@ -213,4 +215,6 @@ IMPL_STDSORT(F64, double)
 IMPL_STDSORT(F32, float)
 #undef IMPL_STDSORT
 
+// NOLINTEND(*-identifier-naming)
+
 #endif // MLIR_CRUNNERUTILS_DEFINE_FUNCTIONS
diff --git a/mlir/test/python/execution_engine.py b/mlir/test/python/execution_engine.py
index d569fcef32bfd..38b5a60624ad6 100644
--- a/mlir/test/python/execution_engine.py
+++ b/mlir/test/python/execution_engine.py
@@ -777,7 +777,7 @@ def testNanoTime():
 run(testNanoTime)
 
 
-#  Test that nano time clock is available.
+#  Test dump to object file.
 # CHECK-LABEL: TEST: testDumpToObjectFile
 def testDumpToObjectFile():
     fd, object_path = tempfile.mkstemp(suffix=".o")
@@ -787,8 +787,12 @@ def testDumpToObjectFile():
             module = Module.parse(
                 """
         module {
-        func.func @main() attributes { llvm.emit_c_interface } {
-          return
+        func.func @main(%arg0: memref<1xf32>) -> memref<1xf32> attributes {llvm.emit_c_interface} {
+          %out_memref = memref.alloc() : memref<1xf32>
+          %c0 = arith.constant 0 : index
+          %load_value = memref.load %arg0[%c0] : memref<1xf32>
+          memref.store %load_value, %out_memref[%c0] : memref<1xf32>
+          func.return %out_memref : memref<1xf32>
         }
       }"""
             )



More information about the Mlir-commits mailing list