Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Force storing GC state until we see a labeled IG #114475

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

Merged
merged 2 commits into from
Apr 11, 2025

Conversation

kunalspathak
Copy link
Member

This is very odd and corner case scenario. We have a loop after epilog (with stress block layout, we might have something like that). If there are IGs after epilog, the epilog creates additional dummy IG to store GC state in it. We also update the GC vars global variables emitPrevGCrefVars and emitInitGCrefVars to have most up to date information. Whenever their values are different, we mark such IGs with IGF_GC_VARS stating that the IG contains gc information that the gcinfo should record.

The loop that is immediately after the epilog is marked for alignment, and so we create a new label IG for it. At this point, the GC vars information emitPrevGCrefVars == emitInitGCrefVars and so we skip marking this IG with IGF_GC_VARS. As a result, it inherits the GC var liveness information from the previous block (which is the dummy block after the epilog) which is wrong.

The fix is to force store the GC state on all IGs until we come across a valid labeled IG.

Attached is the dump from failing test. Here, IG14 is the epilog and IG15 is the dummy IG for which we add all the GC-vars like V73 etc. When we create IG16, we do not add any new GC vars and hence inherit those from IG15

617.dump.asm.zip

Here is the diff after the fix:

image

Thanks @BruceForstall for brainstorming this scenario with me.

Fixes: #113553

@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 Apr 10, 2025
Copy link
Contributor

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

@BruceForstall BruceForstall self-requested a review April 10, 2025 06:47
@kunalspathak
Copy link
Member Author

As imagined, no diffs because of this being a corner scenario.

@kunalspathak
Copy link
Member Author

/azp run runtime-coreclr gcstress-extra

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@kunalspathak kunalspathak marked this pull request as ready for review April 10, 2025 21:13
@Copilot Copilot AI review requested due to automatic review settings April 10, 2025 21:13
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

@kunalspathak
Copy link
Member Author

@dotnet/jit-contrib

Copy link
Member

@BruceForstall BruceForstall left a comment

Choose a reason for hiding this comment

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

A few suggestions.

@kunalspathak
Copy link
Member Author

format job failures are unrelated.

@kunalspathak kunalspathak merged commit 47797ad into dotnet:main Apr 11, 2025
109 of 111 checks passed
@kunalspathak kunalspathak deleted the issue-113553 branch April 11, 2025 06:02
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.

Test failure in RunReflectionScenario_UnsafeRead
2 participants