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

JIT: produce consistent flow graph when producing or consuming profile data #85860

Merged
merged 1 commit into from
May 6, 2023

Conversation

AndyAyersMS
Copy link
Member

Always try and merge "branch to next" blocks when building the initial flow graph if BBINSTR or BBOPT is set.

Fixes #85856.

…e data

Always try and merge "branch to next" blocks when building the intial flow graph
if BBINSTR or BBOPT is set.

Fixes dotnet#85856.
@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 May 6, 2023
@ghost ghost assigned AndyAyersMS May 6, 2023
@ghost
Copy link

ghost commented May 6, 2023

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

Issue Details

Always try and merge "branch to next" blocks when building the initial flow graph if BBINSTR or BBOPT is set.

Fixes #85856.

Author: AndyAyersMS
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@AndyAyersMS
Copy link
Member Author

@EgorBo PTAL
cc @dotnet/jit-contrib

This is going to cause some diffs and perhaps some (short lived) perf regressions, until static PGO catches up with updated schemas for some methods.

@AndyAyersMS
Copy link
Member Author

AndyAyersMS commented May 6, 2023

Diffs from CI are more extensive than what I saw locally, let me pull down the latest MCHs and recheck this.

Hmm, I guess I just misremembered what I'd seen.

@AndyAyersMS AndyAyersMS merged commit ae1be12 into dotnet:main May 6, 2023
AndyAyersMS added a commit to AndyAyersMS/runtime that referenced this pull request May 12, 2023
OSR and PGO both rely on the fact that the early flowgraph the JIT builds is
the same flowgraph as the one seen in a previous JIT complation of that method,
since there is metadata (patchpoint offset, pgo schema) that refers to the
flowgraph. Previous work here (dotnet#85860) didn't ensure this for enough cases.

In particular if Tier0 does not do early block merging, but OSR does, it's possible
for the OSR entry point to fall within a merged block range, which the JIT is not
prepared to handle. This lead to the asserts seen in dotnet#86125.

The fix is to enable early block merging unless we're truly in a minopts or
debug codegen mode (previous to this Tier0 would not merge unless it also
was instrumenting; now it will always merge).

An alternative fix would be to find the block containing the OSR entry IL
offset, scan its statements, and split the block at the right spot, but that
seemed more involved.

Fixes dotnet#86125.
AndyAyersMS added a commit that referenced this pull request May 13, 2023
OSR and PGO both rely on the fact that the early flowgraph the JIT builds is
the same flowgraph as the one seen in a previous JIT complation of that method,
since there is metadata (patchpoint offset, pgo schema) that refers to the
flowgraph. Previous work here (#85860) didn't ensure this for enough cases.

In particular if Tier0 does not do early block merging, but OSR does, it's possible
for the OSR entry point to fall within a merged block range, which the JIT is not
prepared to handle. This lead to the asserts seen in #86125.

The fix is to enable early block merging unless we're truly in a minopts or
debug codegen mode (previous to this Tier0 would not merge unless it also
was instrumenting; now it will always merge).

An alternative fix would be to find the block containing the OSR entry IL
offset, scan its statements, and split the block at the right spot, but that
seemed more involved.

Fixes #86125.
@ghost ghost locked as resolved and limited conversation to collaborators Jun 5, 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.

JIT: more unexpected dynamic PGO schema mismatches
2 participants