Skip to content
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
4 changes: 2 additions & 2 deletions clang/lib/CodeGen/CodeGenPGO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ void PGOHash::combine(HashType Type) {
if (Count && Count % NumTypesPerWord == 0) {
using namespace llvm::support;
uint64_t Swapped =
endian::byte_swap<uint64_t, llvm::endianness::little>(Working);
endian::byte_swap<uint64_t>(Working, llvm::endianness::little);
MD5.update(llvm::ArrayRef((uint8_t *)&Swapped, sizeof(Swapped)));
Working = 0;
}
Expand All @@ -999,7 +999,7 @@ uint64_t PGOHash::finalize() {
} else {
using namespace llvm::support;
uint64_t Swapped =
endian::byte_swap<uint64_t, llvm::endianness::little>(Working);
endian::byte_swap<uint64_t>(Working, llvm::endianness::little);
MD5.update(llvm::ArrayRef((uint8_t *)&Swapped, sizeof(Swapped)));
}
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Bitstream/BitstreamWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class BitstreamWriter {

void WriteWord(unsigned Value) {
Value =
support::endian::byte_swap<uint32_t, llvm::endianness::little>(Value);
support::endian::byte_swap<uint32_t>(Value, llvm::endianness::little);
Buffer.append(reinterpret_cast<const char *>(&Value),
reinterpret_cast<const char *>(&Value + 1));
}
Expand Down
20 changes: 10 additions & 10 deletions llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -1215,19 +1215,19 @@ namespace accessors {
/// Return the structural hash associated with the function.
template <class FuncRecordTy, llvm::endianness Endian>
uint64_t getFuncHash(const FuncRecordTy *Record) {
return support::endian::byte_swap<uint64_t, Endian>(Record->FuncHash);
return support::endian::byte_swap<uint64_t>(Record->FuncHash, Endian);
}

/// Return the coverage map data size for the function.
template <class FuncRecordTy, llvm::endianness Endian>
uint64_t getDataSize(const FuncRecordTy *Record) {
return support::endian::byte_swap<uint32_t, Endian>(Record->DataSize);
return support::endian::byte_swap<uint32_t>(Record->DataSize, Endian);
}

/// Return the function lookup key. The value is considered opaque.
template <class FuncRecordTy, llvm::endianness Endian>
uint64_t getFuncNameRef(const FuncRecordTy *Record) {
return support::endian::byte_swap<uint64_t, Endian>(Record->NameRef);
return support::endian::byte_swap<uint64_t>(Record->NameRef, Endian);
}

/// Return the PGO name of the function. Used for formats in which the name is
Expand Down Expand Up @@ -1280,14 +1280,14 @@ struct CovMapFunctionRecordV1 {

/// Return function lookup key. The value is consider opaque.
template <llvm::endianness Endian> IntPtrT getFuncNameRef() const {
return support::endian::byte_swap<IntPtrT, Endian>(NamePtr);
return support::endian::byte_swap<IntPtrT>(NamePtr, Endian);
}

/// Return the PGO name of the function.
template <llvm::endianness Endian>
Error getFuncName(InstrProfSymtab &ProfileNames, StringRef &FuncName) const {
IntPtrT NameRef = getFuncNameRef<Endian>();
uint32_t NameS = support::endian::byte_swap<uint32_t, Endian>(NameSize);
uint32_t NameS = support::endian::byte_swap<uint32_t>(NameSize, Endian);
FuncName = ProfileNames.getFuncName(NameRef, NameS);
if (NameS && FuncName.empty())
return make_error<CoverageMapError>(coveragemap_error::malformed,
Expand Down Expand Up @@ -1385,7 +1385,7 @@ struct CovMapFunctionRecordV3 {

/// Get the filename set reference.
template <llvm::endianness Endian> uint64_t getFilenamesRef() const {
return support::endian::byte_swap<uint64_t, Endian>(FilenamesRef);
return support::endian::byte_swap<uint64_t>(FilenamesRef, Endian);
}

/// Read the inline coverage mapping. Ignore the buffer parameter, it is for
Expand Down Expand Up @@ -1416,19 +1416,19 @@ struct CovMapHeader {
#define COVMAP_HEADER(Type, LLVMType, Name, Init) Type Name;
#include "llvm/ProfileData/InstrProfData.inc"
template <llvm::endianness Endian> uint32_t getNRecords() const {
return support::endian::byte_swap<uint32_t, Endian>(NRecords);
return support::endian::byte_swap<uint32_t>(NRecords, Endian);
}

template <llvm::endianness Endian> uint32_t getFilenamesSize() const {
return support::endian::byte_swap<uint32_t, Endian>(FilenamesSize);
return support::endian::byte_swap<uint32_t>(FilenamesSize, Endian);
}

template <llvm::endianness Endian> uint32_t getCoverageSize() const {
return support::endian::byte_swap<uint32_t, Endian>(CoverageSize);
return support::endian::byte_swap<uint32_t>(CoverageSize, Endian);
}

template <llvm::endianness Endian> uint32_t getVersion() const {
return support::endian::byte_swap<uint32_t, Endian>(Version);
return support::endian::byte_swap<uint32_t>(Version, Endian);
}
};

Expand Down
16 changes: 9 additions & 7 deletions llvm/include/llvm/Support/Endian.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ template <typename value_type>

/// Swap the bytes of value to match the given endianness.
template <typename value_type, endianness endian>
[[nodiscard]] inline value_type byte_swap(value_type value) {
[[nodiscard]]
LLVM_DEPRECATED("Pass endian as a function argument instead",
"byte_swap") inline value_type byte_swap(value_type value) {
return byte_swap(value, endian);
}

Expand Down Expand Up @@ -137,8 +139,8 @@ template <typename value_type, endianness endian, std::size_t alignment>
LLVM_ASSUME_ALIGNED(
memory, (detail::PickAlignment<value_type, alignment>::value)),
sizeof(value_type) * 2);
val[0] = byte_swap<value_type, endian>(val[0]);
val[1] = byte_swap<value_type, endian>(val[1]);
val[0] = byte_swap<value_type>(val[0], endian);
val[1] = byte_swap<value_type>(val[1], endian);

// Shift bits from the lower value into place.
make_unsigned_t<value_type> lowerVal = val[0] >> startBit;
Expand Down Expand Up @@ -172,8 +174,8 @@ inline void writeAtBitAlignment(void *memory, value_type value,
LLVM_ASSUME_ALIGNED(
memory, (detail::PickAlignment<value_type, alignment>::value)),
sizeof(value_type) * 2);
val[0] = byte_swap<value_type, endian>(val[0]);
val[1] = byte_swap<value_type, endian>(val[1]);
val[0] = byte_swap<value_type>(val[0], endian);
val[1] = byte_swap<value_type>(val[1], endian);

// Mask off any existing bits in the upper part of the lower value that
// we want to replace.
Expand Down Expand Up @@ -201,8 +203,8 @@ inline void writeAtBitAlignment(void *memory, value_type value,
val[1] |= upperVal;

// Finally, rewrite values.
val[0] = byte_swap<value_type, endian>(val[0]);
val[1] = byte_swap<value_type, endian>(val[1]);
val[0] = byte_swap<value_type>(val[0], endian);
val[1] = byte_swap<value_type>(val[1], endian);
memcpy(LLVM_ASSUME_ALIGNED(
memory, (detail::PickAlignment<value_type, alignment>::value)),
&val[0], sizeof(value_type) * 2);
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CGData/CodeGenDataWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void CGDataOStream::patch(ArrayRef<CGDataPatchItem> P) {
for (const auto &K : P) {
for (size_t I = 0; I < K.D.size(); ++I) {
uint64_t Bytes =
endian::byte_swap<uint64_t, llvm::endianness::little>(K.D[I]);
endian::byte_swap<uint64_t>(K.D[I], llvm::endianness::little);
Data.replace(K.Pos + I * sizeof(uint64_t), sizeof(uint64_t),
reinterpret_cast<const char *>(&Bytes), sizeof(uint64_t));
}
Expand All @@ -52,7 +52,7 @@ void CGDataOStream::patch(ArrayRef<CGDataPatchItem> P) {
for (const auto &K : P) {
for (size_t I = 0; I < K.D.size(); ++I) {
uint64_t Bytes =
endian::byte_swap<uint64_t, llvm::endianness::little>(K.D[I]);
endian::byte_swap<uint64_t>(K.D[I], llvm::endianness::little);
VOStream.pwrite(reinterpret_cast<const char *>(&Bytes),
sizeof(uint64_t), K.Pos + I * sizeof(uint64_t));
}
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/MC/DXContainerRootSignature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ static uint32_t writePlaceholder(raw_svector_ostream &Stream) {
static uint32_t rewriteOffsetToCurrentByte(raw_svector_ostream &Stream,
uint32_t Offset) {
uint32_t ByteOffset = Stream.tell();
uint32_t Value =
support::endian::byte_swap<uint32_t, llvm::endianness::little>(
ByteOffset);
uint32_t Value = support::endian::byte_swap<uint32_t>(
ByteOffset, llvm::endianness::little);
Stream.pwrite(reinterpret_cast<const char *>(&Value), sizeof(Value), Offset);
return ByteOffset;
}
Expand Down
12 changes: 6 additions & 6 deletions llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -949,9 +949,9 @@ loadTestingFormat(StringRef Data, StringRef CompilationDir) {
if (Data.size() < sizeof(uint64_t))
return make_error<CoverageMapError>(coveragemap_error::malformed,
"the size of data is too small");
auto TestingVersion =
support::endian::byte_swap<uint64_t, llvm::endianness::little>(
*reinterpret_cast<const uint64_t *>(Data.data()));
auto TestingVersion = support::endian::byte_swap<uint64_t>(
*reinterpret_cast<const uint64_t *>(Data.data()),
llvm::endianness::little);
Data = Data.substr(sizeof(uint64_t));

// Read the ProfileNames data.
Expand Down Expand Up @@ -1274,9 +1274,9 @@ BinaryCoverageReader::create(
std::vector<std::unique_ptr<BinaryCoverageReader>> Readers;

if (ObjectBuffer.getBuffer().size() > sizeof(TestingFormatMagic)) {
uint64_t Magic =
support::endian::byte_swap<uint64_t, llvm::endianness::little>(
*reinterpret_cast<const uint64_t *>(ObjectBuffer.getBufferStart()));
uint64_t Magic = support::endian::byte_swap<uint64_t>(
*reinterpret_cast<const uint64_t *>(ObjectBuffer.getBufferStart()),
llvm::endianness::little);
if (Magic == TestingFormatMagic) {
// This is a special format used for testing.
auto ReaderOrErr =
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ void CoverageMappingWriter::write(raw_ostream &OS) {

void TestingFormatWriter::write(raw_ostream &OS, TestingFormatVersion Version) {
auto ByteSwap = [](uint64_t N) {
return support::endian::byte_swap<uint64_t, llvm::endianness::little>(N);
return support::endian::byte_swap<uint64_t>(N, llvm::endianness::little);
};

// Output a 64bit magic number.
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/ProfileData/InstrProf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ void ProfOStream::patch(ArrayRef<PatchItem> P) {
for (const auto &K : P) {
for (int I = 0, E = K.D.size(); I != E; I++) {
uint64_t Bytes =
endian::byte_swap<uint64_t, llvm::endianness::little>(K.D[I]);
endian::byte_swap<uint64_t>(K.D[I], llvm::endianness::little);
Data.replace(K.Pos + I * sizeof(uint64_t), sizeof(uint64_t),
(const char *)&Bytes, sizeof(uint64_t));
}
Expand Down
10 changes: 5 additions & 5 deletions llvm/lib/ProfileData/InstrProfReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1186,10 +1186,10 @@ IndexedInstrProfReader::readSummary(IndexedInstrProf::ProfVersion Version,
if (Version >= IndexedInstrProf::Version4) {
const IndexedInstrProf::Summary *SummaryInLE =
reinterpret_cast<const IndexedInstrProf::Summary *>(Cur);
uint64_t NFields = endian::byte_swap<uint64_t, llvm::endianness::little>(
SummaryInLE->NumSummaryFields);
uint64_t NEntries = endian::byte_swap<uint64_t, llvm::endianness::little>(
SummaryInLE->NumCutoffEntries);
uint64_t NFields = endian::byte_swap<uint64_t>(
SummaryInLE->NumSummaryFields, llvm::endianness::little);
uint64_t NEntries = endian::byte_swap<uint64_t>(
SummaryInLE->NumCutoffEntries, llvm::endianness::little);
uint32_t SummarySize =
IndexedInstrProf::Summary::getSize(NFields, NEntries);
std::unique_ptr<IndexedInstrProf::Summary> SummaryData =
Expand All @@ -1198,7 +1198,7 @@ IndexedInstrProfReader::readSummary(IndexedInstrProf::ProfVersion Version,
const uint64_t *Src = reinterpret_cast<const uint64_t *>(SummaryInLE);
uint64_t *Dst = reinterpret_cast<uint64_t *>(SummaryData.get());
for (unsigned I = 0; I < SummarySize / sizeof(uint64_t); I++)
Dst[I] = endian::byte_swap<uint64_t, llvm::endianness::little>(Src[I]);
Dst[I] = endian::byte_swap<uint64_t>(Src[I], llvm::endianness::little);

SummaryEntryVector DetailedSummary;
for (unsigned I = 0; I < SummaryData->NumCutoffEntries; I++) {
Expand Down
8 changes: 4 additions & 4 deletions llvm/tools/llvm-jitlink/llvm-jitlink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1519,10 +1519,10 @@ class MemoryMatcher {

static StringRef detectStubKind(const Session::MemoryRegionInfo &Stub) {
using namespace support::endian;
auto Armv7MovWTle = byte_swap<uint32_t, endianness::little>(0xe300c000);
auto Armv7BxR12le = byte_swap<uint32_t, endianness::little>(0xe12fff1c);
auto Thumbv7MovWTle = byte_swap<uint32_t, endianness::little>(0x0c00f240);
auto Thumbv7BxR12le = byte_swap<uint16_t, endianness::little>(0x4760);
auto Armv7MovWTle = byte_swap<uint32_t>(0xe300c000, endianness::little);
auto Armv7BxR12le = byte_swap<uint32_t>(0xe12fff1c, endianness::little);
auto Thumbv7MovWTle = byte_swap<uint32_t>(0x0c00f240, endianness::little);
auto Thumbv7BxR12le = byte_swap<uint16_t>(0x4760, endianness::little);

MemoryMatcher M(Stub.getContent());
if (M.matchMask(Thumbv7MovWTle)) {
Expand Down
4 changes: 2 additions & 2 deletions llvm/unittests/MC/StringTableBuilderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ TEST(StringTableBuilderTest, BasicWinCOFF) {

std::string Expected;

ExpectedSize = support::endian::byte_swap<uint32_t, llvm::endianness::little>(
ExpectedSize);
ExpectedSize = support::endian::byte_swap<uint32_t>(ExpectedSize,
llvm::endianness::little);
Expected.append((const char*)&ExpectedSize, 4);
Expected += "pygmy hippopotamus";
Expected += '\x00';
Expand Down
Loading