Repository navigation
Conversation
dotnet#137821) Fixes dotnet#137798 Since dotnet#125214, LSRA may allocate a call's result to ECX (e.g. when it's passed as the first arg of the next call). On x86, `genRemoveAlignmentAfterCall` then clobbered it with `pop ecx` for cdecl calls with 4 bytes of stack args: ```asm call eax ; abs(int) mov ecx, eax pop ecx ; clobbers the result call [Consume(int):int] ``` Use `add esp, 4` when ECX holds the result. The DEBUG-only `JitStackChecks` after calls had the same issue (used ECX as a temp), so it now adjusts the saved SP slot instead of needing a scratch register. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5d4045a5-f371-42f9-8340-91c7c44f2eab (cherry picked from commit efd8294)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8c6b9802-8643-479e-bbb4-f4e04e60fc0a
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
jakobbotsch
approved these changes
Dec 1, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes Issue #137798
main PR #137821
Description
Backport of #137821 to release/11.0. Since #125214, LSRA may allocate a call's result to ECX. On x86,
genRemoveAlignmentAfterCallthen clobbered it withpop ecxafter cdecl calls with 4 bytes of stack args. It now usesadd esp, 4when ECX holds the result. The DEBUG-onlyJitStackCheckscode had the same issue and is fixed too.Customer Impact
Silent bad codegen on Windows x86: the return value of a cdecl call (e.g. a P/Invoke) is replaced by its argument.
Regression
Introduced in .NET 11 by #125214. Works on .NET 10.
Testing
Test is backported.
Risk
Low. x86 only, and only when the call's result is in ECX.
Note
PR description generated with GitHub Copilot.