Skip to content

Commit

Permalink
Fix the EH-write thru scenario (#45248)
Browse files Browse the repository at this point in the history
* Fix the EH-write thru

* Fix condition for BBJ_THROW

* Proper fix
  • Loading branch information
kunalspathak authored Dec 2, 2020
1 parent 784d8f5 commit 63b9b20
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
2 changes: 2 additions & 0 deletions src/coreclr/src/jit/lsra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11007,6 +11007,8 @@ void LinearScan::verifyFinalAllocation()
}
if (currentRefPosition->spillAfter || currentRefPosition->lastUse)
{
assert(!currentRefPosition->spillAfter || currentRefPosition->IsActualRef());

interval->physReg = REG_NA;
interval->assignedReg = nullptr;

Expand Down
25 changes: 3 additions & 22 deletions src/coreclr/src/jit/lsrabuild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2239,35 +2239,16 @@ void LinearScan::buildIntervals()
currentLoc = 1;
}

// Handle special cases for live-in.
// If this block hasEHBoundaryIn, then we will mark the recentRefPosition of each EH Var preemptively as
// spillAfter, since we don't want them to remain in registers.
// Otherwise, determine if we need any DummyDefs.
// We need DummyDefs for cases where "predBlock" isn't really a predecessor.
// For blocks that don't have EHBoundaryIn, we need DummyDefs for cases where "predBlock" isn't
// really a predecessor.
// Note that it's possible to have uses of unitialized variables, in which case even the first
// block may require DummyDefs, which we are not currently adding - this means that these variables
// will always be considered to be in memory on entry (and reloaded when the use is encountered).
// TODO-CQ: Consider how best to tune this. Currently, if we create DummyDefs for uninitialized
// variables (which may actually be initialized along the dynamically executed paths, but not
// on all static paths), we wind up with excessive liveranges for some of these variables.

if (blockInfo[block->bbNum].hasEHBoundaryIn)
{
VARSET_TP liveInEHVars(VarSetOps::Intersection(compiler, currentLiveVars, exceptVars));
VarSetOps::Iter iter(compiler, liveInEHVars);
unsigned varIndex = 0;
while (iter.NextElem(&varIndex))
{
Interval* interval = getIntervalForLocalVar(varIndex);
if (interval->recentRefPosition != nullptr)
{
JITDUMP(" Marking RP #%d of V%02u as spillAfter\n", interval->recentRefPosition->rpNum,
interval->varNum);
interval->recentRefPosition->spillAfter = true;
}
}
}
else
if (!blockInfo[block->bbNum].hasEHBoundaryIn)
{
// Any lclVars live-in on a non-EH boundary edge are resolution candidates.
VarSetOps::UnionD(compiler, resolutionCandidateVars, currentLiveVars);
Expand Down

0 comments on commit 63b9b20

Please sign in to comment.