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

[release/8.0-staging] JIT: Home float parameters before integer parameters #98749

Merged

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Feb 21, 2024

Backport of #96439 to release/8.0-staging

/cc @jakobbotsch

Customer Impact

  • Customer reported
  • Found internally

On windows-x64 the JIT may corrupt the incoming value of a parameter in certain cases when optimizing. This requires a mix of float/double parameters and a parameter of a struct type with a single float, double or Vector2 field. Furthermore, it requires the JIT to decide to enregister the struct parameter's field in the same register as one of the float or double parameters are passed in. In these cases the JIT will corrupt the value of the float or double parameter.

For example, a combination of parameters that can hit the problem is:

static int Foo(Point2D a, float b)
{
}

struct Point2D { public Vector2 V; }

Reported by customers in #96306 and #98748.

Regression

  • Yes
  • No

The underlying issue exists for a long time; however, in .NET 8 we made promotion of these structs more likely to happen, which makes the issue more likely to happen.

Testing

Regression test added.

Risk

Low risk. This reorders the order in which float and integer/struct parameters are handled to make sure that no such conflict happens.

Parameters that are going into float registers can come from integer
registers in the presence of struct promotion. We need to home those
before integer parameters or the source register could have been
overridden by the integer parameter homing logic.

Ideally it seems like the homing logic should be unified to handle all
parameters simultaneously, but this seems like a simple enough fix. I do
not think we have ABIs where we have the opposite kind constraint
(integer parameters coming from float registers).

Fix #96306
@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 Feb 21, 2024
@ghost
Copy link

ghost commented Feb 21, 2024

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

Issue Details

Backport of #96439 to release/8.0-staging

/cc @jakobbotsch

Customer Impact

  • Customer reported
  • Found internally

[Select one or both of the boxes. Describe how this issue impacts customers, citing the expected and actual behaviors and scope of the issue. If customer-reported, provide the issue number.]

Regression

  • Yes
  • No

[If yes, specify when the regression was introduced. Provide the PR or commit if known.]

Testing

[How was the fix verified? How was the issue missed previously? What tests were added?]

Risk

[High/Medium/Low. Justify the indication by mentioning how risks were measured and addressed.]

IMPORTANT: If this backport is for a servicing release, please verify that:

  • The PR target branch is release/X.0-staging, not release/X.0.

  • If the change touches code that ships in a NuGet package, you have added the necessary package authoring and gotten it explicitly reviewed.

Author: github-actions[bot]
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@jakobbotsch jakobbotsch marked this pull request as draft March 6, 2024 13:05
@jakobbotsch

This comment was marked as outdated.

@carlossanlop
Copy link
Member

Friendly reminder that Monday March 11th is the Code Complete date for the April Release. If you want this change to be included in that release, please make sure to mark this as ready for review, get an area owner sign-off, confirm the CI is green or failures are unrelated, and send an email to Tactics requesting approval. @jakobbotsch @AndyAyersMS

@jakobbotsch
Copy link
Member

I pushed another change motivated by validation done in #99286. It ensures that we never try to home a parameter passed in a float register in an integer register, since that's not supported when we home float registers first. This case could happen because we allow enregistration of structs of fitting size in integer registers if they have only whole uses. It is a very rare case because such enregistration only kicks in when the struct parameter also was not promoted.

@AndyAyersMS Can you take another look? cc @dotnet/jit-contrib

@jakobbotsch jakobbotsch marked this pull request as ready for review March 7, 2024 20:06
@jakobbotsch jakobbotsch added the Servicing-consider Issue for next servicing release review label Mar 7, 2024
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 8.0.x

@jakobbotsch jakobbotsch added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Mar 11, 2024
@jakobbotsch
Copy link
Member

Approved by tactics via email. The failures look like infra failures; going to retry them.

@carlossanlop
Copy link
Member

CI green after retries. Merging! :shipit:

@carlossanlop carlossanlop merged commit ebb4a50 into release/8.0-staging Mar 11, 2024
121 of 123 checks passed
@carlossanlop carlossanlop deleted the backport/pr-96439-to-release/8.0-staging branch March 11, 2024 20:46
@github-actions github-actions bot locked and limited conversation to collaborators May 2, 2024
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