Skip to content

JIT: Remove fgRelocateEHRegions #113330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -6165,9 +6165,6 @@ class Compiler
void fgInsertFuncletPrologBlock(BasicBlock* block);
void fgCreateFuncletPrologBlocks();
PhaseStatus fgCreateFunclets();
#if defined(FEATURE_EH_WINDOWS_X86)
bool fgRelocateEHRegions();
#endif // FEATURE_EH_WINDOWS_X86

bool fgOptimizeUncondBranchToSimpleCond(BasicBlock* block, BasicBlock* target);
bool fgFoldSimpleCondByForwardSub(BasicBlock* block);
Expand Down
7 changes: 0 additions & 7 deletions src/coreclr/jit/fgopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3283,13 +3283,6 @@ bool Compiler::fgReorderBlocks(bool useProfile)
// First let us expand the set of run rarely blocks
newRarelyRun |= fgExpandRarelyRunBlocks();

#if defined(FEATURE_EH_WINDOWS_X86)
if (!UsesFunclets())
{
movedBlocks |= fgRelocateEHRegions();
}
#endif // FEATURE_EH_WINDOWS_X86

if (useProfile)
{
// Don't run the new layout until we get to the backend,
Expand Down
118 changes: 0 additions & 118 deletions src/coreclr/jit/jiteh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4386,124 +4386,6 @@ bool Compiler::fgAnyIntraHandlerPreds(BasicBlock* block)
return false;
}

#if defined(FEATURE_EH_WINDOWS_X86)

/*****************************************************************************
*
* Function called to relocate any and all EH regions.
* Only entire consecutive EH regions will be moved and they will be kept together.
* Except for the first block, the range can not have any blocks that jump into or out of the region.
*/

bool Compiler::fgRelocateEHRegions()
{
bool result = false; // Our return value

assert(!UsesFunclets());

#ifdef DEBUG
if (verbose)
printf("*************** In fgRelocateEHRegions()\n");
#endif

unsigned XTnum;
EHblkDsc* HBtab;

for (XTnum = 0, HBtab = compHndBBtab; XTnum < compHndBBtabCount; XTnum++, HBtab++)
{
// Nested EH regions cannot be moved.
// Also we don't want to relocate an EH region that has a filter
if ((HBtab->ebdHandlerNestingLevel == 0) && !HBtab->HasFilter())
{
bool movedTry = false;
#if DEBUG
bool movedHnd = false;
#endif // DEBUG

// Only try to move the outermost try region
if (HBtab->ebdEnclosingTryIndex == EHblkDsc::NO_ENCLOSING_INDEX)
{
// Move the entire try region if it can be moved
if (HBtab->ebdTryBeg->isRunRarely())
{
BasicBlock* bTryLastBB = fgRelocateEHRange(XTnum, FG_RELOCATE_TRY);
if (bTryLastBB != NULL)
{
result = true;
movedTry = true;
}
}
#if DEBUG
if (verbose && movedTry)
{
printf("\nAfter relocating an EH try region");
fgDispBasicBlocks();
fgDispHandlerTab();

// Make sure that the predecessor lists are accurate
if (expensiveDebugCheckLevel >= 2)
{
fgDebugCheckBBlist();
}
}
#endif // DEBUG
}

// Currently it is not good to move the rarely run handler regions to the end of the method
// because fgDetermineFirstColdBlock() must put the start of any handler region in the hot
// section.

#if 0
// Now try to move the entire handler region if it can be moved.
// Don't try to move a finally handler unless we already moved the try region.
if (HBtab->ebdHndBeg->isRunRarely() &&
!HBtab->ebdHndBeg->hasTryIndex() &&
(movedTry || !HBtab->HasFinallyHandler()))
{
BasicBlock* bHndLastBB = fgRelocateEHRange(XTnum, FG_RELOCATE_HANDLER);
if (bHndLastBB != NULL)
{
result = true;
movedHnd = true;
}
}
#endif // 0

#if DEBUG
if (verbose && movedHnd)
{
printf("\nAfter relocating an EH handler region");
fgDispBasicBlocks();
fgDispHandlerTab();

// Make sure that the predecessor lists are accurate
if (expensiveDebugCheckLevel >= 2)
{
fgDebugCheckBBlist();
}
}
#endif // DEBUG
}
}

#if DEBUG
fgVerifyHandlerTab();

if (verbose && result)
{
printf("\nAfter fgRelocateEHRegions()");
fgDispBasicBlocks();
fgDispHandlerTab();
// Make sure that the predecessor lists are accurate
fgDebugCheckBBlist();
}
#endif // DEBUG

return result;
}

#endif // FEATURE_EH_WINDOWS_X86

//------------------------------------------------------------------------
// fgExtendEHRegionBefore: Modify the EH table to account for a new block.
//
Expand Down
Loading