aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ProfileData/InstrProfReader.cpp
diff options
context:
space:
mode:
authorRong Xu <xur@google.com>2019-02-28 19:55:07 +0000
committerRong Xu <xur@google.com>2019-02-28 19:55:07 +0000
commita6ff69f6ddf9ab3b3ea8f3f57e8b91a24fa9319f (patch)
treeb24b61755548564cc6d124f5f7e0cc8acc150e68 /llvm/lib/ProfileData/InstrProfReader.cpp
parent7fc6ef7dd7433c1947e1a00db0c32d1c68bf385f (diff)
downloadllvm-a6ff69f6ddf9ab3b3ea8f3f57e8b91a24fa9319f.zip
llvm-a6ff69f6ddf9ab3b3ea8f3f57e8b91a24fa9319f.tar.gz
llvm-a6ff69f6ddf9ab3b3ea8f3f57e8b91a24fa9319f.tar.bz2
[PGO] Context sensitive PGO (part 2)
Part 2 of CSPGO changes (mostly related to ProfileSummary). Note that I use a default parameter in setProfileSummary() and getSummary(). This is to break the dependency in clang. I will make the parameter explicit after changing clang in a separated patch. Differential Revision: https://reviews.llvm.org/D54175 llvm-svn: 355131
Diffstat (limited to 'llvm/lib/ProfileData/InstrProfReader.cpp')
-rw-r--r--llvm/lib/ProfileData/InstrProfReader.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp
index 5919efa..1852774 100644
--- a/llvm/lib/ProfileData/InstrProfReader.cpp
+++ b/llvm/lib/ProfileData/InstrProfReader.cpp
@@ -162,7 +162,10 @@ Error TextInstrProfReader::readHeader() {
IsIRInstr = true;
else if (Str.equals_lower("fe"))
IsIRInstr = false;
- else
+ else if (Str.equals_lower("csir")) {
+ IsIRInstr = true;
+ HasCSIRLevelProfile = true;
+ } else
return error(instrprof_error::bad_header);
++Line;
@@ -733,7 +736,7 @@ bool IndexedInstrProfReader::hasFormat(const MemoryBuffer &DataBuffer) {
const unsigned char *
IndexedInstrProfReader::readSummary(IndexedInstrProf::ProfVersion Version,
- const unsigned char *Cur) {
+ const unsigned char *Cur, bool UseCS) {
using namespace IndexedInstrProf;
using namespace support;
@@ -760,10 +763,13 @@ IndexedInstrProfReader::readSummary(IndexedInstrProf::ProfVersion Version,
DetailedSummary.emplace_back((uint32_t)Ent.Cutoff, Ent.MinBlockCount,
Ent.NumBlocks);
}
+ std::unique_ptr<llvm::ProfileSummary> &Summary =
+ UseCS ? this->CS_Summary : this->Summary;
+
// initialize InstrProfSummary using the SummaryData from disk.
- this->Summary = llvm::make_unique<ProfileSummary>(
- ProfileSummary::PSK_Instr, DetailedSummary,
- SummaryData->get(Summary::TotalBlockCount),
+ Summary = llvm::make_unique<ProfileSummary>(
+ UseCS ? ProfileSummary::PSK_CSInstr : ProfileSummary::PSK_Instr,
+ DetailedSummary, SummaryData->get(Summary::TotalBlockCount),
SummaryData->get(Summary::MaxBlockCount),
SummaryData->get(Summary::MaxInternalBlockCount),
SummaryData->get(Summary::MaxFunctionCount),
@@ -805,7 +811,11 @@ Error IndexedInstrProfReader::readHeader() {
IndexedInstrProf::ProfVersion::CurrentVersion)
return error(instrprof_error::unsupported_version);
- Cur = readSummary((IndexedInstrProf::ProfVersion)FormatVersion, Cur);
+ Cur = readSummary((IndexedInstrProf::ProfVersion)FormatVersion, Cur,
+ /* UseCS */ false);
+ if (Header->Version & VARIANT_MASK_CSIR_PROF)
+ Cur = readSummary((IndexedInstrProf::ProfVersion)FormatVersion, Cur,
+ /* UseCS */ true);
// Read the hash type and start offset.
IndexedInstrProf::HashT HashType = static_cast<IndexedInstrProf::HashT>(