Skip to content

[JIT] [Wasm]: Check IsInvariantInRange for LEA base addr in GetFoldableAddrMode - #134358

Merged
adamperlin merged 1 commit into
dotnet:mainfrom
adamperlin:adamperlin/wasm-fix-address-mode-lir-check
Sep 22, 2026
Merged

adamperlin merged 1 commit into
dotnet:mainfrom
adamperlin:adamperlin/wasm-fix-address-mode-lir-check

Conversation

@adamperlin

@adamperlin adamperlin commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #132987; This issue was found by an experimental version of Fuzzlyn that supports Wasm.
It fixes an LIR semantics assert and possible operand containment/ordering issue on Wasm with a STOREIND where we attempt to contain part of the computation of the destination address, which is a field, as an LEA+N addressing mode, even though the base address for the field is reloaded during the computation of the value to store. This happens in cases like the following:

public class Program
{
    public static void M0()
    {
        s_1.F0.F0.F8 = (ushort)M1(ref s_1.F8);
    }
}

where the address of field s_1 is used on the left- and right-hand sides of an assignment. Diffs show a regression as expected, but a small one.

@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Sep 21, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 6 pipeline(s).
10 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@adamperlin adamperlin added the arch-wasm WebAssembly architecture label Sep 21, 2026
@adamperlin
adamperlin marked this pull request as ready for review September 21, 2026 22:07
Copilot AI lite review requested due to automatic review settings September 21, 2026 22:07
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Add a regression test covering the Wasm address-ordering pattern before approval.

Review effort: Lite
Findings: None

What changed in this PR

This PR fixes Wasm JIT address folding by ensuring an LEA base remains invariant before containment, preventing LIR ordering and assertion failures.

Changes:

  • Adds an IsInvariantInRange guard for LEA base addresses.
  • Preserves existing SIMD12 and write-barrier exclusions.
  • Requires a regression test for the reported Wasm address-ordering pattern.
File Summary
src/​coreclr/​jit/​lowerwasm.cpp Adds the Wasm LEA base-address invariance guard.

@lewing

lewing commented Sep 21, 2026

Copy link
Copy Markdown
Member

any chance #134262 is related?

@AndyAyersMS

Copy link
Copy Markdown
Member

any chance #134262 is related?

Seems unlikely at first glance.

@adamperlin
adamperlin merged commit 4e6ff09 into dotnet:main Sep 22, 2026
150 of 151 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 23, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasm WebAssembly architecture 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.

[RyuJIT Wasm] Assert: Write to unaliased local overlaps outstanding read

4 participants