[llvm] [PGO] Fix incorrect count threshold calculation when 0% cutoff (PR #117359)

Ken Matsui via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 9 11:35:13 PST 2024


================
@@ -77,9 +77,18 @@ 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.
----------------
ken-matsui wrote:

Actually, it is not a typo.

* `-profile-summary-cutoff-hot`: A count is hot if it exceeds the minimum count to reach this percentile of total counts.
* `-profile-summary-cutoff-cold`: A count is cold if it is below the minimum count to reach this percentile of total counts.

When cutoff is 0, the minimum count is UINT64_MAX. So, when a count exceeds UINT64_MAX, it is hot, meaning no counts are hot. Similarly, when a count is below UINT64_MAX, it is cold, meaning all counts are cold.

https://github.com/llvm/llvm-project/pull/117359


More information about the llvm-commits mailing list