Skip to content

Commit de29e26

Browse files
JIT: Synthesize profile data when invalid counts are discarded (#133206)
Edge-count reconstruction can discard stale, malformed, all-zero, or unreconstructable PGO data after profile incorporation has already begun. Running `RepairLikelihoods` afterward preserves the default edge likelihoods as profile-derived, preventing later heuristics from adjusting cold throw paths. Use `ResetAndSynthesize` when incorporation clears `fgPgoHaveWeights`; successfully incorporated profiles continue through repair. > [!NOTE] > This pull request description was generated by GitHub Copilot. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 7e807be commit de29e26

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/coreclr/jit/fgprofile.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3041,10 +3041,19 @@ PhaseStatus Compiler::fgIncorporateProfileData()
30413041
fgIncorporateBlockCounts();
30423042
}
30433043

3044-
// We now always run repair, to get consistent initial counts
3044+
// Repair retains existing likelihoods. If the counts were discarded,
3045+
// start over and let the normal heuristics set them.
30453046
//
3046-
JITDUMP("\nRepairing profile...\n");
3047-
ProfileSynthesis::Run(this, ProfileSynthesisOption::RepairLikelihoods);
3047+
if (fgPgoHaveWeights)
3048+
{
3049+
JITDUMP("\nRepairing profile...\n");
3050+
ProfileSynthesis::Run(this, ProfileSynthesisOption::RepairLikelihoods);
3051+
}
3052+
else
3053+
{
3054+
JITDUMP("\nSynthesizing profile...\n");
3055+
ProfileSynthesis::Run(this, ProfileSynthesisOption::ResetAndSynthesize);
3056+
}
30483057
}
30493058

30503059
#ifdef DEBUG

0 commit comments

Comments
 (0)