[release/5.0] Fix regression with tail.callvirt transformation to helper call #45880
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.
Backport of #45527 to release/5.0
Customer Impact
The original issue was reported by @KevinRansom - F# 5.0.100 was broken for Linux Arm32 (dotnet/fsharp#10454). He also constructed a short F# repro exposing the bug in #45250.
Later, I discovered that the issue can be reproduced on all platforms if fast tail calls are either disabled or disallowed (e.g. when
localloc
is used in the caller method).The issue impacts F# applications with the following code pattern
and results in side effects being computed twice when such code is transformed to tail call with helpers.
Testing
Constructed a regression test in IL that exposes the failing code pattern (see Runtime_45250.il). Confirmed that the test would fail on all platforms due to incorrect JIT transformation (bad silent codegen). Verified that the change fixes the issue. Ran Pri1 tests in various jit-stress modes. Manually collected the code differences introduced by the change and analyzed some of the differences.
Risk
Low.
Regression
Yes from 3.1, introduced when runtime switched to using tail call with portable helpers.