Skip to content

JIT: Cleanup and harden lowering#130837

Merged
tannergooding merged 4 commits into
dotnet:mainfrom
tannergooding:tannergooding-lowering-cleanup-hardening
Jul 21, 2026
Merged

JIT: Cleanup and harden lowering#130837
tannergooding merged 4 commits into
dotnet:mainfrom
tannergooding:tannergooding-lowering-cleanup-hardening

Conversation

@tannergooding

Copy link
Copy Markdown
Member

A batch of low-risk cleanup and hardening in JIT lowering, found during a lowering deep-dive. None of these are runtime-observable, so there are no regression tests. Grouped into focused commits.


lower.cpp -- debug-only diagnostics
SplitArgumentBetweenRegistersAndStack had a JITDUMP that evaluated splitPoint->GetOffset() on the branch where splitPoint == nullptr -- a verbose-only null-deref, and the format string didn't even consume it. Dropped that and the other unconsumed numRegs, stackSeg.Size args on the FIELD_LIST/BLK/reuse/spill dumps. Also fixed two [%06u} -> [%06u] typos in the containment diagnostics.


lowerarmarch.cpp -- shift/NOT containment hardening + dead stores
The child shift/NOT containment path in IsContainableUnaryOrBinaryOp didn't call IsInvariantInRange before allowing containment, unlike its siblings just above it. This isn't a live bug today (the operand is the immediate LIR predecessor by construction), but it's fragile and inconsistent, so this adds the matching guard and drops a redundant OperIs sub-condition already guaranteed by the enclosing block. Also removes dead stores to oper in LowerHWIntrinsic.


lowerxarch.cpp -- dead code + comment/typo fixes

  • GetOperForHWIntrinsicId(&isScalar) clobbered the outer isScalar; the adjacent local userIsScalar was the intended target. Latent footgun, not a behavior change today.
  • Removed a no-op node->Op(1) = op1;, a tautological assert(!src->TypeIs(TYP_STRUCT));, and dead + (0 * elemSize) arithmetic.
  • Comment fixes: DPPD immediate 0x31 -> 0x33 to match the code, reworded the integer compare-less-than swap comment, Sse41.BlendVariable -> X86Base.BlendVariable, and assorted typos.

Verified: baseline build.cmd clr -rc checked succeeds, jitformat.py is clean, and the x64 JIT rebuilds with no warnings/errors. The lowerarmarch.cpp change is a verbatim structural mirror of adjacent compiling code in the same function.

Note

This PR description was drafted by GitHub Copilot.

tannergooding and others added 4 commits July 15, 2026 19:49
Drop unconsumed JITDUMP arguments (including a null-deref of splitPoint) and correct the [%06u} closing brace to a bracket in the containment diagnostics.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Guard the child shift/NOT containment path with IsInvariantInRange to match its sibling paths, remove the redundant OperIs sub-condition already guaranteed by the enclosing block, and drop dead stores to oper in LowerHWIntrinsic.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Pass &userIsScalar instead of clobbering the outer isScalar, drop the no-op node->Op(1) reassignment and the tautological TYP_STRUCT assert, and simplify the dead + (0 * elemSize) offset arithmetic.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Update the DPPD immediate to 0x33, reword the integer compare-less-than swap comment, refer to X86Base.BlendVariable, and fix assorted typos (so so, don't both, storeInder, ouutIndirOpSource, hsa).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 16, 2026 04:12
@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 Jul 16, 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.

@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 does a small set of cleanup and hardening changes in CoreCLR JIT lowering, primarily removing dead/debug-only hazards and correcting internal comments/diagnostics.

Changes:

  • Fix debug-only JITDUMP issues in lowering diagnostics (format typos, unused varargs, and a null-deref in a verbose-only path).
  • Harden ARMArch shift containment under NOT/*_NOT by adding the same IsInvariantInRange guard used by adjacent containment paths; remove dead oper stores in ARM HWIntrinsic lowering.
  • Remove no-op/dead code in xarch HWIntrinsic lowering, fix a latent isScalar out-param clobber, and update various comments/typos to match current behavior.
Show a summary per file
File Description
src/coreclr/jit/lower.cpp Corrects debug-only containment/split-arg diagnostics (format/args) and removes a verbose-only null-deref hazard.
src/coreclr/jit/lowerarmarch.cpp Adds an IsInvariantInRange containment guard for shift+NOT cases and removes dead stores in HWIntrinsic lowering.
src/coreclr/jit/lowerxarch.cpp Removes no-op/dead assertions/assignments, fixes GetOperForHWIntrinsicId out-param usage, and updates comments/typos for clarity and correctness.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 0

@tannergooding tannergooding reopened this Jul 16, 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.

@github-actions

github-actions Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Workflow state for the Holistic Review Orchestrator.

{
  "version": 5,
  "last_dispatched_commit": "87528676b346b660386e93b9c1bb55cdf2f617f9",
  "last_dispatched_base_ref": "main",
  "last_dispatched_base_sha": "f2281d59e62aa6a75e53055b8f842bac108b9887",
  "last_reviewed_commit": "87528676b346b660386e93b9c1bb55cdf2f617f9",
  "last_reviewed_base_ref": "main",
  "last_reviewed_base_sha": "f2281d59e62aa6a75e53055b8f842bac108b9887",
  "last_recorded_worker_run_id": "29684894810",
  "review_attempt_commit": "",
  "review_attempt_base_ref": "",
  "review_attempt_count": 0,
  "max_review_attempts": 5,
  "review_history_format": "holistic-review-disclosure-v1",
  "review_history": [
    {
      "commit": "87528676b346b660386e93b9c1bb55cdf2f617f9",
      "review_id": 4730669898
    }
  ]
}

@github-actions github-actions Bot 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.

Holistic Review

Motivation: A batch of low-risk cleanup and hardening in JIT lowering, uncovered during a lowering deep-dive. The goal is to remove dead code, fix latent footguns, correct misleading diagnostics, and align inconsistent containment logic—none of which is runtime-observable, so no regression tests accompany the change.

Approach: The PR groups focused edits across three lowering files. In lower.cpp it removes unconsumed JITDUMP arguments (including a verbose-only null-deref of splitPoint->GetOffset() on the splitPoint == nullptr branch) and fixes two [%06u}[%06u] format typos. In lowerarmarch.cpp it adds a missing IsInvariantInRange guard to the shift/NOT containment path in IsContainableUnaryOrBinaryOp (mirroring the sibling GT_ADD/GT_SUB/... and GT_CMP/GT_OR/... blocks), drops an OperIs(GT_LSH, GT_RSH, GT_RSZ) sub-condition already guaranteed by the enclosing if, and removes dead stores to oper in LowerHWIntrinsic. In lowerxarch.cpp it fixes GetOperForHWIntrinsicId(&isScalar)&userIsScalar (the outer isScalar was being clobbered), removes a no-op node->Op(1) = op1;, a tautological assert(!src->TypeIs(TYP_STRUCT)), dead + (0 * elemSize) arithmetic, and assorted comment/typo fixes.

Summary: I reviewed the full base-to-head range and confirmed each change. The removed oper assignments in the ARM LowerHWIntrinsic occur after the last read of oper (lines reading it at the GT_AND/GT_OR checks still see the value set at the top of the function), so the removal is safe. The new IsInvariantInRange guard is a verbatim structural mirror of the adjacent containment blocks in the same function and is strictly more conservative, so it cannot introduce a miscompile; the retained assert(shiftAmountNode->isContained()) matches the siblings. The &userIsScalar fix targets a genuinely misdirected out-parameter and does not change behavior today because the outer isScalar is not subsequently consumed in a way that depended on the clobbered value. The removed node->Op(1) = op1; is a no-op since op1 was just read from node->Op(1) with no intervening reassignment. All remaining edits are diagnostics, comments, and dead arithmetic with no functional effect. The changes are self-consistent, improve robustness, and carry negligible risk.

Verdict: LGTM. No actionable findings.

Note

This review was generated by this repository's Holistic Review agentic workflow to complement the built-in Copilot review.

Generated by Holistic Review · 66.6 AIC · ⌖ 10.6 AIC · ⊞ 10K

@tannergooding
tannergooding requested a review from EgorBo July 21, 2026 14:55
@tannergooding

Copy link
Copy Markdown
Member Author

CC. @dotnet/jit-contrib, @EgorBo. Trivial cleanup of some comments, JITDUMP, and a simplification to a code path

@tannergooding
tannergooding enabled auto-merge (squash) July 21, 2026 14:56
@JulieLeeMSFT JulieLeeMSFT added the Priority:2 Work that is important, but not critical for the release label Jul 21, 2026
@JulieLeeMSFT
JulieLeeMSFT self-requested a review July 21, 2026 18:15
Comment thread src/coreclr/jit/lower.cpp
@tannergooding
tannergooding merged commit ae6601d into dotnet:main Jul 21, 2026
162 checks passed
@tannergooding
tannergooding deleted the tannergooding-lowering-cleanup-hardening branch July 21, 2026 18:59
Comment thread src/coreclr/jit/lowerxarch.cpp
JulieLeeMSFT pushed a commit that referenced this pull request Jul 21, 2026
Follow-up to #130837.

Several `JITDUMP` calls pass a trailing argument to a format string that
has no corresponding `%` specifier, so the argument is silently ignored.
This removes those leftover args. All are `DEBUG`-only and behavior is
unchanged.

- `lower.cpp` -- `JITDUMP("Argument is a local\n", numRegs,
stackSeg.Size)` (the one called out in #130837)
- `importercalls.cpp` -- `arrayElemSize`
- `importervectorization.cpp` -- `str`
- `inductionvariableopts.cpp` -- `dspTreeID(...)` (redundant; the
following `DISPTREE` already dumps the tree) and `lclNum`
- `optimizer.cpp` -- `lclNum`
- `rangecheck.cpp` -- `expr` (two sites)

Found by scanning every `.cpp` under `src/coreclr/jit` for literal
format strings with no conversion but a trailing argument; these were
the only hits.

> [!NOTE]
> This PR description and the changes were drafted with GitHub Copilot.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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 Priority:2 Work that is important, but not critical for the release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants