================ @@ -96,19 +102,63 @@ llvm::SmallVector<SegmentEntry> readSegmentEntries(const char *Ptr) { } llvm::SmallVector<std::pair<uint64_t, MemInfoBlock>> -readMemInfoBlocks(const char *Ptr) { +readMemInfoBlocksV3(const char *Ptr) { using namespace support; const uint64_t NumItemsToRead = - endian::readNext<uint64_t, llvm::endianness::little>(Ptr); + endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr); + llvm::SmallVector<std::pair<uint64_t, MemInfoBlock>> Items; for (uint64_t I = 0; I < NumItemsToRead; I++) { const uint64_t Id = - endian::readNext<uint64_t, llvm::endianness::little>(Ptr); - const MemInfoBlock MIB = *reinterpret_cast<const MemInfoBlock *>(Ptr); + endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr); + + // We cheat a bit here and remove the const from cast to set the + // Histogram Pointer to newly allocated buffer. We also cheat, since V3 and + // V4 do not have the same fields. V3 is missing AccessHistogramSize and + // AccessHistogram. This means we read "dirty" data in here, but it should + // not segfault, since there will be callstack data placed after this in the + // binary format. + MemInfoBlock MIB = *reinterpret_cast<const MemInfoBlock *>(Ptr); + // Overwrite dirty data. ---------------- teresajohnson wrote:
Oh yes you are right, I missed the first `*` which means it is making a copy of what was in the memory pointed to by Ptr. https://github.com/llvm/llvm-project/pull/94264 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits