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: build pred lists first #81448

Merged
merged 3 commits into from
Feb 2, 2023

Conversation

AndyAyersMS
Copy link
Member

Move pred list building before importation. It now runs as the first phase in the phase list.

  • Split up some unions in block.h as some things can't share storage anymore (may revisit this later).
  • Modify importer not to rely on cheap preds. Most of the work here is in impImportLeave.
  • Adjust OSR protection strategy for the method entry. In particular, watch for the degenerate case where the OSR entry is the method entry.
  • Ensure we don't double-decrement some ref counts when blocks with degenerate or folded flow are re-imported.
  • Update spill clique discovery to use the actual pred lists.
  • Add new method impFixPredLists for the importer to use at the end of importation. This adds pred list entries finally returns, which can't be done until all BBJ_LEAVE blocks are processed.

Contributes to #80193.

Move pred list building before importation. It now runs as the first phase in
the phase list.

* Split up some unions in block.h as some things can't share storage anymore
(may revisit this later).
* Modify importer not to rely on cheap preds. Most of the work here is in
`impImportLeave`.
* Adjust OSR protection strategy for the method entry. In particular, watch
for the degenerate case where the OSR entry is the method entry.
* Ensure we don't double-decrement some ref counts when blocks with degenerate
or folded flow are re-imported.
* Update spill clique discovery to use the actual pred lists.
* Add new method `impFixPredLists` for the importer to use at the end of
importation. This adds pred list entries finally returns, which can't be
done until all `BBJ_LEAVE` blocks are processed.

Contributes to dotnet#80193.
@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 Feb 1, 2023
@ghost ghost assigned AndyAyersMS Feb 1, 2023
@ghost
Copy link

ghost commented Feb 1, 2023

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

Issue Details

Move pred list building before importation. It now runs as the first phase in the phase list.

  • Split up some unions in block.h as some things can't share storage anymore (may revisit this later).
  • Modify importer not to rely on cheap preds. Most of the work here is in impImportLeave.
  • Adjust OSR protection strategy for the method entry. In particular, watch for the degenerate case where the OSR entry is the method entry.
  • Ensure we don't double-decrement some ref counts when blocks with degenerate or folded flow are re-imported.
  • Update spill clique discovery to use the actual pred lists.
  • Add new method impFixPredLists for the importer to use at the end of importation. This adds pred list entries finally returns, which can't be done until all BBJ_LEAVE blocks are processed.

Contributes to #80193.

Author: AndyAyersMS
Assignees: AndyAyersMS
Labels:

area-CodeGen-coreclr

Milestone: -

@AndyAyersMS
Copy link
Member Author

@jakobbotsch PTAL (and/or @BruceForstall if you're only quasi-vacationing)
cc @dotnet/jit-contrib

This gets pred list building to the front of the phase list and removes one more user of cheap pred lists.

Some small diffs in methods with patchpoints; the adaptive placement strategy is sensitive to bbRefs and the old code was not always accurate there.

Next step will be to build pred lists when we initially build the flow graph and get rid of the pred list building phase and the last user of cheap preds (eh normalization). Then I'm envisioning a bunch more cleanup as it seems like we can just do "automatic" maintenance of all these references.

@AndyAyersMS AndyAyersMS mentioned this pull request Feb 1, 2023
44 tasks
@AndyAyersMS
Copy link
Member Author

AndyAyersMS commented Feb 1, 2023

Failing on some bad IL tests.

Note even with main these tests will fail if dumps are enabled, as we hit an assert trying to display the successors of an endfinally in the BB table.

Looks like we will now need to BADCODE when building pred lists; odd that we don't catch this sooner.

@AndyAyersMS
Copy link
Member Author

Diffs

TP impact looks high (with minopts close to 1%), but drilling in, the only collection actually slower is minopts coreclr-tests; the other collections are all faster, so possibly a scaling issue with some of the crazier tests. We may gain some of this back in the next stage of work.

Copy link
Member

@jakobbotsch jakobbotsch left a comment

Choose a reason for hiding this comment

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

Generally looks fine to me, though I must admit I didn't spend too much time verifying that all the new fgAddRefPred/fgRemoveRefPred calls are right.
Maybe run some stress pipelines?

@jakobbotsch
Copy link
Member

Diffs

TP impact looks high (with minopts close to 1%), but drilling in, the only collection actually slower is minopts coreclr-tests; the other collections are all faster, so possibly a scaling issue with some of the crazier tests. We may gain some of this back in the next stage of work.

Maybe related to #78267?

@AndyAyersMS
Copy link
Member Author

Maybe run some stress pipelines?

Sure.

TP impact looks high ...

Maybe related to #78267?

Yeah, probably cases like that one. Add/Remove ref can also be quadratic in worst case since they have to search a list, but it only matters when there are huge numbers of predecessors.

@AndyAyersMS
Copy link
Member Author

/azp run runtime-coreclr jitstress, runtime-coreclr libraries-jitstress

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@AndyAyersMS
Copy link
Member Author

Looks like some widespread jitstress issue. Will investigate.

@AndyAyersMS
Copy link
Member Author

/azp run runtime-coreclr jitstress, runtime-coreclr libraries-jitstress

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@AndyAyersMS
Copy link
Member Author

Stress is green.

@AndyAyersMS AndyAyersMS merged commit 75408bb into dotnet:main Feb 2, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Mar 4, 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.

2 participants