Skip to content

Commit

Permalink
JIT: Use fgCalledCount in inlinee weight computation (#112499)
Browse files Browse the repository at this point in the history
I noticed that tweaking the computation of the entry weight for OSR methods (in service of #111915) incurred large inlining diffs. This is due to the fact that we use the entry block's weight to compute the normalized weight of a call site. This means we will get the wrong normalized weight for call sites when the entry block's weight diverges from the method's call count. This is currently possible only when the entry block is part of a loop, or when we compute a weight for the OSR entry fixup block that differs from fgCalledCount (which we almost always do). The correct thing to do is to use the root method's call count to normalize the call site's weight.
  • Loading branch information
amanasifkhalid authored Feb 18, 2025
1 parent d086ec6 commit c37cfcc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12940,7 +12940,7 @@ void Compiler::impMakeDiscretionaryInlineObservations(InlineInfo* pInlineInfo, I
if ((pInlineInfo != nullptr) && rootCompiler->fgHaveSufficientProfileWeights())
{
const weight_t callSiteWeight = pInlineInfo->iciBlock->bbWeight;
const weight_t entryWeight = rootCompiler->fgFirstBB->bbWeight;
const weight_t entryWeight = rootCompiler->fgCalledCount;
profileFreq = fgProfileWeightsEqual(entryWeight, 0.0) ? 0.0 : callSiteWeight / entryWeight;
hasProfile = true;

Expand Down

0 comments on commit c37cfcc

Please sign in to comment.