summaryrefslogtreecommitdiffstats
path: root/llvm/include/llvm/Support/GenericDomTree.h
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/include/llvm/Support/GenericDomTree.h')
-rw-r--r--llvm/include/llvm/Support/GenericDomTree.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/include/llvm/Support/GenericDomTree.h b/llvm/include/llvm/Support/GenericDomTree.h
index d297324dcea..b292709e935 100644
--- a/llvm/include/llvm/Support/GenericDomTree.h
+++ b/llvm/include/llvm/Support/GenericDomTree.h
@@ -778,12 +778,22 @@ public:
/// recalculate - compute a dominator tree for the given function
template <class FT> void recalculate(FT &F) {
+ typedef GraphTraits<FT *> TraitsTy;
reset();
this->Vertex.push_back(nullptr);
if (!this->IsPostDominators) {
+ // Initialize root
+ NodeT *entry = TraitsTy::getEntryNode(&F);
+ addRoot(entry);
+
Calculate<FT, NodeT *>(*this, F);
} else {
+ // Initialize the roots list
+ for (auto *Node : nodes(&F))
+ if (TraitsTy::child_begin(Node) == TraitsTy::child_end(Node))
+ addRoot(Node);
+
Calculate<FT, Inverse<NodeT *>>(*this, F);
}
}
OpenPOWER on IntegriCloud