(original) (raw)
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 }
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 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::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