Skip to content

JIT: better support for patchpoints in try regions - #59784

Merged
AndyAyersMS merged 5 commits into
dotnet:mainfrom
AndyAyersMS:FixMidTryPatchpointPostImporter
Oct 6, 2021
Merged

JIT: better support for patchpoints in try regions#59784
AndyAyersMS merged 5 commits into
dotnet:mainfrom
AndyAyersMS:FixMidTryPatchpointPostImporter

Conversation

@AndyAyersMS

Copy link
Copy Markdown
Member

This change adds control flow to ensure that an OSR method for a patchpoint
nested in try regions enters those regions try from the first block of each
try rather than mid-try.

This lets these OSR methods conform to the data flow expectations that the
only way control flow can enter a try is via its first block.

See #33658 for more details on the approach taken here.

Fixes#35687.

This change adds control flow to ensure that an OSR method for a patchpoint
nested in try regions enters those regions try from the first block of each
try rather than mid-try.
This lets these OSR methods conform to the data flow expectations that the
only way control flow can enter a try is via its first block.
See dotnet#33658 for more details on the approach taken here.
Fixesdotnet#35687.
@ghostghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Sep 29, 2021
@ghost

Copy link
Copy Markdown

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

Issue Details

This change adds control flow to ensure that an OSR method for a patchpoint
nested in try regions enters those regions try from the first block of each
try rather than mid-try.

This lets these OSR methods conform to the data flow expectations that the
only way control flow can enter a try is via its first block.

See #33658 for more details on the approach taken here.

Fixes #35687.

Author:AndyAyersMS
Assignees:-
Labels:

area-CodeGen-coreclr

Milestone:-

@AndyAyersMS

Copy link
Copy Markdown
MemberAuthor

It might be possible to merge this new logic with the try region trimming done in fgRemoveEmptyBlocks but for now I'm keeping it separate.

No diffs outside of OSR (which we currently can't easily diff; seems like I should do an SPMI collection here perhaps).

cc @dotnet/jit-contrib

@AndyAyersMSAndyAyersMS mentioned this pull request Sep 29, 2021
72 tasks

@BruceForstallBruceForstall left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  1. I think you should add some of the comment from #33658 (comment) into your new code, especially the pseudo-code of the flow you are creating.
  2. It's pretty weird that a function named fgRemoveEmptyBlocks can create a bunch of blocks and flow and a new temp.
  3. Re (2), it looks like fgRemoveEmptyBlocks gets called on inlinees, and then later in morph init. I guess that ends up not creating multiple flow because we don't inline functions with EH, but it maybe creates an impediment if we ever do (and the inlinee is an OSR method? So, maybe not a problem?)

@AndyAyersMS

Copy link
Copy Markdown
MemberAuthor

Going to wait on this until #59789 lands so (hopefully) I can get clean OSR runs.

@AndyAyersMS

Copy link
Copy Markdown
MemberAuthor

Yeah, fgRemoveEmptyBlocks should probably be renamed, maybe fgUpdateFlowAfterImportation ...? Similar in nature to fgAddInternal too, though that runs a bit later on.

As for running it on inlinees, right, only the first bit (removing un-imported blocks) will matter today.

We'll never inline OSR methods, they never get called in a normal fashion.

@AndyAyersMS

Copy link
Copy Markdown
MemberAuthor

Merged in the other OSR fix, so will try running the experimental pipeline here. Don't expect it to be green as there is a latent crossgen2 issue.

@AndyAyersMS

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-jit-experimental

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@AndyAyersMS

Copy link
Copy Markdown
MemberAuthor

Looks like a number of novel failures, so I'll have to revise this PR.

@AndyAyersMS

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-jit-experimental

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@AndyAyersMS

Copy link
Copy Markdown
MemberAuthor

Still have one overly aggressive assert (mutual protect case)... the OSR entry can be in a nested try and still not need step blocks.

@AndyAyersMS

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-jit-experimental

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@AndyAyersMS

Copy link
Copy Markdown
MemberAuthor

jit-experimental now has just the expected set of failures.

@AndyAyersMS

Copy link
Copy Markdown
MemberAuthor

@BruceForstall feel free to take another look; think I addressed your comments.

@BruceForstallBruceForstall left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thanks for adding the detailed comments.

@AndyAyersMS
AndyAyersMS merged commit 26954f5 into dotnet:mainOct 6, 2021
@AndyAyersMS
AndyAyersMS deleted the FixMidTryPatchpointPostImporter branch October 6, 2021 01:40
@ghostghost locked as resolved and limited conversation to collaborators Nov 5, 2021
@AndyAyersMS
AndyAyersMS restored the FixMidTryPatchpointPostImporter branch October 11, 2024 21:23
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclrCLR 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.

JIT\opt\OSR\tailrecursetry\tailrecursetry.cmd fails with COMPlus_FastTailCalls=0

2 participants

@AndyAyersMS@BruceForstall