Index: include/llvm/Support/GenericDomTreeConstruction.h =================================================================== --- include/llvm/Support/GenericDomTreeConstruction.h +++ include/llvm/Support/GenericDomTreeConstruction.h @@ -35,10 +35,10 @@ // converting the one argument insert calls. template struct df_iterator_dom_storage { public: - typedef DenseMap BaseSet; + using BaseSet = DenseMap; df_iterator_dom_storage(BaseSet &Storage) : Storage(Storage) {} - typedef typename BaseSet::iterator iterator; + using iterator = typename BaseSet::iterator; std::pair insert(NodeRef N) { return Storage.insert({N, InfoType()}); } @@ -101,20 +101,22 @@ typename GraphT::NodeRef Eval(DominatorTreeBaseByGraphTraits &DT, typename GraphT::NodeRef VIn, unsigned LastLinked) { + using NodePtr = typename GraphT::NodeRef; + auto &VInInfo = DT.Info[VIn]; if (VInInfo.DFSNum < LastLinked) return VIn; - SmallVector Work; - SmallPtrSet Visited; + SmallVector Work; + SmallPtrSet Visited; if (VInInfo.Parent >= LastLinked) Work.push_back(VIn); while (!Work.empty()) { - typename GraphT::NodeRef V = Work.back(); + NodePtr V = Work.back(); auto &VInfo = DT.Info[V]; - typename GraphT::NodeRef VAncestor = DT.Vertex[VInfo.Parent]; + NodePtr VAncestor = DT.Vertex[VInfo.Parent]; // Process Ancestor first if (Visited.insert(VAncestor).second && VInfo.Parent >= LastLinked) { @@ -128,8 +130,8 @@ continue; auto &VAInfo = DT.Info[VAncestor]; - typename GraphT::NodeRef VAncestorLabel = VAInfo.Label; - typename GraphT::NodeRef VLabel = VInfo.Label; + NodePtr VAncestorLabel = VAInfo.Label; + NodePtr VLabel = VInfo.Label; if (DT.Info[VAncestorLabel].Semi < DT.Info[VLabel].Semi) VInfo.Label = VAncestorLabel; VInfo.Parent = VAInfo.Parent; @@ -141,10 +143,11 @@ template void Calculate(DominatorTreeBaseByGraphTraits> &DT, FuncT &F) { - typedef GraphTraits GraphT; - static_assert(std::is_pointer::value, + using GraphT = GraphTraits; + using NodePtr = typename GraphT::NodeRef; + static_assert(std::is_pointer::value, "NodeRef should be pointer type"); - typedef typename std::remove_pointer::type NodeType; + using NodeType = typename std::remove_pointer::type; unsigned N = 0; bool MultipleRoots = (DT.Roots.size() > 1); @@ -186,13 +189,13 @@ Buckets[i] = i; for (unsigned i = N; i >= 2; --i) { - typename GraphT::NodeRef W = DT.Vertex[i]; + NodePtr W = DT.Vertex[i]; auto &WInfo = DT.Info[W]; // Step #2: Implicitly define the immediate dominator of vertices for (unsigned j = i; Buckets[j] != i; j = Buckets[j]) { - typename GraphT::NodeRef V = DT.Vertex[Buckets[j]]; - typename GraphT::NodeRef U = Eval(DT, V, i + 1); + NodePtr V = DT.Vertex[Buckets[j]]; + NodePtr U = Eval(DT, V, i + 1); DT.IDoms[V] = DT.Info[U].Semi < i ? U : W; } @@ -219,17 +222,17 @@ } if (N >= 1) { - typename GraphT::NodeRef Root = DT.Vertex[1]; + NodePtr Root = DT.Vertex[1]; for (unsigned j = 1; Buckets[j] != 1; j = Buckets[j]) { - typename GraphT::NodeRef V = DT.Vertex[Buckets[j]]; + NodePtr V = DT.Vertex[Buckets[j]]; DT.IDoms[V] = Root; } } // Step #4: Explicitly define the immediate dominator of each vertex for (unsigned i = 2; i <= N; ++i) { - typename GraphT::NodeRef W = DT.Vertex[i]; - typename GraphT::NodeRef &WIDom = DT.IDoms[W]; + NodePtr W = DT.Vertex[i]; + NodePtr &WIDom = DT.IDoms[W]; if (WIDom != DT.Vertex[DT.Info[W].Semi]) WIDom = DT.IDoms[WIDom]; } @@ -240,7 +243,7 @@ // one exit block, or it may be the virtual exit (denoted by (BasicBlock *)0) // which postdominates all real exits if there are multiple exit blocks, or // an infinite loop. - typename GraphT::NodeRef Root = !MultipleRoots ? DT.Roots[0] : nullptr; + NodePtr Root = !MultipleRoots ? DT.Roots[0] : nullptr; DT.RootNode = (DT.DomTreeNodes[Root] = @@ -249,13 +252,13 @@ // Loop over all of the reachable blocks in the function... for (unsigned i = 2; i <= N; ++i) { - typename GraphT::NodeRef W = DT.Vertex[i]; + NodePtr W = DT.Vertex[i]; // Don't replace this with 'count', the insertion side effect is important if (DT.DomTreeNodes[W]) continue; // Haven't calculated this node yet? - typename GraphT::NodeRef ImmDom = DT.getIDom(W); + NodePtr ImmDom = DT.getIDom(W); assert(ImmDom || DT.DomTreeNodes[nullptr]);