Skip to content

[ORC][COFF] Remove the ExecutionSession& argument to COFFPlatform factory & constructor #112419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions llvm/include/llvm/ExecutionEngine/Orc/COFFPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,16 @@ class COFFPlatform : public Platform {
/// Try to create a COFFPlatform instance, adding the ORC runtime to the
/// given JITDylib.
static Expected<std::unique_ptr<COFFPlatform>>
Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
JITDylib &PlatformJD,
Create(ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD,
std::unique_ptr<MemoryBuffer> OrcRuntimeArchiveBuffer,
LoadDynamicLibrary LoadDynLibrary, bool StaticVCRuntime = false,
const char *VCRuntimePath = nullptr,
std::optional<SymbolAliasMap> RuntimeAliases = std::nullopt);

static Expected<std::unique_ptr<COFFPlatform>>
Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
JITDylib &PlatformJD, const char *OrcRuntimePath,
LoadDynamicLibrary LoadDynLibrary, bool StaticVCRuntime = false,
const char *VCRuntimePath = nullptr,
Create(ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD,
const char *OrcRuntimePath, LoadDynamicLibrary LoadDynLibrary,
bool StaticVCRuntime = false, const char *VCRuntimePath = nullptr,
std::optional<SymbolAliasMap> RuntimeAliases = std::nullopt);

ExecutionSession &getExecutionSession() const { return ES; }
Expand Down Expand Up @@ -138,8 +136,7 @@ class COFFPlatform : public Platform {
static bool supportedTarget(const Triple &TT);

COFFPlatform(
ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
JITDylib &PlatformJD,
ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD,
std::unique_ptr<StaticLibraryDefinitionGenerator> OrcRuntimeGenerator,
std::unique_ptr<MemoryBuffer> OrcRuntimeArchiveBuffer,
std::unique_ptr<object::Archive> OrcRuntimeArchive,
Expand Down
27 changes: 15 additions & 12 deletions llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,14 @@ class COFFHeaderMaterializationUnit : public MaterializationUnit {
namespace llvm {
namespace orc {

Expected<std::unique_ptr<COFFPlatform>> COFFPlatform::Create(
ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
JITDylib &PlatformJD, std::unique_ptr<MemoryBuffer> OrcRuntimeArchiveBuffer,
LoadDynamicLibrary LoadDynLibrary, bool StaticVCRuntime,
const char *VCRuntimePath, std::optional<SymbolAliasMap> RuntimeAliases) {
Expected<std::unique_ptr<COFFPlatform>>
COFFPlatform::Create(ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD,
std::unique_ptr<MemoryBuffer> OrcRuntimeArchiveBuffer,
LoadDynamicLibrary LoadDynLibrary, bool StaticVCRuntime,
const char *VCRuntimePath,
std::optional<SymbolAliasMap> RuntimeAliases) {

auto &ES = ObjLinkingLayer.getExecutionSession();

// If the target is not supported then bail out immediately.
if (!supportedTarget(ES.getTargetTriple()))
Expand Down Expand Up @@ -214,7 +217,7 @@ Expected<std::unique_ptr<COFFPlatform>> COFFPlatform::Create(
// Create the instance.
Error Err = Error::success();
auto P = std::unique_ptr<COFFPlatform>(new COFFPlatform(
ES, ObjLinkingLayer, PlatformJD, std::move(*OrcRuntimeArchiveGenerator),
ObjLinkingLayer, PlatformJD, std::move(*OrcRuntimeArchiveGenerator),
std::move(OrcRuntimeArchiveBuffer), std::move(RuntimeArchive),
std::move(LoadDynLibrary), StaticVCRuntime, VCRuntimePath, Err));
if (Err)
Expand All @@ -223,8 +226,8 @@ Expected<std::unique_ptr<COFFPlatform>> COFFPlatform::Create(
}

Expected<std::unique_ptr<COFFPlatform>>
COFFPlatform::Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
JITDylib &PlatformJD, const char *OrcRuntimePath,
COFFPlatform::Create(ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD,
const char *OrcRuntimePath,
LoadDynamicLibrary LoadDynLibrary, bool StaticVCRuntime,
const char *VCRuntimePath,
std::optional<SymbolAliasMap> RuntimeAliases) {
Expand All @@ -233,7 +236,7 @@ COFFPlatform::Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
if (!ArchiveBuffer)
return createFileError(OrcRuntimePath, ArchiveBuffer.getError());

return Create(ES, ObjLinkingLayer, PlatformJD, std::move(*ArchiveBuffer),
return Create(ObjLinkingLayer, PlatformJD, std::move(*ArchiveBuffer),
std::move(LoadDynLibrary), StaticVCRuntime, VCRuntimePath,
std::move(RuntimeAliases));
}
Expand Down Expand Up @@ -382,14 +385,14 @@ bool COFFPlatform::supportedTarget(const Triple &TT) {
}

COFFPlatform::COFFPlatform(
ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
JITDylib &PlatformJD,
ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD,
std::unique_ptr<StaticLibraryDefinitionGenerator> OrcRuntimeGenerator,
std::unique_ptr<MemoryBuffer> OrcRuntimeArchiveBuffer,
std::unique_ptr<object::Archive> OrcRuntimeArchive,
LoadDynamicLibrary LoadDynLibrary, bool StaticVCRuntime,
const char *VCRuntimePath, Error &Err)
: ES(ES), ObjLinkingLayer(ObjLinkingLayer),
: ES(ObjLinkingLayer.getExecutionSession()),
ObjLinkingLayer(ObjLinkingLayer),
LoadDynLibrary(std::move(LoadDynLibrary)),
OrcRuntimeArchiveBuffer(std::move(OrcRuntimeArchiveBuffer)),
OrcRuntimeArchive(std::move(OrcRuntimeArchive)),
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ Expected<JITDylibSP> ExecutorNativePlatform::operator()(LLJIT &J) {
StaticVCRuntime = VCRuntime->second;
}
if (auto P = COFFPlatform::Create(
ES, *ObjLinkingLayer, PlatformJD, std::move(RuntimeArchiveBuffer),
*ObjLinkingLayer, PlatformJD, std::move(RuntimeArchiveBuffer),
LoadAndLinkDynLibrary(J), StaticVCRuntime, VCRuntimePath))
J.getExecutionSession().setPlatform(std::move(*P));
else
Expand Down
6 changes: 3 additions & 3 deletions llvm/tools/llvm-jitlink/llvm-jitlink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1057,9 +1057,9 @@ Session::Session(std::unique_ptr<ExecutorProcessControl> EPC, Error &Err)
return loadAndLinkDynamicLibrary(JD, DLLName);
};

if (auto P = COFFPlatform::Create(ES, ObjLayer, *PlatformJD,
OrcRuntime.c_str(),
std::move(LoadDynLibrary)))
if (auto P =
COFFPlatform::Create(ObjLayer, *PlatformJD, OrcRuntime.c_str(),
std::move(LoadDynLibrary)))
ES.setPlatform(std::move(*P));
else {
Err = P.takeError();
Expand Down
Loading