Skip to content

JIT asserts genIsValidIntReg in scope-info for wasm R2R in MinOpts #129630

Closed

Description

@pavelsavara

crossgen2 targeting wasm R2R (--targetarch:wasm --targetos:browser --obj-format:wasm) asserts in the checked JIT when compiling in MinOpts (i.e. without -O):

Assert failure(PID …): src\coreclr\jit\scopeinfo.cpp:161
  Assertion failed 'genIsValidIntReg(reg)' during 'Generate code'

Root cause

CodeGenInterface::siVarLoc::storeVariableInRegisters (scopeinfo.cpp) asserts genIsValidIntReg(reg), but an enregistered local / return value is homed in a wasm virtual register (e.g. 0x20000001), which is not a valid integer register.

The wasm register is visible in R2RDump's variable-location output for the produced image:

Loc Type: VLT_REG
Register: NYI '536870913'        # 0x20000001
...
Base Register: NYI '2'

Reached via the siVarLoc(const LclVarDsc*, …) constructor lvIsInReg() → siFillRegisterVarLoc path. The two storeVariableInRegisters call sites are the return-value location (codegencommon.cpp ~L1840) and scope tracking (scopeinfo.cpp ~L1756).

Repro

crossgen2 a trivial method to wasm R2R without -O:

using System.Threading.Tasks;
class Test { static Task<int> Main(string[] args) { System.Console.WriteLine("Hello World!"); return Task.FromResult(0); } }
crossgen2 --targetarch:wasm --targetos:browser --obj-format:wasm \
  --jitpath:<clrjit_universal_wasm_x64.dll> \
  --codegenopt:JitWasmNyiToR2RUnsupported=1 \
  --out:Test.wasm Test.dll

Adding -O avoids the assert.

Workaround

Pass -O to crossgen2.

Configuration

  • Target: browser-wasm, R2R via crossgen2 (--obj-format:wasm)
  • Checked/Debug wasm JIT (clrjit_universal_wasm_x64.dll)
  • Compilation mode: MinOpts (no -O)

Note

This issue was investigated and authored with the assistance of GitHub Copilot.

Activity

  1. added
    area-CodeGen-coreclr
    on Jun 19, 2026
  2. added
    untriaged
    on Jun 19, 2026
  3. added
    arch-wasm
    os-browser
    and removed
    area-CodeGen-coreclr
    untriaged
    on Jun 19, 2026
  4. dotnet-policy-service commented on Jun 19, 2026

    @dotnet-policy-service
    Contributor

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

  5. dotnet-policy-service commented on Jun 19, 2026

    @dotnet-policy-service
    Contributor

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

  6. added
    area-CodeGen-coreclr
    on Jun 19, 2026
  7. dotnet-policy-service commented on Jun 19, 2026

    @dotnet-policy-service
    Contributor

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

  8. self-assigned this
    on Jun 19, 2026
  9. added a commit that references this issue on Jun 19, 2026
    718366a
  10. added a commit that references this issue on Jun 21, 2026
    3b1cc5f
  11. added a commit that references this issue on Jul 15, 2026
    c67e547
  12. locked and limited conversation to collaborators on Jul 22, 2026
  13. added a commit that references this issue on Jul 22, 2026
    6bf5809
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

arch-wasmarea-CodeGen-coreclros-browser

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions