Skip to content

Commit 4a0ccfa

Browse files
Use llvm::endianness::{big,little,native} (NFC)
Note that llvm::support::endianness has been renamed to llvm::endianness while becoming an enum class as opposed to an enum. This patch replaces support::{big,little,native} with llvm::endianness::{big,little,native}.
1 parent 2045cca commit 4a0ccfa

File tree

142 files changed

+463
-391
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+463
-391
lines changed

bolt/lib/Core/DebugData.cpp

Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,14 @@ writeAddressRanges(raw_svector_ostream &Stream,
124124
const DebugAddressRangesVector &AddressRanges,
125125
const bool WriteRelativeRanges = false) {
126126
for (const DebugAddressRange &Range : AddressRanges) {
127-
support::endian::write(Stream, Range.LowPC, support::little);
127+
support::endian::write(Stream, Range.LowPC, llvm::endianness::little);
128128
support::endian::write(
129129
Stream, WriteRelativeRanges ? Range.HighPC - Range.LowPC : Range.HighPC,
130-
support::little);
130+
llvm::endianness::little);
131131
}
132132
// Finish with 0 entries.
133-
support::endian::write(Stream, 0ULL, support::little);
134-
support::endian::write(Stream, 0ULL, support::little);
133+
support::endian::write(Stream, 0ULL, llvm::endianness::little);
134+
support::endian::write(Stream, 0ULL, llvm::endianness::little);
135135
return AddressRanges.size() * 16 + 16;
136136
}
137137

@@ -209,13 +209,15 @@ getDWARF5Header(const LocListsRangelistsHeader &Header) {
209209
getDWARF5RngListLocListHeaderSize() - sizeof(UnitLengthType);
210210

211211
support::endian::write(*HeaderStream, Header.UnitLength + HeaderSize,
212-
support::little);
213-
support::endian::write(*HeaderStream, Header.Version, support::little);
214-
support::endian::write(*HeaderStream, Header.AddressSize, support::little);
212+
llvm::endianness::little);
213+
support::endian::write(*HeaderStream, Header.Version,
214+
llvm::endianness::little);
215+
support::endian::write(*HeaderStream, Header.AddressSize,
216+
llvm::endianness::little);
215217
support::endian::write(*HeaderStream, Header.SegmentSelector,
216-
support::little);
218+
llvm::endianness::little);
217219
support::endian::write(*HeaderStream, Header.OffsetEntryCount,
218-
support::little);
220+
llvm::endianness::little);
219221
return HeaderBuffer;
220222
}
221223

@@ -254,17 +256,18 @@ static bool emitWithBase(raw_ostream &OS, const DebugVector &Entries,
254256
}
255257

256258
support::endian::write(OS, static_cast<uint8_t>(BaseAddressx),
257-
support::little);
259+
llvm::endianness::little);
258260
uint32_t BaseIndex = AddrWriter.getIndexFromAddress(Base, CU);
259261
encodeULEB128(BaseIndex, OS);
260262
for (auto &OffsetEntry : Offsets) {
261263
support::endian::write(OS, static_cast<uint8_t>(OffsetPair),
262-
support::little);
264+
llvm::endianness::little);
263265
encodeULEB128(OffsetEntry.StartOffset, OS);
264266
encodeULEB128(OffsetEntry.EndOffset, OS);
265267
Func(OffsetEntry.Index);
266268
}
267-
support::endian::write(OS, static_cast<uint8_t>(EndOfList), support::little);
269+
support::endian::write(OS, static_cast<uint8_t>(EndOfList),
270+
llvm::endianness::little);
268271
return true;
269272
}
270273

@@ -291,7 +294,7 @@ DebugRangeListsSectionWriter::addRanges(DebugAddressRangesVector &Ranges) {
291294
const DebugAddressRange &Range = Ranges[I];
292295
support::endian::write(*CUBodyStream,
293296
static_cast<uint8_t>(dwarf::DW_RLE_startx_length),
294-
support::little);
297+
llvm::endianness::little);
295298
uint32_t Index = AddrWriter->getIndexFromAddress(Range.LowPC, *CU);
296299
encodeULEB128(Index, *CUBodyStream);
297300
encodeULEB128(Range.HighPC - Range.LowPC, *CUBodyStream);
@@ -301,7 +304,7 @@ DebugRangeListsSectionWriter::addRanges(DebugAddressRangesVector &Ranges) {
301304
if (WrittenStartxLength)
302305
support::endian::write(*CUBodyStream,
303306
static_cast<uint8_t>(dwarf::DW_RLE_end_of_list),
304-
support::little);
307+
llvm::endianness::little);
305308
CurrentOffset = CUBodyBuffer->size();
306309
return RangeEntries.size() - 1;
307310
}
@@ -315,7 +318,7 @@ void DebugRangeListsSectionWriter::finalizeSection() {
315318
const uint32_t SizeOfArraySection = RangeEntries.size() * SizeOfArrayEntry;
316319
for (uint32_t Offset : RangeEntries)
317320
support::endian::write(*CUArrayStream, Offset + SizeOfArraySection,
318-
support::little);
321+
llvm::endianness::little);
319322

320323
std::unique_ptr<DebugBufferVector> Header = getDWARF5Header(
321324
{static_cast<uint32_t>(SizeOfArraySection + CUBodyBuffer.get()->size()),
@@ -359,17 +362,17 @@ void DebugARangesSectionWriter::writeARangesSection(
359362
uint32_t Size = 8 + 4 + 2 * sizeof(uint64_t) * (AddressRanges.size() + 1);
360363

361364
// Header field #1: set size.
362-
support::endian::write(RangesStream, Size, support::little);
365+
support::endian::write(RangesStream, Size, llvm::endianness::little);
363366

364367
// Header field #2: version number, 2 as per the specification.
365368
support::endian::write(RangesStream, static_cast<uint16_t>(2),
366-
support::little);
369+
llvm::endianness::little);
367370

368371
assert(CUMap.count(Offset) && "Original CU offset is not found in CU Map");
369372
// Header field #3: debug info offset of the correspondent compile unit.
370373
support::endian::write(
371374
RangesStream, static_cast<uint32_t>(CUMap.find(Offset)->second.Offset),
372-
support::little);
375+
llvm::endianness::little);
373376

374377
// Header field #4: address size.
375378
// 8 since we only write ELF64 binaries for now.
@@ -380,7 +383,7 @@ void DebugARangesSectionWriter::writeARangesSection(
380383

381384
// Padding before address table - 4 bytes in the 64-bit-pointer case.
382385
support::endian::write(RangesStream, static_cast<uint32_t>(0),
383-
support::little);
386+
llvm::endianness::little);
384387

385388
writeAddressRanges(RangesStream, AddressRanges, true);
386389
}
@@ -473,10 +476,10 @@ void DebugAddrWriter::update(DIEBuilder &DIEBlder, DWARFUnit &CU) {
473476
break;
474477
case 4:
475478
support::endian::write(*AddressStream, static_cast<uint32_t>(Address),
476-
support::little);
479+
llvm::endianness::little);
477480
break;
478481
case 8:
479-
support::endian::write(*AddressStream, Address, support::little);
482+
support::endian::write(*AddressStream, Address, llvm::endianness::little);
480483
break;
481484
}
482485
};
@@ -492,11 +495,12 @@ void DebugAddrWriter::update(DIEBuilder &DIEBlder, DWARFUnit &CU) {
492495
void DebugAddrWriterDwarf5::update(DIEBuilder &DIEBlder, DWARFUnit &CU) {
493496
// Need to layout all sections within .debug_addr
494497
// Within each section sort Address by index.
495-
const endianness Endian =
496-
BC->DwCtx->isLittleEndian() ? support::little : support::big;
498+
const endianness Endian = BC->DwCtx->isLittleEndian()
499+
? llvm::endianness::little
500+
: llvm::endianness::big;
497501
const DWARFSection &AddrSec = BC->DwCtx->getDWARFObj().getAddrSection();
498502
DWARFDataExtractor AddrData(BC->DwCtx->getDWARFObj(), AddrSec,
499-
Endian == support::little, 0);
503+
Endian == llvm::endianness::little, 0);
500504
DWARFDebugAddrTable AddrTable;
501505
DIDumpOptions DumpOpts;
502506
constexpr uint32_t HeaderSize = 8;
@@ -594,11 +598,11 @@ void DebugLocWriter::addList(DIEBuilder &DIEBldr, DIE &Die, DIEValue &AttrInfo,
594598

595599
for (const DebugLocationEntry &Entry : LocList) {
596600
support::endian::write(*LocStream, static_cast<uint64_t>(Entry.LowPC),
597-
support::little);
601+
llvm::endianness::little);
598602
support::endian::write(*LocStream, static_cast<uint64_t>(Entry.HighPC),
599-
support::little);
603+
llvm::endianness::little);
600604
support::endian::write(*LocStream, static_cast<uint16_t>(Entry.Expr.size()),
601-
support::little);
605+
llvm::endianness::little);
602606
*LocStream << StringRef(reinterpret_cast<const char *>(Entry.Expr.data()),
603607
Entry.Expr.size());
604608
LocSectionOffset += 2 * 8 + 2 + Entry.Expr.size();
@@ -618,15 +622,17 @@ std::unique_ptr<DebugBufferVector> DebugLocWriter::getBuffer() {
618622
void DebugLocWriter::finalize(DIEBuilder &DIEBldr, DIE &Die) {}
619623

620624
static void writeEmptyListDwarf5(raw_svector_ostream &Stream) {
621-
support::endian::write(Stream, static_cast<uint32_t>(4), support::little);
625+
support::endian::write(Stream, static_cast<uint32_t>(4),
626+
llvm::endianness::little);
622627
support::endian::write(Stream, static_cast<uint8_t>(dwarf::DW_LLE_start_end),
623-
support::little);
628+
llvm::endianness::little);
624629

625630
const char Zeroes[16] = {0};
626631
Stream << StringRef(Zeroes, 16);
627632
encodeULEB128(0, Stream);
628-
support::endian::write(
629-
Stream, static_cast<uint8_t>(dwarf::DW_LLE_end_of_list), support::little);
633+
support::endian::write(Stream,
634+
static_cast<uint8_t>(dwarf::DW_LLE_end_of_list),
635+
llvm::endianness::little);
630636
}
631637

632638
static void writeLegacyLocList(DIEValue &AttrInfo,
@@ -645,21 +651,21 @@ static void writeLegacyLocList(DIEValue &AttrInfo,
645651
for (const DebugLocationEntry &Entry : LocList) {
646652
support::endian::write(LocStream,
647653
static_cast<uint8_t>(dwarf::DW_LLE_startx_length),
648-
support::little);
654+
llvm::endianness::little);
649655
const uint32_t Index = AddrWriter.getIndexFromAddress(Entry.LowPC, CU);
650656
encodeULEB128(Index, LocStream);
651657

652658
support::endian::write(LocStream,
653659
static_cast<uint32_t>(Entry.HighPC - Entry.LowPC),
654-
support::little);
660+
llvm::endianness::little);
655661
support::endian::write(LocStream, static_cast<uint16_t>(Entry.Expr.size()),
656-
support::little);
662+
llvm::endianness::little);
657663
LocStream << StringRef(reinterpret_cast<const char *>(Entry.Expr.data()),
658664
Entry.Expr.size());
659665
}
660666
support::endian::write(LocStream,
661667
static_cast<uint8_t>(dwarf::DW_LLE_end_of_list),
662-
support::little);
668+
llvm::endianness::little);
663669
replaceLocValbyForm(DIEBldr, Die, AttrInfo, AttrInfo.getForm(), EntryOffset);
664670
}
665671

@@ -701,7 +707,7 @@ static void writeDWARF5LocList(uint32_t &NumberOfEntries, DIEValue &AttrInfo,
701707
const DebugLocationEntry &Entry = LocList[I];
702708
support::endian::write(LocBodyStream,
703709
static_cast<uint8_t>(dwarf::DW_LLE_startx_length),
704-
support::little);
710+
llvm::endianness::little);
705711
const uint32_t Index = AddrWriter.getIndexFromAddress(Entry.LowPC, CU);
706712
encodeULEB128(Index, LocBodyStream);
707713
encodeULEB128(Entry.HighPC - Entry.LowPC, LocBodyStream);
@@ -713,7 +719,7 @@ static void writeDWARF5LocList(uint32_t &NumberOfEntries, DIEValue &AttrInfo,
713719
if (WrittenStartxLength)
714720
support::endian::write(LocBodyStream,
715721
static_cast<uint8_t>(dwarf::DW_LLE_end_of_list),
716-
support::little);
722+
llvm::endianness::little);
717723
}
718724

719725
void DebugLoclistWriter::addList(DIEBuilder &DIEBldr, DIE &Die,
@@ -753,7 +759,7 @@ void DebugLoclistWriter::finalizeDWARF5(DIEBuilder &DIEBldr, DIE &Die) {
753759
support::endian::write(
754760
*LocArrayStream,
755761
static_cast<uint32_t>(SizeOfArraySection + RelativeOffset),
756-
support::little);
762+
llvm::endianness::little);
757763

758764
std::unique_ptr<DebugBufferVector> Header = getDWARF5Header(
759765
{static_cast<uint32_t>(SizeOfArraySection + LocBodyBuffer.get()->size()),
@@ -884,11 +890,11 @@ void DebugStrOffsetsWriter::finalizeSection(DWARFUnit &Unit,
884890
if (RetVal == ProcessedBaseOffsets.end() || StrOffsetSectionWasModified) {
885891
// Writing out the header for each section.
886892
support::endian::write(*StrOffsetsStream, CurrentSectionSize + 4,
887-
support::little);
893+
llvm::endianness::little);
888894
support::endian::write(*StrOffsetsStream, static_cast<uint16_t>(5),
889-
support::little);
895+
llvm::endianness::little);
890896
support::endian::write(*StrOffsetsStream, static_cast<uint16_t>(0),
891-
support::little);
897+
llvm::endianness::little);
892898

893899
uint64_t BaseOffset = StrOffsetsBuffer->size();
894900
ProcessedBaseOffsets[*Val] = BaseOffset;
@@ -897,7 +903,8 @@ void DebugStrOffsetsWriter::finalizeSection(DWARFUnit &Unit,
897903
StrListBaseAttrInfo.getForm(),
898904
DIEInteger(BaseOffset));
899905
for (const auto &Entry : IndexToAddressMap)
900-
support::endian::write(*StrOffsetsStream, Entry.second, support::little);
906+
support::endian::write(*StrOffsetsStream, Entry.second,
907+
llvm::endianness::little);
901908
} else {
902909
DIEBldr.replaceValue(&Die, dwarf::DW_AT_str_offsets_base,
903910
StrListBaseAttrInfo.getForm(),

bolt/lib/Rewrite/PseudoProbeRewriter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ void PseudoProbeRewriter::encodePseudoProbes() {
248248
auto EmitInt = [&](uint64_t Value, uint32_t Size) {
249249
const bool IsLittleEndian = BC.AsmInfo->isLittleEndian();
250250
uint64_t Swapped = support::endian::byte_swap(
251-
Value, IsLittleEndian ? support::little : support::big);
251+
Value,
252+
IsLittleEndian ? llvm::endianness::little : llvm::endianness::big);
252253
unsigned Index = IsLittleEndian ? 0 : 8 - Size;
253254
auto Entry = StringRef(reinterpret_cast<char *>(&Swapped) + Index, Size);
254255
Contents.append(Entry.begin(), Entry.end());

lld/COFF/DebugTypes.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ Error TpiSource::mergeDebugT(TypeMerger *m) {
311311
"use remapTpiWithGHashes when ghash is enabled");
312312

313313
CVTypeArray types;
314-
BinaryStreamReader reader(file->debugTypes, support::little);
314+
BinaryStreamReader reader(file->debugTypes, llvm::endianness::little);
315315
cantFail(reader.readArray(types, reader.getLength()));
316316

317317
// When dealing with PCH.OBJ, some indices were already merged.
@@ -588,7 +588,7 @@ void TpiSource::loadGHashes() {
588588
ownedGHashes = false;
589589
} else {
590590
CVTypeArray types;
591-
BinaryStreamReader reader(file->debugTypes, support::little);
591+
BinaryStreamReader reader(file->debugTypes, llvm::endianness::little);
592592
cantFail(reader.readArray(types, reader.getLength()));
593593
assignGHashesFromVector(GloballyHashedType::hashTypes(types));
594594
}

lld/COFF/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ static void readCallGraphsFromObjectFiles(COFFLinkerContext &ctx) {
12101210
ArrayRef<uint8_t> contents;
12111211
cantFail(
12121212
obj->getCOFFObj()->getSectionContents(obj->callgraphSec, contents));
1213-
BinaryStreamReader reader(contents, support::little);
1213+
BinaryStreamReader reader(contents, llvm::endianness::little);
12141214
while (!reader.empty()) {
12151215
uint32_t fromIndex, toIndex;
12161216
uint64_t count;

lld/COFF/InputFiles.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ void ObjFile::initializeFlags() {
709709

710710
DebugSubsectionArray subsections;
711711

712-
BinaryStreamReader reader(data, support::little);
712+
BinaryStreamReader reader(data, llvm::endianness::little);
713713
ExitOnError exitOnErr;
714714
exitOnErr(reader.readArray(subsections, data.size()));
715715

@@ -775,7 +775,7 @@ void ObjFile::initializeDependencies() {
775775
// Get the first type record. It will indicate if this object uses a type
776776
// server (/Zi) or a PCH file (/Yu).
777777
CVTypeArray types;
778-
BinaryStreamReader reader(data, support::little);
778+
BinaryStreamReader reader(data, llvm::endianness::little);
779779
cantFail(reader.readArray(types, reader.getLength()));
780780
CVTypeArray::Iterator firstType = types.begin();
781781
if (firstType == types.end())

lld/COFF/PDB.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ Error PDBLinker::writeAllModuleSymbolRecords(ObjFile *file,
656656
auto contents =
657657
SectionChunk::consumeDebugMagic(sectionContents, ".debug$S");
658658
DebugSubsectionArray subsections;
659-
BinaryStreamReader reader(contents, support::little);
659+
BinaryStreamReader reader(contents, llvm::endianness::little);
660660
exitOnErr(reader.readArray(subsections, contents.size()));
661661

662662
uint32_t nextRelocIndex = 0;
@@ -758,7 +758,7 @@ void DebugSHandler::handleDebugS(SectionChunk *debugChunk) {
758758
ArrayRef<uint8_t> contents = debugChunk->getContents();
759759
contents = SectionChunk::consumeDebugMagic(contents, ".debug$S");
760760
DebugSubsectionArray subsections;
761-
BinaryStreamReader reader(contents, support::little);
761+
BinaryStreamReader reader(contents, llvm::endianness::little);
762762
ExitOnError exitOnErr;
763763
exitOnErr(reader.readArray(subsections, contents.size()));
764764
debugChunk->sortRelocations();
@@ -868,7 +868,7 @@ Error UnrelocatedDebugSubsection::commit(BinaryStreamWriter &writer) const {
868868
debugChunk->file->debugTypesObj) {
869869
TpiSource *source = debugChunk->file->debugTypesObj;
870870
DebugInlineeLinesSubsectionRef inlineeLines;
871-
BinaryStreamReader storageReader(relocatedBytes, support::little);
871+
BinaryStreamReader storageReader(relocatedBytes, llvm::endianness::little);
872872
ExitOnError exitOnErr;
873873
exitOnErr(inlineeLines.initialize(storageReader));
874874
for (const InlineeSourceLine &line : inlineeLines) {
@@ -962,7 +962,7 @@ void DebugSHandler::finish() {
962962
// Copy each frame data record, add in rvaStart, translate string table
963963
// indices, and add the record to the PDB.
964964
DebugFrameDataSubsectionRef fds;
965-
BinaryStreamReader reader(subsecData, support::little);
965+
BinaryStreamReader reader(subsecData, llvm::endianness::little);
966966
exitOnErr(fds.initialize(reader));
967967
for (codeview::FrameData fd : fds) {
968968
fd.RvaStart += rvaStart;
@@ -1050,7 +1050,8 @@ void PDBLinker::addDebugSymbols(TpiSource *source) {
10501050
ArrayRef<uint8_t> relocatedDebugContents =
10511051
relocateDebugChunk(*debugChunk);
10521052
FixedStreamArray<object::FpoData> fpoRecords;
1053-
BinaryStreamReader reader(relocatedDebugContents, support::little);
1053+
BinaryStreamReader reader(relocatedDebugContents,
1054+
llvm::endianness::little);
10541055
uint32_t count = relocatedDebugContents.size() / sizeof(object::FpoData);
10551056
exitOnErr(reader.readArray(fpoRecords, count));
10561057

@@ -1772,7 +1773,7 @@ static bool findLineTable(const SectionChunk *c, uint32_t addr,
17721773
ArrayRef<uint8_t> contents =
17731774
SectionChunk::consumeDebugMagic(dbgC->getContents(), ".debug$S");
17741775
DebugSubsectionArray subsections;
1775-
BinaryStreamReader reader(contents, support::little);
1776+
BinaryStreamReader reader(contents, llvm::endianness::little);
17761777
exitOnErr(reader.readArray(subsections, contents.size()));
17771778

17781779
for (const DebugSubsectionRecord &ss : subsections) {

lld/ELF/Arch/Mips.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ template <endianness E> static uint32_t readShuffle(const uint8_t *loc) {
219219
// words in a big-endian order. That is why we have to swap these
220220
// words to get a correct value.
221221
uint32_t v = read32(loc);
222-
if (E == support::little)
222+
if (E == llvm::endianness::little)
223223
return (v << 16) | (v >> 16);
224224
return v;
225225
}
@@ -237,12 +237,12 @@ static void writeShuffleValue(uint8_t *loc, uint64_t v, uint8_t bitsSize,
237237
uint8_t shift) {
238238
// See comments in readShuffle for purpose of this code.
239239
uint16_t *words = (uint16_t *)loc;
240-
if (E == support::little)
240+
if (E == llvm::endianness::little)
241241
std::swap(words[0], words[1]);
242242

243243
writeValue(loc, v, bitsSize, shift);
244244

245-
if (E == support::little)
245+
if (E == llvm::endianness::little)
246246
std::swap(words[0], words[1]);
247247
}
248248

0 commit comments

Comments
 (0)