[llvm] 0df6656 - [ORC] Add an ExecutionSession::getTargetTriple convenience function.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 21 20:16:56 PST 2023
Author: Lang Hames
Date: 2023-02-21T19:57:36-08:00
New Revision: 0df66569e529be4bcea06f314c02c6af74989704
URL: https://github.com/llvm/llvm-project/commit/0df66569e529be4bcea06f314c02c6af74989704
DIFF: https://github.com/llvm/llvm-project/commit/0df66569e529be4bcea06f314c02c6af74989704.diff
LOG: [ORC] Add an ExecutionSession::getTargetTriple convenience function.
Forwards to ExecutorProcessControl::getTargetTriple, and saves clients the
trouble of spelling 'getExecutorProcessControl()' everywhere.
Added:
Modified:
llvm/include/llvm/ExecutionEngine/Orc/Core.h
llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp
llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp
llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
llvm/tools/llvm-jitlink/llvm-jitlink.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Core.h b/llvm/include/llvm/ExecutionEngine/Orc/Core.h
index daa0fa2755912..adab75d3aaf15 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/Core.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/Core.h
@@ -1415,6 +1415,9 @@ class ExecutionSession {
/// ExecutionSession.
ExecutorProcessControl &getExecutorProcessControl() { return *EPC; }
+ /// Return the triple for the executor.
+ const Triple &getTargetTriple() const { return EPC->getTargetTriple(); }
+
/// Get the SymbolStringPool for this instance.
std::shared_ptr<SymbolStringPool> getSymbolStringPool() {
return EPC->getSymbolStringPool();
diff --git a/llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp b/llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp
index d0b8762df5151..a3cef492ad018 100644
--- a/llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/COFFPlatform.cpp
@@ -55,8 +55,7 @@ class COFFHeaderMaterializationUnit : public MaterializationUnit {
void materialize(std::unique_ptr<MaterializationResponsibility> R) override {
unsigned PointerSize;
support::endianness Endianness;
- const auto &TT =
- CP.getExecutionSession().getExecutorProcessControl().getTargetTriple();
+ const auto &TT = CP.getExecutionSession().getTargetTriple();
switch (TT.getArch()) {
case Triple::x86_64:
@@ -166,14 +165,15 @@ COFFPlatform::Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
LoadDynamicLibrary LoadDynLibrary, bool StaticVCRuntime,
const char *VCRuntimePath,
std::optional<SymbolAliasMap> RuntimeAliases) {
- auto &EPC = ES.getExecutorProcessControl();
// If the target is not supported then bail out immediately.
- if (!supportedTarget(EPC.getTargetTriple()))
+ if (!supportedTarget(ES.getTargetTriple()))
return make_error<StringError>("Unsupported COFFPlatform triple: " +
- EPC.getTargetTriple().str(),
+ ES.getTargetTriple().str(),
inconvertibleErrorCode());
+ auto &EPC = ES.getExecutorProcessControl();
+
// Create default aliases if the caller didn't supply any.
if (!RuntimeAliases)
RuntimeAliases = standardPlatformAliases(ES);
diff --git a/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp b/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp
index ec31fa4ca7ca5..cbf078858c133 100644
--- a/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/ELFNixPlatform.cpp
@@ -41,8 +41,7 @@ class DSOHandleMaterializationUnit : public MaterializationUnit {
unsigned PointerSize;
support::endianness Endianness;
jitlink::Edge::Kind EdgeKind;
- const auto &TT =
- ENP.getExecutionSession().getExecutorProcessControl().getTargetTriple();
+ const auto &TT = ENP.getExecutionSession().getTargetTriple();
switch (TT.getArch()) {
case Triple::x86_64:
@@ -107,14 +106,14 @@ Expected<std::unique_ptr<ELFNixPlatform>> ELFNixPlatform::Create(
JITDylib &PlatformJD, std::unique_ptr<DefinitionGenerator> OrcRuntime,
std::optional<SymbolAliasMap> RuntimeAliases) {
- auto &EPC = ES.getExecutorProcessControl();
-
// If the target is not supported then bail out immediately.
- if (!supportedTarget(EPC.getTargetTriple()))
+ if (!supportedTarget(ES.getTargetTriple()))
return make_error<StringError>("Unsupported ELFNixPlatform triple: " +
- EPC.getTargetTriple().str(),
+ ES.getTargetTriple().str(),
inconvertibleErrorCode());
+ auto &EPC = ES.getExecutorProcessControl();
+
// Create default aliases if the caller didn't supply any.
if (!RuntimeAliases) {
auto StandardRuntimeAliases = standardPlatformAliases(ES, PlatformJD);
@@ -154,8 +153,7 @@ ELFNixPlatform::Create(ExecutionSession &ES,
// Create a generator for the ORC runtime archive.
auto OrcRuntimeArchiveGenerator = StaticLibraryDefinitionGenerator::Load(
- ObjLinkingLayer, OrcRuntimePath,
- ES.getExecutorProcessControl().getTargetTriple());
+ ObjLinkingLayer, OrcRuntimePath, ES.getTargetTriple());
if (!OrcRuntimeArchiveGenerator)
return OrcRuntimeArchiveGenerator.takeError();
diff --git a/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp b/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
index b21c81abbfec1..b6fb769cd128f 100644
--- a/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
@@ -571,7 +571,7 @@ DLLImportDefinitionGenerator::getTargetEndianness(const Triple &TT) {
Expected<std::unique_ptr<jitlink::LinkGraph>>
DLLImportDefinitionGenerator::createStubsGraph(const SymbolMap &Resolved) {
- Triple TT = ES.getExecutorProcessControl().getTargetTriple();
+ Triple TT = ES.getTargetTriple();
auto PointerSize = getTargetEndianness(TT);
if (!PointerSize)
return PointerSize.takeError();
diff --git a/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp b/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
index b23f3cd9bf0dd..f21cb7103c333 100644
--- a/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp
@@ -63,8 +63,7 @@ std::unique_ptr<jitlink::LinkGraph> createPlatformGraph(MachOPlatform &MOP,
std::string Name) {
unsigned PointerSize;
support::endianness Endianness;
- const auto &TT =
- MOP.getExecutionSession().getExecutorProcessControl().getTargetTriple();
+ const auto &TT = MOP.getExecutionSession().getTargetTriple();
switch (TT.getArch()) {
case Triple::aarch64:
@@ -258,14 +257,14 @@ MachOPlatform::Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
std::unique_ptr<DefinitionGenerator> OrcRuntime,
std::optional<SymbolAliasMap> RuntimeAliases) {
- auto &EPC = ES.getExecutorProcessControl();
-
// If the target is not supported then bail out immediately.
- if (!supportedTarget(EPC.getTargetTriple()))
+ if (!supportedTarget(ES.getTargetTriple()))
return make_error<StringError>("Unsupported MachOPlatform triple: " +
- EPC.getTargetTriple().str(),
+ ES.getTargetTriple().str(),
inconvertibleErrorCode());
+ auto &EPC = ES.getExecutorProcessControl();
+
// Create default aliases if the caller didn't supply any.
if (!RuntimeAliases)
RuntimeAliases = standardPlatformAliases(ES);
@@ -300,8 +299,7 @@ MachOPlatform::Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
// Create a generator for the ORC runtime archive.
auto OrcRuntimeArchiveGenerator = StaticLibraryDefinitionGenerator::Load(
- ObjLinkingLayer, OrcRuntimePath,
- ES.getExecutorProcessControl().getTargetTriple());
+ ObjLinkingLayer, OrcRuntimePath, ES.getTargetTriple());
if (!OrcRuntimeArchiveGenerator)
return OrcRuntimeArchiveGenerator.takeError();
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
index d98cd77b30ba9..ed5d15bd375cf 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -982,7 +982,7 @@ Session::Session(std::unique_ptr<ExecutorProcessControl> EPC, Error &Err)
ExitOnErr(loadDylibs(*this));
- auto &TT = ES.getExecutorProcessControl().getTargetTriple();
+ auto &TT = ES.getTargetTriple();
if (DebuggerSupport && TT.isOSBinFormatMachO())
ObjLayer.addPlugin(ExitOnErr(
@@ -1072,14 +1072,13 @@ void Session::modifyPassConfig(const Triple &TT,
PassConfiguration &PassConfig) {
if (!CheckFiles.empty())
PassConfig.PostFixupPasses.push_back([this](LinkGraph &G) {
- auto &EPC = ES.getExecutorProcessControl();
- if (EPC.getTargetTriple().getObjectFormat() == Triple::ELF)
+ if (ES.getTargetTriple().getObjectFormat() == Triple::ELF)
return registerELFGraphInfo(*this, G);
- if (EPC.getTargetTriple().getObjectFormat() == Triple::MachO)
+ if (ES.getTargetTriple().getObjectFormat() == Triple::MachO)
return registerMachOGraphInfo(*this, G);
- if (EPC.getTargetTriple().getObjectFormat() == Triple::COFF)
+ if (ES.getTargetTriple().getObjectFormat() == Triple::COFF)
return registerCOFFGraphInfo(*this, G);
return make_error<StringError>("Unsupported object format for GOT/stub "
@@ -1497,7 +1496,7 @@ getObjectFileInterfaceHidden(ExecutionSession &ES, MemoryBufferRef ObjBuffer) {
static SmallVector<StringRef, 5> getSearchPathsFromEnvVar(Session &S) {
// FIXME: Handle EPC environment.
SmallVector<StringRef, 5> PathVec;
- auto TT = S.ES.getExecutorProcessControl().getTargetTriple();
+ auto TT = S.ES.getTargetTriple();
if (TT.isOSBinFormatCOFF())
StringRef(getenv("PATH")).split(PathVec, ";");
else if (TT.isOSBinFormatELF())
@@ -1632,7 +1631,7 @@ static Error addLibraries(Session &S,
break;
}
auto G = StaticLibraryDefinitionGenerator::Load(
- S.ObjLayer, Path, S.ES.getExecutorProcessControl().getTargetTriple(),
+ S.ObjLayer, Path, S.ES.getTargetTriple(),
std::move(GetObjFileInterface));
if (!G)
return G.takeError();
@@ -1868,14 +1867,12 @@ static TargetInfo getTargetInfo(const Triple &TT) {
}
static Error runChecks(Session &S) {
- const auto &TT = S.ES.getExecutorProcessControl().getTargetTriple();
-
if (CheckFiles.empty())
return Error::success();
LLVM_DEBUG(dbgs() << "Running checks...\n");
- auto TI = getTargetInfo(TT);
+ auto TI = getTargetInfo(S.ES.getTargetTriple());
auto IsSymbolValid = [&S](StringRef Symbol) {
return S.isSymbolRegistered(Symbol);
@@ -1899,7 +1896,7 @@ static Error runChecks(Session &S) {
RuntimeDyldChecker Checker(
IsSymbolValid, GetSymbolInfo, GetSectionInfo, GetStubInfo, GetGOTInfo,
- TT.isLittleEndian() ? support::little : support::big,
+ S.ES.getTargetTriple().isLittleEndian() ? support::little : support::big,
TI.Disassembler.get(), TI.InstPrinter.get(), dbgs());
std::string CheckLineStart = "# " + CheckName + ":";
@@ -1942,8 +1939,7 @@ static Expected<JITEvaluatedSymbol> getMainEntryPoint(Session &S) {
static Expected<JITEvaluatedSymbol> getOrcRuntimeEntryPoint(Session &S) {
std::string RuntimeEntryPoint = "__orc_rt_run_program_wrapper";
- const auto &TT = S.ES.getExecutorProcessControl().getTargetTriple();
- if (TT.getObjectFormat() == Triple::MachO)
+ if (S.ES.getTargetTriple().getObjectFormat() == Triple::MachO)
RuntimeEntryPoint = '_' + RuntimeEntryPoint;
return S.ES.lookup(S.JDSearchOrder, S.ES.intern(RuntimeEntryPoint));
}
@@ -1980,8 +1976,7 @@ static Expected<JITEvaluatedSymbol> getEntryPoint(Session &S) {
static Expected<int> runWithRuntime(Session &S, ExecutorAddr EntryPointAddr) {
StringRef DemangledEntryPoint = EntryPointName;
- const auto &TT = S.ES.getExecutorProcessControl().getTargetTriple();
- if (TT.getObjectFormat() == Triple::MachO &&
+ if (S.ES.getTargetTriple().getObjectFormat() == Triple::MachO &&
DemangledEntryPoint.front() == '_')
DemangledEntryPoint = DemangledEntryPoint.drop_front();
using llvm::orc::shared::SPSString;
More information about the llvm-commits
mailing list