[llvm] lli: Record the host triple on triple-less modules (PR #216132)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 13 10:52:48 PDT 2026
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/216132
The JIT compiles for the host, but modules without a target triple kept
an empty triple, which module-triple-based analyses (e.g. runtime
libcall selection) cannot resolve. Set the resolved JIT triple on the
module. This defends against jit test regressions when RuntimeLibraryInfo
starts getting computed from the module instead of TargetOptions.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
>From 715b0c4ecf1a67389f6fcb7179d6f85f0e345311 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Thu, 13 Aug 2026 18:26:54 +0200
Subject: [PATCH] lli: Record the host triple on triple-less modules
The JIT compiles for the host, but modules without a target triple kept
an empty triple, which module-triple-based analyses (e.g. runtime
libcall selection) cannot resolve. Set the resolved JIT triple on the
module. This defends against jit test regressions when RuntimeLibraryInfo
starts getting computed from the module instead of TargetOptions.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
---
llvm/tools/lli/lli.cpp | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp
index cbc85d6272010..5f3eece50ad09 100644
--- a/llvm/tools/lli/lli.cpp
+++ b/llvm/tools/lli/lli.cpp
@@ -516,7 +516,12 @@ int main(int argc, char **argv, char * const *envp) {
builder.setTargetOptions(Options);
- std::unique_ptr<ExecutionEngine> EE(builder.create());
+ // Resolve the target the JIT will compile for and record it in the module
+ TargetMachine *TM = builder.selectTarget();
+ if (TM && Mod->getTargetTriple().empty())
+ Mod->setTargetTriple(TM->getTargetTriple());
+
+ std::unique_ptr<ExecutionEngine> EE(builder.create(TM));
if (!EE) {
if (!ErrorMsg.empty())
WithColor::error(errs(), argv[0])
@@ -946,6 +951,14 @@ static int runOrcJIT(const char *ProgName) {
Builder.getJITTargetMachineBuilder()->getTargetTriple().setArchName(
codegen::getMArch());
+ // Record the triple the JIT compiles for on triple-less modules.
+ const Triple &JITTriple =
+ Builder.getJITTargetMachineBuilder()->getTargetTriple();
+ MainModule.withModuleDo([&](Module &M) {
+ if (M.getTargetTriple().empty())
+ M.setTargetTriple(JITTriple);
+ });
+
Builder.getJITTargetMachineBuilder()
->setCPU(codegen::getCPUStr())
.addFeatures(codegen::getFeatureList())
More information about the llvm-commits
mailing list