Skip to content

JIT: Fix promoted liveness in forward substitution - #133703

Merged
AndyAyersMS merged 4 commits into
dotnet:mainfrom
AndyAyersMS:fix-133641-forward-sub-liveness
Sep 18, 2026
Merged

AndyAyersMS merged 4 commits into
dotnet:mainfrom
AndyAyersMS:fix-133641-forward-sub-liveness

Conversation

@AndyAyersMS

Copy link
Copy Markdown
Member

Multi-use forward substitution could leave stale last-use flags on promoted struct parents, allowing a live struct copy to be removed.

Make last-use invalidation promotion-aware and reuse the same logic for single- and multi-use substitution. Add a regression test.

Fixes #133641

Note

This PR description was generated with GitHub Copilot.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 11, 2026 15:49
@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 Sep 11, 2026
@AndyAyersMS AndyAyersMS changed the title Fix promoted liveness in forward substitution JIT: Fix promoted liveness in forward substitution Sep 11, 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.

@AndyAyersMS

Copy link
Copy Markdown
Member Author

@jakobbotsch ptal
fyi @dotnet/jit-contrib

No diffs expected

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

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.

🔵 Needs a closer look

The JIT liveness change is correctness-sensitive and warrants final human review.

Pull request overview

Fixes a CoreCLR JIT forward-substitution liveness bug involving promoted structs.

Changes:

  • Adds promotion-aware last-use invalidation for substitution.
  • Adds and registers regression coverage for issue #133641.
File summaries
File Changes
src/tests/JIT/Regression/Regression_ro_2.csproj Registers the regression test.
src/tests/JIT/Regression/JitBlue/Runtime_133641/Runtime_133641.cs Adds regression coverage.
src/coreclr/jit/forwardsub.cpp Updates liveness invalidation logic.
src/coreclr/jit/compiler.h Declares the shared helper.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 11, 2026 15:58

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.

🔵 Needs a closer look

The supplied readiness assessments are mixed, so final human review is warranted.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Comment thread src/coreclr/jit/forwardsub.cpp Outdated
Comment thread src/coreclr/jit/forwardsub.cpp Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 17, 2026 19:04

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.

🔵 Needs a closer look

JIT liveness changes require final human review.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@AndyAyersMS

Copy link
Copy Markdown
Member Author

Somehow this agent was able to auto-post. Still working on this, more changes to come.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 17, 2026 21:13

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.

🔵 Needs a closer look

The JIT liveness change is correctness-sensitive, and final human validation is warranted.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@AndyAyersMS

Copy link
Copy Markdown
Member Author

a few diffs

@AndyAyersMS
AndyAyersMS merged commit 539d1a2 into dotnet:main Sep 18, 2026
140 of 143 checks passed
@AndyAyersMS

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)

JulieLeeMSFT pushed a commit that referenced this pull request Sep 21, 2026
…34349)

Backport of #133703 to release/11.0

/cc @AndyAyersMS

## Customer Impact

- [ ] Customer reported
- [x] Found internally

Forward substitution can leave stale last-use flags on promoted struct
parents and remove a live struct copy. The reported case returns `6`
instead of the correct value `8`. This reproduces on .NET 11 RC2; .NET
8, 9, and 10 are correct. See #133641.

## Regression

- [x] Yes
- [ ] No

Introduced during the .NET 11 cycle by #129312.

## Testing

Added a focused regression test that exercises multi-use forward
substitution of a promoted struct and verifies that the defining copy
remains live. The source PR was validated through JIT CI and SuperPMI
analysis; only a small number of expected code-generation differences
were observed.

## Risk

Low. The fix makes last-use invalidation promotion-aware and reuses the
same logic for single- and multi-use substitution. It preserves liveness
conservatively rather than enabling a new optimization.

Co-authored-by: Andy Ayers <andya@microsoft.com>
Co-authored-by: Copilot <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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JIT: (bug) Forward substitution drops a promoted struct's defining store

3 participants