Skip to content

JIT: Fix empty-block cycle hang - #132795

Merged
AndyAyersMS merged 3 commits into
dotnet:mainfrom
AndyAyersMS:fix-fgopt-empty-cycle
Aug 27, 2026
Merged

JIT: Fix empty-block cycle hang#132795
AndyAyersMS merged 3 commits into
dotnet:mainfrom
AndyAyersMS:fix-fgopt-empty-cycle

Conversation

@AndyAyersMS

@AndyAyersMS AndyAyersMS commented Aug 26, 2026

Copy link
Copy Markdown
Member

Fixes #132785.

fgOptimizeBranchToEmptyUnconditional only recognized two-block empty cycles. Detect any empty unconditional cycle before redirecting the edge so flow optimization terminates.

Adds the regression test to the shared JIT regression runner and uses AggressiveOptimization to exercise FullOpts.

Validation:

  • Checked CoreCLR and libraries build
  • Regression test hangs with the pre-fix JIT and passes with the fixed JIT
  • Regression_ro_2 build
  • jit-format

Note

This pull request description was generated by GitHub Copilot.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 26, 2026 19:55
@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 Aug 26, 2026
@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.

@AndyAyersMS

Copy link
Copy Markdown
Member Author

@jakobbotsch PTAL
fyi @dotnet/jit-contrib

Fixes a fuzzing-created example; haven't seen this in real code.

@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 updates CoreCLR JIT flow-graph optimization to avoid non-terminating rewrites when a branch targets an empty BBJ_ALWAYS block that participates in an empty-block cycle, and adds a focused regression test to cover the hang scenario.

Changes:

  • Extend fgOptimizeBranchToEmptyUnconditional to detect cycles in empty unconditional chains (using a slow/fast pointer walk) and suppress the redirect when a cycle is found.
  • Add a new JitBlue regression test project Runtime_132785 that runs with DOTNET_TieredCompilation=0 to ensure the optimizing JIT path is exercised deterministically.

Reviewed changes

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

File Description
src/coreclr/jit/fgopt.cpp Prevents repeated edge redirection around empty-block cycles so flow optimization terminates.
src/tests/JIT/Regression/JitBlue/Runtime_132785/Runtime_132785.csproj Adds isolated JIT regression test project configuration, including tiered compilation disabled.
src/tests/JIT/Regression/JitBlue/Runtime_132785/Runtime_132785.cs Adds an xUnit-based repro-derived test that asserts the expected result and guards against the compilation hang.

Comment thread src/tests/JIT/Regression/JitBlue/Runtime_132785/Runtime_132785.csproj Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 27, 2026 16:38
# Conflicts:
#	src/tests/JIT/Regression/Regression_ro_2.csproj

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

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

Copilot AI review requested due to automatic review settings August 27, 2026 16:46

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

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

@AndyAyersMS

Copy link
Copy Markdown
Member Author

/ba-g OSX timeouts

@AndyAyersMS
AndyAyersMS merged commit d9a6b9e into dotnet:main Aug 27, 2026
137 of 139 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Aug 28, 2026
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: fgOptimizeBranchToEmptyUnconditional loops forever on longer empty-block cycle

3 participants