Dominator Trees

Hello everyone,

I would like to implement a query to check if a node in the CallGraph dominates another CallGraph node. I thus started specializing DomTreeNodeBase and DominatorTreeBase such as I can have CallGraphDomTreeNode and CallGraphDominatorTree.

After allocating the tree, I call DomTreeNode::recalculate(CallGraph &). However, I cannot instantiate the template as it does seem the part of that function dealing with initializing the post-dominator roots:

00692 // Initialize the roots list
00693 for (typename TraitsTy::nodes_iterator I = TraitsTy::nodes_begin(&F),
00694 E = TraitsTy::nodes_end(&F); I != E; ++I) {
00695 if (TraitsTy::child_begin(I) == TraitsTy::child_end(I))
00696 addRoot(I);
00697
00698 // Prepopulate maps so that we don’t get iterator invalidation issues later.
00699 this->IDoms[I] = nullptr;
00700 this->DomTreeNodes[I] = nullptr;
00701 }

implicitly assumes that it should be possible to convert a TraitsTy::nodes_iterator into a NodeT *.

In my case, TraitsTy is GraphTraits<CallGraph *> and NodeT is CallGraphNode. I was able to understand that this works fine for the DominatorTree class, as the corresponding TraitsTy::nodes_iterator is a iplist::iterator, which provides a type-cast operator to BasicBlock *. I was also able to understand the error I got, since the same operator is missing for GraphTraits<CallGraph *>::nodes_iterator.

My question is whether the ability of casting a GraphTraits::nodes_iterator into a NodeT * is a mandatory requirement for using DominatorTreeBase.

Thanks,
Ettore Speziale