[llvm] [PGO] Fix incorrect count threshold calculation when 0% cutoff (PR #117359)
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 25 07:21:16 PST 2024
================
@@ -77,9 +77,19 @@ static const uint32_t DefaultCutoffsData[] = {
const ArrayRef<uint32_t> ProfileSummaryBuilder::DefaultCutoffs =
DefaultCutoffsData;
+// An entry for the 0th percentile to correctly calculate hot/cold count
+// thresholds when -profile-summary-cutoff-hot/cold is 0. If the hot cutoff is
+// 0, no sample counts are treated as hot. If the cold cutoff is 0, all sample
+// counts are treated as cold. Assumes there is no UINT64_MAX sample counts.
+static const ProfileSummaryEntry ZeroCutoffEntry = {0, UINT64_MAX, 0};
+
const ProfileSummaryEntry &
ProfileSummaryBuilder::getEntryForPercentile(const SummaryEntryVector &DS,
uint64_t Percentile) {
+ if (Percentile == 0) {
----------------
mtrofin wrote:
Nit: you can drop the curly braces here.
https://github.com/llvm/llvm-project/pull/117359
More information about the llvm-commits
mailing list