[llvm] a06e94c - [ProfileData] Remove getHostEndianness (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 5 21:30:54 PDT 2023
Author: Kazu Hirata
Date: 2023-10-05T21:30:48-07:00
New Revision: a06e94cf3b375cdfd81f42f60e16ce0c3783ff4a
URL: https://github.com/llvm/llvm-project/commit/a06e94cf3b375cdfd81f42f60e16ce0c3783ff4a
DIFF: https://github.com/llvm/llvm-project/commit/a06e94cf3b375cdfd81f42f60e16ce0c3783ff4a.diff
LOG: [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.
Added:
Modified:
llvm/include/llvm/ProfileData/InstrProf.h
llvm/include/llvm/ProfileData/InstrProfReader.h
llvm/lib/ProfileData/InstrProf.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h
index bee40351c4eaf97..9239c1a691eca19 100644
--- a/llvm/include/llvm/ProfileData/InstrProf.h
+++ b/llvm/include/llvm/ProfileData/InstrProf.h
@@ -949,10 +949,6 @@ void InstrProfRecord::reserveSites(uint32_t ValueKind, uint32_t NumValueSites) {
getOrCreateValueSitesForKind(ValueKind).reserve(NumValueSites);
}
-inline support::endianness getHostEndianness() {
- return sys::IsLittleEndianHost ? support::little : support::big;
-}
-
// Include definitions for value profile data
#define INSTR_PROF_VALUE_PROF_DATA
#include "llvm/ProfileData/InstrProfData.inc"
diff --git a/llvm/include/llvm/ProfileData/InstrProfReader.h b/llvm/include/llvm/ProfileData/InstrProfReader.h
index 723df8bff5284e3..acbc9e21fcc7612 100644
--- a/llvm/include/llvm/ProfileData/InstrProfReader.h
+++ b/llvm/include/llvm/ProfileData/InstrProfReader.h
@@ -413,10 +413,9 @@ class RawInstrProfReader : public InstrProfReader {
}
support::endianness getDataEndianness() const {
- support::endianness HostEndian = getHostEndianness();
if (!ShouldSwapBytes)
- return HostEndian;
- if (HostEndian == support::little)
+ return llvm::endianness::native;
+ if (llvm::endianness::native == llvm::endianness::little)
return support::big;
else
return support::little;
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
index e82cb5c535f1f5a..1375713cb3f805a 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -989,7 +989,7 @@ void ValueProfRecord::swapBytes(support::endianness Old,
if (Old == New)
return;
- if (getHostEndianness() != Old) {
+ if (llvm::endianness::native != Old) {
sys::swapByteOrder<uint32_t>(NumValueSites);
sys::swapByteOrder<uint32_t>(Kind);
}
@@ -1001,7 +1001,7 @@ void ValueProfRecord::swapBytes(support::endianness Old,
sys::swapByteOrder<uint64_t>(VD[I].Value);
sys::swapByteOrder<uint64_t>(VD[I].Count);
}
- if (getHostEndianness() == Old) {
+ if (llvm::endianness::native == Old) {
sys::swapByteOrder<uint32_t>(NumValueSites);
sys::swapByteOrder<uint32_t>(Kind);
}
@@ -1086,7 +1086,7 @@ ValueProfData::getValueProfData(const unsigned char *D,
void ValueProfData::swapBytesToHost(support::endianness Endianness) {
using namespace support;
- if (Endianness == getHostEndianness())
+ if (Endianness == llvm::endianness::native)
return;
sys::swapByteOrder<uint32_t>(TotalSize);
@@ -1094,7 +1094,7 @@ void ValueProfData::swapBytesToHost(support::endianness Endianness) {
ValueProfRecord *VR = getFirstValueProfRecord(this);
for (uint32_t K = 0; K < NumValueKinds; K++) {
- VR->swapBytes(Endianness, getHostEndianness());
+ VR->swapBytes(Endianness, llvm::endianness::native);
VR = getValueProfRecordNext(VR);
}
}
@@ -1102,13 +1102,13 @@ void ValueProfData::swapBytesToHost(support::endianness Endianness) {
void ValueProfData::swapBytesFromHost(support::endianness Endianness) {
using namespace support;
- if (Endianness == getHostEndianness())
+ if (Endianness == llvm::endianness::native)
return;
ValueProfRecord *VR = getFirstValueProfRecord(this);
for (uint32_t K = 0; K < NumValueKinds; K++) {
ValueProfRecord *NVR = getValueProfRecordNext(VR);
- VR->swapBytes(getHostEndianness(), Endianness);
+ VR->swapBytes(llvm::endianness::native, Endianness);
VR = NVR;
}
sys::swapByteOrder<uint32_t>(TotalSize);
More information about the llvm-commits
mailing list