/// inlined in it.
uint64_t getMaxCountInside() const {
uint64_t MaxCount = 0;
- for (const auto &L : getBodySamples()) {
+ for (const auto &L : getBodySamples())
MaxCount = std::max(MaxCount, L.second.getSamples());
- }
- for (const auto &C : getCallsiteSamples()) {
- for (const auto &F : C.second) {
+ for (const auto &C : getCallsiteSamples())
+ for (const FunctionSamplesMap::value_type &F : C.second)
MaxCount = std::max(MaxCount, F.second.getMaxCountInside());
- }
- }
return MaxCount;
}
-; RUN: llvm-profdata show --sample --hot-func-list %S/Inputs/sample-hot-func-list.proftext | FileCheck %s
-; CHECK: 8 out of 10 functions with profile (80.00%) are considered hot functions (max sample >= 470).
-; CHECK-NEXT: 355251 out of 356026 profile counts (99.78%) are from hot functions.
-; CHECK-NEXT: Total sample (%) Max sample Entry sample Function name
-; CHECK-NEXT: 184019 (51.69%) 2300 534 main
-; CHECK-NEXT: 97401 (27.36%) 10640 3035 Func3
-; CHECK-NEXT: 20305 (5.70%) 1000 1000 _Z3bazi
-; CHECK-NEXT: 20301 (5.70%) 1437 1437 _Z3bari
-; CHECK-NEXT: 17043 (4.79%) 3105 1594 Func2
-; CHECK-NEXT: 7711 (2.17%) 610 610 _Z3fooi
-; CHECK-NEXT: 6948 (1.95%) 3507 470 Func5
-; CHECK-NEXT: 1523 (0.43%) 563 169 Func1
+; RUN: llvm-profdata show --sample --hot-func-list %S/Inputs/sample-hot-func-list.proftext | FileCheck %s --match-full-lines --strict-whitespace
+
+; CHECK:8 out of 10 functions with profile (80.00%) are considered hot functions (max sample >= 470).
+; CHECK-NEXT:355251 out of 356026 profile counts (99.78%) are from hot functions.
+; CHECK-NEXT: Total sample (%) Max sample Entry sample Function name
+; CHECK-NEXT: 184019 (51.69%) 2300 534 main
+; CHECK-NEXT: 97401 (27.36%) 10640 3035 Func3
+; CHECK-NEXT: 20305 (5.70%) 1000 1000 _Z3bazi
+; CHECK-NEXT: 20301 (5.70%) 1437 1437 _Z3bari
+; CHECK-NEXT: 17043 (4.79%) 3105 1594 Func2
+; CHECK-NEXT: 7711 (2.17%) 610 610 _Z3fooi
+; CHECK-NEXT: 6948 (1.95%) 3507 470 Func5
+; CHECK-NEXT: 1523 (0.43%) 563 169 Func1
}
}
+namespace {
struct HotFuncInfo {
StringRef FuncName;
uint64_t TotalCount;
: FuncName(FN), TotalCount(TS), TotalCountPercent(TSP), MaxCount(MS),
EntryCount(ES) {}
};
+} // namespace
// Print out detailed information about hot functions in PrintValues vector.
// Users specify titles and offset of every columns through ColumnTitle and
}
FOS << "\n";
- for (const auto &R : PrintValues) {
+ for (const HotFuncInfo &R : PrintValues) {
FOS.PadToColumn(ColumnOffset[0]);
FOS << R.TotalCount << " (" << format("%.2f%%", R.TotalCountPercent) << ")";
FOS.PadToColumn(ColumnOffset[1]);
const uint32_t HotFuncCutoff = 990000;
auto &SummaryVector = PS.getDetailedSummary();
uint64_t MinCountThreshold = 0;
- for (const auto &SummaryEntry : SummaryVector) {
+ for (const ProfileSummaryEntry &SummaryEntry : SummaryVector) {
if (SummaryEntry.Cutoff == HotFuncCutoff) {
MinCountThreshold = SummaryEntry.MinCount;
break;
uint64_t HotFuncCount = 0;
uint64_t MaxCount = 0;
for (const auto &I : Profiles) {
- const auto &FuncProf = I.second;
+ const FunctionSamples &FuncProf = I.second;
ProfileTotalSample += FuncProf.getTotalSamples();
MaxCount = FuncProf.getMaxCountInside();
std::string("max sample >= ") + std::to_string(MinCountThreshold);
std::vector<HotFuncInfo> PrintValues;
for (const auto &FuncPair : HotFunc) {
- const auto &FuncPtr = FuncPair.second.first;
+ const FunctionSamples &Func = *FuncPair.second.first;
double TotalSamplePercent =
(ProfileTotalSample > 0)
- ? (FuncPtr->getTotalSamples() * 100.0) / ProfileTotalSample
+ ? (Func.getTotalSamples() * 100.0) / ProfileTotalSample
: 0;
PrintValues.emplace_back(HotFuncInfo(
- FuncPtr->getFuncName(), FuncPtr->getTotalSamples(), TotalSamplePercent,
- FuncPair.second.second, FuncPtr->getEntrySamples()));
+ Func.getFuncName(), Func.getTotalSamples(), TotalSamplePercent,
+ FuncPair.second.second, Func.getEntrySamples()));
}
dumpHotFunctionList(ColumnTitle, ColumnOffset, PrintValues, HotFuncCount,
Profiles.size(), HotFuncSample, ProfileTotalSample,