Skip to content

Fix NativeAOT nullable isinst branch elimination - #134823

Merged
agocke merged 1 commit into
dotnet:mainfrom
agocke:naot-is-test
Sep 29, 2026
Merged

agocke merged 1 commit into
dotnet:mainfrom
agocke:naot-is-test

Conversation

@agocke

@agocke agocke commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Summary

  • avoid treating isinst Nullable<T> success branches as unreachable based on the absence of a constructed Nullable<T> MethodTable
  • keep substituted IL generation and dependency scanning consistent for nullable type tests
  • add a new regression test for NativeAOT coverage for generic nullable type-test branches with matching, mismatching, and null inputs

Resolves #134799

Note

This pull request description was generated with GitHub Copilot.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 318157b0-8bdc-4d1e-b18e-25341047f8c3
@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: @agocke, @dotnet/ilc-contrib
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.

Copilot review overview

🟢 Approval recommended

The focused fix consistently addresses both affected compiler paths and includes representative regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes incorrect NativeAOT elimination of reachable isinst Nullable<T> branches.

Changes:

  • Excludes nullable type tests from unsafe branch folding and conditional dependency scanning.
  • Adds regression coverage for matching, mismatching, and null inputs.
File Description
SubstitutedILProvider.cs Preserves nullable isinst branches.
ILImporter.Scanner.cs Scans nullable success-branch dependencies unconditionally.
Generics.cs Adds NativeAOT nullable branch regression tests.

@agocke
agocke merged commit 8692b67 into dotnet:main Sep 29, 2026
118 of 120 checks passed
@agocke
agocke deleted the naot-is-test branch September 29, 2026 17:59
@agocke

agocke commented Sep 29, 2026

Copy link
Copy Markdown
Member Author

/backport to release/11.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0 (link to workflow run)

@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 30, 2026
JulieLeeMSFT pushed a commit that referenced this pull request Oct 1, 2026
)

Backport of #134823 to release/11.0

/cc @agocke

## Customer Impact

- [x] Customer reported
- [ ] Found internally

[Select one or both of the boxes. Describe how this issue impacts
customers, citing the expected and actual behaviors and scope of the
issue. If customer-reported, provide the issue number.]

## Regression

- [ ] Yes
- [x] No

[If yes, specify when the regression was introduced. Provide the PR or
commit if known.]

## Testing

Unit test.

## Risk

Very low.

Co-authored-by: Andy Gocke <angocke@microsoft.com>
Copilot-Session: 318157b0-8bdc-4d1e-b18e-25341047f8c3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

NativeAOT: generic 'o is T' with T = Nullable<int> never returns, so MemoryCache.TryGetValue(key, out int?) hangs

3 participants