summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2016-01-14 02:47:01 +0000
committerXinliang David Li <davidxl@google.com>2016-01-14 02:47:01 +0000
commita6b2c4f721f4243d4b39f1ab02bbdc986002afdc (patch)
treed00cedf098f2558dce79e9ceb1d533ba2f1bed75
parent4b35874b2a9e8efc8e3123726bc611030d382ecf (diff)
downloadbcm5719-llvm-a6b2c4f721f4243d4b39f1ab02bbdc986002afdc.tar.gz
bcm5719-llvm-a6b2c4f721f4243d4b39f1ab02bbdc986002afdc.zip
[PGO] clean up and documentation
Introduce enum for indexed format versions and document indexed format change history. llvm-svn: 257737
-rw-r--r--llvm/include/llvm/ProfileData/InstrProf.h21
-rw-r--r--llvm/lib/ProfileData/InstrProfReader.cpp7
-rw-r--r--llvm/lib/ProfileData/InstrProfWriter.cpp2
3 files changed, 25 insertions, 5 deletions
diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h
index c84d8d24f20..791dc033dc6 100644
--- a/llvm/include/llvm/ProfileData/InstrProf.h
+++ b/llvm/include/llvm/ProfileData/InstrProf.h
@@ -581,7 +581,26 @@ inline uint64_t ComputeHash(HashT Type, StringRef K) {
}
const uint64_t Magic = 0x8169666f72706cff; // "\xfflprofi\x81"
-const uint64_t Version = INSTR_PROF_INDEX_VERSION;
+
+enum ProfVersion {
+ // Version 1 is the first version. In this version, the value of
+ // a key/value pair can only include profile data of a single function.
+ // Due to this restriction, the number of block counters for a given
+ // function is not recorded by derived from the length of the value.
+ Version1 = 1,
+ // In version 2, the format supports recording profile data of multiple
+ // functions which share the same key in one value field. To suppor this,
+ // the number block counters is recorded as an uint64_t right after the
+ // function structural hash.
+ Version2 = 2,
+ // Version 3 supports value profile data. Value profile data is expected
+ // to follow the block counter profile data.
+ Version3 = 3,
+ // The current version is 3.
+ CurrentVersion = INSTR_PROF_INDEX_VERSION
+};
+const uint64_t Version = ProfVersion::CurrentVersion;
+
const HashT HashType = HashT::MD5;
inline uint64_t ComputeHash(StringRef K) { return ComputeHash(HashType, K); }
diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp
index 5e83456822f..7e9b7ab7c8a 100644
--- a/llvm/lib/ProfileData/InstrProfReader.cpp
+++ b/llvm/lib/ProfileData/InstrProfReader.cpp
@@ -478,7 +478,7 @@ data_type InstrProfLookupTrait::ReadData(StringRef K, const unsigned char *D,
// Initialize number of counters for FormatVersion == 1.
uint64_t CountsSize = N / sizeof(uint64_t) - 1;
// If format version is different then read the number of counters.
- if (FormatVersion != 1) {
+ if (FormatVersion != IndexedInstrProf::ProfVersion::Version1) {
if (D + sizeof(uint64_t) > End)
return data_type();
CountsSize = endian::readNext<uint64_t, little, unaligned>(D);
@@ -495,7 +495,8 @@ data_type InstrProfLookupTrait::ReadData(StringRef K, const unsigned char *D,
DataBuffer.emplace_back(K, Hash, std::move(CounterBuffer));
// Read value profiling data.
- if (FormatVersion > 2 && !readValueProfilingData(D, End)) {
+ if (FormatVersion > IndexedInstrProf::ProfVersion::Version2 &&
+ !readValueProfilingData(D, End)) {
DataBuffer.clear();
return data_type();
}
@@ -572,7 +573,7 @@ std::error_code IndexedInstrProfReader::readHeader() {
// Read the version.
uint64_t FormatVersion = endian::byte_swap<uint64_t, little>(Header->Version);
- if (FormatVersion > IndexedInstrProf::Version)
+ if (FormatVersion > IndexedInstrProf::ProfVersion::CurrentVersion)
return error(instrprof_error::unsupported_version);
// Read the maximal function count.
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp
index f5227248af2..44ad016f1a8 100644
--- a/llvm/lib/ProfileData/InstrProfWriter.cpp
+++ b/llvm/lib/ProfileData/InstrProfWriter.cpp
@@ -140,7 +140,7 @@ std::pair<uint64_t, uint64_t> InstrProfWriter::writeImpl(raw_ostream &OS) {
// Write the header.
IndexedInstrProf::Header Header;
Header.Magic = IndexedInstrProf::Magic;
- Header.Version = IndexedInstrProf::Version;
+ Header.Version = IndexedInstrProf::ProfVersion::CurrentVersion;
Header.MaxFunctionCount = MaxFunctionCount;
Header.HashType = static_cast<uint64_t>(IndexedInstrProf::HashType);
Header.HashOffset = 0;
OpenPOWER on IntegriCloud