[ORC] Add an ExecutionSession::getTargetTriple convenience function.

Forwards to ExecutorProcessControl::getTargetTriple, and saves clients the
trouble of spelling 'getExecutorProcessControl()' everywhere.
This commit is contained in:
Lang Hames
2023-02-21 19:09:34 -08:00
parent cf550e6184
commit 0df66569e5
6 changed files with 31 additions and 37 deletions

View File

@@ -1415,6 +1415,9 @@ public:
/// 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();

View File

@@ -55,8 +55,7 @@ public:
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);

View File

@@ -41,8 +41,7 @@ public:
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();

View File

@@ -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();

View File

@@ -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();

View File

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