Skip to content

JIT: rework phase objects so we can use them more widely#31808

Merged
AndyAyersMS merged 2 commits intodotnet:masterfrom
AndyAyersMS:ImprovedPhases
Feb 6, 2020
Merged

JIT: rework phase objects so we can use them more widely#31808
AndyAyersMS merged 2 commits intodotnet:masterfrom
AndyAyersMS:ImprovedPhases

Conversation

@AndyAyersMS
Copy link
Member

Next part of #2109.

Add support for phases that are simply compiler methods or lambdas. These are
not used yet -- the plan is to introduce new phases gradually, cleaning up
redundant checking and dumping along the way. This will happen in subequent
changes.

Remove a bit of now-redundant post-phase dumping and checking from lower.

Add the active phase to the assertion text, so we have some context.

Next part of dotnet#2109.

Add support for phases that are simply compiler methods or lambdas. These are
not used yet -- the plan is to introduce new phases gradually, cleaning up
redundant checking and dumping along the way. This will happen in subequent
changes.

Remove a bit of now-redundant post-phase dumping and checking from lower.

Add the active phase to the assertion text, so we have some context.
@AndyAyersMS
Copy link
Member Author

cc @dotnet/jit-contrib

No diffs; jit dump is a bit smaller as there were basically two IR dumps at the end of lower.

Copy link
Contributor

@CarolEidt CarolEidt left a comment

Choose a reason for hiding this comment

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

LGTM - I really like the direction this is going! I'm not sure I would have added the method/lambda version until it's used, but no harm I guess.


// End of the morphing phases
//
// We can now enable all phase checking
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! Might be worth a comment explaining why this can't be done earlier.

Copy link
Member Author

Choose a reason for hiding this comment

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

This should be temporary (see below).

LogEnv* env = JitTls::GetLogEnv();
const int BUFF_SIZE = 8192;
char* buff = (char*)alloca(BUFF_SIZE);
const char* phaseName = "unknown phase";
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding the phase to the assert is great!

@sandreenko sandreenko added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI and removed area-Meta labels Feb 5, 2020
@AndyAyersMS
Copy link
Member Author

I have another change that phasifies everything (and uses the new phase forms introduced here) but it currently introduces a lot of redundant dumping and checking.

I do not want to make checked builds slower or use more memory or make jit dump files larger. So I have to work towards this bit by bit.

The next few steps are:

  • introduce check auditing so we know what post-phase checks we run currently
  • introduce some simple ways of indicating that a phase did not modify anything and suppress redundant post-phase dumps and checks. Initially this will just catch the trivial cases where the phase itself is certain it did not make changes. Later we can consider trying to auto-detect this somehow.
  • gradually start introducing phase objects to wrap things that should be phases. Verify via check auditing that the jit is doing the same checks it does now. Remove redundant manually invoked checks or dumps.
  • hopefully enough of the new phase-ending checks and dumps are redundant and we can do the above without impacting TP/mem/dump file size.
  • break checks into finer granularity parcels and enable the simpler checks as early as possible.

@BruceForstall
Copy link
Contributor

Maybe you could start by having a phase opt-in to post-phase checks/dumps that it already does, remove those manual steps, and have the phase infrastructure do them.

@AndyAyersMS
Copy link
Member Author

I had originally thought to strongly couple phases to post-phase checks, but didn't like how this came out, it was a lot of extra detail. Current proposal is that the set of active post-phase checks will be part of the ambient compiler state, so as we progress through the phase list we will add / remove active checks. We can do this either in between or during phases.

On top of this, I may add a way for a phase to request "additional" checks, if there are phases that warrant extra scrutiny and the extra checks are not specific to just one phase.

Copy link
Contributor

@BruceForstall BruceForstall left a comment

Choose a reason for hiding this comment

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

LGTM

# add the install targets
install_clr(TARGETS ${jitName})
endfunction()

Copy link
Contributor

Choose a reason for hiding this comment

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

hmmm... you don't like whitespace?

Copy link
Member Author

Choose a reason for hiding this comment

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

Didn't mean to do that. Let me undo that part.

@AndyAyersMS AndyAyersMS merged commit 5040afe into dotnet:master Feb 6, 2020
@AndyAyersMS AndyAyersMS deleted the ImprovedPhases branch February 6, 2020 02:34
@ghost ghost added the will_lock_this label Dec 6, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Jan 5, 2021
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.

5 participants