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

Spill side effects before impStoreNullableFields #105529

Merged
merged 4 commits into from
Jul 26, 2024

Conversation

EgorBo
Copy link
Member

@EgorBo EgorBo commented Jul 26, 2024

Fixes #105518

The root cause of the issue is the IR like this:

[000852] UAC-G------                         *  STORE_LCL_FLD struct<System.Decimal, 16> V41 tmp36        [+8]
[000849] S-C-G------                         \--*  CALLV vt-ind struct Microsoft.Data.Sqlite.SqliteValueReader:GetDecimal(int):System.Decimal:this
[000847] ----------- this                       +--*  LCL_VAR   ref    V00 this         
[000848] ----------- arg1                       \--*  LCL_VAR   int    V02 arg1     

since that call demands a ret-buffer (to return System.Decimal) on Windows, we have to spill it right in the importer. @jakobbotsch pointed me to impStoreStruct helper that takes care about ABI for such stores.

This led to an assert in LowerStructCall in Checked and to an invalid program exception in Release in EF. I've validated that this fix fixes the EF repro.

It's a bit unfortunate that we have to care about codegen-level things like ABI handling that early, but 🤷

@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 Jul 26, 2024
Copy link
Contributor

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

@EgorBo EgorBo marked this pull request as ready for review July 26, 2024 08:34
@EgorBo
Copy link
Member Author

EgorBo commented Jul 26, 2024

The root cause of the issue is the IR like this:

[000852] UAC-G------                         *  STORE_LCL_FLD struct<System.Decimal, 16> V41 tmp36        [+8]
[000849] S-C-G------                         \--*  CALLV vt-ind struct Microsoft.Data.Sqlite.SqliteValueReader:GetDecimal(int):System.Decimal:this
[000847] ----------- this                       +--*  LCL_VAR   ref    V00 this         
[000848] ----------- arg1                       \--*  LCL_VAR   int    V02 arg1     

since that call demands a ret-buffer (to return System.Decimal) on Windows, we have to spill it right in the importer. @jakobbotsch pointed me to impStoreStruct helper that takes care about ABI for such stores.

This led to an assert in LowerStructCall in Checked and to an invalid program exception in Release in EF. I've validated that this fix fixes the EF repro.

PTAL @jakobbotsch @AndyAyersMS

@EgorBo EgorBo merged commit ebbebac into dotnet:main Jul 26, 2024
109 of 114 checks passed
@EgorBo EgorBo deleted the spill-sideeffects-store-nullable branch July 26, 2024 15:28
@github-actions github-actions bot locked and limited conversation to collaborators Aug 27, 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The JIT compiler encountered invalid IL code or an internal limitation.
2 participants