summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@google.com>2013-12-02 14:08:27 +0000
committerDiego Novillo <dnovillo@google.com>2013-12-02 14:08:27 +0000
commit97add46aeea26db338f68f16aaf2587737ab46da (patch)
tree4319b8962e7a45ccf859745bef2087bc5e07ef07 /include
parentc15aff93c49dabb5ed174fd3731c7219e96af1f4 (diff)
downloadllvm-97add46aeea26db338f68f16aaf2587737ab46da.tar.gz
llvm-97add46aeea26db338f68f16aaf2587737ab46da.tar.bz2
llvm-97add46aeea26db338f68f16aaf2587737ab46da.tar.xz
Fix dominator descendants for unreachable blocks.
When a block is unreachable, asking its dom tree descendants should return the empty set. However, the computation of the descendants was causing a segmentation fault because the dom tree node we get from the basic block is initially NULL. Fixed by adding a test for a valid dom tree node before we iterate. The patch also adds some unit tests to the existing dom tree tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196099 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Analysis/Dominators.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/include/llvm/Analysis/Dominators.h b/include/llvm/Analysis/Dominators.h
index e35e101de3..896664c1c1 100644
--- a/include/llvm/Analysis/Dominators.h
+++ b/include/llvm/Analysis/Dominators.h
@@ -348,10 +348,12 @@ public:
/// Get all nodes dominated by R, including R itself.
void getDescendants(NodeT *R, SmallVectorImpl<NodeT *> &Result) const {
+ Result.clear();
const DomTreeNodeBase<NodeT> *RN = getNode(R);
+ if (RN == NULL)
+ return; // If R is unreachable, it will not be present in the DOM tree.
SmallVector<const DomTreeNodeBase<NodeT> *, 8> WL;
WL.push_back(RN);
- Result.clear();
while (!WL.empty()) {
const DomTreeNodeBase<NodeT> *N = WL.pop_back_val();