This is an archive of the discontinued LLVM Phabricator instance.

[Dominators] Facilitate updates to MachinePostDominatorTree
ClosedPublic

Authored by critson on Apr 11 2020, 11:44 PM.

Details

Summary

Add getBase accessor so that underlying tree can be
manipulated in a similar manner to MachineDominatorTree.

Diff Detail

Event Timeline

critson created this revision.Apr 11 2020, 11:44 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2020, 11:44 PM

Could you add some basic unit tests and a separate set of unit tests where critical edges get split?

critson updated this revision to Diff 256944.Apr 13 2020, 1:52 AM

Add basic unit tests.

lkail added a subscriber: lkail.Apr 13 2020, 2:11 AM

Couldn't whichever user of MachineDominatorTree needs this just access the underlying dominator tree structures via the getBase() accessor method and call the relevant functions on there?

The reason I'm concerned about this is that the current MachineDominatorTree falls out of the more common pattern for analyses that has been established for the new pass manager. If you'll look at the dominator tree on IR, for example, you'll see that there's a DominatorTree class that is not a pass in any way, and then DominatorTreeWrapperPass (old pass manager) and DominatorTreeAnalysis (new pass manager) wrapper passes that will return the DominatorTree object.

I think it would be better if the MachineDominatorTree usage would be better aligned with that pattern, rather than moving further away from it. (Currently, MachineDominatorTree has the custom critical-edge-split handling which should arguably be refactored into a use of the general dominator tree-updater mechanism as well...)

Couldn't whichever user of MachineDominatorTree needs this just access the underlying dominator tree structures via the getBase() accessor method and call the relevant functions on there?

The reason I'm concerned about this is that the current MachineDominatorTree falls out of the more common pattern for analyses that has been established for the new pass manager. If you'll look at the dominator tree on IR, for example, you'll see that there's a DominatorTree class that is not a pass in any way, and then DominatorTreeWrapperPass (old pass manager) and DominatorTreeAnalysis (new pass manager) wrapper passes that will return the DominatorTree object.

I think it would be better if the MachineDominatorTree usage would be better aligned with that pattern, rather than moving further away from it. (Currently, MachineDominatorTree has the custom critical-edge-split handling which should arguably be refactored into a use of the general dominator tree-updater mechanism as well...)

Having spent a while looking at it recently, I agree the interface for MachineDominatorTree is definitely uncomfortably far from the DominatorTree interface and fixing that would be a good thing.

Looking into it I can refactor the changes I had in mind to use getBase(), although it is missing for MachinePostDominatorTree.
So I can reduce this change to adding a getBase() accessor for MachinePostDominatorTree.

critson updated this revision to Diff 257274.Apr 14 2020, 4:01 AM

Simplify the change set to bare minimum required.

critson retitled this revision from [Dominators] Facilitate updates to MachineDominator trees to [Dominators] Facilitate updates to MachinePostDominatorTree.Apr 14 2020, 4:02 AM
critson edited the summary of this revision. (Show Details)
critson updated this revision to Diff 257292.Apr 14 2020, 5:01 AM

Upload correct diff.

kuhar accepted this revision.Apr 18 2020, 3:06 PM

LGTM.

While this is fine, I'm I don't understand how splitting critical edges will interact with domtree updates when you call getBase in MachineDominators.h. But we can discuss that in another patch.

This revision is now accepted and ready to land.Apr 18 2020, 3:06 PM
This revision was automatically updated to reflect the committed changes.