Skip to content

Commit c37cfcc

Browse files
JIT: Use fgCalledCount in inlinee weight computation (#112499)
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.
1 parent d086ec6 commit c37cfcc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/coreclr/jit/importer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12940,7 +12940,7 @@ void Compiler::impMakeDiscretionaryInlineObservations(InlineInfo* pInlineInfo, I
1294012940
if ((pInlineInfo != nullptr) && rootCompiler->fgHaveSufficientProfileWeights())
1294112941
{
1294212942
const weight_t callSiteWeight = pInlineInfo->iciBlock->bbWeight;
12943-
const weight_t entryWeight = rootCompiler->fgFirstBB->bbWeight;
12943+
const weight_t entryWeight = rootCompiler->fgCalledCount;
1294412944
profileFreq = fgProfileWeightsEqual(entryWeight, 0.0) ? 0.0 : callSiteWeight / entryWeight;
1294512945
hasProfile = true;
1294612946

0 commit comments

Comments
 (0)