}
//------------------------------------------------------------------------
-// setBlockSequence:Determine the block order for register allocation.
+// setBlockSequence: Determine the block order for register allocation.
//
// Arguments:
// None
void LinearScan::setBlockSequence()
{
- // Reset the "visited" flag on each block.
+ assert(!blockSequencingDone); // The method should be called only once.
+
compiler->EnsureBasicBlockEpoch();
+#ifdef DEBUG
+ blockEpoch = compiler->GetCurBasicBlockEpoch();
+#endif // DEBUG
+
+ // Initialize the "visited" blocks set.
bbVisitedSet = BlockSetOps::MakeEmpty(compiler);
+
BlockSet readySet(BlockSetOps::MakeEmpty(compiler));
BlockSet predSet(BlockSetOps::MakeEmpty(compiler));
{
setBlockSequence();
}
+ else
+ {
+ clearVisitedBlocks();
+ }
+
BasicBlock* curBB = compiler->fgFirstBB;
curBBSeqNum = 0;
curBBNum = curBB->bbNum;
- clearVisitedBlocks();
assert(blockSequence[0] == compiler->fgFirstBB);
markBlockVisited(curBB);
return curBB;
enregisterLocalVars = false;
}
- unsigned lsraBlockEpoch = compiler->GetCurBasicBlockEpoch();
-
splitBBNumToTargetBBNumMap = nullptr;
// This is complicated by the fact that physical registers have refs associated
DBEXEC(VERBOSE, lsraDumpIntervals("after buildIntervals"));
- clearVisitedBlocks();
initVarRegMaps();
allocateRegisters();
allocationPassComplete = true;
resolveRegisters();
compiler->EndPhase(PHASE_LINEAR_SCAN_RESOLVE);
+ assert(blockSequencingDone); // Should do at least one traversal.
+ assert(blockEpoch == compiler->GetCurBasicBlockEpoch());
+
#if TRACK_LSRA_STATS
if ((JitConfig.DisplayLsraStats() != 0)
#ifdef DEBUG
DBEXEC(VERBOSE, TupleStyleDump(LSRA_DUMP_POST));
compiler->compLSRADone = true;
- noway_assert(lsraBlockEpoch = compiler->GetCurBasicBlockEpoch());
}
//------------------------------------------------------------------------
int compareBlocksForSequencing(BasicBlock* block1, BasicBlock* block2, bool useBlockWeights);
BasicBlockList* blockSequenceWorkList;
bool blockSequencingDone;
+#ifdef DEBUG
+ // LSRA must not change number of blocks and blockEpoch that it initializes at start.
+ unsigned blockEpoch;
+#endif // DEBUG
void addToBlockSequenceWorkList(BlockSet sequencedBlockSet, BasicBlock* block, BlockSet& predSet);
void removeFromBlockSequenceWorkList(BasicBlockList* listNode, BasicBlockList* prevNode);
BasicBlock* getNextCandidateFromWorkList();