This is an archive of the discontinued LLVM Phabricator instance.

[Dominators] Remove requirement to use NodeRef->getParent().
AbandonedPublic

Authored by fhahn on Jan 9 2023, 12:51 AM.

Details

Summary

At the moment, DominatorTreeBase requires NodeRef->getParent to return a
pointer to the container containing all NodeRefs.

This prevents DominatorTreeBase being used for hierarchical structures
where NodeRef can have multiple sub-types, with different parents. This
for example is the case for VPlan, which has region blocks that can be
nested, and regular blocks. NodeRef::getParent() here returns the
containing region. The 'parent' to use for the dominator tree is a VPlan
though, which contains the hierarchical CFG.

To enable such uses cases, allow GraphTraits to provide a custom ParentPtrTy to
directly define what parent pointer to use and add a ::getParent helper, which
can be specialized.

The main motivation for this patch is using DominatorTreeBase across all
regions of a VPlan, see D140513 https://reviews.llvm.org/D140513.

Diff Detail

Event Timeline

fhahn created this revision.Jan 9 2023, 12:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 9 2023, 12:51 AM
fhahn requested review of this revision.Jan 9 2023, 12:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 9 2023, 12:51 AM
fhahn updated this revision to Diff 490676.Jan 19 2023, 3:25 PM

Simplify.

fhahn retitled this revision from [Dominators] Remove requirement to have NodeRef->getParent(). (WIP) to [Dominators] Remove requirement to use NodeRef->getParent()..Jan 19 2023, 3:27 PM
fhahn edited the summary of this revision. (Show Details)
fhahn added reviewers: Ayal, foad, nhaehnle, asbirlea, kuhar.
kuhar added inline comments.Jan 19 2023, 6:08 PM
llvm/include/llvm/Support/GenericDomTree.h
228–229

What do you think about making this a little bit more general, say: struct DominatorTreeNodeTraits and moving NodePtr/ParentType/GraphTraits (from D142162) there as well?

fhahn marked an inline comment as done.Jan 20 2023, 7:09 AM
fhahn added inline comments.
llvm/include/llvm/Support/GenericDomTree.h
228–229

I updated D142162 to add a DomTreeNodeTraits class with a customization option. Is that along the lines you had in mind?

fhahn abandoned this revision.Jan 20 2023, 7:11 AM
fhahn marked an inline comment as done.

Subsumed by more general D142162