Skip to content

JIT: Preserve unused volatile loads - #137117

Merged
AndyAyersMS merged 1 commit into
dotnet:mainfrom
AndyAyersMS:fix-136888-volatile-side-effects
Nov 9, 2026
Merged

AndyAyersMS merged 1 commit into
dotnet:mainfrom
AndyAyersMS:fix-136888-volatile-side-effects

Conversation

@AndyAyersMS

Copy link
Copy Markdown
Member

Side effect extraction could drop a nonfaulting volatile read when folding a comparison. Repeated optimization could then hoist an ordinary load out of the polling loop and cause a hang.

Recognize volatile ordering effects and preserve acquire semantics through comma morphing, unused-load lowering, and LIR dead-code removal. Ordinary operations with ordering constraints remain removable.

Validation on Windows x64 Checked:

  • Checked native and cross-target JITs built, with a hash-matched Core_Root.
  • All 471 existing Regression_ro_2 tests, the original regression under JitStress=214, and 13 volatile-prefix tests passed.
  • ARM32/ARM64 codegen retains acquire loads and ordinary-data reloads in the loop. Native ARM execution was not run.

Default python src\coreclr\scripts\superpmi.py asmdiffs: 968,442 contexts, zero missing, four diffs, +21 bytes. Only Runtime_134477:Test grows; three other contexts replace null-check compares with same-size volatile loads. NativeAOT and libraries have no diffs.

Resolves #136888

Note

This pull request was generated with GitHub Copilot.

Keep volatile loads and their acquire semantics when extracting side effects and removing dead code.

Resolves dotnet#136888

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 9cc9c0d2-0703-4d8a-bd9a-84a28b236726
@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 Nov 6, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 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.

@AndyAyersMS

Copy link
Copy Markdown
Member Author

ptal @dotnet/contrib

Comment thread src/coreclr/jit/gentree.cpp Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Test failure: global::Runtime_134477.TestEntryPoint()

2 participants