Skip to content

Commit cc20dd2

Browse files
committed
[ORC][ELF] Remove the ExecutionSession& argument to ELFNixPlatform::Create.
We can get a reference to the ExecutionSession from the ObjectLinkingLayer argument, so there's no need to pass it in separately.
1 parent 45cc743 commit cc20dd2

File tree

4 files changed

+23
-22
lines changed

4 files changed

+23
-22
lines changed

llvm/include/llvm/ExecutionEngine/Orc/ELFNixPlatform.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ class ELFNixPlatform : public Platform {
106106
/// RuntimeAliases function, in which case the client is responsible for
107107
/// setting up all aliases (including the required ones).
108108
static Expected<std::unique_ptr<ELFNixPlatform>>
109-
Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
110-
JITDylib &PlatformJD, std::unique_ptr<DefinitionGenerator> OrcRuntime,
109+
Create(ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD,
110+
std::unique_ptr<DefinitionGenerator> OrcRuntime,
111111
std::optional<SymbolAliasMap> RuntimeAliases = std::nullopt);
112112

113113
/// Construct using a path to the ORC runtime.
114114
static Expected<std::unique_ptr<ELFNixPlatform>>
115-
Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
116-
JITDylib &PlatformJD, const char *OrcRuntimePath,
115+
Create(ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD,
116+
const char *OrcRuntimePath,
117117
std::optional<SymbolAliasMap> RuntimeAliases = std::nullopt);
118118

119119
ExecutionSession &getExecutionSession() const { return ES; }
@@ -211,8 +211,7 @@ class ELFNixPlatform : public Platform {
211211

212212
static bool supportedTarget(const Triple &TT);
213213

214-
ELFNixPlatform(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
215-
JITDylib &PlatformJD,
214+
ELFNixPlatform(ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD,
216215
std::unique_ptr<DefinitionGenerator> OrcRuntimeGenerator,
217216
Error &Err);
218217

@@ -308,4 +307,4 @@ using SPSELFNixJITDylibDepInfoMap =
308307
} // end namespace orc
309308
} // end namespace llvm
310309

311-
#endif // LLVM_EXECUTIONENGINE_ORC_ELFNIXPLATFORM_H
310+
#endif // LLVM_EXECUTIONENGINE_ORC_ELFNIXPLATFORM_H

llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,13 @@ class DSOHandleMaterializationUnit : public MaterializationUnit {
233233
namespace llvm {
234234
namespace orc {
235235

236-
Expected<std::unique_ptr<ELFNixPlatform>> ELFNixPlatform::Create(
237-
ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
238-
JITDylib &PlatformJD, std::unique_ptr<DefinitionGenerator> OrcRuntime,
239-
std::optional<SymbolAliasMap> RuntimeAliases) {
236+
Expected<std::unique_ptr<ELFNixPlatform>>
237+
ELFNixPlatform::Create(ObjectLinkingLayer &ObjLinkingLayer,
238+
JITDylib &PlatformJD,
239+
std::unique_ptr<DefinitionGenerator> OrcRuntime,
240+
std::optional<SymbolAliasMap> RuntimeAliases) {
241+
242+
auto &ES = ObjLinkingLayer.getExecutionSession();
240243

241244
// If the target is not supported then bail out immediately.
242245
if (!supportedTarget(ES.getTargetTriple()))
@@ -271,15 +274,14 @@ Expected<std::unique_ptr<ELFNixPlatform>> ELFNixPlatform::Create(
271274
// Create the instance.
272275
Error Err = Error::success();
273276
auto P = std::unique_ptr<ELFNixPlatform>(new ELFNixPlatform(
274-
ES, ObjLinkingLayer, PlatformJD, std::move(OrcRuntime), Err));
277+
ObjLinkingLayer, PlatformJD, std::move(OrcRuntime), Err));
275278
if (Err)
276279
return std::move(Err);
277280
return std::move(P);
278281
}
279282

280283
Expected<std::unique_ptr<ELFNixPlatform>>
281-
ELFNixPlatform::Create(ExecutionSession &ES,
282-
ObjectLinkingLayer &ObjLinkingLayer,
284+
ELFNixPlatform::Create(ObjectLinkingLayer &ObjLinkingLayer,
283285
JITDylib &PlatformJD, const char *OrcRuntimePath,
284286
std::optional<SymbolAliasMap> RuntimeAliases) {
285287

@@ -289,7 +291,7 @@ ELFNixPlatform::Create(ExecutionSession &ES,
289291
if (!OrcRuntimeArchiveGenerator)
290292
return OrcRuntimeArchiveGenerator.takeError();
291293

292-
return Create(ES, ObjLinkingLayer, PlatformJD,
294+
return Create(ObjLinkingLayer, PlatformJD,
293295
std::move(*OrcRuntimeArchiveGenerator),
294296
std::move(RuntimeAliases));
295297
}
@@ -392,10 +394,10 @@ bool ELFNixPlatform::supportedTarget(const Triple &TT) {
392394
}
393395

394396
ELFNixPlatform::ELFNixPlatform(
395-
ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
396-
JITDylib &PlatformJD,
397+
ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD,
397398
std::unique_ptr<DefinitionGenerator> OrcRuntimeGenerator, Error &Err)
398-
: ES(ES), PlatformJD(PlatformJD), ObjLinkingLayer(ObjLinkingLayer),
399+
: ES(ObjLinkingLayer.getExecutionSession()), PlatformJD(PlatformJD),
400+
ObjLinkingLayer(ObjLinkingLayer),
399401
DSOHandleSymbol(ES.intern("__dso_handle")) {
400402
ErrorAsOutParameter _(&Err);
401403
ObjLinkingLayer.addPlugin(std::make_unique<ELFNixPlatformPlugin>(*this));

llvm/lib/ExecutionEngine/Orc/LLJIT.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,8 +1185,8 @@ Expected<JITDylibSP> ExecutorNativePlatform::operator()(LLJIT &J) {
11851185
if (!G)
11861186
return G.takeError();
11871187

1188-
if (auto P = ELFNixPlatform::Create(ES, *ObjLinkingLayer, PlatformJD,
1189-
std::move(*G)))
1188+
if (auto P =
1189+
ELFNixPlatform::Create(*ObjLinkingLayer, PlatformJD, std::move(*G)))
11901190
J.getExecutionSession().setPlatform(std::move(*P));
11911191
else
11921192
return P.takeError();

llvm/tools/llvm-jitlink/llvm-jitlink.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,8 +1041,8 @@ Session::Session(std::unique_ptr<ExecutorProcessControl> EPC, Error &Err)
10411041
return;
10421042
}
10431043
} else if (TT.isOSBinFormatELF()) {
1044-
if (auto P = ELFNixPlatform::Create(ES, ObjLayer, *PlatformJD,
1045-
OrcRuntime.c_str()))
1044+
if (auto P =
1045+
ELFNixPlatform::Create(ObjLayer, *PlatformJD, OrcRuntime.c_str()))
10461046
ES.setPlatform(std::move(*P));
10471047
else {
10481048
Err = P.takeError();

0 commit comments

Comments
 (0)