|
19 | 19 | #include "llvm/IR/Module.h"
|
20 | 20 | #include "llvm/IR/ProfileSummary.h"
|
21 | 21 | #include "llvm/InitializePasses.h"
|
| 22 | +#include "llvm/ProfileData/ProfileCommon.h" |
22 | 23 | #include "llvm/Support/CommandLine.h"
|
23 | 24 | using namespace llvm;
|
24 | 25 |
|
@@ -86,19 +87,6 @@ static cl::opt<double> PartialSampleProfileWorkingSetSizeScaleFactor(
|
86 | 87 | "and the factor to scale the working set size to use the same "
|
87 | 88 | "shared thresholds as PGO."));
|
88 | 89 |
|
89 |
| -// Find the summary entry for a desired percentile of counts. |
90 |
| -static const ProfileSummaryEntry &getEntryForPercentile(SummaryEntryVector &DS, |
91 |
| - uint64_t Percentile) { |
92 |
| - auto It = partition_point(DS, [=](const ProfileSummaryEntry &Entry) { |
93 |
| - return Entry.Cutoff < Percentile; |
94 |
| - }); |
95 |
| - // The required percentile has to be <= one of the percentiles in the |
96 |
| - // detailed summary. |
97 |
| - if (It == DS.end()) |
98 |
| - report_fatal_error("Desired percentile exceeds the maximum cutoff"); |
99 |
| - return *It; |
100 |
| -} |
101 |
| - |
102 | 90 | // The profile summary metadata may be attached either by the frontend or by
|
103 | 91 | // any backend passes (IR level instrumentation, for example). This method
|
104 | 92 | // checks if the Summary is null and if so checks if the summary metadata is now
|
@@ -284,13 +272,13 @@ bool ProfileSummaryInfo::isFunctionEntryCold(const Function *F) const {
|
284 | 272 | /// Compute the hot and cold thresholds.
|
285 | 273 | void ProfileSummaryInfo::computeThresholds() {
|
286 | 274 | auto &DetailedSummary = Summary->getDetailedSummary();
|
287 |
| - auto &HotEntry = |
288 |
| - getEntryForPercentile(DetailedSummary, ProfileSummaryCutoffHot); |
| 275 | + auto &HotEntry = ProfileSummaryBuilder::getEntryForPercentile( |
| 276 | + DetailedSummary, ProfileSummaryCutoffHot); |
289 | 277 | HotCountThreshold = HotEntry.MinCount;
|
290 | 278 | if (ProfileSummaryHotCount.getNumOccurrences() > 0)
|
291 | 279 | HotCountThreshold = ProfileSummaryHotCount;
|
292 |
| - auto &ColdEntry = |
293 |
| - getEntryForPercentile(DetailedSummary, ProfileSummaryCutoffCold); |
| 280 | + auto &ColdEntry = ProfileSummaryBuilder::getEntryForPercentile( |
| 281 | + DetailedSummary, ProfileSummaryCutoffCold); |
294 | 282 | ColdCountThreshold = ColdEntry.MinCount;
|
295 | 283 | if (ProfileSummaryColdCount.getNumOccurrences() > 0)
|
296 | 284 | ColdCountThreshold = ProfileSummaryColdCount;
|
@@ -324,8 +312,8 @@ ProfileSummaryInfo::computeThreshold(int PercentileCutoff) const {
|
324 | 312 | return iter->second;
|
325 | 313 | }
|
326 | 314 | auto &DetailedSummary = Summary->getDetailedSummary();
|
327 |
| - auto &Entry = |
328 |
| - getEntryForPercentile(DetailedSummary, PercentileCutoff); |
| 315 | + auto &Entry = ProfileSummaryBuilder::getEntryForPercentile(DetailedSummary, |
| 316 | + PercentileCutoff); |
329 | 317 | uint64_t CountThreshold = Entry.MinCount;
|
330 | 318 | ThresholdCache[PercentileCutoff] = CountThreshold;
|
331 | 319 | return CountThreshold;
|
|
0 commit comments