@@ -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