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: Sign/zero-extend small primitive arguments on arm32 and Apple arm64 #106312

Closed
wants to merge 5 commits into from

Conversation

jakobbotsch
Copy link
Member

Fix #101046

This has some semi large regressions.

@jakobbotsch
Copy link
Member Author

cc @dotnet/jit-contrib @jkotas

This changes the calling convention for Apple arm64 and ARM32 to be in line with the platform calling convention, which requires sign/zero extension to 32 bits for small typed arguments. Sadly it has some relatively large regressions that I'm not too happy about taking at this stage.

I opened an alternative fix in #106314 that I'm inclined to take instead. It keeps the managed calling convention the same, meaning that small typed arguments are not guaranteed to be normalized. Instead it just fixes the problem for pinvokes only.
The downside is that it means that we accept the managed calling convention diverges from the platform calling convention, which definitely comes with some pain. For example, fcalls with small typed arguments need to be handled carefully to avoid the native compiler relying on normalization guarantees on Apple arm64/ARM32 targets. (To be fair that's not new with the PR, and things have been working fine even without it for a long time.)

Alternatively, since we don't know of any customer issue here, we can just wait for .NET 10 and take the first fix instead when we'll have longer to handle to sort out potential regressions.

Thoughts? Opinions?

@jkotas
Copy link
Member

jkotas commented Aug 13, 2024

we accept the managed calling convention diverges from the platform calling convention

The managed calling convention on x86/x64 had divergence for small integers since forever. I do not see a problem with having similar divergence on other platforms as well.

I tried to convince people like 10 years ago to get rid of the x86/x64 divergence, but I was not able to make a convincing argument. There was a peanut butter regression similar to the one you are seeing that was not easy to fix.

@jakobbotsch
Copy link
Member Author

Ok, sounds good to me -- let's go with the alternate fix.

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JIT: Small primitives on arm32/apple arm64 ABI need explicit normalization to 32 bits
2 participants