Skip to content

Commit a06e94c

Browse files
[ProfileData] Remove getHostEndianness (NFC)
With the recent redefinition of llvm::endianness::native, it is equal to either llvm::endianness::big or llvm::endianness::little depending on the host endianness. Since getHostEndianness just returns llvm::endianness::native, this patch removes the function and "constant propagates" llvm::endianness:native.
1 parent af8eff4 commit a06e94c

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

llvm/include/llvm/ProfileData/InstrProf.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -949,10 +949,6 @@ void InstrProfRecord::reserveSites(uint32_t ValueKind, uint32_t NumValueSites) {
949949
getOrCreateValueSitesForKind(ValueKind).reserve(NumValueSites);
950950
}
951951

952-
inline support::endianness getHostEndianness() {
953-
return sys::IsLittleEndianHost ? support::little : support::big;
954-
}
955-
956952
// Include definitions for value profile data
957953
#define INSTR_PROF_VALUE_PROF_DATA
958954
#include "llvm/ProfileData/InstrProfData.inc"

llvm/include/llvm/ProfileData/InstrProfReader.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,9 @@ class RawInstrProfReader : public InstrProfReader {
413413
}
414414

415415
support::endianness getDataEndianness() const {
416-
support::endianness HostEndian = getHostEndianness();
417416
if (!ShouldSwapBytes)
418-
return HostEndian;
419-
if (HostEndian == support::little)
417+
return llvm::endianness::native;
418+
if (llvm::endianness::native == llvm::endianness::little)
420419
return support::big;
421420
else
422421
return support::little;

llvm/lib/ProfileData/InstrProf.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ void ValueProfRecord::swapBytes(support::endianness Old,
989989
if (Old == New)
990990
return;
991991

992-
if (getHostEndianness() != Old) {
992+
if (llvm::endianness::native != Old) {
993993
sys::swapByteOrder<uint32_t>(NumValueSites);
994994
sys::swapByteOrder<uint32_t>(Kind);
995995
}
@@ -1001,7 +1001,7 @@ void ValueProfRecord::swapBytes(support::endianness Old,
10011001
sys::swapByteOrder<uint64_t>(VD[I].Value);
10021002
sys::swapByteOrder<uint64_t>(VD[I].Count);
10031003
}
1004-
if (getHostEndianness() == Old) {
1004+
if (llvm::endianness::native == Old) {
10051005
sys::swapByteOrder<uint32_t>(NumValueSites);
10061006
sys::swapByteOrder<uint32_t>(Kind);
10071007
}
@@ -1086,29 +1086,29 @@ ValueProfData::getValueProfData(const unsigned char *D,
10861086
void ValueProfData::swapBytesToHost(support::endianness Endianness) {
10871087
using namespace support;
10881088

1089-
if (Endianness == getHostEndianness())
1089+
if (Endianness == llvm::endianness::native)
10901090
return;
10911091

10921092
sys::swapByteOrder<uint32_t>(TotalSize);
10931093
sys::swapByteOrder<uint32_t>(NumValueKinds);
10941094

10951095
ValueProfRecord *VR = getFirstValueProfRecord(this);
10961096
for (uint32_t K = 0; K < NumValueKinds; K++) {
1097-
VR->swapBytes(Endianness, getHostEndianness());
1097+
VR->swapBytes(Endianness, llvm::endianness::native);
10981098
VR = getValueProfRecordNext(VR);
10991099
}
11001100
}
11011101

11021102
void ValueProfData::swapBytesFromHost(support::endianness Endianness) {
11031103
using namespace support;
11041104

1105-
if (Endianness == getHostEndianness())
1105+
if (Endianness == llvm::endianness::native)
11061106
return;
11071107

11081108
ValueProfRecord *VR = getFirstValueProfRecord(this);
11091109
for (uint32_t K = 0; K < NumValueKinds; K++) {
11101110
ValueProfRecord *NVR = getValueProfRecordNext(VR);
1111-
VR->swapBytes(getHostEndianness(), Endianness);
1111+
VR->swapBytes(llvm::endianness::native, Endianness);
11121112
VR = NVR;
11131113
}
11141114
sys::swapByteOrder<uint32_t>(TotalSize);

0 commit comments

Comments
 (0)