Skip to content

Commit adc9777

Browse files
JIT: Don't move EH entry block to enable branch reversal during flow opts (#117618)
Fixes #117581.
1 parent 5888837 commit adc9777

File tree

3 files changed

+3
-15
lines changed

3 files changed

+3
-15
lines changed

src/coreclr/jit/compiler.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6153,8 +6153,6 @@ class Compiler
61536153

61546154
bool fgExpandRarelyRunBlocks();
61556155

6156-
bool fgEhAllowsMoveBlock(BasicBlock* bBefore, BasicBlock* bAfter);
6157-
61586156
void fgMoveBlocksAfter(BasicBlock* bStart, BasicBlock* bEnd, BasicBlock* insertAfterBlk);
61596157

61606158
PhaseStatus fgHeadTailMerge(bool early);

src/coreclr/jit/fgbasic.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5309,18 +5309,6 @@ bool Compiler::fgIsForwardBranch(BasicBlock* bJump, BasicBlock* bDest, BasicBloc
53095309
return result;
53105310
}
53115311

5312-
/*****************************************************************************
5313-
*
5314-
* Returns true if it is allowable (based upon the EH regions)
5315-
* to place block bAfter immediately after bBefore. It is allowable
5316-
* if the 'bBefore' and 'bAfter' blocks are in the exact same EH region.
5317-
*/
5318-
5319-
bool Compiler::fgEhAllowsMoveBlock(BasicBlock* bBefore, BasicBlock* bAfter)
5320-
{
5321-
return BasicBlock::sameEHRegion(bBefore, bAfter);
5322-
}
5323-
53245312
/*****************************************************************************
53255313
*
53265314
* Function called to move the range of blocks [bStart .. bEnd].

src/coreclr/jit/fgopt.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4517,8 +4517,10 @@ bool Compiler::fgUpdateFlowGraph(bool doTailDuplication /* = false */, bool isPh
45174517
{
45184518
// In the join free case, we also need to move bDest right after bNext
45194519
// to create same flow as in the isJumpAroundEmpty case.
4520+
// However, we cannot move bDest if it will break EH invariants.
45204521
//
4521-
if (!fgEhAllowsMoveBlock(bNext, bDest) || bDest->isBBCallFinallyPair())
4522+
if (!BasicBlock::sameEHRegion(bNext, bDest) || bbIsTryBeg(bDest) || bbIsHandlerBeg(bDest) ||
4523+
bDest->isBBCallFinallyPair())
45224524
{
45234525
optimizeJump = false;
45244526
}

0 commit comments

Comments
 (0)