Skip to content

[release/10.0] JIT: only imply non-null assertions from exact-type assertions - #132628

Open
EgorBo wants to merge 1 commit into
dotnet:release/10.0from
EgorBo:jit-132599-assertionprop-nonnull
Open

[release/10.0] JIT: only imply non-null assertions from exact-type assertions#132628
EgorBo wants to merge 1 commit into
dotnet:release/10.0from
EgorBo:jit-132599-assertionprop-nonnull

Conversation

@EgorBo

@EgorBo EgorBo commented Aug 21, 2026

Copy link
Copy Markdown
Member

Fixes #132599 in release/10.0. There is no PR to backport: main is already unaffected because #123856 deleted optImpliedByTypeOfAssertions outright as a throughput cleanup, so the bug was fixed there by accident and never flagged for servicing.

Customer Impact

  • Customer reported
  • Found internally

Reported in #132599. Silent wrong code, no exception: enumerating a large OpenXML worksheet returned 0 rows (or a truncated count) once the method tiered up, so the customer's 1,000,000-row import quietly dropped data.

optImpliedByTypeOfAssertions treated any lcl != <const> assertion as a non-null assertion — it only checked op2.kind == O2K_CONST_INT and never that the constant was 0. The exact-type assertion produced by the guarded devirtualization check on Type.Equals (t is RuntimeType) therefore activated the unrelated t != typeof(Row) assertion on the same VN, inside the devirtualized block itself. Assertion prop then folded the live comparison to a constant and dropped the matching arm:

VN relop based constant assertion prop in BB24:
Assertion index=#09: [002712] != 1230248688 (gcref)
...
Bashed to int constant: CNS_INT int 1
Conditional folded at BB24
BB24 becomes a BBJ_ALWAYS to BB06     <-- 'count++' block now unreachable

Any virtualCall().Equals(typeof(T)) in a hot loop can hit this. Mitigations were DOTNET_TieredPGO=0 or DOTNET_JitEnableGuardedDevirtualization=0.

Regression

  • Yes
  • No

Long-standing: the missing iconVal == 0 check predates .NET 10. It became reachable in practice as GDV started producing exact-type assertions in more shapes.

Testing

Added regression test Runtime_132599, reduced from the customer report to a self-contained 30-line case

Risk

Low. The change only narrows an implication to the case the surrounding code already documents ("must be a Non Null assertion"), so it can only remove assertions that were never valid.

optImpliedByTypeOfAssertions treated any "lcl != <const>" assertion as a
non-null assertion, because it never checked that the constant was 0. An
exact-type assertion could therefore activate an unrelated constant
assertion on the same VN, and assertion prop would fold a live comparison
away.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ec11ff08-3e62-4386-a86e-51f868acffe1
Copilot AI lite review requested due to automatic review settings August 21, 2026 15:24
@EgorBo EgorBo added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Aug 21, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 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.

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.

Pull request overview

This PR fixes a JIT assertion propagation bug in release/10.0 where non-null implications were incorrectly derived from any lcl != <const> assertion, even when the constant was not 0. The change narrows the implication to only treat lcl != 0 as non-null, and adds a targeted regression test based on the reported OpenXML iterator data-loss scenario.

Changes:

  • Restrict non-null implication logic to != 0 constant assertions in optImpliedByTypeOfAssertions.
  • Add a new JIT regression test (Runtime_132599) that validates correctness under Tiered Compilation + Tiered PGO.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/coreclr/jit/assertionprop.cpp Adds the missing iconVal == 0 check so only true non-null assertions imply non-null.
src/tests/JIT/Regression/JitBlue/Runtime_132599/Runtime_132599.cs New regression test reproducing the reported silent wrong-code pattern in a small self-contained case.
src/tests/JIT/Regression/JitBlue/Runtime_132599/Runtime_132599.csproj Test project config enabling Tiered Compilation and Tiered PGO for the regression scenario.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@JulieLeeMSFT JulieLeeMSFT added the Servicing-consider Issue for next servicing release review label Aug 24, 2026
@JulieLeeMSFT JulieLeeMSFT added this to the 10.0.x milestone Aug 24, 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 Servicing-consider Issue for next servicing release review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants