Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JIT: consistently handle no return calls in qmarks #94690

Merged
merged 1 commit into from
Nov 14, 2023

Conversation

AndyAyersMS
Copy link
Member

When we expand QMARKS, ensure that any block with a no-return call gets changed to BBJ_THROW.

This fixes a case I am seeing with cross-block local assertion prop, as the upper QMARK gets optimized away and so we don't check if the expansing has any noreturn calls.

It also happens in places with just within-block local assertion prop.

Contributes to #94363.

When we expand QMARKS, ensure that any block with a no-return call gets
changed to BBJ_THROW.

This fixes a case I am seeing with cross-block local assertion prop,
as the upper QMARK gets optimized away and so we don't check if the
expansing has any noreturn calls.

It also happens in places with just within-block local assertion prop.

Contributes to dotnet#94363.
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Nov 14, 2023
@ghost ghost assigned AndyAyersMS Nov 14, 2023
@ghost
Copy link

ghost commented Nov 14, 2023

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

Issue Details

When we expand QMARKS, ensure that any block with a no-return call gets changed to BBJ_THROW.

This fixes a case I am seeing with cross-block local assertion prop, as the upper QMARK gets optimized away and so we don't check if the expansing has any noreturn calls.

It also happens in places with just within-block local assertion prop.

Contributes to #94363.

Author: AndyAyersMS
Assignees: AndyAyersMS
Labels:

area-CodeGen-coreclr

Milestone: -

@AndyAyersMS
Copy link
Member Author

@dotnet/jit-contrib fyi
@jakobbotsch PTAL

A handful of diffs expected (a few more with cross-block enabled, but still not a lot).

Ideally we'd tail merge these, but the noreturn calls often end up with different arguments, and tail merge / throw helper merge aren't able to handle these cases (yet).

Copy link
Member

@jakobbotsch jakobbotsch left a comment

Choose a reason for hiding this comment

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

LGTM. Is the fgExpandQmarkForCastInstOf special case still necessary?

@AndyAyersMS
Copy link
Member Author

LGTM. Is the fgExpandQmarkForCastInstOf special case still necessary?

You mean the part that is described by

        // This is a rare case that arises when we are doing minopts and encounter isinst of null
        // gtFoldExpr was still is able to optimize away part of the tree (but not all).
        // That means it does not match our pattern.

I don't see how it can be reached, as the outer qmark is the one that would have the GTF_QMARK_CAST_INSTOF bit, and that's the one that can get optimized away.

Let me see if we get there with SPMI.

@jakobbotsch
Copy link
Member

jakobbotsch commented Nov 14, 2023

I mean the entirety of fgExpandQmarkForCastInstOf... it was never clear to me why the normal qmark expansion wouldn't be sufficient, apart from this difference in handling of no-return calls.

@AndyAyersMS
Copy link
Member Author

Ah... I can look at this. Maybe as part of revisiting #86778.

@AndyAyersMS
Copy link
Member Author

Will revisit some of the above when I look at moving qmark expansion earlier.

@AndyAyersMS AndyAyersMS merged commit 3e66124 into dotnet:main Nov 14, 2023
129 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Dec 15, 2023
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.

2 participants