[llvm] d1c4d96 - [ORC][ORC_RT][COFF] Remove public bootstrap method.

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 9 23:27:52 PDT 2022


Author: sunho
Date: 2022-09-10T15:25:50+09:00
New Revision: d1c4d96126921e02a8f39b9a8ffa3c875158ffaf

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

LOG: [ORC][ORC_RT][COFF] Remove public bootstrap method.

Removes public bootstrap method that is not really necessary and not consistent with other platform API.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D132780

Added: 
    

Modified: 
    llvm/include/llvm/ExecutionEngine/Orc/COFFPlatform.h
    llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
    llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp
    llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
    llvm/tools/lli/lli.cpp
    llvm/tools/llvm-jitlink/llvm-jitlink.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/COFFPlatform.h b/llvm/include/llvm/ExecutionEngine/Orc/COFFPlatform.h
index 4b954cd0c1302..09b08f0ad9a0f 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/COFFPlatform.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/COFFPlatform.h
@@ -46,8 +46,6 @@ class COFFPlatform : public Platform {
          const char *VCRuntimePath = nullptr,
          Optional<SymbolAliasMap> RuntimeAliases = None);
 
-  Error bootstrap(JITDylib &PlatformJD);
-
   ExecutionSession &getExecutionSession() const { return ES; }
   ObjectLinkingLayer &getObjectLinkingLayer() const { return ObjLinkingLayer; }
 

diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h b/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
index d67a7f2bfeb20..dc6854756381b 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h
@@ -447,6 +447,9 @@ class LLLazyJITBuilder
       public LLLazyJITBuilderSetters<LLLazyJIT, LLLazyJITBuilder,
                                      LLLazyJITBuilderState> {};
 
+/// Configure the LLJIT instance to use orc runtime support. 
+Error setUpOrcPlatform(LLJIT& J);
+
 /// Configure the LLJIT instance to scrape modules for llvm.global_ctors and
 /// llvm.global_dtors variables and (if present) build initialization and
 /// deinitialization functions. Platform specific initialization configurations

diff  --git a/llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp b/llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp
index 4730f7d4fab60..30a51c107cf7b 100644
--- a/llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp
@@ -413,33 +413,35 @@ COFFPlatform::COFFPlatform(ExecutionSession &ES,
     Err = std::move(E2);
     return;
   }
-}
 
-Error COFFPlatform::bootstrap(JITDylib &PlatformJD) {
-  for (auto &Lib : DylibsToPreload)
-    if (auto Err = LoadDynLibrary(PlatformJD, Lib))
-      return Err;
+  for (auto& Lib : DylibsToPreload)
+      if (auto E2 = LoadDynLibrary(PlatformJD, Lib)) {
+          Err = std::move(E2);
+          return;
+      }
 
   if (StaticVCRuntime)
-    if (auto Err = VCRuntimeBootstrap->initializeStaticVCRuntime(PlatformJD))
-      return Err;
+      if (auto E2 = VCRuntimeBootstrap->initializeStaticVCRuntime(PlatformJD)) {
+          Err = std::move(E2);
+          return;
+      }
 
   // Associate wrapper function tags with JIT-side function implementations.
-  if (auto Err = associateRuntimeSupportFunctions(PlatformJD)) {
-    return Err;
+  if (auto E2 = associateRuntimeSupportFunctions(PlatformJD)) {
+      Err = std::move(E2);
+      return;
   }
 
   // Lookup addresses of runtime functions callable by the platform,
   // call the platform bootstrap function to initialize the platform-state
   // object in the executor.
-  if (auto Err = bootstrapCOFFRuntime(PlatformJD)) {
-    return Err;
+  if (auto E2 = bootstrapCOFFRuntime(PlatformJD)) {
+      Err = std::move(E2);
+      return;
   }
 
   Bootstrapping.store(false);
   JDBootstrapStates.clear();
-
-  return Error::success();
 }
 
 Expected<COFFPlatform::JITDylibDepMap>

diff  --git a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
index 17ad0a2170f91..18f287a91d589 100644
--- a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
@@ -81,6 +81,53 @@ Function *addHelperAndWrapper(Module &M, StringRef WrapperName,
   return WrapperFn;
 }
 
+class ORCPlatformSupport : public LLJIT::PlatformSupport {
+public:
+  ORCPlatformSupport(orc::LLJIT &J) : J(J) {}
+
+  Error initialize(orc::JITDylib &JD) override {
+    using llvm::orc::shared::SPSExecutorAddr;
+    using llvm::orc::shared::SPSString;
+    using SPSDLOpenSig = SPSExecutorAddr(SPSString, int32_t);
+    enum dlopen_mode : int32_t {
+      ORC_RT_RTLD_LAZY = 0x1,
+      ORC_RT_RTLD_NOW = 0x2,
+      ORC_RT_RTLD_LOCAL = 0x4,
+      ORC_RT_RTLD_GLOBAL = 0x8
+    };
+
+    if (auto WrapperAddr = J.lookup("__orc_rt_jit_dlopen_wrapper")) {
+      return J.getExecutionSession().callSPSWrapper<SPSDLOpenSig>(
+          *WrapperAddr, DSOHandles[&JD], JD.getName(),
+          int32_t(ORC_RT_RTLD_LAZY));
+    } else
+      return WrapperAddr.takeError();
+  }
+
+  Error deinitialize(orc::JITDylib &JD) override {
+    using llvm::orc::shared::SPSExecutorAddr;
+    using SPSDLCloseSig = int32_t(SPSExecutorAddr);
+
+    if (auto WrapperAddr = J.lookup("__orc_rt_jit_dlclose_wrapper")) {
+      int32_t result;
+      auto E = J.getExecutionSession().callSPSWrapper<SPSDLCloseSig>(
+          *WrapperAddr, result, DSOHandles[&JD]);
+      if (E)
+        return E;
+      else if (result)
+        return make_error<StringError>("dlclose failed",
+                                       inconvertibleErrorCode());
+      DSOHandles.erase(&JD);
+    } else
+      return WrapperAddr.takeError();
+    return Error::success();
+  }
+
+private:
+  orc::LLJIT &J;
+  DenseMap<orc::JITDylib *, orc::ExecutorAddr> DSOHandles;
+};
+
 class GenericLLVMIRPlatformSupport;
 
 /// orc::Platform component of Generic LLVM IR Platform support.
@@ -880,6 +927,13 @@ Error LLJIT::applyDataLayout(Module &M) {
   return Error::success();
 }
 
+Error setUpOrcPlatform(LLJIT& J) {
+    LLVM_DEBUG(
+        { dbgs() << "Setting up orc platform support for LLJIT\n"; });
+    J.setPlatformSupport(std::make_unique<ORCPlatformSupport>(J));
+    return Error::success();
+}
+
 void setUpGenericLLVMIRPlatform(LLJIT &J) {
   LLVM_DEBUG(
       { dbgs() << "Setting up GenericLLVMIRPlatform support for LLJIT\n"; });

diff  --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp
index 3fd2a618bf1af..4b1359f9e7120 100644
--- a/llvm/tools/lli/lli.cpp
+++ b/llvm/tools/lli/lli.cpp
@@ -373,53 +373,6 @@ class LLIObjectCache : public ObjectCache {
   }
 };
 
-class ORCPlatformSupport : public orc::LLJIT::PlatformSupport {
-public:
-  ORCPlatformSupport(orc::LLJIT &J) : J(J) {}
-
-  Error initialize(orc::JITDylib &JD) override {
-    using llvm::orc::shared::SPSExecutorAddr;
-    using llvm::orc::shared::SPSString;
-    using SPSDLOpenSig = SPSExecutorAddr(SPSString, int32_t);
-    enum dlopen_mode : int32_t {
-      ORC_RT_RTLD_LAZY = 0x1,
-      ORC_RT_RTLD_NOW = 0x2,
-      ORC_RT_RTLD_LOCAL = 0x4,
-      ORC_RT_RTLD_GLOBAL = 0x8
-    };
-
-    if (auto WrapperAddr = J.lookup("__orc_rt_jit_dlopen_wrapper")) {
-      return J.getExecutionSession().callSPSWrapper<SPSDLOpenSig>(
-          *WrapperAddr, DSOHandles[&JD], JD.getName(),
-          int32_t(ORC_RT_RTLD_LAZY));
-    } else
-      return WrapperAddr.takeError();
-  }
-
-  Error deinitialize(orc::JITDylib &JD) override {
-    using llvm::orc::shared::SPSExecutorAddr;
-    using SPSDLCloseSig = int32_t(SPSExecutorAddr);
-
-    if (auto WrapperAddr = J.lookup("__orc_rt_jit_dlclose_wrapper")) {
-      int32_t result;
-      auto E = J.getExecutionSession().callSPSWrapper<SPSDLCloseSig>(
-          *WrapperAddr, result, DSOHandles[&JD]);
-      if (E)
-        return E;
-      else if (result)
-        return make_error<StringError>("dlclose failed",
-                                       inconvertibleErrorCode());
-      DSOHandles.erase(&JD);
-    } else
-      return WrapperAddr.takeError();
-    return Error::success();
-  }
-
-private:
-  orc::LLJIT &J;
-  DenseMap<orc::JITDylib *, orc::ExecutorAddr> DSOHandles;
-};
-
 // On Mingw and Cygwin, an external symbol named '__main' is called from the
 // generated 'main' function to allow static initialization.  To avoid linking
 // problems with remote targets (because lli's remote target support does not
@@ -969,10 +922,7 @@ int runOrcJIT(const char *ProgName) {
   }
   switch (P) {
   case LLJITPlatform::ORC:
-    Builder.setPlatformSetUp([](llvm::orc::LLJIT &J) -> llvm::Error {
-      J.setPlatformSupport(std::make_unique<ORCPlatformSupport>(J));
-      return Error::success();
-    });
+    Builder.setPlatformSetUp(orc::setUpOrcPlatform);
     break;
   case LLJITPlatform::GenericIR:
     // Nothing to do: LLJITBuilder will use this by default.

diff  --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
index 5efbd6538388d..13503bbc1b3cc 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -1239,16 +1239,9 @@ Session::Session(std::unique_ptr<ExecutorProcessControl> EPC, Error &Err)
     };
 
     if (auto P = COFFPlatform::Create(ES, ObjLayer, *MainJD, OrcRuntime.c_str(),
-                                      std::move(LoadDynLibrary))) {
-      // Set platform early to register jitdylib of dynamic libraries.
-      auto &CP = **P;
+                                      std::move(LoadDynLibrary))) 
       ES.setPlatform(std::move(*P));
-
-      if (auto E2 = CP.bootstrap(*MainJD)) {
-        Err = std::move(E2);
-        return;
-      }
-    } else {
+     else {
       Err = P.takeError();
       return;
     }


        


More information about the llvm-commits mailing list