Skip to content

Commit

Permalink
Revert b28f4d4 "[memprof] Omit the key length for the record table (#…
Browse files Browse the repository at this point in the history
…89527)"

Breaks on EXPENSIVE_CHECKS builds which still use the static ReadKeyDataLength implementation in several locations
  • Loading branch information
RKSimon committed Apr 23, 2024
1 parent f220c35 commit 20cb2ed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
12 changes: 3 additions & 9 deletions llvm/include/llvm/ProfileData/MemProf.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,16 +471,12 @@ class RecordLookupTrait {

hash_value_type ComputeHash(uint64_t K) { return K; }

std::pair<offset_type, offset_type>
static std::pair<offset_type, offset_type>
ReadKeyDataLength(const unsigned char *&D) {
using namespace support;

// Starting with Version2, we don't read the key length because it is a
// constant.
offset_type KeyLen =
Version < Version2
? endian::readNext<offset_type, llvm::endianness::little>(D)
: sizeof(uint64_t);
endian::readNext<offset_type, llvm::endianness::little>(D);
offset_type DataLen =
endian::readNext<offset_type, llvm::endianness::little>(D);
return std::make_pair(KeyLen, DataLen);
Expand Down Expand Up @@ -538,9 +534,7 @@ class RecordWriterTrait {

endian::Writer LE(Out, llvm::endianness::little);
offset_type N = sizeof(K);
// Starting with Version2, we omit the key length because it is a constant.
if (Version < Version2)
LE.write<offset_type>(N);
LE.write<offset_type>(N);
offset_type M = V.serializedSize(Version);
LE.write<offset_type>(M);
return std::make_pair(N, M);
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Support/OnDiskHashTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ template <typename Info> class OnDiskChainedHashTable {

// Determine the length of the key and the data.
const std::pair<offset_type, offset_type> &L =
InfoPtr->ReadKeyDataLength(Items);
Info::ReadKeyDataLength(Items);
offset_type ItemLen = L.first + L.second;

// Compare the hashes. If they are not the same, skip the entry entirely.
Expand Down

1 comment on commit 20cb2ed

@kazutakahirata
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for taking care of this!

Please sign in to comment.