Skip to content

JIT: preserve null checks when folding ThrowIfNull in Tier0 - #135823

Merged
EgorBo merged 3 commits into
mainfrom
copilot/tier0-fix-argumentnullexception
Oct 20, 2026
Merged

EgorBo merged 3 commits into
mainfrom
copilot/tier0-fix-argumentnullexception

Conversation

Copilot AI commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Tier0’s CORINFO_HELP_BOX folding dropped the struct read, so ArgumentNullException.ThrowIfNull(r.Ref) no longer threw NullReferenceException for a null byref.

  • Importer: preserve GT_NULLCHECK on potentially null source addresses, before paramName evaluation.
  • Regression coverage: add an isolated Tier0 theory covering null and valid byrefs, plus argument evaluation order and side effects.

No diffs

@azure-pipelines

azure-pipelines Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
11 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: @dotnet/runtime-infrastructure
See info in area-owners.md if you want to be subscribed.

@jkotas jkotas added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI and removed area-Infrastructure labels Oct 14, 2026
@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.

Copilot AI changed the title [WIP] Fix ArgumentNullException on null byref in Tier0 JIT: preserve null checks when folding ThrowIfNull in Tier0 Oct 14, 2026
Copilot AI requested a review from EgorBo October 14, 2026 23:05
@EgorBo

EgorBo commented Oct 14, 2026

Copy link
Copy Markdown
Member

@copilot remove the csproj for test, make it single *.cs test (see jit regression test skill).

Copilot AI commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

@copilot remove the csproj for test, make it single *.cs test (see jit regression test skill).

Addressed in 1879e63: removed the .csproj and moved the unchanged test into Regression_ro_2. All four cases pass under Tier0 and FullOpts.

@EgorBo

EgorBo commented Oct 15, 2026

Copy link
Copy Markdown
Member

PTAL @dotnet/jit-contrib, trivial change, no diffs

@EgorBo

EgorBo commented Oct 16, 2026

Copy link
Copy Markdown
Member

ping @dotnet/jit-contrib simple change, just adds a nullcheck

@JulieLeeMSFT

Copy link
Copy Markdown
Member

LGTM.

ArgumentNullException.ThrowIfNull(CORINFO_HELP_BOX(cls, addr), name)
                         │
                         ▼
Tier0 importer (impThrowIfNull)
   old: addr spilled, helper assumed non-null -> NOP (null deref lost!)
   new: addr spilled
        if (addr could be null) -> emit explicit NULLCHECK(addr)
        -> NOP (side effects + null check preserved)

@EgorBo

EgorBo commented Oct 20, 2026

Copy link
Copy Markdown
Member

/ba-g failure is #136153

@EgorBo
EgorBo enabled auto-merge (squash) October 20, 2026 14:00
@EgorBo
EgorBo merged commit 1a7c0b4 into main Oct 20, 2026
130 of 133 checks passed
@EgorBo
EgorBo deleted the copilot/tier0-fix-argumentnullexception branch October 20, 2026 14:02
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Oct 21, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

JIT: (bug) [Tier0] ArgumentNullException.ThrowIfNull(r.Ref) on a null byref no longer throws NullReferenceException

4 participants