[llvm] [PGO] Gracefully handle zero entry-count in `fixFuncEntryCount` (PR #112029)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 16 17:07:10 PDT 2024
================
@@ -1972,11 +1972,9 @@ static void fixFuncEntryCount(PGOUseFunc &Func, LoopInfo &LI,
BranchProbabilityInfo &NBPI) {
Function &F = Func.getFunc();
BlockFrequencyInfo NBFI(F, NBPI, LI);
-#ifndef NDEBUG
auto BFIEntryCount = F.getEntryCount();
- assert(BFIEntryCount && (BFIEntryCount->getCount() > 0) &&
- "Invalid BFI Entrycount");
-#endif
+ if (!BFIEntryCount || BFIEntryCount->getCount() == 0)
----------------
WenleiHe wrote:
Yeah, given we're doing that already, I think it makes sense to fix it in `populateCounters` -- that code below should be close. Entry should not be zero if there is any count in the function.
```
// Fix the obviously inconsistent entry count.
if (FuncMaxCount > 0 && FuncEntryCount == 0)
FuncEntryCount = 1;
```
https://github.com/llvm/llvm-project/pull/112029
More information about the llvm-commits
mailing list