-typedef InstrProfLookupTrait::data_type data_type;
-typedef InstrProfLookupTrait::offset_type offset_type;
-
-data_type InstrProfLookupTrait::ReadData(StringRef K, const unsigned char *D,
- offset_type N) {
-
- // Check if the data is corrupt. If so, don't try to read it.
- if (N % sizeof(uint64_t))
- return data_type();
-
- DataBuffer.clear();
- uint64_t NumCounts;
- uint64_t NumEntries = N / sizeof(uint64_t);
- std::vector<uint64_t> CounterBuffer;
- for (uint64_t I = 0; I < NumEntries; I += NumCounts) {
- using namespace support;
- // The function hash comes first.
- uint64_t Hash = endian::readNext<uint64_t, little, unaligned>(D);
-
- if (++I >= NumEntries)
- return data_type();
-
- // In v1, we have at least one count.
- // Later, we have the number of counts.
- NumCounts = (1 == FormatVersion)
- ? NumEntries - I
- : endian::readNext<uint64_t, little, unaligned>(D);
- if (1 != FormatVersion)
- ++I;
-
- // If we have more counts than data, this is bogus.
- if (I + NumCounts > NumEntries)
- return data_type();
-
- CounterBuffer.clear();
- for (unsigned J = 0; J < NumCounts; ++J)
- CounterBuffer.push_back(endian::readNext<uint64_t, little, unaligned>(D));
-
- DataBuffer.push_back(InstrProfRecord(K, Hash, CounterBuffer));
- }
- return DataBuffer;
-}
-