[compiler-rt] 0820fba - [ORC-RT] Rename ExecutorAddress to ExecutorAddr.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 23 21:42:45 PDT 2021
Author: Lang Hames
Date: 2021-09-23T21:42:23-07:00
New Revision: 0820fbab99a1f1986a8c6e0a8e5cb4542ec52515
URL: https://github.com/llvm/llvm-project/commit/0820fbab99a1f1986a8c6e0a8e5cb4542ec52515
DIFF: https://github.com/llvm/llvm-project/commit/0820fbab99a1f1986a8c6e0a8e5cb4542ec52515.diff
LOG: [ORC-RT] Rename ExecutorAddress to ExecutorAddr.
This is an ORC-runtime counterpart to LLVM commit ef391df2b63, and the
motivation is the same: to move to a shorter name to improve the ergonomics of
this type before it's more widely adopted.
Added:
Modified:
compiler-rt/lib/orc/elfnix_platform.cpp
compiler-rt/lib/orc/elfnix_platform.h
compiler-rt/lib/orc/executor_address.h
compiler-rt/lib/orc/macho_platform.cpp
compiler-rt/lib/orc/macho_platform.h
compiler-rt/lib/orc/simple_packed_serialization.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/orc/elfnix_platform.cpp b/compiler-rt/lib/orc/elfnix_platform.cpp
index 6d44aa058e6a8..73183b3df922d 100644
--- a/compiler-rt/lib/orc/elfnix_platform.cpp
+++ b/compiler-rt/lib/orc/elfnix_platform.cpp
@@ -37,7 +37,7 @@ extern "C" void __deregister_frame(const void *);
namespace {
Error validatePointerSectionExtent(const char *SectionName,
- const ExecutorAddressRange &SE) {
+ const ExecutorAddrRange &SE) {
if (SE.size().getValue() % sizeof(uintptr_t)) {
std::ostringstream ErrMsg;
ErrMsg << std::hex << "Size of " << SectionName << " 0x"
@@ -48,7 +48,7 @@ Error validatePointerSectionExtent(const char *SectionName,
return Error::success();
}
-Error runInitArray(const std::vector<ExecutorAddressRange> &InitArraySections,
+Error runInitArray(const std::vector<ExecutorAddrRange> &InitArraySections,
const ELFNixJITDylibInitializers &MOJDIs) {
for (const auto &ModInits : InitArraySections) {
@@ -120,8 +120,8 @@ class ELFNixPlatformRuntimeState {
Error registerThreadDataSection(span<const char> ThreadDataSection);
- Expected<ExecutorAddress> lookupSymbolInJITDylib(void *DSOHandle,
- string_view Symbol);
+ Expected<ExecutorAddr> lookupSymbolInJITDylib(void *DSOHandle,
+ string_view Symbol);
Expected<ELFNixJITDylibInitializerSequence>
getJITDylibInitializersByName(string_view Path);
@@ -131,7 +131,7 @@ class ELFNixPlatformRuntimeState {
static ELFNixPlatformRuntimeState *MOPS;
using InitSectionHandler =
- Error (*)(const std::vector<ExecutorAddressRange> &Sections,
+ Error (*)(const std::vector<ExecutorAddrRange> &Sections,
const ELFNixJITDylibInitializers &MOJDIs);
const std::vector<std::pair<const char *, InitSectionHandler>> InitSections =
{{".init_array", runInitArray}};
@@ -318,14 +318,15 @@ Error ELFNixPlatformRuntimeState::registerThreadDataSection(
return Error::success();
}
-Expected<ExecutorAddress>
+Expected<ExecutorAddr>
ELFNixPlatformRuntimeState::lookupSymbolInJITDylib(void *DSOHandle,
string_view Sym) {
- Expected<ExecutorAddress> Result((ExecutorAddress()));
- if (auto Err = WrapperFunction<SPSExpected<SPSExecutorAddress>(
- SPSExecutorAddress,
- SPSString)>::call(&__orc_rt_elfnix_symbol_lookup_tag, Result,
- ExecutorAddress::fromPtr(DSOHandle), Sym))
+ Expected<ExecutorAddr> Result((ExecutorAddr()));
+ if (auto Err = WrapperFunction<SPSExpected<SPSExecutorAddr>(
+ SPSExecutorAddr, SPSString)>::call(&__orc_rt_elfnix_symbol_lookup_tag,
+ Result,
+ ExecutorAddr::fromPtr(DSOHandle),
+ Sym))
return std::move(Err);
return Result;
}
diff --git a/compiler-rt/lib/orc/elfnix_platform.h b/compiler-rt/lib/orc/elfnix_platform.h
index 288ed615ef923..5afeac55419b1 100644
--- a/compiler-rt/lib/orc/elfnix_platform.h
+++ b/compiler-rt/lib/orc/elfnix_platform.h
@@ -32,19 +32,19 @@ namespace __orc_rt {
namespace elfnix {
struct ELFNixPerObjectSectionsToRegister {
- ExecutorAddressRange EHFrameSection;
- ExecutorAddressRange ThreadDataSection;
+ ExecutorAddrRange EHFrameSection;
+ ExecutorAddrRange ThreadDataSection;
};
struct ELFNixJITDylibInitializers {
- using SectionList = std::vector<ExecutorAddressRange>;
+ using SectionList = std::vector<ExecutorAddrRange>;
ELFNixJITDylibInitializers() = default;
- ELFNixJITDylibInitializers(std::string Name, ExecutorAddress DSOHandleAddress)
+ ELFNixJITDylibInitializers(std::string Name, ExecutorAddr DSOHandleAddress)
: Name(std::move(Name)), DSOHandleAddress(std::move(DSOHandleAddress)) {}
std::string Name;
- ExecutorAddress DSOHandleAddress;
+ ExecutorAddr DSOHandleAddress;
std::unordered_map<std::string, SectionList> InitSections;
};
@@ -67,7 +67,7 @@ enum dlopen_mode : int {
} // end namespace elfnix
using SPSELFNixPerObjectSectionsToRegister =
- SPSTuple<SPSExecutorAddressRange, SPSExecutorAddressRange>;
+ SPSTuple<SPSExecutorAddrRange, SPSExecutorAddrRange>;
template <>
class SPSSerializationTraits<SPSELFNixPerObjectSectionsToRegister,
@@ -93,12 +93,11 @@ class SPSSerializationTraits<SPSELFNixPerObjectSectionsToRegister,
}
};
-using SPSNamedExecutorAddressRangeSequenceMap =
- SPSSequence<SPSTuple<SPSString, SPSExecutorAddressRangeSequence>>;
+using SPSNamedExecutorAddrRangeSequenceMap =
+ SPSSequence<SPSTuple<SPSString, SPSExecutorAddrRangeSequence>>;
using SPSELFNixJITDylibInitializers =
- SPSTuple<SPSString, SPSExecutorAddress,
- SPSNamedExecutorAddressRangeSequenceMap>;
+ SPSTuple<SPSString, SPSExecutorAddr, SPSNamedExecutorAddrRangeSequenceMap>;
using SPSELFNixJITDylibInitializerSequence =
SPSSequence<SPSELFNixJITDylibInitializers>;
diff --git a/compiler-rt/lib/orc/executor_address.h b/compiler-rt/lib/orc/executor_address.h
index cfe985bdb60f9..f39f7d7ddb612 100644
--- a/compiler-rt/lib/orc/executor_address.h
+++ b/compiler-rt/lib/orc/executor_address.h
@@ -37,19 +37,19 @@ class ExecutorAddrDiff {
};
/// Represents an address in the executor process.
-class ExecutorAddress {
+class ExecutorAddr {
public:
- ExecutorAddress() = default;
- explicit ExecutorAddress(uint64_t Addr) : Addr(Addr) {}
+ ExecutorAddr() = default;
+ explicit ExecutorAddr(uint64_t Addr) : Addr(Addr) {}
- /// Create an ExecutorAddress from the given pointer.
+ /// Create an ExecutorAddr from the given pointer.
/// Warning: This should only be used when JITing in-process.
- template <typename T> static ExecutorAddress fromPtr(T *Value) {
- return ExecutorAddress(
+ template <typename T> static ExecutorAddr fromPtr(T *Value) {
+ return ExecutorAddr(
static_cast<uint64_t>(reinterpret_cast<uintptr_t>(Value)));
}
- /// Cast this ExecutorAddress to a pointer of the given type.
+ /// Cast this ExecutorAddr to a pointer of the given type.
/// Warning: This should only be esude when JITing in-process.
template <typename T> T toPtr() const {
static_assert(std::is_pointer<T>::value, "T must be a pointer type");
@@ -65,53 +65,47 @@ class ExecutorAddress {
explicit operator bool() const { return Addr != 0; }
- friend bool operator==(const ExecutorAddress &LHS,
- const ExecutorAddress &RHS) {
+ friend bool operator==(const ExecutorAddr &LHS, const ExecutorAddr &RHS) {
return LHS.Addr == RHS.Addr;
}
- friend bool operator!=(const ExecutorAddress &LHS,
- const ExecutorAddress &RHS) {
+ friend bool operator!=(const ExecutorAddr &LHS, const ExecutorAddr &RHS) {
return LHS.Addr != RHS.Addr;
}
- friend bool operator<(const ExecutorAddress &LHS,
- const ExecutorAddress &RHS) {
+ friend bool operator<(const ExecutorAddr &LHS, const ExecutorAddr &RHS) {
return LHS.Addr < RHS.Addr;
}
- friend bool operator<=(const ExecutorAddress &LHS,
- const ExecutorAddress &RHS) {
+ friend bool operator<=(const ExecutorAddr &LHS, const ExecutorAddr &RHS) {
return LHS.Addr <= RHS.Addr;
}
- friend bool operator>(const ExecutorAddress &LHS,
- const ExecutorAddress &RHS) {
+ friend bool operator>(const ExecutorAddr &LHS, const ExecutorAddr &RHS) {
return LHS.Addr > RHS.Addr;
}
- friend bool operator>=(const ExecutorAddress &LHS,
- const ExecutorAddress &RHS) {
+ friend bool operator>=(const ExecutorAddr &LHS, const ExecutorAddr &RHS) {
return LHS.Addr >= RHS.Addr;
}
- ExecutorAddress &operator++() {
+ ExecutorAddr &operator++() {
++Addr;
return *this;
}
- ExecutorAddress &operator--() {
+ ExecutorAddr &operator--() {
--Addr;
return *this;
}
- ExecutorAddress operator++(int) { return ExecutorAddress(Addr++); }
- ExecutorAddress operator--(int) { return ExecutorAddress(Addr++); }
+ ExecutorAddr operator++(int) { return ExecutorAddr(Addr++); }
+ ExecutorAddr operator--(int) { return ExecutorAddr(Addr++); }
- ExecutorAddress &operator+=(const ExecutorAddrDiff Delta) {
+ ExecutorAddr &operator+=(const ExecutorAddrDiff Delta) {
Addr += Delta.getValue();
return *this;
}
- ExecutorAddress &operator-=(const ExecutorAddrDiff Delta) {
+ ExecutorAddr &operator-=(const ExecutorAddrDiff Delta) {
Addr -= Delta.getValue();
return *this;
}
@@ -121,27 +115,27 @@ class ExecutorAddress {
};
/// Subtracting two addresses yields an offset.
-inline ExecutorAddrDiff operator-(const ExecutorAddress &LHS,
- const ExecutorAddress &RHS) {
+inline ExecutorAddrDiff operator-(const ExecutorAddr &LHS,
+ const ExecutorAddr &RHS) {
return ExecutorAddrDiff(LHS.getValue() - RHS.getValue());
}
/// Adding an offset and an address yields an address.
-inline ExecutorAddress operator+(const ExecutorAddress &LHS,
- const ExecutorAddrDiff &RHS) {
- return ExecutorAddress(LHS.getValue() + RHS.getValue());
+inline ExecutorAddr operator+(const ExecutorAddr &LHS,
+ const ExecutorAddrDiff &RHS) {
+ return ExecutorAddr(LHS.getValue() + RHS.getValue());
}
/// Adding an address and an offset yields an address.
-inline ExecutorAddress operator+(const ExecutorAddrDiff &LHS,
- const ExecutorAddress &RHS) {
- return ExecutorAddress(LHS.getValue() + RHS.getValue());
+inline ExecutorAddr operator+(const ExecutorAddrDiff &LHS,
+ const ExecutorAddr &RHS) {
+ return ExecutorAddr(LHS.getValue() + RHS.getValue());
}
/// Represents an address range in the exceutor process.
-struct ExecutorAddressRange {
- ExecutorAddressRange() = default;
- ExecutorAddressRange(ExecutorAddress StartAddress, ExecutorAddress EndAddress)
+struct ExecutorAddrRange {
+ ExecutorAddrRange() = default;
+ ExecutorAddrRange(ExecutorAddr StartAddress, ExecutorAddr EndAddress)
: StartAddress(StartAddress), EndAddress(EndAddress) {}
bool empty() const { return StartAddress == EndAddress; }
@@ -153,55 +147,53 @@ struct ExecutorAddressRange {
return span<T>(StartAddress.toPtr<T *>(), size().getValue() / sizeof(T));
}
- ExecutorAddress StartAddress;
- ExecutorAddress EndAddress;
+ ExecutorAddr StartAddress;
+ ExecutorAddr EndAddress;
};
-/// SPS serializatior for ExecutorAddress.
-template <> class SPSSerializationTraits<SPSExecutorAddress, ExecutorAddress> {
+/// SPS serializatior for ExecutorAddr.
+template <> class SPSSerializationTraits<SPSExecutorAddr, ExecutorAddr> {
public:
- static size_t size(const ExecutorAddress &EA) {
+ static size_t size(const ExecutorAddr &EA) {
return SPSArgList<uint64_t>::size(EA.getValue());
}
- static bool serialize(SPSOutputBuffer &BOB, const ExecutorAddress &EA) {
+ static bool serialize(SPSOutputBuffer &BOB, const ExecutorAddr &EA) {
return SPSArgList<uint64_t>::serialize(BOB, EA.getValue());
}
- static bool deserialize(SPSInputBuffer &BIB, ExecutorAddress &EA) {
+ static bool deserialize(SPSInputBuffer &BIB, ExecutorAddr &EA) {
uint64_t Tmp;
if (!SPSArgList<uint64_t>::deserialize(BIB, Tmp))
return false;
- EA = ExecutorAddress(Tmp);
+ EA = ExecutorAddr(Tmp);
return true;
}
};
-using SPSExecutorAddressRange =
- SPSTuple<SPSExecutorAddress, SPSExecutorAddress>;
+using SPSExecutorAddrRange = SPSTuple<SPSExecutorAddr, SPSExecutorAddr>;
/// Serialization traits for address ranges.
template <>
-class SPSSerializationTraits<SPSExecutorAddressRange, ExecutorAddressRange> {
+class SPSSerializationTraits<SPSExecutorAddrRange, ExecutorAddrRange> {
public:
- static size_t size(const ExecutorAddressRange &Value) {
- return SPSArgList<SPSExecutorAddress, SPSExecutorAddress>::size(
+ static size_t size(const ExecutorAddrRange &Value) {
+ return SPSArgList<SPSExecutorAddr, SPSExecutorAddr>::size(
Value.StartAddress, Value.EndAddress);
}
- static bool serialize(SPSOutputBuffer &BOB,
- const ExecutorAddressRange &Value) {
- return SPSArgList<SPSExecutorAddress, SPSExecutorAddress>::serialize(
+ static bool serialize(SPSOutputBuffer &BOB, const ExecutorAddrRange &Value) {
+ return SPSArgList<SPSExecutorAddr, SPSExecutorAddr>::serialize(
BOB, Value.StartAddress, Value.EndAddress);
}
- static bool deserialize(SPSInputBuffer &BIB, ExecutorAddressRange &Value) {
- return SPSArgList<SPSExecutorAddress, SPSExecutorAddress>::deserialize(
+ static bool deserialize(SPSInputBuffer &BIB, ExecutorAddrRange &Value) {
+ return SPSArgList<SPSExecutorAddr, SPSExecutorAddr>::deserialize(
BIB, Value.StartAddress, Value.EndAddress);
}
};
-using SPSExecutorAddressRangeSequence = SPSSequence<SPSExecutorAddressRange>;
+using SPSExecutorAddrRangeSequence = SPSSequence<SPSExecutorAddrRange>;
} // End namespace __orc_rt
diff --git a/compiler-rt/lib/orc/macho_platform.cpp b/compiler-rt/lib/orc/macho_platform.cpp
index 2a960fb548fae..62629215a920d 100644
--- a/compiler-rt/lib/orc/macho_platform.cpp
+++ b/compiler-rt/lib/orc/macho_platform.cpp
@@ -89,7 +89,7 @@ void walkEHFrameSection(span<const char> EHFrameSection,
}
Error validatePointerSectionExtent(const char *SectionName,
- const ExecutorAddressRange &SE) {
+ const ExecutorAddrRange &SE) {
if (SE.size().getValue() % sizeof(uintptr_t)) {
std::ostringstream ErrMsg;
ErrMsg << std::hex << "Size of " << SectionName << " 0x"
@@ -101,7 +101,7 @@ Error validatePointerSectionExtent(const char *SectionName,
}
Error registerObjCSelectors(
- const std::vector<ExecutorAddressRange> &ObjCSelRefsSections,
+ const std::vector<ExecutorAddrRange> &ObjCSelRefsSections,
const MachOJITDylibInitializers &MOJDIs) {
if (ORC_RT_UNLIKELY(!sel_registerName))
@@ -126,7 +126,7 @@ Error registerObjCSelectors(
}
Error registerObjCClasses(
- const std::vector<ExecutorAddressRange> &ObjCClassListSections,
+ const std::vector<ExecutorAddrRange> &ObjCClassListSections,
const MachOJITDylibInitializers &MOJDIs) {
if (ObjCClassListSections.empty())
@@ -170,7 +170,7 @@ Error registerObjCClasses(
}
Error registerSwift5Protocols(
- const std::vector<ExecutorAddressRange> &Swift5ProtocolSections,
+ const std::vector<ExecutorAddrRange> &Swift5ProtocolSections,
const MachOJITDylibInitializers &MOJDIs) {
if (ORC_RT_UNLIKELY(!Swift5ProtocolSections.empty() &&
@@ -186,7 +186,7 @@ Error registerSwift5Protocols(
}
Error registerSwift5ProtocolConformances(
- const std::vector<ExecutorAddressRange> &Swift5ProtocolConformanceSections,
+ const std::vector<ExecutorAddrRange> &Swift5ProtocolConformanceSections,
const MachOJITDylibInitializers &MOJDIs) {
if (ORC_RT_UNLIKELY(!Swift5ProtocolConformanceSections.empty() &&
@@ -202,7 +202,7 @@ Error registerSwift5ProtocolConformances(
return Error::success();
}
-Error runModInits(const std::vector<ExecutorAddressRange> &ModInitsSections,
+Error runModInits(const std::vector<ExecutorAddrRange> &ModInitsSections,
const MachOJITDylibInitializers &MOJDIs) {
for (const auto &ModInits : ModInitsSections) {
@@ -275,8 +275,8 @@ class MachOPlatformRuntimeState {
Error registerThreadDataSection(span<const char> ThreadDataSec);
- Expected<ExecutorAddress> lookupSymbolInJITDylib(void *DSOHandle,
- string_view Symbol);
+ Expected<ExecutorAddr> lookupSymbolInJITDylib(void *DSOHandle,
+ string_view Symbol);
Expected<MachOJITDylibInitializerSequence>
getJITDylibInitializersByName(string_view Path);
@@ -286,7 +286,7 @@ class MachOPlatformRuntimeState {
static MachOPlatformRuntimeState *MOPS;
using InitSectionHandler =
- Error (*)(const std::vector<ExecutorAddressRange> &Sections,
+ Error (*)(const std::vector<ExecutorAddrRange> &Sections,
const MachOJITDylibInitializers &MOJDIs);
const std::vector<std::pair<const char *, InitSectionHandler>> InitSections =
{{"__DATA,__objc_selrefs", registerObjCSelectors},
@@ -479,14 +479,15 @@ Error MachOPlatformRuntimeState::registerThreadDataSection(
return Error::success();
}
-Expected<ExecutorAddress>
+Expected<ExecutorAddr>
MachOPlatformRuntimeState::lookupSymbolInJITDylib(void *DSOHandle,
string_view Sym) {
- Expected<ExecutorAddress> Result((ExecutorAddress()));
- if (auto Err = WrapperFunction<SPSExpected<SPSExecutorAddress>(
- SPSExecutorAddress,
- SPSString)>::call(&__orc_rt_macho_symbol_lookup_tag, Result,
- ExecutorAddress::fromPtr(DSOHandle), Sym))
+ Expected<ExecutorAddr> Result((ExecutorAddr()));
+ if (auto Err = WrapperFunction<SPSExpected<SPSExecutorAddr>(
+ SPSExecutorAddr, SPSString)>::call(&__orc_rt_macho_symbol_lookup_tag,
+ Result,
+ ExecutorAddr::fromPtr(DSOHandle),
+ Sym))
return std::move(Err);
return Result;
}
diff --git a/compiler-rt/lib/orc/macho_platform.h b/compiler-rt/lib/orc/macho_platform.h
index 6c05e844b0cd9..7f0edc651f349 100644
--- a/compiler-rt/lib/orc/macho_platform.h
+++ b/compiler-rt/lib/orc/macho_platform.h
@@ -32,22 +32,21 @@ namespace __orc_rt {
namespace macho {
struct MachOPerObjectSectionsToRegister {
- ExecutorAddressRange EHFrameSection;
- ExecutorAddressRange ThreadDataSection;
+ ExecutorAddrRange EHFrameSection;
+ ExecutorAddrRange ThreadDataSection;
};
struct MachOJITDylibInitializers {
- using SectionList = std::vector<ExecutorAddressRange>;
+ using SectionList = std::vector<ExecutorAddrRange>;
MachOJITDylibInitializers() = default;
- MachOJITDylibInitializers(std::string Name,
- ExecutorAddress MachOHeaderAddress)
+ MachOJITDylibInitializers(std::string Name, ExecutorAddr MachOHeaderAddress)
: Name(std::move(Name)),
MachOHeaderAddress(std::move(MachOHeaderAddress)) {}
std::string Name;
- ExecutorAddress MachOHeaderAddress;
- ExecutorAddress ObjCImageInfoAddress;
+ ExecutorAddr MachOHeaderAddress;
+ ExecutorAddr ObjCImageInfoAddress;
std::unordered_map<std::string, SectionList> InitSections;
};
@@ -69,7 +68,7 @@ enum dlopen_mode : int {
} // end namespace macho
using SPSMachOPerObjectSectionsToRegister =
- SPSTuple<SPSExecutorAddressRange, SPSExecutorAddressRange>;
+ SPSTuple<SPSExecutorAddrRange, SPSExecutorAddrRange>;
template <>
class SPSSerializationTraits<SPSMachOPerObjectSectionsToRegister,
@@ -94,12 +93,12 @@ class SPSSerializationTraits<SPSMachOPerObjectSectionsToRegister,
}
};
-using SPSNamedExecutorAddressRangeSequenceMap =
- SPSSequence<SPSTuple<SPSString, SPSExecutorAddressRangeSequence>>;
+using SPSNamedExecutorAddrRangeSequenceMap =
+ SPSSequence<SPSTuple<SPSString, SPSExecutorAddrRangeSequence>>;
using SPSMachOJITDylibInitializers =
- SPSTuple<SPSString, SPSExecutorAddress, SPSExecutorAddress,
- SPSNamedExecutorAddressRangeSequenceMap>;
+ SPSTuple<SPSString, SPSExecutorAddr, SPSExecutorAddr,
+ SPSNamedExecutorAddrRangeSequenceMap>;
using SPSMachOJITDylibInitializerSequence =
SPSSequence<SPSMachOJITDylibInitializers>;
diff --git a/compiler-rt/lib/orc/simple_packed_serialization.h b/compiler-rt/lib/orc/simple_packed_serialization.h
index b561a19d8f048..b00707e50e462 100644
--- a/compiler-rt/lib/orc/simple_packed_serialization.h
+++ b/compiler-rt/lib/orc/simple_packed_serialization.h
@@ -176,7 +176,7 @@ class SPSSerializationTraits<
class SPSEmpty {};
/// Represents an address in the executor.
-class SPSExecutorAddress {};
+class SPSExecutorAddr {};
/// SPS tag type for tuples.
///
More information about the llvm-commits
mailing list