[PATCH] D148868: [llvm-profdata] ProfileReader cleanup - preparation for MD5 refactoring

William Junda Huang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 25 14:41:30 PDT 2023


huangjd added inline comments.


================
Comment at: llvm/lib/ProfileData/SampleProfReader.cpp:538
+    assert(MD5NameMemStart);
+    auto FID = reinterpret_cast<const uint64_t*>(MD5NameMemStart)[*Idx];
+    SR = MD5StringBuf.emplace_back(std::to_string(FID));
----------------
huangjd wrote:
> davidxl wrote:
> > Can you explain the cleanup done here?
> This corresponds to 
> ```
> Data = MD5NameMemStart + ((*Idx) * sizeof(uint64_t));
> End = reinterpret_cast<const uint8_t *>(
>         std::numeric_limits<uintptr_t>::max());
> auto FID = readUnencodedNumber<uint64_t>();
> if (std::error_code EC = FID.getError())
>   return EC;```
> 
> However the check is not necessary because when reading the name table we already ensured the name table contains correct number of entries, and readStringIndex in this function ensures the index is in range, so the fixed length MD5 can be directly accessed with an index into the base address
Modified code to use endian::read because it is necessary for correctness on big endian platform 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148868/new/

https://reviews.llvm.org/D148868



More information about the llvm-commits mailing list