Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly represent BBJ_EHFINALLYRET successors #93377

Conversation

BruceForstall
Copy link
Member

Currently, BBJ_EHFINALLYRET blocks have no explicit successors in the IR. To implement successor iteration, a very expensive process is followed to (1) find the region of blocks where a BBJ_CALLFINALLY block calling the finally might be found, (2) search the region for such blocks, and (3) return as a successor all the BBJ_ALWAYS blocks in the corresponding BBJ_CALLFINALLY/BBJ_ALWAYS pair.

Change the IR to explicitly represent and maintain this list of successors for BBJ_EHFINALLYRET blocks. The representation is a simple array of BasicBlock*, similar to how BBJ_SWITCH block targets are represented.

Fixes #84278

Notes:

  1. The BBJ_EHFINALLYRET successors are computed in impFixPredLists(). There are various dumpers that run before this, so we need to tolerate incomplete successor information in some places.
  2. ehGetCallFinallyBlockRange() is still used by some code. I changed the semantics to return a [first..last] range inclusive of last instead of the previous [beginning..end) range exclusive of end. This makes it easier to use with our BasicBlock iterators.

Currently, BBJ_EHFINALLYRET blocks have no explicit successors in the IR.
To implement successor iteration, a very expensive process is followed to
(1) find the region of blocks where a BBJ_CALLFINALLY block calling the
`finally` might be found, (2) search the region for such blocks, and (3)
return as a successor all the BBJ_ALWAYS blocks in the corresponding
BBJ_CALLFINALLY/BBJ_ALWAYS pair.

Change the IR to explicitly represent and maintain this list of successors
for BBJ_EHFINALLYRET blocks. The representation is a simple array of
`BasicBlock*`, similar to how BBJ_SWITCH block targets are represented.

Fixes dotnet#84278

Notes:
1. The BBJ_EHFINALLYRET successors are computed in `impFixPredLists()`.
There are various dumpers that run before this, so we need to tolerate
incomplete successor information in some places.
2. `ehGetCallFinallyBlockRange()` is still used by some code. I changed the
semantics to return a `[first..last]` range inclusive of `last` instead of
the previous `[beginning..end)` range exclusive of `end`. This makes it easier
to use with our BasicBlock iterators.
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Oct 12, 2023
@ghost ghost assigned BruceForstall Oct 12, 2023
@ghost
Copy link

ghost commented Oct 12, 2023

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

Issue Details

Currently, BBJ_EHFINALLYRET blocks have no explicit successors in the IR. To implement successor iteration, a very expensive process is followed to (1) find the region of blocks where a BBJ_CALLFINALLY block calling the finally might be found, (2) search the region for such blocks, and (3) return as a successor all the BBJ_ALWAYS blocks in the corresponding BBJ_CALLFINALLY/BBJ_ALWAYS pair.

Change the IR to explicitly represent and maintain this list of successors for BBJ_EHFINALLYRET blocks. The representation is a simple array of BasicBlock*, similar to how BBJ_SWITCH block targets are represented.

Fixes #84278

Notes:

  1. The BBJ_EHFINALLYRET successors are computed in impFixPredLists(). There are various dumpers that run before this, so we need to tolerate incomplete successor information in some places.
  2. ehGetCallFinallyBlockRange() is still used by some code. I changed the semantics to return a [first..last] range inclusive of last instead of the previous [beginning..end) range exclusive of end. This makes it easier to use with our BasicBlock iterators.
Author: BruceForstall
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@BruceForstall
Copy link
Member Author

No diffs, generally a slight TP improvement, in some cases significant.

@BruceForstall
Copy link
Member Author

@AndyAyersMS PTAL
cc @dotnet/jit-contrib

Copy link
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.

Looks good overall. Left a few suggestions for possibly simplifying the code.

src/coreclr/jit/fgbasic.cpp Outdated Show resolved Hide resolved
src/coreclr/jit/fgbasic.cpp Show resolved Hide resolved
src/coreclr/jit/fgbasic.cpp Show resolved Hide resolved
src/coreclr/jit/fgdiagnostic.cpp Show resolved Hide resolved
@BruceForstall
Copy link
Member Author

@AndyAyersMS I addressed your suggestions.

@BruceForstall
Copy link
Member Author

The superpmi-diffs failure is out of disk space.
The test failures are Quic (known) and 4 win-arm64 failures. Oddly, the exact same 4 failures were reported by a release/7.0 PR today: #93424. I can't repro the failures locally either with my change, without it, or with a fresh build of HEAD of runtime/main.

@BruceForstall
Copy link
Member Author

Looks like @AndyAyersMS had a PR with the same win-arm64 failures: #93371

@BruceForstall
Copy link
Member Author

Oddly, the exact same 4 failures were reported by a release/7.0 PR

Maybe the build machines picked up a new MSVC arm64 compiler that has a bug? It does look like the compiler changed recently.

@BruceForstall BruceForstall merged commit 851c274 into dotnet:main Oct 13, 2023
121 of 129 checks passed
@BruceForstall BruceForstall deleted the ExplicitlyRepresentEHFINALLYRETSuccessors branch October 13, 2023 05:06
@ghost ghost locked as resolved and limited conversation to collaborators Nov 12, 2023
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.

Flow graph successors representation for BBJ_EHFINALLYRET
2 participants