summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Andreenko <seandree@microsoft.com>2019-04-16 01:49:23 -0700
committerGitHub <noreply@github.com>2019-04-16 01:49:23 -0700
commit994a50ee370cfe62ea4e56d3e55dc5babb65d575 (patch)
tree7a22282d6aeb9ae21bc91bf0d719f6e86bd01cca /src
parent08318afbeb726eb80f212c70310e5750daec5abf (diff)
parent4905d63d9d03cc1b8b46f6830b50489ee93ce33f (diff)
downloadcoreclr-994a50ee370cfe62ea4e56d3e55dc5babb65d575.tar.gz
coreclr-994a50ee370cfe62ea4e56d3e55dc5babb65d575.tar.bz2
coreclr-994a50ee370cfe62ea4e56d3e55dc5babb65d575.zip
Merge pull request #24009 from sandreenko/fixLsraBlockEpochCheck
Fix lsraBlockEpoch check.
Diffstat (limited to 'src')
-rw-r--r--src/jit/lsra.cpp24
-rw-r--r--src/jit/lsra.h4
2 files changed, 21 insertions, 7 deletions
diff --git a/src/jit/lsra.cpp b/src/jit/lsra.cpp
index 8a5323ced2..e672582c03 100644
--- a/src/jit/lsra.cpp
+++ b/src/jit/lsra.cpp
@@ -740,7 +740,7 @@ BasicBlock* LinearScan::getNextCandidateFromWorkList()
}
//------------------------------------------------------------------------
-// setBlockSequence:Determine the block order for register allocation.
+// setBlockSequence: Determine the block order for register allocation.
//
// Arguments:
// None
@@ -756,9 +756,16 @@ BasicBlock* LinearScan::getNextCandidateFromWorkList()
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));
@@ -1094,10 +1101,14 @@ BasicBlock* LinearScan::startBlockSequence()
{
setBlockSequence();
}
+ else
+ {
+ clearVisitedBlocks();
+ }
+
BasicBlock* curBB = compiler->fgFirstBB;
curBBSeqNum = 0;
curBBNum = curBB->bbNum;
- clearVisitedBlocks();
assert(blockSequence[0] == compiler->fgFirstBB);
markBlockVisited(curBB);
return curBB;
@@ -1172,8 +1183,6 @@ void LinearScan::doLinearScan()
enregisterLocalVars = false;
}
- unsigned lsraBlockEpoch = compiler->GetCurBasicBlockEpoch();
-
splitBBNumToTargetBBNumMap = nullptr;
// This is complicated by the fact that physical registers have refs associated
@@ -1189,7 +1198,6 @@ void LinearScan::doLinearScan()
DBEXEC(VERBOSE, lsraDumpIntervals("after buildIntervals"));
- clearVisitedBlocks();
initVarRegMaps();
allocateRegisters();
allocationPassComplete = true;
@@ -1197,6 +1205,9 @@ void LinearScan::doLinearScan()
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
@@ -1211,7 +1222,6 @@ void LinearScan::doLinearScan()
DBEXEC(VERBOSE, TupleStyleDump(LSRA_DUMP_POST));
compiler->compLSRADone = true;
- noway_assert(lsraBlockEpoch = compiler->GetCurBasicBlockEpoch());
}
//------------------------------------------------------------------------
diff --git a/src/jit/lsra.h b/src/jit/lsra.h
index e03b6f9e6f..c5477bf9e1 100644
--- a/src/jit/lsra.h
+++ b/src/jit/lsra.h
@@ -1397,6 +1397,10 @@ private:
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();