[llvm] 22641f5 - [ORC] Use EPC for EPCGeneric MemoryAccess / JITLinkMemoryManager construction.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 10 18:30:09 PDT 2021


Author: Lang Hames
Date: 2021-09-11T11:24:00+10:00
New Revision: 22641f585372dd228bf668bcf0c0e171f6ff26c3

URL: https://github.com/llvm/llvm-project/commit/22641f585372dd228bf668bcf0c0e171f6ff26c3
DIFF: https://github.com/llvm/llvm-project/commit/22641f585372dd228bf668bcf0c0e171f6ff26c3.diff

LOG: [ORC] Use EPC for EPCGeneric MemoryAccess / JITLinkMemoryManager construction.

This allows these classes to be created during EPC construction, before an
ExecutionSession is available.

Added: 
    

Modified: 
    llvm/include/llvm/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.h
    llvm/include/llvm/ExecutionEngine/Orc/EPCGenericMemoryAccess.h
    llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp
    llvm/lib/ExecutionEngine/Orc/EPCGenericMemoryAccess.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.h b/llvm/include/llvm/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.h
index 6ad2351fb449c..0dd1e6a7562a5 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.h
@@ -38,10 +38,10 @@ class EPCGenericJITLinkMemoryManager : public jitlink::JITLinkMemoryManager {
   EPCGenericJITLinkMemoryManager(ExecutorProcessControl &EPC, FuncAddrs FAs)
       : EPC(EPC), FAs(FAs) {}
 
-  /// Create using the standard memory access function names from the ORC
-  /// runtime.
+  /// Create using the standard memory allocation function names from the
+  /// ORCTargetProcess library.
   static Expected<std::unique_ptr<EPCGenericJITLinkMemoryManager>>
-  CreateUsingOrcRTFuncs(ExecutionSession &ES, JITDylib &OrcRuntimeJD);
+  CreateUsingOrcRTFuncs(ExecutorProcessControl &EPC);
 
   Expected<std::unique_ptr<Allocation>>
   allocate(const jitlink::JITLinkDylib *JD,

diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/EPCGenericMemoryAccess.h b/llvm/include/llvm/ExecutionEngine/Orc/EPCGenericMemoryAccess.h
index 20a47846927a4..fe9d1c13881cb 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/EPCGenericMemoryAccess.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/EPCGenericMemoryAccess.h
@@ -39,10 +39,10 @@ class EPCGenericMemoryAccess : public ExecutorProcessControl::MemoryAccess {
   EPCGenericMemoryAccess(ExecutorProcessControl &EPC, FuncAddrs FAs)
       : EPC(EPC), FAs(FAs) {}
 
-  /// Create using the standard memory access function names from the ORC
-  /// runtime.
+  /// Create using the standard memory access function names from the
+  /// ORCTargetProcess library.
   static Expected<std::unique_ptr<EPCGenericMemoryAccess>>
-  CreateUsingOrcRTFuncs(ExecutionSession &ES, JITDylib &OrcRuntimeJD);
+  CreateUsingOrcRTFuncs(ExecutorProcessControl &EPC);
 
   void writeUInt8sAsync(ArrayRef<tpctypes::UInt8Write> Ws,
                         WriteResultFn OnWriteComplete) override {

diff  --git a/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp b/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp
index 012ff73fc8e5b..ac6de224c9c5f 100644
--- a/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.cpp
@@ -88,25 +88,28 @@ class EPCGenericJITLinkMemoryManager::Alloc
 
 /// Create from a ExecutorProcessControl instance.
 Expected<std::unique_ptr<EPCGenericJITLinkMemoryManager>>
-EPCGenericJITLinkMemoryManager::CreateUsingOrcRTFuncs(ExecutionSession &ES,
-                                                      JITDylib &OrcRuntimeJD) {
+EPCGenericJITLinkMemoryManager::CreateUsingOrcRTFuncs(
+    ExecutorProcessControl &EPC) {
+
+  auto H = EPC.loadDylib("");
+  if (!H)
+    return H.takeError();
 
   StringRef GlobalPrefix = "";
-  if (ES.getExecutorProcessControl().getTargetTriple().isOSBinFormatMachO())
+  if (EPC.getTargetTriple().isOSBinFormatMachO())
     GlobalPrefix = "_";
 
   FuncAddrs FAs;
   if (auto Err = lookupAndRecordAddrs(
-          ES, LookupKind::Static, makeJITDylibSearchOrder(&OrcRuntimeJD),
-          {{ES.intern((GlobalPrefix + "__orc_rt_reserve").str()), &FAs.Reserve},
-           {ES.intern((GlobalPrefix + "__orc_rt_finalize").str()),
+          EPC, *H,
+          {{EPC.intern((GlobalPrefix + "__orc_rt_reserve").str()), &FAs.Reserve},
+           {EPC.intern((GlobalPrefix + "__orc_rt_finalize").str()),
             &FAs.Finalize},
-           {ES.intern((GlobalPrefix + "__orc_rt_deallocate").str()),
+           {EPC.intern((GlobalPrefix + "__orc_rt_deallocate").str()),
             &FAs.Deallocate}}))
     return std::move(Err);
 
-  return std::make_unique<EPCGenericJITLinkMemoryManager>(
-      ES.getExecutorProcessControl(), FAs);
+  return std::make_unique<EPCGenericJITLinkMemoryManager>(EPC, std::move(FAs));
 }
 
 Expected<std::unique_ptr<jitlink::JITLinkMemoryManager::Allocation>>

diff  --git a/llvm/lib/ExecutionEngine/Orc/EPCGenericMemoryAccess.cpp b/llvm/lib/ExecutionEngine/Orc/EPCGenericMemoryAccess.cpp
index 319909fed7837..e4ecd479e22d2 100644
--- a/llvm/lib/ExecutionEngine/Orc/EPCGenericMemoryAccess.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/EPCGenericMemoryAccess.cpp
@@ -14,30 +14,32 @@ namespace orc {
 
 /// Create from a ExecutorProcessControl instance.
 Expected<std::unique_ptr<EPCGenericMemoryAccess>>
-EPCGenericMemoryAccess::CreateUsingOrcRTFuncs(ExecutionSession &ES,
-                                              JITDylib &OrcRuntimeJD) {
+EPCGenericMemoryAccess::CreateUsingOrcRTFuncs(ExecutorProcessControl &EPC) {
+
+  auto H = EPC.loadDylib("");
+  if (!H)
+    return H.takeError();
 
   StringRef GlobalPrefix = "";
-  if (ES.getExecutorProcessControl().getTargetTriple().isOSBinFormatMachO())
+  if (EPC.getTargetTriple().isOSBinFormatMachO())
     GlobalPrefix = "_";
 
   FuncAddrs FAs;
   if (auto Err = lookupAndRecordAddrs(
-          ES, LookupKind::Static, makeJITDylibSearchOrder(&OrcRuntimeJD),
-          {{ES.intern((GlobalPrefix + "__orc_rt_write_uint8s_wrapper").str()),
+          EPC, *H,
+          {{EPC.intern((GlobalPrefix + "__orc_rt_write_uint8s_wrapper").str()),
             &FAs.WriteUInt8s},
-           {ES.intern((GlobalPrefix + "__orc_rt_write_uint16s_wrapper").str()),
+           {EPC.intern((GlobalPrefix + "__orc_rt_write_uint16s_wrapper").str()),
             &FAs.WriteUInt16s},
-           {ES.intern((GlobalPrefix + "__orc_rt_write_uint32s_wrapper").str()),
+           {EPC.intern((GlobalPrefix + "__orc_rt_write_uint32s_wrapper").str()),
             &FAs.WriteUInt32s},
-           {ES.intern((GlobalPrefix + "__orc_rt_write_uint64s_wrapper").str()),
+           {EPC.intern((GlobalPrefix + "__orc_rt_write_uint64s_wrapper").str()),
             &FAs.WriteUInt64s},
-           {ES.intern((GlobalPrefix + "__orc_rt_write_buffers_wrapper").str()),
+           {EPC.intern((GlobalPrefix + "__orc_rt_write_buffers_wrapper").str()),
             &FAs.WriteBuffers}}))
     return std::move(Err);
 
-  return std::make_unique<EPCGenericMemoryAccess>(
-      ES.getExecutorProcessControl(), FAs);
+  return std::make_unique<EPCGenericMemoryAccess>(EPC, std::move(FAs));
 }
 
 } // end namespace orc


        


More information about the llvm-commits mailing list