From 89d2616c01f8dce92612713595ceca4a756dcf0e Mon Sep 17 00:00:00 2001 From: Fabian Schuiki Date: Thu, 9 Jul 2026 16:12:39 -0700 Subject: [PATCH] [Arcilator] Add --jit-object-file option to dump JIT-compiled object Write the object bytes the JIT compiles to a file when the option is provided. Enables the execution engine's object dump and calls dumpToObjectFile after the module has been JIT-compiled. Co-Authored-By: Claude Opus 4.7 (1M context) --- integration_test/arcilator/JIT/object-file.mlir | 6 ++++++ tools/arcilator/arcilator.cpp | 10 ++++++++++ 2 files changed, 16 insertions(+) create mode 100644 integration_test/arcilator/JIT/object-file.mlir diff --git a/integration_test/arcilator/JIT/object-file.mlir b/integration_test/arcilator/JIT/object-file.mlir new file mode 100644 index 000000000000..39eb5e74b136 --- /dev/null +++ b/integration_test/arcilator/JIT/object-file.mlir @@ -0,0 +1,6 @@ +// RUN: arcilator %s --run --jit-entry=main --jit-object-file=%t && test -s %t +// REQUIRES: arcilator-jit + +func.func @main() { + return +} diff --git a/tools/arcilator/arcilator.cpp b/tools/arcilator/arcilator.cpp index 63c1b3016420..8dfa3bcc81ce 100644 --- a/tools/arcilator/arcilator.cpp +++ b/tools/arcilator/arcilator.cpp @@ -280,6 +280,11 @@ static llvm::cl::opt jitVcdFile( "Create a VCD trace for JIT runs and output it to the specified file"), llvm::cl::init(""), llvm::cl::cat(mainCategory)); +static llvm::cl::opt jitObjectFile( + "jit-object-file", + llvm::cl::desc("Write the JIT-compiled object code to the specified file"), + llvm::cl::init(""), llvm::cl::cat(mainCategory)); + #ifdef CIRCT_LIBFST_ENABLED static llvm::cl::opt jitFstFile( "jit-fst-file", @@ -539,6 +544,8 @@ static LogicalResult processBuffer( /*targetMachine=*/nullptr); engineOptions.transformer = transformer; engineOptions.sharedLibPaths = sharedLibraries; + if (!jitObjectFile.empty()) + engineOptions.enableObjectDump = true; auto tsCompile = tsJit.nest("Compile"); auto executionEngine = @@ -555,6 +562,9 @@ static LogicalResult processBuffer( if (!noJitRuntime) bindArcRuntimeSymbols(**executionEngine); + if (!jitObjectFile.empty()) + (*executionEngine)->dumpToObjectFile(jitObjectFile); + auto expectedFunc = (*executionEngine)->lookupPacked(jitEntryPoint); if (!expectedFunc) { llvm::handleAllErrors(