You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JIT: (bug) stack-move peephole coalesces two Volatile.Writes to an address-exposed local #135386
The x64 emitter's redundant-stack-move peephole removes a volatile store to a stack local when it's identical to the previous instruction. ECMA-335 I.12.6.7 says an optimizing compiler shall not remove or coalesce volatile operations.
Two mov dword ptr [rsp+0x28], ebx stores, one per Volatile.Write.
Actual
learcx,[rsp+0x28]call[Program:Use(byref)]mov dword ptr [rsp+0x28],ebx ; only one storemoveax, dword ptr [rsp+0x28]
JitDump: -- suppressing mov because last instruction already moved from src to dst. The program prints the correct value (5).
Regression?
No. Reproduces on .NET 8.0, 9.0, 10.0, 11.0-rc2 and main.
Notes
Volatile indirections of a contained GT_LCL_ADDR go through emitIns_S_R/emitIns_R_S, and IsRedundantStackMov (emitxarch.cpp) has no notion of volatility. A volatile load of the same register right after a store to the same slot would be dropped too ("opposite move").
Low impact: spec conformance only, no wrong result observed; another thread can only reach such a local through an unsafe pointer.
Fix: skip the peephole for GTF_IND_VOLATILE indirections.
Activity
dotnet-policy-service commentedon Oct 8, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
JIT: Do not contain local addresses of volatile indirections on xarch (…