[llvm] [PGO] Gracefully handle zero entry-count in `fixFuncEntryCount` (PR #112029)
Michael O'Farrell via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 16 12:47:00 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)
----------------
mofarrell wrote:
Currently the profile data does not track that it originated from sampled instrumentation code. It could be added. Alternatively to skipping fixFuncEntryCount (as implemented here) we could extend the many attempts to ensure the entry block count is never zero to cover the corner case shown in the added unit test.
https://github.com/llvm/llvm-project/pull/112029
More information about the llvm-commits
mailing list