[llvm] [PGO] Ensure non-zero entry-count after `populateCounters` (PR #112029)
Michael O'Farrell via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 18 09:27:00 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)
----------------
mofarrell wrote:
FWIW I went this route because there are already similar feeble attempts elsewhere. Like when loading the profile (but it only works if the entry block was chosen for instrumentation): https://github.com/llvm/llvm-project/blob/abfdcb663983eaa8c7ce0d03a3c6440c5fc97e9a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp#L1279-L1280
That does factor in to the MaxCount at the end of the day though.
https://github.com/llvm/llvm-project/pull/112029
More information about the llvm-commits
mailing list