[llvm-commits] CVS: llvm/include/llvm/Analysis/Dominators.h ET-Forest.h
Chris Lattner
clattner at apple.com
Sat Apr 21 23:49:16 PDT 2007
> Add accessor to get the blocks immediately dominated by a given
> block to ETForest.
Ok...
> @@ -327,6 +327,20 @@
> const ETNode *idom = NodeA->getFather();
> return idom ? idom->getData<BasicBlock>() : 0;
> }
> +
> + void getChildren(BasicBlock *A, std::vector<BasicBlock*>&
> children) {
> + ETNode *NodeA = getNode(A);
> + const ETNode* son = NodeA->getSon();
> +
> + if (!son) return;
> + children.push_back(son->getData<BasicBlock>());
> +
> + const ETNode* brother = son->getBrother();
> + while (brother != son) {
> + children.push_back(brother->getData<BasicBlock>());
> + brother = brother->getBrother();
> + }
> + }
Two things :). First, why merge domtree into etforest? The tree
structure used by domtree is more efficient for representing children
than the one used by etforest. If you really want to merge into
etforest, please change it to keep a vector of children, instead of
the brother scheme it uses. This will allow this accessor to be a
constant time operation (returning a const reference to a pre-
existing vector) that doesn't do a ton of pointer chasing.
Is that feasible?
-Chris
More information about the llvm-commits
mailing list