summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ProfileData
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/ProfileData')
-rw-r--r--llvm/lib/ProfileData/InstrProfReader.cpp6
-rw-r--r--llvm/lib/ProfileData/InstrProfWriter.cpp6
-rw-r--r--llvm/lib/ProfileData/ProfileSummary.cpp45
3 files changed, 34 insertions, 23 deletions
diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp
index 7968cf1f60d..9c17d4e082d 100644
--- a/llvm/lib/ProfileData/InstrProfReader.cpp
+++ b/llvm/lib/ProfileData/InstrProfReader.cpp
@@ -589,15 +589,15 @@ IndexedInstrProfReader::readSummary(IndexedInstrProf::ProfVersion Version,
for (unsigned I = 0; I < SummarySize / sizeof(uint64_t); I++)
Dst[I] = endian::byte_swap<uint64_t, little>(Src[I]);
- // initialize ProfileSummary using the SummaryData from disk.
- this->Summary = llvm::make_unique<ProfileSummary>(*(SummaryData.get()));
+ // initialize InstrProfSummary using the SummaryData from disk.
+ this->Summary = llvm::make_unique<InstrProfSummary>(*(SummaryData.get()));
return Cur + SummarySize;
} else {
// For older version of profile data, we need to compute on the fly:
using namespace IndexedInstrProf;
std::vector<uint32_t> Cutoffs(&SummaryCutoffs[0],
&SummaryCutoffs[NumSummaryCutoffs]);
- this->Summary = llvm::make_unique<ProfileSummary>(Cutoffs);
+ this->Summary = llvm::make_unique<InstrProfSummary>(Cutoffs);
this->Summary->computeDetailedSummary();
return Cur;
}
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp
index 3e325718769..19a16b82932 100644
--- a/llvm/lib/ProfileData/InstrProfWriter.cpp
+++ b/llvm/lib/ProfileData/InstrProfWriter.cpp
@@ -84,7 +84,7 @@ public:
typedef uint64_t offset_type;
support::endianness ValueProfDataEndianness;
- ProfileSummary *TheProfileSummary;
+ InstrProfSummary *TheProfileSummary;
InstrProfRecordWriterTrait() : ValueProfDataEndianness(support::little) {}
static hash_value_type ComputeHash(key_type_ref K) {
@@ -197,7 +197,7 @@ bool InstrProfWriter::shouldEncodeData(const ProfilingData &PD) {
}
static void setSummary(IndexedInstrProf::Summary *TheSummary,
- ProfileSummary &PS) {
+ InstrProfSummary &PS) {
using namespace IndexedInstrProf;
std::vector<ProfileSummaryEntry> &Res = PS.getDetailedSummary();
TheSummary->NumSummaryFields = Summary::NumKinds;
@@ -219,7 +219,7 @@ void InstrProfWriter::writeImpl(ProfOStream &OS) {
using namespace IndexedInstrProf;
std::vector<uint32_t> Cutoffs(&SummaryCutoffs[0],
&SummaryCutoffs[NumSummaryCutoffs]);
- ProfileSummary PS(Cutoffs);
+ InstrProfSummary PS(Cutoffs);
InfoObj->TheProfileSummary = &PS;
// Populate the hash table generator.
diff --git a/llvm/lib/ProfileData/ProfileSummary.cpp b/llvm/lib/ProfileData/ProfileSummary.cpp
index a16094be20f..716c39e4354 100644
--- a/llvm/lib/ProfileData/ProfileSummary.cpp
+++ b/llvm/lib/ProfileData/ProfileSummary.cpp
@@ -16,17 +16,14 @@
using namespace llvm;
-void ProfileSummary::addRecord(const InstrProfRecord &R) {
- NumFunctions++;
- if (R.Counts[0] > MaxFunctionCount)
- MaxFunctionCount = R.Counts[0];
-
- for (size_t I = 0, E = R.Counts.size(); I < E; ++I)
- addCount(R.Counts[I], (I == 0));
+void InstrProfSummary::addRecord(const InstrProfRecord &R) {
+ addEntryCount(R.Counts[0]);
+ for (size_t I = 1, E = R.Counts.size(); I < E; ++I)
+ addInternalCount(R.Counts[I]);
}
// The argument to this method is a vector of cutoff percentages and the return
-// value is a vector of (Cutoff, MinBlockCount, NumBlocks) triplets.
+// value is a vector of (Cutoff, MinCount, NumCounts) triplets.
void ProfileSummary::computeDetailedSummary() {
if (DetailedSummaryCutoffs.empty())
return;
@@ -34,7 +31,7 @@ void ProfileSummary::computeDetailedSummary() {
auto End = CountFrequencies.end();
std::sort(DetailedSummaryCutoffs.begin(), DetailedSummaryCutoffs.end());
- uint32_t BlocksSeen = 0;
+ uint32_t CountsSeen = 0;
uint64_t CurrSum = 0, Count = 0;
for (uint32_t Cutoff : DetailedSummaryCutoffs) {
@@ -50,26 +47,40 @@ void ProfileSummary::computeDetailedSummary() {
Count = Iter->first;
uint32_t Freq = Iter->second;
CurrSum += (Count * Freq);
- BlocksSeen += Freq;
+ CountsSeen += Freq;
Iter++;
}
assert(CurrSum >= DesiredCount);
- ProfileSummaryEntry PSE = {Cutoff, Count, BlocksSeen};
+ ProfileSummaryEntry PSE = {Cutoff, Count, CountsSeen};
DetailedSummary.push_back(PSE);
}
}
-ProfileSummary::ProfileSummary(const IndexedInstrProf::Summary &S)
- : TotalCount(S.get(IndexedInstrProf::Summary::TotalBlockCount)),
- MaxBlockCount(S.get(IndexedInstrProf::Summary::MaxBlockCount)),
- MaxInternalBlockCount(
- S.get(IndexedInstrProf::Summary::MaxInternalBlockCount)),
+InstrProfSummary::InstrProfSummary(const IndexedInstrProf::Summary &S)
+ : ProfileSummary(), MaxInternalBlockCount(S.get(
+ IndexedInstrProf::Summary::MaxInternalBlockCount)),
MaxFunctionCount(S.get(IndexedInstrProf::Summary::MaxFunctionCount)),
- NumBlocks(S.get(IndexedInstrProf::Summary::TotalNumBlocks)),
NumFunctions(S.get(IndexedInstrProf::Summary::TotalNumFunctions)) {
+
+ TotalCount = S.get(IndexedInstrProf::Summary::TotalBlockCount);
+ MaxCount = S.get(IndexedInstrProf::Summary::MaxBlockCount);
+ NumCounts = S.get(IndexedInstrProf::Summary::TotalNumBlocks);
+
for (unsigned I = 0; I < S.NumCutoffEntries; I++) {
const IndexedInstrProf::Summary::Entry &Ent = S.getEntry(I);
DetailedSummary.emplace_back((uint32_t)Ent.Cutoff, Ent.MinBlockCount,
Ent.NumBlocks);
}
}
+void InstrProfSummary::addEntryCount(uint64_t Count) {
+ addCount(Count);
+ NumFunctions++;
+ if (Count > MaxFunctionCount)
+ MaxFunctionCount = Count;
+}
+
+void InstrProfSummary::addInternalCount(uint64_t Count) {
+ addCount(Count);
+ if (Count > MaxInternalBlockCount)
+ MaxInternalBlockCount = Count;
+}
OpenPOWER on IntegriCloud