Skip to content

Commit 49dcb70

Browse files
committed
Add BBJ_ALWAYS in fgAlways list
1 parent 134ab01 commit 49dcb70

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

src/coreclr/jit/compiler.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4985,6 +4985,10 @@ class Compiler
49854985

49864986
BlockSet fgEnterBlks; // Set of blocks which have a special transfer of control; the "entry" blocks plus EH handler
49874987
// begin blocks.
4988+
#if defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM)
4989+
BlockSet fgAlwaysBlks; // Set of blocks which are BBJ_ALWAYS part of BBJ_CALLFINALLY/BBJ_ALWAYS pair that should never
4990+
// be removed due to a requirement to use the BBJ_ALWAYS for generating code and not have "retless" blocks.
4991+
#endif // defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM)
49884992

49894993
#ifdef DEBUG
49904994
bool fgReachabilitySetsValid; // Are the bbReach sets valid?

src/coreclr/jit/fgbasic.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ void Compiler::fgInit()
119119
/* This is set by fgComputeReachability */
120120
fgEnterBlks = BlockSetOps::UninitVal();
121121

122+
#if defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM)
123+
fgAlwaysBlks = BlockSetOps::UninitVal();
124+
#endif // defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM)
125+
122126
#ifdef DEBUG
123127
fgEnterBlksSetValid = false;
124128
#endif // DEBUG

src/coreclr/jit/fgopt.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,10 @@ void Compiler::fgComputeEnterBlocksSet()
297297

298298
fgEnterBlks = BlockSetOps::MakeEmpty(this);
299299

300+
#if defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM)
301+
fgAlwaysBlks = BlockSetOps::MakeEmpty(this);
302+
#endif // defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM)
303+
300304
/* Now set the entry basic block */
301305
BlockSetOps::AddElemD(this, fgEnterBlks, fgFirstBB->bbNum);
302306
assert(fgFirstBB->bbNum == 1);
@@ -315,19 +319,15 @@ void Compiler::fgComputeEnterBlocksSet()
315319
}
316320

317321
#if defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM)
318-
// TODO-ARM-Cleanup: The ARM code here to prevent creating retless calls by adding the BBJ_ALWAYS
319-
// to the enter blocks is a bit of a compromise, because sometimes the blocks are already reachable,
320-
// and it messes up DFS ordering to have them marked as enter block. We should prevent the
321-
// creation of retless calls some other way.
322+
// For ARM code, prevent creating retless calls by adding the BBJ_ALWAYS to the "fgAlwaysBlks" list.
322323
for (BasicBlock* const block : Blocks())
323324
{
324325
if (block->bbJumpKind == BBJ_CALLFINALLY)
325326
{
326327
assert(block->isBBCallAlwaysPair());
327-
328-
// Don't remove the BBJ_ALWAYS block that is only here for the unwinder. It might be dead
329-
// if the finally is no-return, so mark it as an entry point.
330-
BlockSetOps::AddElemD(this, fgEnterBlks, block->bbNext->bbNum);
328+
329+
// Don't remove the BBJ_ALWAYS block that is only here for the unwinder.
330+
BlockSetOps::AddElemD(this, fgAlwaysBlks, block->bbNext->bbNum);
331331
}
332332
}
333333
#endif // defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM)
@@ -401,6 +401,13 @@ bool Compiler::fgRemoveUnreachableBlocks()
401401
{
402402
goto SKIP_BLOCK;
403403
}
404+
405+
#if defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM)
406+
if (!BlockSetOps::IsEmptyIntersection(this, fgAlwaysBlks, block->bbReach))
407+
{
408+
goto SKIP_BLOCK;
409+
}
410+
#endif // defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM)
404411
}
405412

406413
// Remove all the code for the block
@@ -637,7 +644,6 @@ void Compiler::fgDfsInvPostOrder()
637644
assert(fgEnterBlksSetValid);
638645

639646
BlockSetOps::UnionD(this, startNodes, fgEnterBlks);
640-
641647
assert(BlockSetOps::IsMember(this, startNodes, fgFirstBB->bbNum));
642648

643649
// Call the flowgraph DFS traversal helper.

0 commit comments

Comments
 (0)