Skip to content

Commit

Permalink
JIT: Update profile data for continuation block of removed call-final…
Browse files Browse the repository at this point in the history
…ly (#110327)

Fixes #110317. Follow-up to #109792. When removing a call-finally pair associated with an empty try region, decrement any flow from the pair into the continuation block, and add any flow from the now-inlined finally region's exit(s) into the continuation block.
  • Loading branch information
amanasifkhalid authored Dec 2, 2024
1 parent 8106feb commit 758bbc6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/coreclr/jit/fgehopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,12 @@ PhaseStatus Compiler::fgRemoveEmptyTry()
fgPrepareCallFinallyRetForRemoval(leave);
fgRemoveBlock(leave, /* unreachable */ true);

// Remove profile weight into the continuation block
if (continuation->hasProfileWeight())
{
continuation->setBBProfileWeight(max(0.0, continuation->bbWeight - leave->bbWeight));
}

// (3) Convert the callfinally to a normal jump to the handler
assert(callFinally->HasInitializedTarget());
callFinally->SetKind(BBJ_ALWAYS);
Expand Down Expand Up @@ -695,6 +701,12 @@ PhaseStatus Compiler::fgRemoveEmptyTry()
fgRemoveStmt(block, finallyRet);
FlowEdge* const newEdge = fgAddRefPred(continuation, block);
block->SetKindAndTargetEdge(BBJ_ALWAYS, newEdge);

// Propagate profile weight into the continuation block
if (continuation->hasProfileWeight())
{
continuation->setBBProfileWeight(continuation->bbWeight + block->bbWeight);
}
}
}

Expand Down

0 comments on commit 758bbc6

Please sign in to comment.