[llvm] r257987 - [PGO] fix a bug in profile summary computation
Xinliang David Li via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 15 21:29:49 PST 2016
Author: davidxl
Date: Fri Jan 15 23:29:49 2016
New Revision: 257987
URL: http://llvm.org/viewvc/llvm-project?rev=257987&view=rev
Log:
[PGO] fix a bug in profile summary computation
Entry block count was not counted and is corrected. Also
introduce a new metric that is MaxInternalBlockCount which
show command shows (as before).
Modified:
llvm/trunk/include/llvm/ProfileData/InstrProf.h
llvm/trunk/test/tools/llvm-profdata/general.proftext
llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp
Modified: llvm/trunk/include/llvm/ProfileData/InstrProf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/InstrProf.h?rev=257987&r1=257986&r2=257987&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/InstrProf.h (original)
+++ llvm/trunk/include/llvm/ProfileData/InstrProf.h Fri Jan 15 23:29:49 2016
@@ -573,16 +573,16 @@ class ProfileSummary {
std::vector<uint32_t> DetailedSummaryCutoffs;
// Sum of all counts.
uint64_t TotalCount;
- uint64_t MaxBlockCount, MaxFunctionCount;
+ uint64_t MaxBlockCount, MaxInternalBlockCount, MaxFunctionCount;
uint32_t NumBlocks, NumFunctions;
- inline void addCount(uint64_t Count);
+ inline void addCount(uint64_t Count, bool IsEntry);
void computeDetailedSummary();
public:
static const int Scale = 1000000;
ProfileSummary(std::vector<uint32_t> Cutoffs)
: DetailedSummaryCutoffs(Cutoffs), TotalCount(0), MaxBlockCount(0),
- MaxFunctionCount(0), NumBlocks(0), NumFunctions(0) {}
+ MaxInternalBlockCount(0), MaxFunctionCount(0), NumBlocks(0), NumFunctions(0) {}
inline void addRecord(const InstrProfRecord &);
inline std::vector<ProfileSummaryEntry> &getDetailedSummary();
uint32_t getNumBlocks() { return NumBlocks; }
@@ -590,13 +590,16 @@ public:
uint32_t getNumFunctions() { return NumFunctions; }
uint64_t getMaxFunctionCount() { return MaxFunctionCount; }
uint64_t getMaxBlockCount() { return MaxBlockCount; }
+ uint64_t getMaxInternalBlockCount() { return MaxInternalBlockCount; }
};
// This is called when a count is seen in the profile.
-void ProfileSummary::addCount(uint64_t Count) {
+void ProfileSummary::addCount(uint64_t Count, bool IsEntry) {
TotalCount += Count;
if (Count > MaxBlockCount)
MaxBlockCount = Count;
+ if (!IsEntry && Count > MaxInternalBlockCount)
+ MaxInternalBlockCount = Count;
NumBlocks++;
CountFrequencies[Count]++;
}
@@ -606,8 +609,8 @@ void ProfileSummary::addRecord(const Ins
if (R.Counts[0] > MaxFunctionCount)
MaxFunctionCount = R.Counts[0];
- for (size_t I = 1, E = R.Counts.size(); I < E; ++I)
- addCount(R.Counts[I]);
+ for (size_t I = 0, E = R.Counts.size(); I < E; ++I)
+ addCount(R.Counts[I], (I == 0));
}
std::vector<ProfileSummaryEntry> &ProfileSummary::getDetailedSummary() {
Modified: llvm/trunk/test/tools/llvm-profdata/general.proftext
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-profdata/general.proftext?rev=257987&r1=257986&r2=257987&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-profdata/general.proftext (original)
+++ llvm/trunk/test/tools/llvm-profdata/general.proftext Fri Jan 15 23:29:49 2016
@@ -65,20 +65,20 @@ hex_hash
# RUN: llvm-profdata show --detailed-summary %t.profdata | FileCheck %s -check-prefix=DETAILED-SUMMARY
# DETAILED-SUMMARY: Detailed summary:
-# DETAILED-SUMMARY: Total number of blocks: 6
-# DETAILED-SUMMARY: Total count: 2233785415175766016
-# DETAILED-SUMMARY: 3 blocks with count >= 288230376151711744 account for 80 percentage of the total counts
-# DETAILED-SUMMARY: 3 blocks with count >= 288230376151711744 account for 90 percentage of the total counts
-# DETAILED-SUMMARY: 4 blocks with count >= 144115188075855872 account for 95 percentage of the total counts.
-# DETAILED-SUMMARY: 5 blocks with count >= 72057594037927936 account for 99 percentage of the total counts.
-# DETAILED-SUMMARY: 5 blocks with count >= 72057594037927936 account for 99.9 percentage of the total counts.
-# DETAILED-SUMMARY: 5 blocks with count >= 72057594037927936 account for 99.99 percentage of the total counts.
-# DETAILED-SUMMARY: 5 blocks with count >= 72057594037927936 account for 99.999 percentage of the total counts.
+# DETAILED-SUMMARY: Total number of blocks: 10
+# DETAILED-SUMMARY: Total count: 4539628424389557499
+# DETAILED-SUMMARY: 3 blocks with count >= 576460752303423488 account for 80 percentage of the total counts.
+# DETAILED-SUMMARY: 4 blocks with count >= 288230376151711744 account for 90 percentage of the total counts.
+# DETAILED-SUMMARY: 4 blocks with count >= 288230376151711744 account for 95 percentage of the total counts.
+# DETAILED-SUMMARY: 6 blocks with count >= 72057594037927936 account for 99 percentage of the total counts.
+# DETAILED-SUMMARY: 6 blocks with count >= 72057594037927936 account for 99.9 percentage of the total counts.
+# DETAILED-SUMMARY: 6 blocks with count >= 72057594037927936 account for 99.99 percentage of the total counts.
+# DETAILED-SUMMARY: 6 blocks with count >= 72057594037927936 account for 99.999 percentage of the total counts.
# RUN: llvm-profdata show --detailed-summary --detailed-summary-cutoffs=600000 %t.profdata | FileCheck %s -check-prefix=DETAILED-SUMMARY-2
-# DETAILED-SUMMARY-2: 2 blocks with count >= 576460752303423488 account for 60 percentage of the total counts.
+# DETAILED-SUMMARY-2: 2 blocks with count >= 1152921504606846976 account for 60 percentage of the total counts.
#
# RUN: llvm-profdata show --detailed-summary --detailed-summary-cutoffs=600000,900000,999999 %t.profdata | FileCheck %s -check-prefix=DETAILED-SUMMARY-3
-# DETAILED-SUMMARY-3: 2 blocks with count >= 576460752303423488 account for 60 percentage of the total counts.
-# DETAILED-SUMMARY-3: 3 blocks with count >= 288230376151711744 account for 90 percentage of the total counts
-# DETAILED-SUMMARY-3: 5 blocks with count >= 72057594037927936 account for 99.9999 percentage of the total counts.
+# DETAILED-SUMMARY-3: 2 blocks with count >= 1152921504606846976 account for 60 percentage of the total counts.
+# DETAILED-SUMMARY-3: 4 blocks with count >= 288230376151711744 account for 90 percentage of the total counts.
+# DETAILED-SUMMARY-3: 6 blocks with count >= 72057594037927936 account for 99.9999 percentage of the total counts.
Modified: llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp?rev=257987&r1=257986&r2=257987&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp (original)
+++ llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp Fri Jan 15 23:29:49 2016
@@ -333,7 +333,7 @@ static int showInstrProfile(std::string
OS << "Functions shown: " << ShownFunctions << "\n";
OS << "Total functions: " << PS.getNumFunctions() << "\n";
OS << "Maximum function count: " << PS.getMaxFunctionCount() << "\n";
- OS << "Maximum internal block count: " << PS.getMaxBlockCount() << "\n";
+ OS << "Maximum internal block count: " << PS.getMaxInternalBlockCount() << "\n";
if (ShowDetailedSummary) {
OS << "Detailed summary:\n";
More information about the llvm-commits
mailing list