Skip to content

JIT: Compute new dominators earlier and invalidate old dominators - #95925

Merged
jakobbotsch merged 1 commit into
dotnet:mainfrom
jakobbotsch:ssa-dominators-earlier
Dec 13, 2023
Merged

jakobbotsch merged 1 commit into
dotnet:mainfrom
jakobbotsch:ssa-dominators-earlier

Conversation

@jakobbotsch

Copy link
Copy Markdown
Member
  • Add a new phase to compute new dominators and exceptional entries based on them after loop unrolling. Invalidate the old dominators at the same time.
  • Rename LclVarDsc::lvVolatileHint => LclVarDsc::lvHasExceptionalUsesHint
  • Switch early prop to use lvLiveInOutOfHndlr for one of its correctness checks. When this code was originally written it seems lvLiveInOutOfHndlr was debug-only. (Also, lvHasExceptionalUsesHint does not seem like it would be a sufficient check for correctness purposes)
  • Add a convenience GetPostOrder(unsigned index) accessor to the DFS tree class and switch some uses to it

* Add a new phase to compute new dominators and exceptional entries
  based on them after loop unrolling. Invalidate the old dominators at
  the same time.
* Rename `LclVarDsc::lvVolatileHint` =>
  `LclVarDsc::lvHasExceptionalUsesHint`
* Switch early prop to use `lvLiveInOutOfHndlr` for one of its
  correctness checks. When this code was originally written it seems
  `lvLiveInOutOfHndlr` was debug-only. (Also, `lvHasExceptionalUsesHint`
  does not seem like it would be a sufficient check for correctness
  purposes)
* Add a convenience `GetPostOrder(unsigned index)` accessor to the DFS
  tree class and switch some uses to it
@ghost ghost assigned jakobbotsch Dec 12, 2023
@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Dec 12, 2023
@ghost

ghost commented Dec 12, 2023

Copy link
Copy Markdown

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

Issue Details
  • Add a new phase to compute new dominators and exceptional entries based on them after loop unrolling. Invalidate the old dominators at the same time.
  • Rename LclVarDsc::lvVolatileHint => LclVarDsc::lvHasExceptionalUsesHint
  • Switch early prop to use lvLiveInOutOfHndlr for one of its correctness checks. When this code was originally written it seems lvLiveInOutOfHndlr was debug-only. (Also, lvHasExceptionalUsesHint does not seem like it would be a sufficient check for correctness purposes)
  • Add a convenience GetPostOrder(unsigned index) accessor to the DFS tree class and switch some uses to it
Author: jakobbotsch
Assignees: jakobbotsch
Labels:

area-CodeGen-coreclr

Milestone: -

// Inside try we allow only stores to locals not live in handlers.
// lvVolatileHint is set to true on variables that are line in handlers.
result = tree->OperIs(GT_STORE_LCL_VAR) && !lvaTable[tree->AsLclVar()->GetLclNum()].lvVolatileHint;
result = tree->OperIs(GT_STORE_LCL_VAR) && !lvaTable[tree->AsLclVar()->GetLclNum()].lvLiveInOutOfHndlr;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Looks like we didn't use this originally because it was debug-only back then:
#1735 (comment)

However, today we do have it in all flavors and it gets computed right before early prop.

Comment thread src/coreclr/jit/fgopt.cpp
// Returns:
// Suitable phase status.
//
PhaseStatus Compiler::fgComputeDominators()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's a bit confusing that we now have fgComputeDoms and fgComputeDominators, but the confusion should only be temporary...

@jakobbotsch

Copy link
Copy Markdown
Member Author

cc @dotnet/jit-contrib PTAL @BruceForstall

Diffs. Mainly from the early prop change that gives us a bit more precision than using "dominated by exceptional entry".

@jakobbotsch
jakobbotsch marked this pull request as ready for review December 12, 2023 20:15
printf("*************** In SsaBuilder::Build()\n");
}
#endif
JITDUMP("*************** In SsaBuilder::Build()\n");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In general, this is fine. Note, however, that the older form has one useful feature: you can set an unconditional line-based breakpoint on the "printf" that only activates when debugging a function where you've enabled JitDump (so verbose is true).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah, that makes sense... I'll avoid making this change in the future.

@jakobbotsch
jakobbotsch merged commit 93da46f into dotnet:main Dec 13, 2023
@jakobbotsch
jakobbotsch deleted the ssa-dominators-earlier branch December 13, 2023 10:02
@jakobbotsch jakobbotsch mentioned this pull request Dec 13, 2023
15 of 21 tasks
@github-actions github-actions Bot locked and limited conversation to collaborators Jan 13, 2024
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