aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ProfileData/InstrProfReader.cpp
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2015-12-11 06:53:53 +0000
committerXinliang David Li <davidxl@google.com>2015-12-11 06:53:53 +0000
commitd922c26c02e8dc376b62a5e9ea642d1dfbcd523e (patch)
tree41ae261639b860b405cc433d7776fd78a9b5acef /llvm/lib/ProfileData/InstrProfReader.cpp
parent20f733acc44de4a3ba023a31bec8699d149bb535 (diff)
downloadllvm-d922c26c02e8dc376b62a5e9ea642d1dfbcd523e.zip
llvm-d922c26c02e8dc376b62a5e9ea642d1dfbcd523e.tar.gz
llvm-d922c26c02e8dc376b62a5e9ea642d1dfbcd523e.tar.bz2
[PGO] Read VP raw data without depending on the Value field
Before this patch, each function's on-disk VP data is 'pointed' to by the Value field of per-function ProfileData structue, and read relies on this field (relocated with ValueDataDelta field) to read the value data. However this means the Value field needs to be updated during runtime before dumping, which creates undesirable data races. With this patch, the reading of VP data no longer depends on Value field. There is no format change. ValueDataDelta header field becomes obsolute but will be kept for compatibility reason (will be removed next time the raw format change is needed). llvm-svn: 255329
Diffstat (limited to 'llvm/lib/ProfileData/InstrProfReader.cpp')
-rw-r--r--llvm/lib/ProfileData/InstrProfReader.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp
index 394893d..da68242 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();
}