[llvm] [PGO][profcheck] ignore explicitly cold functions (PR #151778)
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 2 08:41:53 PDT 2025
================
@@ -63,6 +67,17 @@ bool ProfileInjector::inject() {
// will get the same BPI it does if the injector wasn't running.
auto &BPI = FAM.getResult<BranchProbabilityAnalysis>(F);
+ // Inject a function count if there's none. It's reasonable for a pass to
+ // want to clear the MD_prof of a function with zero entry count. From a
+ // metadata economy perspective, if a profile comes empty for a function, it's
+ // cheaper to assign it the 0-entry count explicitly than to mark every branch
+ // as cold.
+ if (!F.getEntryCount(true))
+ F.setEntryCount(DefaultFunctionEntryCount);
+ // If there is an entry count that's 0, then don't bother injecting. We won't
+ // verify these either.
+ if (F.getEntryCount(true)->getCount() == 0)
----------------
mtrofin wrote:
I did it though for the usage in the verifier
https://github.com/llvm/llvm-project/pull/151778
More information about the llvm-commits
mailing list