Add getBase accessor so that underlying tree can be
manipulated in a similar manner to MachineDominatorTree.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Could you add some basic unit tests and a separate set of unit tests where critical edges get split?
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.
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.