Skip to content

Commit e98dca2

Browse files
committed
don't use pred assertions from unreachables
1 parent 6a07b54 commit e98dca2

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/coreclr/jit/compiler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4799,7 +4799,7 @@ class Compiler
47994799
FoldResult fgFoldConditional(BasicBlock* block);
48004800

48014801
PhaseStatus fgMorphBlocks();
4802-
void fgMorphBlock(BasicBlock* block);
4802+
void fgMorphBlock(BasicBlock* block, unsigned highestReachablePostorder = 0);
48034803
void fgMorphStmts(BasicBlock* block);
48044804

48054805
void fgMergeBlockReturn(BasicBlock* block);

src/coreclr/jit/morph.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13772,8 +13772,10 @@ void Compiler::fgMorphStmts(BasicBlock* block)
1377213772
//
1377313773
// Arguments:
1377413774
// block - block in question
13775+
// highestReachablePostorder - maximum postorder number for a
13776+
// reachable block.
1377513777
//
13776-
void Compiler::fgMorphBlock(BasicBlock* block)
13778+
void Compiler::fgMorphBlock(BasicBlock* block, unsigned highestReachablePostorder)
1377713779
{
1377813780
JITDUMP("\nMorphing " FMT_BB "\n", block->bbNum);
1377913781

@@ -13788,6 +13790,8 @@ void Compiler::fgMorphBlock(BasicBlock* block)
1378813790
}
1378913791
else
1379013792
{
13793+
assert(highestReachablePostorder > 0);
13794+
1379113795
// Determine if this block can leverage assertions from its pred blocks.
1379213796
//
1379313797
// Some blocks are ineligible.
@@ -13818,6 +13822,14 @@ void Compiler::fgMorphBlock(BasicBlock* block)
1381813822
break;
1381913823
}
1382013824

13825+
if (pred->bbPostorderNum > highestReachablePostorder)
13826+
{
13827+
// This pred was not reachable from the original DFS root set, so
13828+
// we can ignore its assertion information.
13829+
//
13830+
continue;
13831+
}
13832+
1382113833
// Yes, pred assertions are available. If this is the first pred, copy.
1382213834
// If this is a subsequent pred, intersect.
1382313835
//
@@ -13939,7 +13951,7 @@ PhaseStatus Compiler::fgMorphBlocks()
1393913951
// We are optimizing. Process in RPO.
1394013952
//
1394113953
fgRenumberBlocks();
13942-
fgDfsReversePostorder();
13954+
const unsigned highestReachablePostorder = fgDfsReversePostorder();
1394313955

1394413956
// Disallow general creation of new blocks or edges as it
1394513957
// would invalidate RPO.
@@ -13971,7 +13983,7 @@ PhaseStatus Compiler::fgMorphBlocks()
1397113983
for (unsigned i = 1; i <= bbNumMax; i++)
1397213984
{
1397313985
BasicBlock* const block = fgBBReversePostorder[i];
13974-
fgMorphBlock(block);
13986+
fgMorphBlock(block, highestReachablePostorder);
1397513987
}
1397613988
assert(bbNumMax == fgBBNumMax);
1397713989

0 commit comments

Comments
 (0)