Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mlir/lib/ExecutionEngine/ExecutionEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ ExecutionEngine::create(Operation *m, const ExecutionEngineOptions &options,
// Remember all entry-points if object dumping is enabled.
if (options.enableObjectDump) {
for (auto funcOp : m->getRegion(0).getOps<LLVM::LLVMFuncOp>()) {
if (funcOp.getBlocks().empty())
continue;
StringRef funcName = funcOp.getSymName();
engine->functionNames.push_back(funcName.str());
}
Expand Down
2 changes: 1 addition & 1 deletion mlir/test/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ add_public_tablegen_target(MLIRPythonTestIncGen)

add_subdirectory(lib)

set(MLIR_PYTHON_TEST_DEPENDS MLIRPythonModules)
set(MLIR_PYTHON_TEST_DEPENDS MLIRPythonModules mlir-runner)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like I (potentially) broke lots of tests in this PR #157176 because mlir/test/lit.cfg.py tries to call mlir-runner (which might not be built):

def have_host_jit_feature_support(feature_name):
mlir_runner_exe = lit.util.which("mlir-runner", config.mlir_tools_dir)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, I double checked and this is the only tool that's required.

if(NOT MLIR_STANDALONE_BUILD)
list(APPEND MLIR_PYTHON_TEST_DEPENDS FileCheck count not)
endif()
Expand Down
27 changes: 20 additions & 7 deletions mlir/test/python/execution_engine.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# RUN: env MLIR_RUNNER_UTILS=%mlir_runner_utils MLIR_C_RUNNER_UTILS=%mlir_c_runner_utils %PYTHON %s 2>&1 | FileCheck %s
# REQUIRES: host-supports-jit
import gc, sys, os, tempfile
from textwrap import dedent
from mlir.ir import *
from mlir.passmanager import *
from mlir.execution_engine import *
Expand All @@ -21,6 +22,7 @@
"MLIR_C_RUNNER_UTILS", "../../../../lib/libmlir_c_runner_utils.so"
)


# Log everything to stderr and flush so that we have a unified stream to match
# errors/info emitted by MLIR to stderr.
def log(*args):
Expand Down Expand Up @@ -337,6 +339,7 @@ def callback(a):
ctypes.pointer(ctypes.pointer(get_ranked_memref_descriptor(inp_arr))),
)


run(testUnrankedMemRefWithOffsetCallback)


Expand Down Expand Up @@ -785,15 +788,25 @@ def testDumpToObjectFile():
try:
with Context():
module = Module.parse(
"""
module {
func.func @main() attributes { llvm.emit_c_interface } {
return
}
}"""
dedent(
"""
func.func private @printF32(f32)
func.func @main(%arg0: f32) attributes { llvm.emit_c_interface } {
call @printF32(%arg0) : (f32) -> ()
return
}
"""
)
)

execution_engine = ExecutionEngine(lowerToLLVM(module), opt_level=3)
execution_engine = ExecutionEngine(
lowerToLLVM(module),
opt_level=3,
# Loading MLIR_C_RUNNER_UTILS is necessary even though we don't actually run the code (i.e., call printF32)
# because RTDyldObjectLinkingLayer::emit will try to resolve symbols before dumping
# (see the jitLinkForORC call at the bottom there).
shared_libs=[MLIR_C_RUNNER_UTILS],
)

# CHECK: Object file exists: True
print(f"Object file exists: {os.path.exists(object_path)}")
Expand Down