[llvm] [lli] Mimic default LLJIT logic with explicit --jit-linker option (PR #76964)

Stefan Gränitz via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 4 06:53:00 PST 2024


https://github.com/weliveindetail created https://github.com/llvm/llvm-project/pull/76964

Forcing the JITLinker to the default configuration shouldn't affect the configuration of the JIT. Since it's implemented by setting the ObjectLinkingLayerCreator, it did have side-effects though. In particular, we skipped the Code- and RelocationModel setting in `LLJITBuilderState::prepareForConstruction()` (here: https://github.com/llvm/llvm-project/blob/release/17.x/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp#L759-L760).

>From 4848ebcdebb11f919e313e5aa89683d61a7525c1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <stefan.graenitz at gmail.com>
Date: Thu, 4 Jan 2024 15:41:29 +0100
Subject: [PATCH] [lli] Mimic default LLJIT logic with explicit --jit-linker
 option

---
 llvm/tools/lli/lli.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp
index 5f1fd15787642a..8a7ea2d3d0c582 100644
--- a/llvm/tools/lli/lli.cpp
+++ b/llvm/tools/lli/lli.cpp
@@ -965,9 +965,12 @@ int runOrcJIT(const char *ProgName) {
     EPC = ExitOnErr(orc::SelfExecutorProcessControl::Create(
         std::make_shared<orc::SymbolStringPool>()));
 
-    Builder.setObjectLinkingLayerCreator([&EPC, &P](orc::ExecutionSession &ES,
-                                                    const Triple &TT) {
-      auto L = std::make_unique<orc::ObjectLinkingLayer>(ES, EPC->getMemMgr());
+    Builder.getJITTargetMachineBuilder()
+        ->setRelocationModel(Reloc::PIC_)
+        .setCodeModel(CodeModel::Small);
+    Builder.setObjectLinkingLayerCreator([&P](orc::ExecutionSession &ES,
+                                              const Triple &TT) {
+      auto L = std::make_unique<orc::ObjectLinkingLayer>(ES);
       if (P != LLJITPlatform::ExecutorNative)
         L->addPlugin(std::make_unique<orc::EHFrameRegistrationPlugin>(
             ES, ExitOnErr(orc::EPCEHFrameRegistrar::Create(ES))));



More information about the llvm-commits mailing list