[llvm] b3ec059 - [llvm] Drop unaligned from calls to llvm::support::endian::{read,write} (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 10 18:57:29 PDT 2023
Author: Kazu Hirata
Date: 2023-10-10T18:57:14-07:00
New Revision: b3ec0595d38cfa09f52dc8a5c1c119fa3293d797
URL: https://github.com/llvm/llvm-project/commit/b3ec0595d38cfa09f52dc8a5c1c119fa3293d797
DIFF: https://github.com/llvm/llvm-project/commit/b3ec0595d38cfa09f52dc8a5c1c119fa3293d797.diff
LOG: [llvm] Drop unaligned from calls to llvm::support::endian::{read,write} (NFC)
The last template parameter of llvm::support::endian::{read,write}
defaults to unaligned, so we can drop that at call sites.
Added:
Modified:
llvm/include/llvm/Bitstream/BitstreamReader.h
llvm/include/llvm/Object/GOFF.h
llvm/include/llvm/Support/MD5.h
llvm/lib/ObjectYAML/COFFEmitter.cpp
llvm/lib/ProfileData/SampleProfReader.cpp
llvm/lib/Remarks/YAMLRemarkParser.cpp
llvm/tools/llvm-objdump/MachODump.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Bitstream/BitstreamReader.h b/llvm/include/llvm/Bitstream/BitstreamReader.h
index d271fed1375e4db..978ab7c2422b4bd 100644
--- a/llvm/include/llvm/Bitstream/BitstreamReader.h
+++ b/llvm/include/llvm/Bitstream/BitstreamReader.h
@@ -168,9 +168,7 @@ class SimpleBitstreamCursor {
unsigned BytesRead;
if (BitcodeBytes.size() >= NextChar + sizeof(word_t)) {
BytesRead = sizeof(word_t);
- CurWord =
- support::endian::read<word_t, support::little, support::unaligned>(
- NextCharPtr);
+ CurWord = support::endian::read<word_t, support::little>(NextCharPtr);
} else {
// Short read.
BytesRead = BitcodeBytes.size() - NextChar;
diff --git a/llvm/include/llvm/Object/GOFF.h b/llvm/include/llvm/Object/GOFF.h
index f4aa04cd99fcf5d..31f2f82fffd6aa9 100644
--- a/llvm/include/llvm/Object/GOFF.h
+++ b/llvm/include/llvm/Object/GOFF.h
@@ -69,8 +69,7 @@ class Record {
static void get(const uint8_t *Bytes, uint8_t ByteIndex, T &Value) {
assert(ByteIndex + sizeof(T) <= GOFF::RecordLength &&
"Byte index out of bounds!");
- Value = support::endian::read<T, support::big, support::unaligned>(
- &Bytes[ByteIndex]);
+ Value = support::endian::read<T, support::big>(&Bytes[ByteIndex]);
}
};
diff --git a/llvm/include/llvm/Support/MD5.h b/llvm/include/llvm/Support/MD5.h
index fa2f477261dd905..61af6002696adf7 100644
--- a/llvm/include/llvm/Support/MD5.h
+++ b/llvm/include/llvm/Support/MD5.h
@@ -47,12 +47,12 @@ class MD5 {
// Our MD5 implementation returns the result in little endian, so the low
// word is first.
using namespace support;
- return endian::read<uint64_t, little, unaligned>(data());
+ return endian::read<uint64_t, little>(data());
}
uint64_t high() const {
using namespace support;
- return endian::read<uint64_t, little, unaligned>(data() + 8);
+ return endian::read<uint64_t, little>(data() + 8);
}
std::pair<uint64_t, uint64_t> words() const {
using namespace support;
diff --git a/llvm/lib/ObjectYAML/COFFEmitter.cpp b/llvm/lib/ObjectYAML/COFFEmitter.cpp
index 2e72e4fa7f4916d..015c293fba46f7b 100644
--- a/llvm/lib/ObjectYAML/COFFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/COFFEmitter.cpp
@@ -314,8 +314,7 @@ template <typename value_type>
raw_ostream &operator<<(raw_ostream &OS,
const binary_le_impl<value_type> &BLE) {
char Buffer[sizeof(BLE.Value)];
- support::endian::write<value_type, support::little, support::unaligned>(
- Buffer, BLE.Value);
+ support::endian::write<value_type, support::little>(Buffer, BLE.Value);
OS.write(Buffer, sizeof(BLE.Value));
return OS;
}
diff --git a/llvm/lib/ProfileData/SampleProfReader.cpp b/llvm/lib/ProfileData/SampleProfReader.cpp
index d632a812b86e004..e8e468ed7370c79 100644
--- a/llvm/lib/ProfileData/SampleProfReader.cpp
+++ b/llvm/lib/ProfileData/SampleProfReader.cpp
@@ -531,8 +531,8 @@ SampleProfileReaderBinary::readStringFromTable(size_t *RetIdx) {
if (!SR.data()) {
assert(MD5NameMemStart);
using namespace support;
- uint64_t FID = endian::read<uint64_t, little, unaligned>(
- MD5NameMemStart + (*Idx) * sizeof(uint64_t));
+ uint64_t FID = endian::read<uint64_t, little>(MD5NameMemStart +
+ (*Idx) * sizeof(uint64_t));
SR = MD5StringBuf.emplace_back(std::to_string(FID));
}
if (RetIdx)
diff --git a/llvm/lib/Remarks/YAMLRemarkParser.cpp b/llvm/lib/Remarks/YAMLRemarkParser.cpp
index f5123b0f64ce113..8a7d00aa1dc089c 100644
--- a/llvm/lib/Remarks/YAMLRemarkParser.cpp
+++ b/llvm/lib/Remarks/YAMLRemarkParser.cpp
@@ -75,8 +75,7 @@ static Expected<uint64_t> parseVersion(StringRef &Buf) {
"Expecting version number.");
uint64_t Version =
- support::endian::read<uint64_t, support::little, support::unaligned>(
- Buf.data());
+ support::endian::read<uint64_t, support::little>(Buf.data());
if (Version != remarks::CurrentRemarkVersion)
return createStringError(std::errc::illegal_byte_sequence,
"Mismatching remark version. Got %" PRId64
@@ -91,8 +90,7 @@ static Expected<uint64_t> parseStrTabSize(StringRef &Buf) {
return createStringError(std::errc::illegal_byte_sequence,
"Expecting string table size.");
uint64_t StrTabSize =
- support::endian::read<uint64_t, support::little, support::unaligned>(
- Buf.data());
+ support::endian::read<uint64_t, support::little>(Buf.data());
Buf = Buf.drop_front(sizeof(uint64_t));
return StrTabSize;
}
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp
index 0e4aa25005d9794..fb8bc034b29c098 100644
--- a/llvm/tools/llvm-objdump/MachODump.cpp
+++ b/llvm/tools/llvm-objdump/MachODump.cpp
@@ -7630,15 +7630,13 @@ namespace {
template <typename T>
static uint64_t read(StringRef Contents, ptr
diff _t Offset) {
using llvm::support::little;
- using llvm::support::unaligned;
if (Offset + sizeof(T) > Contents.size()) {
outs() << "warning: attempt to read past end of buffer\n";
return T();
}
- uint64_t Val =
- support::endian::read<T, little, unaligned>(Contents.data() + Offset);
+ uint64_t Val = support::endian::read<T, little>(Contents.data() + Offset);
return Val;
}
More information about the llvm-commits
mailing list