Skip to content

Commit

Permalink
Do not perform vector save/restore around call that will never return (
Browse files Browse the repository at this point in the history
…dotnet#62662)

* Do not perform vector save/restore around call that will never return

* First check if tree is a call

* Use the IsNoReturn() method
  • Loading branch information
kunalspathak authored Dec 13, 2021
1 parent 4a48840 commit a7ae08b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/coreclr/jit/lsra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6274,6 +6274,14 @@ void LinearScan::insertUpperVectorSave(GenTree* tree,
return;
}

#ifdef DEBUG
if (tree->IsCall())
{
// Make sure that we do not insert vector save before calls that does not return.
assert(!tree->AsCall()->IsNoReturn());
}
#endif

LclVarDsc* varDsc = compiler->lvaGetDesc(lclVarInterval->varNum);
assert(Compiler::varTypeNeedsPartialCalleeSave(varDsc->GetRegisterType()));

Expand Down
9 changes: 9 additions & 0 deletions src/coreclr/jit/lsrabuild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1481,6 +1481,15 @@ Interval* LinearScan::getUpperVectorInterval(unsigned varIndex)
//
void LinearScan::buildUpperVectorSaveRefPositions(GenTree* tree, LsraLocation currentLoc, regMaskTP fpCalleeKillSet)
{
if ((tree != nullptr) && tree->IsCall())
{
if (tree->AsCall()->IsNoReturn())
{
// No point in having vector save/restore if the call will not return.
return;
}
}

if (enregisterLocalVars && !VarSetOps::IsEmpty(compiler, largeVectorVars))
{
// We assume that the kill set includes at least some callee-trash registers, but
Expand Down

0 comments on commit a7ae08b

Please sign in to comment.