X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FIR%2FDominators.h;h=37447c353b195c316fd700dd8338c7d2f2c94c36;hb=eac309550f259b7f78f1e69ea8e62fea493efd43;hp=8080ae7c1224eb8e860083cc92c97ad169633304;hpb=204b59072d38d8b441a607cd7bcc24e33a6220df;p=oota-llvm.git diff --git a/include/llvm/IR/Dominators.h b/include/llvm/IR/Dominators.h index 8080ae7c122..37447c353b1 100644 --- a/include/llvm/IR/Dominators.h +++ b/include/llvm/IR/Dominators.h @@ -64,11 +64,30 @@ public: /// \brief Concrete subclass of DominatorTreeBase that is used to compute a /// normal dominator tree. +/// +/// Definition: A block is said to be forward statically reachable if there is +/// a path from the entry of the function to the block. A statically reachable +/// block may become statically unreachable during optimization. +/// +/// A forward unreachable block may appear in the dominator tree, or it may +/// not. If it does, dominance queries will return results as if all reachable +/// blocks dominate it. When asking for a Node corresponding to a potentially +/// unreachable block, calling code must handle the case where the block was +/// unreachable and the result of getNode() is nullptr. +/// +/// Generally, a block known to be unreachable when the dominator tree is +/// constructed will not be in the tree. One which becomes unreachable after +/// the dominator tree is initially constructed may still exist in the tree, +/// even if the tree is properly updated. Calling code should not rely on the +/// preceding statements; this is stated only to assist human understanding. class DominatorTree : public DominatorTreeBase { public: typedef DominatorTreeBase Base; DominatorTree() : DominatorTreeBase(false) {} + explicit DominatorTree(Function &F) : DominatorTreeBase(false) { + recalculate(F); + } DominatorTree(DominatorTree &&Arg) : Base(std::move(static_cast(Arg))) {} @@ -122,55 +141,34 @@ public: // DominatorTree GraphTraits specializations so the DominatorTree can be // iterable by generic graph iterators. -template <> struct GraphTraits { - typedef DomTreeNode NodeType; - typedef NodeType::iterator ChildIteratorType; +template struct DomTreeGraphTraitsBase { + typedef Node NodeType; + typedef ChildIterator ChildIteratorType; + typedef df_iterator> nodes_iterator; - static NodeType *getEntryNode(NodeType *N) { - return N; - } + static NodeType *getEntryNode(NodeType *N) { return N; } static inline ChildIteratorType child_begin(NodeType *N) { return N->begin(); } - static inline ChildIteratorType child_end(NodeType *N) { - return N->end(); - } + static inline ChildIteratorType child_end(NodeType *N) { return N->end(); } - typedef df_iterator nodes_iterator; - - static nodes_iterator nodes_begin(DomTreeNode *N) { + static nodes_iterator nodes_begin(NodeType *N) { return df_begin(getEntryNode(N)); } - static nodes_iterator nodes_end(DomTreeNode *N) { + static nodes_iterator nodes_end(NodeType *N) { return df_end(getEntryNode(N)); } }; -template <> struct GraphTraits { - typedef const DomTreeNode NodeType; - typedef NodeType::const_iterator ChildIteratorType; +template <> +struct GraphTraits + : public DomTreeGraphTraitsBase {}; - static NodeType *getEntryNode(NodeType *N) { - return N; - } - static inline ChildIteratorType child_begin(NodeType *N) { - return N->begin(); - } - static inline ChildIteratorType child_end(NodeType *N) { - return N->end(); - } - - typedef df_iterator nodes_iterator; - - static nodes_iterator nodes_begin(const DomTreeNode *N) { - return df_begin(getEntryNode(N)); - } - - static nodes_iterator nodes_end(const DomTreeNode *N) { - return df_end(getEntryNode(N)); - } -}; +template <> +struct GraphTraits + : public DomTreeGraphTraitsBase {}; template <> struct GraphTraits : public GraphTraits {