Skip to content

Commit 8b6071e

Browse files
JIT: Use fgCalledCount for OSR method entry weight (#112662)
Follow-up to #112499. By ensuring OSR method entry blocks' weights match fgCalledCount during entry canonicalization, we can guarantee that later runs of profile synthesis won't modify fgCalledCount. This should unblock #111915 (comment).
1 parent 9283581 commit 8b6071e

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/coreclr/jit/fgbasic.cpp

+7-12
Original file line numberDiff line numberDiff line change
@@ -4046,18 +4046,13 @@ void Compiler::fgFixEntryFlowForOSR()
40464046

40474047
fgRedirectTargetEdge(fgFirstBB, fgOSREntryBB);
40484048

4049-
// We don't know the right weight for this block, since
4050-
// execution of the method was interrupted within the
4051-
// loop containing fgOSREntryBB.
4052-
//
4053-
// A plausible guess might be to sum the non-backedge
4054-
// weights of fgOSREntryBB and use those, but we don't
4055-
// have edge weights available yet. Note that might be
4056-
// an underestimate.
4057-
//
4058-
// For now we just guess that the loop will execute 100x.
4059-
//
4060-
fgFirstBB->inheritWeightPercentage(fgOSREntryBB, 1);
4049+
fgFirstBB->bbWeight = fgCalledCount;
4050+
fgFirstBB->CopyFlags(fgEntryBB, BBF_PROF_WEIGHT);
4051+
4052+
if (fgCalledCount == BB_ZERO_WEIGHT)
4053+
{
4054+
fgFirstBB->bbSetRunRarely();
4055+
}
40614056

40624057
JITDUMP("OSR: redirecting flow at method entry from " FMT_BB " to OSR entry " FMT_BB " for the importer\n",
40634058
fgFirstBB->bbNum, fgOSREntryBB->bbNum);

0 commit comments

Comments
 (0)