diff options
| author | Philip Reames <listmail@philipreames.com> | 2015-09-23 18:39:37 +0000 |
|---|---|---|
| committer | Philip Reames <listmail@philipreames.com> | 2015-09-23 18:39:37 +0000 |
| commit | e1440256520aba388015a15f5c273afa799271d5 (patch) | |
| tree | fe53a5082b6d0726e868c0aa3c1379833e31c41b /llvm | |
| parent | 4327d7aa124d9af021a17710a2c3c7dad0ef6416 (diff) | |
| download | bcm5719-llvm-e1440256520aba388015a15f5c273afa799271d5.tar.gz bcm5719-llvm-e1440256520aba388015a15f5c273afa799271d5.zip | |
[docs] Update DominatorTree docs to clarify expectations around unreachable blocks
Note: I'm am not trying to describe what "should be"; I'm only describing what is true today.
This came out of my recent question to llvm-dev titled: When can the dominator tree not contain a node for a basic block?
Differential Revision: http://reviews.llvm.org/D13078
llvm-svn: 248417
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/IR/Dominators.h | 16 | ||||
| -rw-r--r-- | llvm/include/llvm/Support/GenericDomTree.h | 6 |
2 files changed, 20 insertions, 2 deletions
diff --git a/llvm/include/llvm/IR/Dominators.h b/llvm/include/llvm/IR/Dominators.h index f306b0fccc7..37447c353b1 100644 --- a/llvm/include/llvm/IR/Dominators.h +++ b/llvm/include/llvm/IR/Dominators.h @@ -64,6 +64,22 @@ 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<BasicBlock> { public: typedef DominatorTreeBase<BasicBlock> Base; diff --git a/llvm/include/llvm/Support/GenericDomTree.h b/llvm/include/llvm/Support/GenericDomTree.h index 63678bb98bb..a790d754d20 100644 --- a/llvm/include/llvm/Support/GenericDomTree.h +++ b/llvm/include/llvm/Support/GenericDomTree.h @@ -371,8 +371,9 @@ public: void releaseMemory() { reset(); } /// getNode - return the (Post)DominatorTree node for the specified basic - /// block. This is the same as using operator[] on this class. - /// + /// block. This is the same as using operator[] on this class. The result + /// may (but is not required to) be null for a forward (backwards) + /// statically unreachable block. DomTreeNodeBase<NodeT> *getNode(NodeT *BB) const { auto I = DomTreeNodes.find(BB); if (I != DomTreeNodes.end()) @@ -380,6 +381,7 @@ public: return nullptr; } + /// See getNode. DomTreeNodeBase<NodeT> *operator[](NodeT *BB) const { return getNode(BB); } /// getRootNode - This returns the entry node for the CFG of the function. If |

