[llvm] [PGO] Ensure non-zero entry-count after `populateCounters` (PR #112029)

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 17 14:26:49 PDT 2024


================
@@ -1624,8 +1624,12 @@ void PGOUseFunc::populateCounters() {
     FuncMaxCount = std::max(FuncMaxCount, *BI->Count);
   }
 
-  // Fix the obviously inconsistent entry count.
-  if (FuncMaxCount > 0 && FuncEntryCount == 0)
+  // Fix the obviously inconsistent entry count.  A function that has all zero
+  // counters will skip populating the counters so a minimum entry count of 1
+  // makes sense.  Note that the presence of a non-zero counter does not imply
+  // FuncMaxCount is greater than zero because the only non-zero counts could
+  // be for select instrumentation which is handled later.
+  if (FuncEntryCount == 0)
----------------
WenleiHe wrote:

Can we somehow "fix" FuncMaxCount here instead? Sorry if I wasn't clear earlier, but I think Max count should consider any count including those from select. 

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


More information about the llvm-commits mailing list