Skip to content

JIT: Preserve null checks in SequenceEqual VN folding - #135364

Merged
EgorBo merged 1 commit into
dotnet:mainfrom
EgorBo:fix-sequenceequal-vn-nullchecks
Oct 8, 2026
Merged

EgorBo merged 1 commit into
dotnet:mainfrom
EgorBo:fix-sequenceequal-vn-nullchecks

Conversation

@EgorBo

@EgorBo EgorBo commented Oct 7, 2026

Copy link
Copy Markdown
Member

The equal-VN fold of SpanHelpers.SequenceEqual can return true for identical null refs even when the managed implementation would dereference them and throw.

Preserve GT_NULLCHECKs for short, nonempty sequences (0 < length < sizeof(nuint)), while keeping the zero-length and long-buffer shortcuts. Retain the call when the length is unknown and the refs may be null. Argument side effects remain evaluated before the null checks.

Preserve faulting behavior for equal references with short nonempty sequences, and retain nullable calls when the length is unknown.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 7219f17d-da1f-42e0-bd7c-d9eecdba5eb6
@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 Oct 7, 2026
@EgorBo
EgorBo requested a balanced review from Copilot October 7, 2026 20:51
@azure-pipelines

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: @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.

🟡 Changes recommended

The behavioral JIT fix lacks targeted regression coverage for null refs, length boundaries, and evaluation order.

1 open finding
What changed in this PR

Corrects JIT folding of SpanHelpers.SequenceEqual to preserve required null-check behavior.

Changes:

  • Handles zero and unknown lengths safely.
  • Emits null checks for short, equal-address sequences.
  • Preserves argument side effects.
File Description
src/​coreclr/​jit/​assertionprop.cpp Refines equal-VN SequenceEqual folding semantics.

🧠 Review effort: Balanced

Comment thread src/coreclr/jit/assertionprop.cpp
@EgorBo

EgorBo commented Oct 8, 2026

Copy link
Copy Markdown
Member Author

/ba-g unrelated SMPT failures

@EgorBo
EgorBo merged commit 8aaa594 into dotnet:main Oct 8, 2026
140 of 142 checks passed
@EgorBo
EgorBo deleted the fix-sequenceequal-vn-nullchecks branch October 8, 2026 23:15
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.

3 participants