diff options
-rw-r--r-- | llvm/include/llvm/ProfileData/InstrProfReader.h | 18 | ||||
-rw-r--r-- | llvm/lib/ProfileData/InstrProfReader.cpp | 12 |
2 files changed, 14 insertions, 16 deletions
diff --git a/llvm/include/llvm/ProfileData/InstrProfReader.h b/llvm/include/llvm/ProfileData/InstrProfReader.h index 2837e421ba8..304606de679 100644 --- a/llvm/include/llvm/ProfileData/InstrProfReader.h +++ b/llvm/include/llvm/ProfileData/InstrProfReader.h @@ -136,7 +136,6 @@ private: bool ShouldSwapBytes; uint64_t CountersDelta; uint64_t NamesDelta; - uint64_t ValueDataDelta; const RawInstrProf::ProfileData<IntPtrT> *Data; const RawInstrProf::ProfileData<IntPtrT> *DataEnd; const uint64_t *CountersStart; @@ -144,6 +143,7 @@ private: const uint8_t *ValueDataStart; const char *ProfileEnd; uint32_t ValueKindLast; + uint32_t CurValueDataSize; // String table for holding a unique copy of all the strings in the profile. InstrProfStringTable StringTable; @@ -183,7 +183,10 @@ private: std::error_code readRawCounts(InstrProfRecord &Record); std::error_code readValueProfilingData(InstrProfRecord &Record); bool atEnd() const { return Data == DataEnd; } - void advanceData() { Data++; } + void advanceData() { + Data++; + ValueDataStart += CurValueDataSize; + } const uint64_t *getCounter(IntPtrT CounterPtr) const { ptrdiff_t Offset = (swap(CounterPtr) - CountersDelta) / sizeof(uint64_t); @@ -193,17 +196,6 @@ private: ptrdiff_t Offset = (swap(NamePtr) - NamesDelta) / sizeof(char); return NamesStart + Offset; } - const uint8_t *getValueDataCounts(IntPtrT ValueCountsPtr) const { - ptrdiff_t Offset = - (swap(ValueCountsPtr) - ValueDataDelta) / sizeof(uint8_t); - return ValueDataStart + Offset; - } - // This accepts an already byte-swapped ValueDataPtr argument. - const InstrProfValueData *getValueData(IntPtrT ValueDataPtr) const { - ptrdiff_t Offset = (ValueDataPtr - ValueDataDelta) / sizeof(uint8_t); - return reinterpret_cast<const InstrProfValueData *>(ValueDataStart + - Offset); - } }; typedef RawInstrProfReader<uint32_t> RawInstrProfReader32; diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp index 394893d3701..da68242b461 100644 --- a/llvm/lib/ProfileData/InstrProfReader.cpp +++ b/llvm/lib/ProfileData/InstrProfReader.cpp @@ -207,7 +207,6 @@ std::error_code RawInstrProfReader<IntPtrT>::readHeader( CountersDelta = swap(Header.CountersDelta); NamesDelta = swap(Header.NamesDelta); - ValueDataDelta = swap(Header.ValueDataDelta); auto DataSize = swap(Header.DataSize); auto CountersSize = swap(Header.CountersSize); auto NamesSize = swap(Header.NamesSize); @@ -301,11 +300,17 @@ std::error_code RawInstrProfReader<IntPtrT>::readValueProfilingData(InstrProfRecord &Record) { Record.clearValueData(); - if (!Data->Values || (ValueDataDelta == 0)) + CurValueDataSize = 0; + // Need to match the logic in value profile dumper code in compiler-rt: + uint32_t NumValueKinds = 0; + for (uint32_t I = 0; I < IPVK_Last + 1; I++) + NumValueKinds += (Data->NumValueSites[I] != 0); + + if (!NumValueKinds) return success(); ErrorOr<std::unique_ptr<ValueProfData>> VDataPtrOrErr = - ValueProfData::getValueProfData(getValueDataCounts(Data->Values), + ValueProfData::getValueProfData(ValueDataStart, (const unsigned char *)ProfileEnd, getDataEndianness()); @@ -313,6 +318,7 @@ RawInstrProfReader<IntPtrT>::readValueProfilingData(InstrProfRecord &Record) { return VDataPtrOrErr.getError(); VDataPtrOrErr.get()->deserializeTo(Record, &FunctionPtrToNameMap); + CurValueDataSize = VDataPtrOrErr.get()->getSize(); return success(); } |