diff --git a/src/coreclr/jit/fgprofilesynthesis.cpp b/src/coreclr/jit/fgprofilesynthesis.cpp index d76dcece8220da..2de615136cfeb4 100644 --- a/src/coreclr/jit/fgprofilesynthesis.cpp +++ b/src/coreclr/jit/fgprofilesynthesis.cpp @@ -1289,6 +1289,12 @@ void ProfileSynthesis::GaussSeidelSolver() residual = change; residualBlock = block; } + + if (newWeight >= maxCount) + { + JITDUMP("count overflow in " FMT_BB ": " FMT_WT "\n", block->bbNum, newWeight); + m_overflow = true; + } } // If there were no improper headers, we will have converged in one pass. @@ -1312,6 +1318,11 @@ void ProfileSynthesis::GaussSeidelSolver() break; } + if (m_overflow) + { + break; + } + // If we have been iterating for a bit, estimate the dominant GS // eigenvalue. (we might want to start with Jacobi iterations // to get the Jacobi eigenvalue instead). diff --git a/src/coreclr/jit/fgprofilesynthesis.h b/src/coreclr/jit/fgprofilesynthesis.h index c5e3883bdca000..216bd58297286a 100644 --- a/src/coreclr/jit/fgprofilesynthesis.h +++ b/src/coreclr/jit/fgprofilesynthesis.h @@ -51,6 +51,7 @@ class ProfileSynthesis static constexpr weight_t ilNextLikelihood = 0.52; static constexpr weight_t loopBackLikelihood = 0.9; static constexpr weight_t loopExitLikelihood = 0.9; + static constexpr weight_t maxCount = 1e12; void Run(ProfileSynthesisOption option); @@ -84,6 +85,7 @@ class ProfileSynthesis unsigned m_improperLoopHeaders = 0; unsigned m_cappedCyclicProbabilities = 0; bool m_approximate = false; + bool m_overflow = false; }; #endif // !_FGPROFILESYNTHESIS_H_