@@ -28,10 +28,6 @@ size_t BasicBlock::s_Count;
2828// The max # of tree nodes in any BB
2929/* static */
3030unsigned BasicBlock::s_nMaxTrees;
31-
32- // Temporary target to initialize blocks with jumps
33- /* static */
34- BasicBlock BasicBlock::bbTempJumpDest;
3531#endif // DEBUG
3632
3733#ifdef DEBUG
@@ -1449,14 +1445,14 @@ bool BasicBlock::endsWithTailCallConvertibleToLoop(Compiler* comp, GenTree** tai
14491445 * Allocate a basic block but don't append it to the current BB list.
14501446 */
14511447
1452- BasicBlock* Compiler ::bbNewBasicBlock ()
1448+ BasicBlock* BasicBlock ::bbNewBasicBlock (Compiler* compiler )
14531449{
14541450 BasicBlock* block;
14551451
14561452 /* Allocate the block descriptor and zero it out */
1457- assert (fgSafeBasicBlockCreation);
1453+ assert (compiler-> fgSafeBasicBlockCreation );
14581454
1459- block = new (this , CMK_BasicBlock) BasicBlock;
1455+ block = new (compiler , CMK_BasicBlock) BasicBlock;
14601456
14611457#if MEASURE_BLOCK_SIZE
14621458 BasicBlock::s_Count += 1 ;
@@ -1465,7 +1461,7 @@ BasicBlock* Compiler::bbNewBasicBlock()
14651461
14661462#ifdef DEBUG
14671463 // fgLookupBB() is invalid until fgInitBBLookup() is called again.
1468- fgBBs = (BasicBlock**) 0xCDCD ;
1464+ compiler-> fgInvalidateBBLookup () ;
14691465#endif
14701466
14711467 // TODO-Throughput: The following memset is pretty expensive - do something else?
@@ -1479,15 +1475,15 @@ BasicBlock* Compiler::bbNewBasicBlock()
14791475 block->bbCodeOffsEnd = BAD_IL_OFFSET;
14801476
14811477#ifdef DEBUG
1482- block->bbID = compBasicBlockID++;
1478+ block->bbID = compiler-> compBasicBlockID ++;
14831479#endif
14841480
14851481 /* Give the block a number, set the ancestor count and weight */
14861482
1487- ++fgBBcount;
1488- block->bbNum = ++fgBBNumMax;
1483+ ++compiler-> fgBBcount ;
1484+ block->bbNum = ++compiler-> fgBBNumMax ;
14891485
1490- if (compRationalIRForm)
1486+ if (compiler-> compRationalIRForm )
14911487 {
14921488 block->bbFlags |= BBF_IS_LIR;
14931489 }
@@ -1501,7 +1497,7 @@ BasicBlock* Compiler::bbNewBasicBlock()
15011497 block->bbEntryState = nullptr ;
15021498
15031499#ifdef DEBUG
1504- if (verbose)
1500+ if (compiler-> verbose )
15051501 {
15061502 printf (" New Basic Block %s created.\n " , block->dspToString ());
15071503 }
@@ -1510,21 +1506,21 @@ BasicBlock* Compiler::bbNewBasicBlock()
15101506 // We will give all the blocks var sets after the number of tracked variables
15111507 // is determined and frozen. After that, if we dynamically create a basic block,
15121508 // we will initialize its var sets.
1513- if (fgBBVarSetsInited)
1509+ if (compiler-> fgBBVarSetsInited )
15141510 {
1515- VarSetOps::AssignNoCopy (this , block->bbVarUse , VarSetOps::MakeEmpty (this ));
1516- VarSetOps::AssignNoCopy (this , block->bbVarDef , VarSetOps::MakeEmpty (this ));
1517- VarSetOps::AssignNoCopy (this , block->bbLiveIn , VarSetOps::MakeEmpty (this ));
1518- VarSetOps::AssignNoCopy (this , block->bbLiveOut , VarSetOps::MakeEmpty (this ));
1519- VarSetOps::AssignNoCopy (this , block->bbScope , VarSetOps::MakeEmpty (this ));
1511+ VarSetOps::AssignNoCopy (compiler , block->bbVarUse , VarSetOps::MakeEmpty (compiler ));
1512+ VarSetOps::AssignNoCopy (compiler , block->bbVarDef , VarSetOps::MakeEmpty (compiler ));
1513+ VarSetOps::AssignNoCopy (compiler , block->bbLiveIn , VarSetOps::MakeEmpty (compiler ));
1514+ VarSetOps::AssignNoCopy (compiler , block->bbLiveOut , VarSetOps::MakeEmpty (compiler ));
1515+ VarSetOps::AssignNoCopy (compiler , block->bbScope , VarSetOps::MakeEmpty (compiler ));
15201516 }
15211517 else
15221518 {
1523- VarSetOps::AssignNoCopy (this , block->bbVarUse , VarSetOps::UninitVal ());
1524- VarSetOps::AssignNoCopy (this , block->bbVarDef , VarSetOps::UninitVal ());
1525- VarSetOps::AssignNoCopy (this , block->bbLiveIn , VarSetOps::UninitVal ());
1526- VarSetOps::AssignNoCopy (this , block->bbLiveOut , VarSetOps::UninitVal ());
1527- VarSetOps::AssignNoCopy (this , block->bbScope , VarSetOps::UninitVal ());
1519+ VarSetOps::AssignNoCopy (compiler , block->bbVarUse , VarSetOps::UninitVal ());
1520+ VarSetOps::AssignNoCopy (compiler , block->bbVarDef , VarSetOps::UninitVal ());
1521+ VarSetOps::AssignNoCopy (compiler , block->bbLiveIn , VarSetOps::UninitVal ());
1522+ VarSetOps::AssignNoCopy (compiler , block->bbLiveOut , VarSetOps::UninitVal ());
1523+ VarSetOps::AssignNoCopy (compiler , block->bbScope , VarSetOps::UninitVal ());
15281524 }
15291525
15301526 block->bbMemoryUse = emptyMemoryKindSet;
@@ -1550,10 +1546,15 @@ BasicBlock* Compiler::bbNewBasicBlock()
15501546 return block;
15511547}
15521548
1553- BasicBlock* Compiler ::bbNewBasicBlock (BBjumpKinds jumpKind, BasicBlock* jumpDest /* = nullptr */ )
1549+ BasicBlock* BasicBlock ::bbNewBasicBlock (Compiler* compiler, BBjumpKinds jumpKind, BasicBlock* jumpDest /* = nullptr */ )
15541550{
1555- BasicBlock* block = bbNewBasicBlock ();
1556- block->SetJumpKindAndTarget (jumpKind, jumpDest DEBUG_ARG (this ));
1551+ BasicBlock* block = BasicBlock::bbNewBasicBlock (compiler);
1552+
1553+ // In some cases, we don't know a block's jump target during initialization, so don't check the jump kind/target
1554+ // yet.
1555+ // The checks will be done any time the jump kind/target is read or written to after initialization.
1556+ block->bbJumpKind = jumpKind;
1557+ block->bbJumpDest = jumpDest;
15571558
15581559 if (jumpKind == BBJ_THROW)
15591560 {
@@ -1563,17 +1564,19 @@ BasicBlock* Compiler::bbNewBasicBlock(BBjumpKinds jumpKind, BasicBlock* jumpDest
15631564 return block;
15641565}
15651566
1566- BasicBlock* Compiler ::bbNewBasicBlock (BBswtDesc* jumpSwt)
1567+ BasicBlock* BasicBlock ::bbNewBasicBlock (Compiler* compiler, BBswtDesc* jumpSwt)
15671568{
1568- BasicBlock* block = bbNewBasicBlock ();
1569- block->SetSwitchKindAndTarget (jumpSwt);
1569+ BasicBlock* block = BasicBlock::bbNewBasicBlock (compiler);
1570+ block->bbJumpKind = BBJ_SWITCH;
1571+ block->bbJumpSwt = jumpSwt;
15701572 return block;
15711573}
15721574
1573- BasicBlock* Compiler ::bbNewBasicBlock (BBjumpKinds jumpKind, unsigned jumpOffs)
1575+ BasicBlock* BasicBlock ::bbNewBasicBlock (Compiler* compiler, BBjumpKinds jumpKind, unsigned jumpOffs)
15741576{
1575- BasicBlock* block = bbNewBasicBlock ();
1576- block->SetJumpKindAndTarget (jumpKind, jumpOffs);
1577+ BasicBlock* block = BasicBlock::bbNewBasicBlock (compiler);
1578+ block->bbJumpKind = jumpKind;
1579+ block->bbJumpOffs = jumpOffs;
15771580 return block;
15781581}
15791582
0 commit comments