Skip to content

Conversation

@amanasifkhalid
Copy link
Contributor

Fixes #117581 (comment). cc @dotnet/jit-contrib, @AndyAyersMS PTAL. Thanks!

Copilot AI review requested due to automatic review settings July 14, 2025 18:07
@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 14, 2025
Copy link
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 refines flow optimization by preventing the movement of exception-handling entry blocks when enabling branch reversal.

  • Inlines and extends the EH-region check in fgopt.cpp to disallow moving try/handler entries in addition to same-region blocks.
  • Removes the now-unneeded helper fgEhAllowsMoveBlock from fgbasic.cpp and its declaration in compiler.h.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/coreclr/jit/fgopt.cpp Inlined EH checks and added disallow conditions for EH entry blocks
src/coreclr/jit/fgbasic.cpp Removed fgEhAllowsMoveBlock implementation
src/coreclr/jit/compiler.h Removed fgEhAllowsMoveBlock declaration
Comments suppressed due to low confidence (2)

src/coreclr/jit/fgopt.cpp:4520

  • The comment mentions EH invariants but doesn't reflect the newly added checks for try/handler entry blocks. Consider updating it to enumerate these conditions or reference the specific invariants for clarity.
                        // However, we cannot move bDest if it will break EH invariants.

src/coreclr/jit/fgopt.cpp:4523

  • Consider adding or updating JIT unit tests to cover branch reversal scenarios near EH boundaries (try/handler entries and call-finally pairs) to ensure this new logic prevents invalid block moves.
                            bDest->isBBCallFinallyPair())

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@amanasifkhalid
Copy link
Contributor Author

No diffs.

@amanasifkhalid
Copy link
Contributor Author

/ba-g android-x64 CoreCLR build stuck

@amanasifkhalid amanasifkhalid enabled auto-merge (squash) July 14, 2025 20:46
@amanasifkhalid amanasifkhalid merged commit adc9777 into dotnet:main Jul 14, 2025
108 of 112 checks passed
@amanasifkhalid amanasifkhalid deleted the branch-reversal-eh-entry branch July 14, 2025 20:55
@github-actions github-actions bot locked and limited conversation to collaborators Aug 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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.

Assertion failed 'block->bbTryIndex == blockTryIndex[block->bbNum]' in 'System.Collections.Immutable.Tests.ImmutableArrayTest

2 participants