[llvm] [llvm-jitlink] Add -show-jit-result option (PR #226149)
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 24 05:50:15 PDT 2026
https://github.com/lhames created https://github.com/llvm/llvm-project/pull/226149
Add a -show-jit-result option that prints the int result of the JIT'd main / entry function to stdout as:
JIT result: <return value>
This makes the result of the JIT'd main / entry function FileCheck-able, and distinguishable from an llvm-jitlink failure.
This will be used in upcoming ORC runtime tests.
Since we don't currently run code under llvm-jitlink in LLVM regression tests, this commit does not include an LLVM-side test.
>From fade5467c6f2bb874d3f8a23c8fea2ac9a7dde14 Mon Sep 17 00:00:00 2001
From: Lang Hames <lhames at gmail.com>
Date: Thu, 24 Sep 2026 22:35:46 +1000
Subject: [PATCH] [llvm-jitlink] Add -show-jit-result option
Add a -show-jit-result option that prints the int result of the JIT'd
main / entry function to stdout as:
JIT result: <return value>
This makes the result of the JIT'd main / entry function FileCheck-able,
and distinguishable from an llvm-jitlink failure.
This will be used in upcoming ORC runtime tests.
Since we don't currently run code under llvm-jitlink in LLVM regression
tests, this commit does not include an LLVM-side test.
---
llvm/tools/llvm-jitlink/llvm-jitlink.cpp | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
index 1160167c1cdad..22382d855b9ae 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -195,6 +195,11 @@ static cl::opt<std::string>
CheckName("check-name", cl::desc("Name of checks to match against"),
cl::init("jitlink-check"), cl::cat(JITLinkCategory));
+static cl::opt<bool>
+ ShowJITResult("show-jit-result",
+ cl::desc("Print result of JIT'd main/entry to stdout"),
+ cl::init(false), cl::cat(JITLinkCategory));
+
static cl::opt<std::string>
EntryPointName("entry", cl::desc("Symbol to call as main entry point"),
cl::init(""), cl::cat(JITLinkCategory));
@@ -3166,6 +3171,8 @@ int main(int argc, char *argv[]) {
Result = ExitOnErr(runWithRuntime(*S, EntryPoint->getAddress()));
else
Result = ExitOnErr(runWithoutRuntime(*S, EntryPoint->getAddress()));
+ if (ShowJITResult)
+ outs() << "JIT result: " << Result << "\n";
}
// Destroy the session.
More information about the llvm-commits
mailing list