Skip to content

Commit

Permalink
JIT: Remove implicit fallthrough assumption in `fgExpandRarelyRunBloc…
Browse files Browse the repository at this point in the history
…ks` (dotnet#107350)
  • Loading branch information
amanasifkhalid authored Sep 5, 2024
1 parent 40cafd7 commit 0961328
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/coreclr/jit/fgopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3126,7 +3126,7 @@ bool Compiler::fgExpandRarelyRunBlocks()
break;

case BBJ_COND:
if (block->isRunRarely() && bPrev->GetTrueTarget()->isRunRarely())
if (bPrev->GetTrueTarget()->isRunRarely() && bPrev->GetFalseTarget()->isRunRarely())
{
INDEBUG(reason = "Both sides of a conditional jump are rarely run");
setRarelyRun = true;
Expand Down Expand Up @@ -3230,21 +3230,13 @@ bool Compiler::fgExpandRarelyRunBlocks()
}
}

/* COMPACT blocks if possible */
if (fgCanCompactBlock(bPrev))
{
fgCompactBlock(bPrev);

block = bPrev;
continue;
}
//
// if bPrev->bbWeight is not based upon profile data we can adjust
// the weights of bPrev and block
//
else if (bPrev->isBBCallFinallyPair() && // we must have a BBJ_CALLFINALLY and BBJ_CALLFINALLYRET pair
(bPrev->bbWeight != block->bbWeight) && // the weights are currently different
!bPrev->hasProfileWeight()) // and the BBJ_CALLFINALLY block is not using profiled weights
if (bPrev->isBBCallFinallyPair() && // we must have a BBJ_CALLFINALLY and BBJ_CALLFINALLYRET pair
(bPrev->bbWeight != block->bbWeight) && // the weights are currently different
!bPrev->hasProfileWeight()) // and the BBJ_CALLFINALLY block is not using profiled weights
{
if (block->isRunRarely())
{
Expand Down

0 comments on commit 0961328

Please sign in to comment.