Skip to content

Commit 8fa662c

Browse files
authored
JIT: Remove always-true fgCanRelocateEHRegions (#110612)
1 parent 1622f51 commit 8fa662c

File tree

3 files changed

+54
-60
lines changed

3 files changed

+54
-60
lines changed

src/coreclr/jit/compiler.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4059,8 +4059,6 @@ void Compiler::compSetOptimizationLevel()
40594059
JitMetadata::report(this, JitMetadata::TieringName, tieringName, strlen(tieringName));
40604060
#endif
40614061
}
4062-
4063-
fgCanRelocateEHRegions = true;
40644062
}
40654063

40664064
#if defined(TARGET_ARMARCH) || defined(TARGET_RISCV64)

src/coreclr/jit/compiler.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5332,7 +5332,6 @@ class Compiler
53325332
// - Rationalization links all nodes into linear form which is kept until
53335333
// the end of compilation. The first and last nodes are stored in the block.
53345334
NodeThreading fgNodeThreading = NodeThreading::None;
5335-
bool fgCanRelocateEHRegions; // true if we are allowed to relocate the EH regions
53365335
weight_t fgCalledCount = BB_ZERO_WEIGHT; // count of the number of times this method was called
53375336
// This is derived from the profile data
53385337
// or is BB_UNITY_WEIGHT when we don't have profile data

src/coreclr/jit/jiteh.cpp

Lines changed: 54 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -4397,75 +4397,37 @@ bool Compiler::fgRelocateEHRegions()
43974397
printf("*************** In fgRelocateEHRegions()\n");
43984398
#endif
43994399

4400-
if (fgCanRelocateEHRegions)
4401-
{
4402-
unsigned XTnum;
4403-
EHblkDsc* HBtab;
4400+
unsigned XTnum;
4401+
EHblkDsc* HBtab;
44044402

4405-
for (XTnum = 0, HBtab = compHndBBtab; XTnum < compHndBBtabCount; XTnum++, HBtab++)
4403+
for (XTnum = 0, HBtab = compHndBBtab; XTnum < compHndBBtabCount; XTnum++, HBtab++)
4404+
{
4405+
// Nested EH regions cannot be moved.
4406+
// Also we don't want to relocate an EH region that has a filter
4407+
if ((HBtab->ebdHandlerNestingLevel == 0) && !HBtab->HasFilter())
44064408
{
4407-
// Nested EH regions cannot be moved.
4408-
// Also we don't want to relocate an EH region that has a filter
4409-
if ((HBtab->ebdHandlerNestingLevel == 0) && !HBtab->HasFilter())
4410-
{
4411-
bool movedTry = false;
4409+
bool movedTry = false;
44124410
#if DEBUG
4413-
bool movedHnd = false;
4411+
bool movedHnd = false;
44144412
#endif // DEBUG
44154413

4416-
// Only try to move the outermost try region
4417-
if (HBtab->ebdEnclosingTryIndex == EHblkDsc::NO_ENCLOSING_INDEX)
4418-
{
4419-
// Move the entire try region if it can be moved
4420-
if (HBtab->ebdTryBeg->isRunRarely())
4421-
{
4422-
BasicBlock* bTryLastBB = fgRelocateEHRange(XTnum, FG_RELOCATE_TRY);
4423-
if (bTryLastBB != NULL)
4424-
{
4425-
result = true;
4426-
movedTry = true;
4427-
}
4428-
}
4429-
#if DEBUG
4430-
if (verbose && movedTry)
4431-
{
4432-
printf("\nAfter relocating an EH try region");
4433-
fgDispBasicBlocks();
4434-
fgDispHandlerTab();
4435-
4436-
// Make sure that the predecessor lists are accurate
4437-
if (expensiveDebugCheckLevel >= 2)
4438-
{
4439-
fgDebugCheckBBlist();
4440-
}
4441-
}
4442-
#endif // DEBUG
4443-
}
4444-
4445-
// Currently it is not good to move the rarely run handler regions to the end of the method
4446-
// because fgDetermineFirstColdBlock() must put the start of any handler region in the hot
4447-
// section.
4448-
4449-
#if 0
4450-
// Now try to move the entire handler region if it can be moved.
4451-
// Don't try to move a finally handler unless we already moved the try region.
4452-
if (HBtab->ebdHndBeg->isRunRarely() &&
4453-
!HBtab->ebdHndBeg->hasTryIndex() &&
4454-
(movedTry || !HBtab->HasFinallyHandler()))
4414+
// Only try to move the outermost try region
4415+
if (HBtab->ebdEnclosingTryIndex == EHblkDsc::NO_ENCLOSING_INDEX)
4416+
{
4417+
// Move the entire try region if it can be moved
4418+
if (HBtab->ebdTryBeg->isRunRarely())
44554419
{
4456-
BasicBlock* bHndLastBB = fgRelocateEHRange(XTnum, FG_RELOCATE_HANDLER);
4457-
if (bHndLastBB != NULL)
4420+
BasicBlock* bTryLastBB = fgRelocateEHRange(XTnum, FG_RELOCATE_TRY);
4421+
if (bTryLastBB != NULL)
44584422
{
44594423
result = true;
4460-
movedHnd = true;
4424+
movedTry = true;
44614425
}
44624426
}
4463-
#endif // 0
4464-
44654427
#if DEBUG
4466-
if (verbose && movedHnd)
4428+
if (verbose && movedTry)
44674429
{
4468-
printf("\nAfter relocating an EH handler region");
4430+
printf("\nAfter relocating an EH try region");
44694431
fgDispBasicBlocks();
44704432
fgDispHandlerTab();
44714433

@@ -4477,6 +4439,41 @@ bool Compiler::fgRelocateEHRegions()
44774439
}
44784440
#endif // DEBUG
44794441
}
4442+
4443+
// Currently it is not good to move the rarely run handler regions to the end of the method
4444+
// because fgDetermineFirstColdBlock() must put the start of any handler region in the hot
4445+
// section.
4446+
4447+
#if 0
4448+
// Now try to move the entire handler region if it can be moved.
4449+
// Don't try to move a finally handler unless we already moved the try region.
4450+
if (HBtab->ebdHndBeg->isRunRarely() &&
4451+
!HBtab->ebdHndBeg->hasTryIndex() &&
4452+
(movedTry || !HBtab->HasFinallyHandler()))
4453+
{
4454+
BasicBlock* bHndLastBB = fgRelocateEHRange(XTnum, FG_RELOCATE_HANDLER);
4455+
if (bHndLastBB != NULL)
4456+
{
4457+
result = true;
4458+
movedHnd = true;
4459+
}
4460+
}
4461+
#endif // 0
4462+
4463+
#if DEBUG
4464+
if (verbose && movedHnd)
4465+
{
4466+
printf("\nAfter relocating an EH handler region");
4467+
fgDispBasicBlocks();
4468+
fgDispHandlerTab();
4469+
4470+
// Make sure that the predecessor lists are accurate
4471+
if (expensiveDebugCheckLevel >= 2)
4472+
{
4473+
fgDebugCheckBBlist();
4474+
}
4475+
}
4476+
#endif // DEBUG
44804477
}
44814478
}
44824479

0 commit comments

Comments
 (0)