@@ -1565,8 +1565,8 @@ void Compiler::fgAddSyncMethodEnterExit()
1565
1565
// We need to do this transformation before funclets are created.
1566
1566
assert (!fgFuncletsCreated);
1567
1567
1568
- // Assume we don't need to update the bbPreds lists.
1569
- assert (! fgComputePredsDone);
1568
+ // We need to update the bbPreds lists.
1569
+ assert (fgComputePredsDone);
1570
1570
1571
1571
#if !FEATURE_EH
1572
1572
// If we don't support EH, we can't add the EH needed by synchronized methods.
@@ -1595,6 +1595,7 @@ void Compiler::fgAddSyncMethodEnterExit()
1595
1595
}
1596
1596
1597
1597
// Create a block for the fault.
1598
+ // It gets an artificial ref count.
1598
1599
1599
1600
assert (!tryLastBB->bbFallsThrough ());
1600
1601
BasicBlock* faultBB = fgNewBBafter (BBJ_EHFINALLYRET, tryLastBB, false );
@@ -1603,6 +1604,8 @@ void Compiler::fgAddSyncMethodEnterExit()
1603
1604
assert (faultBB->bbNext == nullptr );
1604
1605
assert (faultBB == fgLastBB);
1605
1606
1607
+ faultBB->bbRefs = 1 ;
1608
+
1606
1609
{ // Scope the EH region creation
1607
1610
1608
1611
// Add the new EH region at the end, since it is the least nested,
@@ -2184,7 +2187,6 @@ class MergedReturns
2184
2187
BasicBlock* CreateReturnBB (unsigned index, GenTreeIntConCommon* returnConst = nullptr )
2185
2188
{
2186
2189
BasicBlock* newReturnBB = comp->fgNewBBinRegion (BBJ_RETURN);
2187
- newReturnBB->bbRefs = 1 ; // bbRefs gets update later, for now it should be 1
2188
2190
comp->fgReturnCount ++;
2189
2191
2190
2192
noway_assert (newReturnBB->bbNext == nullptr );
@@ -2344,6 +2346,7 @@ class MergedReturns
2344
2346
assert ((comp->info .compFlags & CORINFO_FLG_SYNCH) == 0 );
2345
2347
returnBlock->bbJumpKind = BBJ_ALWAYS;
2346
2348
returnBlock->bbJumpDest = constReturnBlock;
2349
+ comp->fgAddRefPred (constReturnBlock, returnBlock);
2347
2350
2348
2351
// Remove GT_RETURN since constReturnBlock returns the constant.
2349
2352
assert (returnBlock->lastStmt ()->GetRootNode ()->OperIs (GT_RETURN));
0 commit comments