Skip to content

Remove PHASE_MERGE_THROWS#129084

Merged
EgorBo merged 5 commits into
dotnet:mainfrom
EgorBo:remove-fgTailMergeThrows
Jun 8, 2026
Merged

Remove PHASE_MERGE_THROWS#129084
EgorBo merged 5 commits into
dotnet:mainfrom
EgorBo:remove-fgTailMergeThrows

Conversation

@EgorBo
Copy link
Copy Markdown
Member

@EgorBo EgorBo commented Jun 6, 2026

PHASE_HEAD_TAIL_MERGE fully covers what PHASE_MERGE_THROWS did. Had to bump the threshold to cover some regressions.

-13kb diffs on win-x64

Copilot AI review requested due to automatic review settings June 6, 2026 22:28
@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 Jun 6, 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 removes the standalone throw-block tail-merge phase (PHASE_MERGE_THROWS / Compiler::fgTailMergeThrows) and folds its intent into the existing PHASE_HEAD_TAIL_MERGE implementation, expanding terminal (return/throw) tail-merging behavior.

Changes:

  • Adjusts fgHeadTailMerge to apply the predecessor-count cap only for common-successor tail merges, and to retry terminal (return/throw) merges until no more groups are found.
  • Deletes fgTailMergeThrows and all related plumbing (phase entry, mem kind, compiler.h declaration, phase invocation).
  • Removes the PHASE_MERGE_THROWS phase name and TailMergeThrows allocation kind.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/coreclr/jit/fgopt.cpp Updates head/tail merge to retry terminal merges and exempts terminal merges from the pred-count cap.
src/coreclr/jit/fgehopt.cpp Removes the old fgTailMergeThrows implementation entirely.
src/coreclr/jit/compphases.h Removes PHASE_MERGE_THROWS from the phase list.
src/coreclr/jit/compmemkind.h Removes TailMergeThrows memory kind.
src/coreclr/jit/compiler.h Removes the fgTailMergeThrows declaration.
src/coreclr/jit/compiler.cpp Removes the DoPhase(... PHASE_MERGE_THROWS ...) invocation.

Comment thread src/coreclr/jit/fgopt.cpp Outdated
Comment thread src/coreclr/jit/fgopt.cpp Outdated
EgorBo and others added 2 commits June 7, 2026 00:37
Bounds the terminal-block merge work instead of leaving it unlimited. 2x (100) is the minimal multiple that avoids code-size regressions vs the fgTailMergeThrows baseline (SPMI asmdiffs over libraries.pmi/benchmarks/aspnet); 1x regresses +5,982 bytes on libraries.pmi.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 6, 2026 23:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

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

Copilot AI review requested due to automatic review settings June 6, 2026 23:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

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

@EgorBo
Copy link
Copy Markdown
Member Author

EgorBo commented Jun 8, 2026

PTAL cleanup @AndyAyersMS @dotnet/jit-contrib

Copy link
Copy Markdown
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Interesting that there are diffs. I couldn't see what they were from. Maybe we need a tails merged metric.

@EgorBo
Copy link
Copy Markdown
Member Author

EgorBo commented Jun 8, 2026

LGTM

Interesting that there are diffs. I couldn't see what they were from. Maybe we need a tails merged metric.

Just from bumping the threshold maybe? I can add the metric if you think it's worth it (as part of some other change)

@EgorBo EgorBo merged commit ed9aba2 into dotnet:main Jun 8, 2026
142 checks passed
@EgorBo EgorBo deleted the remove-fgTailMergeThrows branch June 8, 2026 15:10
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