Skip to content

JIT: preserve null check dependencies in call arguments - #137276

Merged
AndyAyersMS merged 1 commit into
dotnet:mainfrom
AndyAyersMS:jit-fix-134473
Nov 11, 2026
Merged

AndyAyersMS merged 1 commit into
dotnet:mainfrom
AndyAyersMS:jit-fix-134473

Conversation

@AndyAyersMS

Copy link
Copy Markdown
Member

Preserve dependencies between earlier throwing arguments and later arguments with GTF_ORDER_SIDEEFF. A later argument may rely on an earlier implicit null check, even when it cannot throw itself or throws the same exception.

Evaluate the earlier throwing arguments into temps before argument sorting. Add regression cases for non-throwing dependencies, still-throwing dependencies, and multiple earlier guards.

Validation

Windows x64 Release:

  • .\build.cmd clr+libs -c Release and .\build.cmd clr.jit -c Release: passed.
  • .\src\tests\build.cmd x64 Release -Priority 1 -Test JIT\Regression_ro_2\Regression_ro_2.csproj: passed.
  • All three new cases crash with 0xC0000005 before the fix and pass afterward. The full Regression_ro_2 runner passes all 498 cases.
  • SuperPMI: 335,720 contexts across benchmark and library collections, with zero failed or missing compiles in either JIT.

Checked and other platforms were not run.

Codegen and performance

SuperPMI changes 931 contexts, with a net code-size increase of 1,144 bytes (+0.0018%).

Local BenchmarkDotNet results on Windows x64 under Hyper-V, with tiering and ReadyToRun disabled (one launch, five warmups, ten iterations):

Call Baseline Fixed Change
Large-offset field 3.584 ns 3.875 ns +8.1%
Small-offset field 3.568 ns 3.570 ns Within noise

Resolves #134473

Note

This fix and PR description were prepared with GitHub Copilot.

@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 10, 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.

@AndyAyersMS

Copy link
Copy Markdown
Member Author

@dotnet/jit-contrib PTAL

Relatively simple fix to call argument ordering.

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.

🟢 Approval recommended

No active review issues are reported for the JIT call-argument ordering change.

No open issues 🎉

What changed in this PR

This PR fixes JIT call-argument reordering that can move a dependent argument ahead of an implicit null check, causing an access violation instead of a NullReferenceException.

Changes:

  • Preserve earlier throwing arguments in temporaries when a later argument carries GTF_ORDER_SIDEEFF.
  • Keep exception tracking limited to arguments that can throw.
  • Add regression cases for non-throwing dependencies, throwing dependencies, and multiple earlier guards.
File Description
src/​tests/​JIT/​Regression_ro_2/​Runtime_134473.cs Adds three regression cases checking results and null-reference behavior.
src/​coreclr/​jit/​morph.cpp Preserves null-check dependencies before sorting call arguments.

Review effort: Balanced

@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
AndyAyersMS merged commit af49c2c into dotnet:main Nov 11, 2026
134 of 140 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 11, 2026
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.

JIT: (bug) big-offset field load in a call argument is hoisted above the null check of an earlier argument (AV instead of NRE)

4 participants