This simplifies readability / maintainability.
private:
const Kind PSK;
- SummaryEntryVector DetailedSummary;
- uint64_t TotalCount, MaxCount, MaxInternalCount, MaxFunctionCount;
- uint32_t NumCounts, NumFunctions;
+ const SummaryEntryVector DetailedSummary;
+ const uint64_t TotalCount, MaxCount, MaxInternalCount, MaxFunctionCount;
+ const uint32_t NumCounts, NumFunctions;
/// If 'Partial' is false, it means the profile being used to optimize
/// a target is collected from the same target.
/// If 'Partial' is true, it means the profile is for common/shared
public:
static const int Scale = 1000000;
- ProfileSummary(Kind K, SummaryEntryVector DetailedSummary,
+ ProfileSummary(Kind K, const SummaryEntryVector &DetailedSummary,
uint64_t TotalCount, uint64_t MaxCount,
uint64_t MaxInternalCount, uint64_t MaxFunctionCount,
uint32_t NumCounts, uint32_t NumFunctions,
bool AddPartialProfileRatioField = true);
/// Construct profile summary from metdata.
static ProfileSummary *getFromMD(Metadata *MD);
- SummaryEntryVector &getDetailedSummary() { return DetailedSummary; }
+ const SummaryEntryVector &getDetailedSummary() { return DetailedSummary; }
uint32_t getNumFunctions() const { return NumFunctions; }
uint64_t getMaxFunctionCount() const { return MaxFunctionCount; }
uint32_t getNumCounts() const { return NumCounts; }
/// Find the summary entry for a desired percentile of counts.
static const ProfileSummaryEntry &
- getEntryForPercentile(SummaryEntryVector &DS, uint64_t Percentile);
- static uint64_t getHotCountThreshold(SummaryEntryVector &DS);
- static uint64_t getColdCountThreshold(SummaryEntryVector &DS);
+ getEntryForPercentile(const SummaryEntryVector &DS, uint64_t Percentile);
+ static uint64_t getHotCountThreshold(const SummaryEntryVector &DS);
+ static uint64_t getColdCountThreshold(const SummaryEntryVector &DS);
};
class InstrProfSummaryBuilder final : public ProfileSummaryBuilder {
ProfileSummary &PS) {
using namespace IndexedInstrProf;
- std::vector<ProfileSummaryEntry> &Res = PS.getDetailedSummary();
+ const std::vector<ProfileSummaryEntry> &Res = PS.getDetailedSummary();
TheSummary->NumSummaryFields = Summary::NumKinds;
TheSummary->NumCutoffEntries = Res.size();
TheSummary->set(Summary::MaxFunctionCount, PS.getMaxFunctionCount());
DefaultCutoffsData;
const ProfileSummaryEntry &
-ProfileSummaryBuilder::getEntryForPercentile(SummaryEntryVector &DS,
+ProfileSummaryBuilder::getEntryForPercentile(const SummaryEntryVector &DS,
uint64_t Percentile) {
auto It = partition_point(DS, [=](const ProfileSummaryEntry &Entry) {
return Entry.Cutoff < Percentile;
}
}
-uint64_t ProfileSummaryBuilder::getHotCountThreshold(SummaryEntryVector &DS) {
+uint64_t
+ProfileSummaryBuilder::getHotCountThreshold(const SummaryEntryVector &DS) {
auto &HotEntry =
ProfileSummaryBuilder::getEntryForPercentile(DS, ProfileSummaryCutoffHot);
uint64_t HotCountThreshold = HotEntry.MinCount;
return HotCountThreshold;
}
-uint64_t ProfileSummaryBuilder::getColdCountThreshold(SummaryEntryVector &DS) {
+uint64_t
+ProfileSummaryBuilder::getColdCountThreshold(const SummaryEntryVector &DS) {
auto &ColdEntry = ProfileSummaryBuilder::getEntryForPercentile(
DS, ProfileSummaryCutoffCold);
uint64_t ColdCountThreshold = ColdEntry.MinCount;
encodeULEB128(Summary->getMaxFunctionCount(), OS);
encodeULEB128(Summary->getNumCounts(), OS);
encodeULEB128(Summary->getNumFunctions(), OS);
- std::vector<ProfileSummaryEntry> &Entries = Summary->getDetailedSummary();
+ const std::vector<ProfileSummaryEntry> &Entries =
+ Summary->getDetailedSummary();
encodeULEB128(Entries.size(), OS);
for (auto Entry : Entries) {
encodeULEB128(Entry.Cutoff, OS);
ASSERT_EQ(2305843009213693952U, IPS.getMaxCount());
ASSERT_EQ(10U, IPS.getNumCounts());
ASSERT_EQ(4539628424389557499U, IPS.getTotalCount());
- std::vector<ProfileSummaryEntry> &Details = IPS.getDetailedSummary();
+ const std::vector<ProfileSummaryEntry> &Details = IPS.getDetailedSummary();
uint32_t Cutoff = 800000;
auto Predicate = [&Cutoff](const ProfileSummaryEntry &PE) {
return PE.Cutoff == Cutoff;
auto Predicate = [&Cutoff](const ProfileSummaryEntry &PE) {
return PE.Cutoff == Cutoff;
};
- std::vector<ProfileSummaryEntry> &Details = Summary.getDetailedSummary();
+ const std::vector<ProfileSummaryEntry> &Details =
+ Summary.getDetailedSummary();
auto EightyPerc = find_if(Details, Predicate);
Cutoff = 900000;
auto NinetyPerc = find_if(Details, Predicate);