Skip to content

Conversation

@BruceForstall
Copy link
Contributor

In the FEATURE_EH_CALLFINALLY_THUNKS case, BBJ_CALLFINALLY blocks live
in the EH region enclosing the try block that needs to call the finally.
However, we need all flow to the CALLFINALLY to come from that try block;
we don't want flow optimizations to otherwise branch directly to this
CALLFINALLY block. Add an assert to verify this is the case.

@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jul 16, 2021
@BruceForstall
Copy link
Contributor Author

/azp run runtime-coreclr jitstress

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@BruceForstall
Copy link
Contributor Author

This assert doesn't fire in SPMI, but does fire for the test case here: #55131 (comment).

@AndyAyersMS @kunalspathak PTAL
cc @dotnet/jit-contrib

@AndyAyersMS
Copy link
Member

we don't want flow optimizations to otherwise branch directly to this CALLFINALLY block

I'm not opposed to this, but we should acknowledge this is a choice, not a hard requirement ... unless you know of an actual unfixable correctness issue here.

@kunalspathak
Copy link
Contributor

Looks like the assertion is hit during crossgen2 compilation of SPC.dll on windows x86.

Copy link
Contributor

@kunalspathak kunalspathak Jul 16, 2021

Choose a reason for hiding this comment

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

From your comments, should this be under #ifdef FEATURE_EH_CALLFINALLY_THUNKS ?

@BruceForstall
Copy link
Contributor Author

I'm not opposed to this, but we should acknowledge this is a choice, not a hard requirement ... unless you know of an actual unfixable correctness issue here.

True, this is a conservative statement about our existing EH flow model. Changing this to be more liberal requires more thinking about the implications. I can add a comment to that effect.

From your comments, should this be under #ifdef FEATURE_EH_CALLFINALLY_THUNKS ?

It should work for all cases, as the callee does the right thing in all cases.

In the FEATURE_EH_CALLFINALLY_THUNKS case, BBJ_CALLFINALLY blocks live
in the EH region enclosing the `try` block that needs to call the finally.
However, we need all flow to the BBJ_CALLFINALLY to come from that try block;
we don't want flow optimizations to otherwise branch directly to this
BBJ_CALLFINALLY block. Add an assert to verify this is the case. The assert
also covers the non-FEATURE_EH_CALLFINALLY_THUNKS case.
@BruceForstall BruceForstall force-pushed the AddBranchToCallFinallyAssert branch from 687b0a6 to f8dff60 Compare July 17, 2021 00:40
@BruceForstall
Copy link
Contributor Author

I verified that the new test in #55674 hits this assert, and succeeds without hitting this assert with the code fix in that PR is included in the JIT.

@BruceForstall
Copy link
Contributor Author

/azp run runtime-coreclr jitstress

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

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

LGTM.

@BruceForstall BruceForstall merged commit c8f9a24 into dotnet:main Jul 19, 2021
@BruceForstall BruceForstall deleted the AddBranchToCallFinallyAssert branch July 19, 2021 20:03
@ghost ghost locked as resolved and limited conversation to collaborators Aug 18, 2021
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.

3 participants