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: don't dead store OSR exposed locals #89867

Merged
merged 1 commit into from
Aug 10, 2023

Conversation

AndyAyersMS
Copy link
Member

Backport of #89743 to 7.0.

Customer Impact

Fixes customer reported issue #89666.

Methods with loops might unexpectedly start running incorrectly after some time, because the runtime/JIT transitioned execution to a new native version via OSR, and in some rare cases the OSR method will not properly update a local variable.

Testing

Verified test from #89666 case fixed, added new test based on the underlying problem. SPMI screening of this fix in main showed minimal diffs and no instances of the problem.

Risk

Low, targeted fix for OSR that disable some optimizations.

The local var ref count for OSR locals can be misleading, since some of the appearances may be in the "tier0" parts of the methods and won't be visible once we trim the OSR method down to just the part we're going to compile.

Fix by giving OSR-exposed locals an implicit ref count; this prevents the JIT from inferring that a store to a local is not needed because the stored value cannot be read.

Backport of dotnet#89743 to 7.0.

The local var ref count for OSR locals can be misleading, since some
of the appearances may be in the "tier0" parts of the methods and
won't be visible once we trim the OSR method down to just the part
we're going to compile.

Fix by giving OSR-exposed locals an implicit ref count.

Fixes dotnet#89666.
@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 Aug 2, 2023
@ghost ghost assigned AndyAyersMS Aug 2, 2023
@ghost
Copy link

ghost commented Aug 2, 2023

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

Issue Details

Backport of #89743 to 7.0.

Customer Impact

Fixes customer reported issue #89666.

Methods with loops might unexpectedly start running incorrectly after some time, because the runtime/JIT transitioned execution to a new native version via OSR, and in some rare cases the OSR method will not properly update a local variable.

Testing

Verified test from #89666 case fixed, added new test based on the underlying problem. SPMI screening of this fix in main showed minimal diffs and no instances of the problem.

Risk

Low, targeted fix for OSR that disable some optimizations.

The local var ref count for OSR locals can be misleading, since some of the appearances may be in the "tier0" parts of the methods and won't be visible once we trim the OSR method down to just the part we're going to compile.

Fix by giving OSR-exposed locals an implicit ref count; this prevents the JIT from inferring that a store to a local is not needed because the stored value cannot be read.

Author: AndyAyersMS
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@AndyAyersMS
Copy link
Member Author

@jakobbotsch PTAL
cc @dotnet/jit-contrib

Copy link
Member

@jeffschwMSFT jeffschwMSFT left a comment

Choose a reason for hiding this comment

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

approved. we will take for consideration in 7.0.x

@JulieLeeMSFT JulieLeeMSFT added the Servicing-consider Issue for next servicing release review label Aug 2, 2023
@JulieLeeMSFT JulieLeeMSFT added this to the 7.0.x milestone Aug 2, 2023
@carlossanlop
Copy link
Member

Friendly reminder: if you want this servicing fix to be included in the September 2023 Release, you'll have to merge this PR before August 14th.

@jeffschwMSFT jeffschwMSFT added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Aug 10, 2023
@jeffschwMSFT jeffschwMSFT modified the milestones: 7.0.x, 7.0.11 Aug 10, 2023
@jeffschwMSFT
Copy link
Member

@JulieLeeMSFT can you take a look at the CI failures? Once we understand them we can merge.

@JulieLeeMSFT
Copy link
Member

JulieLeeMSFT commented Aug 10, 2023

There is only 1 failure on mono test, which is not related to this PR. It is a known issue. Merging this PR.

@JulieLeeMSFT JulieLeeMSFT merged commit df0930c into dotnet:release/7.0-staging Aug 10, 2023
119 of 126 checks passed
@ghost ghost locked as resolved and limited conversation to collaborators Sep 10, 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 Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants