Skip to content

Conversation

@kunalspathak
Copy link
Contributor

We were inserting vector save/restore moves around ThrowException that never returns. As such, we hit an assert because the code doesn't expect the restore generated in the end of blocks other than BBJ_COND, BBJ_NONE, BBJ_SWITCH or BBJ_ALWAYS. In this case, it was BBJ_THROW.

The fix is to not generate save/restore around such calls. We were hitting this issue while jitting a method that was added in #61439.

Fixes: #62005

@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Dec 10, 2021
@ghost
Copy link

ghost commented Dec 10, 2021

Tagging subscribers to this area: @JulieLeeMSFT
See info in area-owners.md if you want to be subscribed.

Issue Details

We were inserting vector save/restore moves around ThrowException that never returns. As such, we hit an assert because the code doesn't expect the restore generated in the end of blocks other than BBJ_COND, BBJ_NONE, BBJ_SWITCH or BBJ_ALWAYS. In this case, it was BBJ_THROW.

The fix is to not generate save/restore around such calls. We were hitting this issue while jitting a method that was added in #61439.

Fixes: #62005

Author: kunalspathak
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -


#ifdef DEBUG
GenTreeCall* call = tree->AsCall();
if ((call != nullptr) && (call->gtOper == GT_CALL))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once you've done AsCall you've already done a null check and an assert that it's GT_CALL. So if you need to do those checks, you need to do it on tree before you use AsCall

if ((call != nullptr) && (call->gtOper == GT_CALL))
{
// Make sure that we do not insert vector save before calls that does not return.
assert((call->AsCall()->gtCallMoreFlags & GTF_CALL_M_DOES_NOT_RETURN) == 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert((call->AsCall()->gtCallMoreFlags & GTF_CALL_M_DOES_NOT_RETURN) == 0);
assert(!call->IsNoReturn());

Comment on lines 1484 to 1492
GenTreeCall* call = tree->AsCall();
if ((call != nullptr) && (call->gtOper == GT_CALL))
{
if ((call->AsCall()->gtCallMoreFlags & GTF_CALL_M_DOES_NOT_RETURN) != 0)
{
// No point in having vector save/restore if the call will not return.
return;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments as above

@kunalspathak
Copy link
Contributor Author

/azp run runtime-coreclr superpmi-replay

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@kunalspathak
Copy link
Contributor Author

/azp run runtime-coreclr superpmi-replay

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@kunalspathak
Copy link
Contributor Author

@BruceForstall - can you review the changes?

}

#ifdef DEBUG
if ((tree != nullptr) && tree->IsCall())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like checking tree != nullptr is unnecessary, as the JITDUMP above will crash (in DEBUG) if it's null.

@kunalspathak kunalspathak merged commit a7ae08b into dotnet:main Dec 13, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jan 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Assertion failed 'block->bbJumpKind == BBJ_NONE || block->bbJumpKind == BBJ_ALWAYS'

2 participants