[llvm] 67a1b7f - [Orc][LLJIT] Automatically use JITLink for LLJIT on supported platforms.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 15 21:58:01 PST 2019


Author: Lang Hames
Date: 2019-12-15T21:57:10-08:00
New Revision: 67a1b7f05379f2686f858fc103debcac0aed3973

URL: https://github.com/llvm/llvm-project/commit/67a1b7f05379f2686f858fc103debcac0aed3973
DIFF: https://github.com/llvm/llvm-project/commit/67a1b7f05379f2686f858fc103debcac0aed3973.diff

LOG: [Orc][LLJIT] Automatically use JITLink for LLJIT on supported platforms.

JITLink (which underlies ObjectLinkingLayer) is a replacement for RuntimeDyld.
It supports the native code model, and linker plugins that enable a wider range
of features than RuntimeDyld.

Currently only enabled for MachO/x86-64 and MachO/arm64. New architectures will
be added as JITLink support for them is developed.

Added: 
    

Modified: 
    llvm/lib/ExecutionEngine/Orc/LLJIT.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
index 89dad6d61b42..5c393739f401 100644
--- a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
@@ -7,6 +7,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/ExecutionEngine/Orc/LLJIT.h"
+#include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h"
+#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
 #include "llvm/ExecutionEngine/Orc/OrcError.h"
 #include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
 #include "llvm/ExecutionEngine/SectionMemoryManager.h"
@@ -22,6 +24,22 @@ Error LLJITBuilderState::prepareForConstruction() {
       JTMB = std::move(*JTMBOrErr);
     else
       return JTMBOrErr.takeError();
+
+    // If no ObjectLinkingLayer creator was set and the target supports JITLink
+    // then configure for JITLink.
+    auto &TT = JTMB->getTargetTriple();
+    if (!CreateObjectLinkingLayer && TT.isOSBinFormatMachO() &&
+        (TT.getArch() == Triple::aarch64 || TT.getArch() == Triple::x86_64)) {
+
+      JTMB->setRelocationModel(Reloc::PIC_);
+      JTMB->setCodeModel(CodeModel::Small);
+      CreateObjectLinkingLayer =
+          [](ExecutionSession &ES,
+             const Triple &) -> std::unique_ptr<ObjectLayer> {
+        return std::make_unique<ObjectLinkingLayer>(
+            ES, std::make_unique<jitlink::InProcessMemoryManager>());
+      };
+    }
   }
 
   return Error::success();


        


More information about the llvm-commits mailing list