diff options
| author | Denys Shabalin <shabalin@google.com> | 2022-10-20 12:58:49 +0200 |
|---|---|---|
| committer | Denys Shabalin <shabalin@google.com> | 2022-10-20 15:53:16 +0200 |
| commit | 95c083f579d6246a052ed798c6f02e30b2c3cf87 (patch) | |
| tree | 129627cea650928e9052f3e021b75e396357af63 /mlir/test/python/execution_engine.py | |
| parent | 903cc71a82431d79e5fb541946a9e7c93750e374 (diff) | |
[mlir] Fix and test python bindings for dump_to_object_file
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D136334
Diffstat (limited to 'mlir/test/python/execution_engine.py')
| -rw-r--r-- | mlir/test/python/execution_engine.py | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/mlir/test/python/execution_engine.py b/mlir/test/python/execution_engine.py index 64d7ee079e56..92471cc70121 100644 --- a/mlir/test/python/execution_engine.py +++ b/mlir/test/python/execution_engine.py @@ -1,6 +1,6 @@ # RUN: %PYTHON %s 2>&1 | FileCheck %s # REQUIRES: host-supports-jit -import gc, sys +import gc, sys, os, tempfile from mlir.ir import * from mlir.passmanager import * from mlir.execution_engine import * @@ -552,3 +552,40 @@ def testNanoTime(): run(testNanoTime) + + +# Test that nano time clock is available. +# CHECK-LABEL: TEST: testDumpToObjectFile +def testDumpToObjectFile(): + _, object_path = tempfile.mkstemp(suffix=".o") + + try: + with Context(): + module = Module.parse(""" + module { + func.func @main() attributes { llvm.emit_c_interface } { + return + } + }""") + + execution_engine = ExecutionEngine( + lowerToLLVM(module), + opt_level=3) + + # CHECK: Object file exists: True + print(f"Object file exists: {os.path.exists(object_path)}") + # CHECK: Object file is empty: True + print(f"Object file is empty: {os.path.getsize(object_path) == 0}") + + execution_engine.dump_to_object_file(object_path) + + # CHECK: Object file exists: True + print(f"Object file exists: {os.path.exists(object_path)}") + # CHECK: Object file is empty: False + print(f"Object file is empty: {os.path.getsize(object_path) == 0}") + + finally: + os.remove(object_path) + + +run(testDumpToObjectFile) |
