Skip to content

Commit a344abd

Browse files
authored
JIT: fix stress issue with profile consistency (#101259)
In rare cases profile stress will put weight on unreachable preds of loop blocks, throwing off the cyclic probability computations. Fix by ignoring such preds.
1 parent 3b1836c commit a344abd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/coreclr/jit/fgprofilesynthesis.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,12 @@ void ProfileSynthesis::ComputeCyclicProbabilities(FlowGraphNaturalLoop* loop)
811811

812812
for (FlowEdge* const edge : block->PredEdges())
813813
{
814-
if (BasicBlock::sameHndRegion(block, edge->getSourceBlock()))
814+
BasicBlock* const sourceBlock = edge->getSourceBlock();
815+
816+
// Ignore flow across EH, or from preds not in the loop.
817+
// Latter can happen if there are unreachable blocks that flow into the loop.
818+
//
819+
if (BasicBlock::sameHndRegion(block, sourceBlock) && loop->ContainsBlock(sourceBlock))
815820
{
816821
newWeight += edge->getLikelyWeight();
817822
}

0 commit comments

Comments
 (0)