Index: include/llvm/Support/GenericDomTree.h =================================================================== --- include/llvm/Support/GenericDomTree.h +++ include/llvm/Support/GenericDomTree.h @@ -247,7 +247,7 @@ unsigned Parent; unsigned Semi; NodeT *Label; - + SmallVector ReverseChildren; InfoRec() : DFSNum(0), Parent(0), Semi(0), Label(nullptr) {} }; Index: include/llvm/Support/GenericDomTreeConstruction.h =================================================================== --- include/llvm/Support/GenericDomTreeConstruction.h +++ include/llvm/Support/GenericDomTreeConstruction.h @@ -93,6 +93,8 @@ typename GraphT::NodeRef Succ = *NextSucc; auto &SuccVInfo = DT.Info[Succ]; + SuccVInfo.ReverseChildren.push_back(BB); + if (SuccVInfo.Semi == 0) { SuccVInfo.Parent = BBDFSNum; Worklist.push_back(std::make_pair(Succ, GraphT::child_begin(Succ))); @@ -201,16 +203,10 @@ // initialize the semi dominator to point to the parent node WInfo.Semi = WInfo.Parent; - typedef GraphTraits > InvTraits; - for (typename InvTraits::ChildIteratorType CI = - InvTraits::child_begin(W), - E = InvTraits::child_end(W); CI != E; ++CI) { - typename InvTraits::NodeRef N = *CI; - if (DT.Info.count(N)) { // Only if this predecessor is reachable! + for (auto *N : WInfo.ReverseChildren) { unsigned SemiU = DT.Info[Eval(DT, N, i + 1)].Semi; if (SemiU < WInfo.Semi) WInfo.Semi = SemiU; - } } // If V is a non-root vertex and sdom(V) = parent(V), then idom(V) is