[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
This commit is contained in:
sunho 2022-09-10 15:25:50 +09:00
parent 73c4033987
commit d1c4d96126
6 changed files with 75 additions and 75 deletions

View File

@ -46,8 +46,6 @@ public:
const char *VCRuntimePath = nullptr,
Optional<SymbolAliasMap> RuntimeAliases = None);
Error bootstrap(JITDylib &PlatformJD);
ExecutionSession &getExecutionSession() const { return ES; }
ObjectLinkingLayer &getObjectLinkingLayer() const { return ObjLinkingLayer; }

View File

@ -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

View File

@ -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>

View File

@ -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"; });

View File

@ -373,53 +373,6 @@ private:
}
};
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.

View File

@ -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;
}