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: Conditional Escape Analysis and Cloning #111473

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

AndyAyersMS
Copy link
Member

Enhance escape analysis to determine if an object escapes only under failed GDV tests. If so, clone to create a path of code so that the object doesn't escape, and then stack allocate the object.

More details in the included document.

Contributes to #108913

Enhance escape analysis to determine if an object escapes only under
failed GDV tests. If so, clone to create a path of code so that
the object doesn't escape, and then stack allocate the object.

More details in the included document.

Contributes to dotnet#108913
@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 Jan 15, 2025
Copy link
Contributor

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

@AndyAyersMS
Copy link
Member Author

AndyAyersMS commented Jan 15, 2025

@dotnet/jit-contrib PTAL

Not sure who wants to sign up to review this. Let me know.

SPMI is not going to be useful here. We can try MihuBot but that may not show much either.

Copy link
Member

@amanasifkhalid amanasifkhalid left a comment

Choose a reason for hiding this comment

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

Nice writeup! I haven't looked at the code yet, though you should probably get someone else to look at it

@AndyAyersMS
Copy link
Member Author

One of the libraries failures is that we're not updating the enclosing EH extents properly.

Assertion failed 'found && "BBJ_EHFINALLYRET predecessor of block that doesn't follow a BBJ_CALLFINALLY!"' in 'System.IO.File:InternalWriteAllLines(System.IO.StreamWriter,System.Collections.Generic.IEnumerable`1[System.String])' during 'Allocate Objects' (IL size 84; hash 0xfef048f0; Tier1)

fgCloneTryRegion assumes the cloned try will be lexically after the original, so any EH extent that ended at the original now ends at the clone. But here we're often putting the clone before the original, and so we get the enclosing extent wrong.

It should be possible to reorder these and put the clone after, but the EH lexicality constraints have been a consistent source of trouble.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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