Skip to content

Comments

[RyuJit/WASM] Rewrite SP references into PHYSREGs#124710

Merged
AndyAyersMS merged 1 commit intodotnet:mainfrom
SingleAccretion:WasmJit-SP
Feb 22, 2026
Merged

[RyuJit/WASM] Rewrite SP references into PHYSREGs#124710
AndyAyersMS merged 1 commit intodotnet:mainfrom
SingleAccretion:WasmJit-SP

Conversation

@SingleAccretion
Copy link
Contributor

The special SP local presents unique challenges for RA:

  1. It can't be a proper candidate since it lacks correct liveness due to implicit uses.
  2. Even if we change liveness, we don't want to allocate it to stack even in debug mode. Both because it is wasteful and because it makes the contract for opcodes like LCLHEAP more complicated.

The solution implemented here is to treat the SP specially in RA:

  1. Neuter its local to make it look as if it has no references. That makes sure we don't spill it to stack in debug code and straightens out the contract with codegen w.r.t. candidate liveness.
  2. Rewrite all explicit references into PHYSREG nodes.

In effect, we transfer the 'ownership' of the SP value from the local to the "SP reg" well-known codegen location, confining all the "specialness" to RA.

@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 Feb 21, 2026
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Feb 21, 2026
The special SP local presents unique challenges for RA:
1) It can't be a proper candidate since it lacks correct liveness
   due to implicit uses.
2) Even if we change liveness, we don't want to allocate
   it to stack even in debug mode. Both because it is wasteful
   and because it makes the contract for opcodes like LCLHEAP
   more complicated.

The solution implemented here is to treat the SP specially in RA:
1) Neuter its local to make it look as if it has no references.
   That makes sure we don't spill it to stack in debug code and
   straightens out the contract with codegen w.r.t. candidate
   liveness.
2) Rewrite all explicit references into PHYSREG nodes.

In effect, we transfer the 'ownership' of the SP value from
the local to the "SP reg" well-known codegen location, confining
all the "specialness" to RA.
@am11 am11 added the arch-wasm WebAssembly architecture label Feb 21, 2026
@dotnet-policy-service
Copy link
Contributor

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

@SingleAccretion
Copy link
Contributor Author

@dotnet/jit-contrib

@AndyAyersMS AndyAyersMS merged commit a48fa8e into dotnet:main Feb 22, 2026
127 of 130 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants