From 4e626e2dccf5060ab9c50dc3a9baab547ee2b31e Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Mon, 6 May 2024 17:08:10 -0700 Subject: [PATCH] JIT: fix STRESS_BB_PROFILE issue (#101925) Incorporate "stress" profile counts even if we're not optimizing. Scale after synthesis, not before. Fixes #101901. --- src/coreclr/jit/fgprofile.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/coreclr/jit/fgprofile.cpp b/src/coreclr/jit/fgprofile.cpp index 1afd6bcda7631..4fcf748416d7a 100644 --- a/src/coreclr/jit/fgprofile.cpp +++ b/src/coreclr/jit/fgprofile.cpp @@ -2846,22 +2846,14 @@ PhaseStatus Compiler::fgInstrumentMethod() // PhaseStatus Compiler::fgIncorporateProfileData() { - // For now we only rely on profile data when optimizing. - // - if (!opts.OptimizationEnabled()) - { - JITDUMP("not optimizing, so not incorporating any profile data\n"); - return PhaseStatus::MODIFIED_NOTHING; - } - // Are we doing profile stress? // if (fgStressBBProf() > 0) { JITDUMP("JitStress -- incorporating random profile data\n"); fgIncorporateBlockCounts(); - fgApplyProfileScale(); ProfileSynthesis::Run(this, ProfileSynthesisOption::RepairLikelihoods); + fgApplyProfileScale(); return PhaseStatus::MODIFIED_EVERYTHING; } @@ -2882,6 +2874,7 @@ PhaseStatus Compiler::fgIncorporateProfileData() { JITDUMP("Synthesizing profile data\n"); ProfileSynthesis::Run(this, ProfileSynthesisOption::AssignLikelihoods); + fgApplyProfileScale(); return PhaseStatus::MODIFIED_EVERYTHING; } } @@ -2893,6 +2886,7 @@ PhaseStatus Compiler::fgIncorporateProfileData() { JITDUMP("Synthesizing profile data and writing it out as the actual profile data\n"); ProfileSynthesis::Run(this, ProfileSynthesisOption::AssignLikelihoods); + fgApplyProfileScale(); return PhaseStatus::MODIFIED_EVERYTHING; } #endif