diff options
Diffstat (limited to 'include/llvm/Support/GenericDomTreeConstruction.h')
-rw-r--r-- | include/llvm/Support/GenericDomTreeConstruction.h | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/include/llvm/Support/GenericDomTreeConstruction.h b/include/llvm/Support/GenericDomTreeConstruction.h index c1d757f3ab6a3..449c385bc86a0 100644 --- a/include/llvm/Support/GenericDomTreeConstruction.h +++ b/include/llvm/Support/GenericDomTreeConstruction.h @@ -35,10 +35,10 @@ namespace llvm { // converting the one argument insert calls. template <class NodeRef, class InfoType> struct df_iterator_dom_storage { public: - typedef DenseMap<NodeRef, InfoType> BaseSet; + using BaseSet = DenseMap<NodeRef, InfoType>; df_iterator_dom_storage(BaseSet &Storage) : Storage(Storage) {} - typedef typename BaseSet::iterator iterator; + using iterator = typename BaseSet::iterator; std::pair<iterator, bool> insert(NodeRef N) { return Storage.insert({N, InfoType()}); } @@ -101,20 +101,22 @@ template <class GraphT> typename GraphT::NodeRef Eval(DominatorTreeBaseByGraphTraits<GraphT> &DT, typename GraphT::NodeRef VIn, unsigned LastLinked) { + using NodePtr = typename GraphT::NodeRef; + auto &VInInfo = DT.Info[VIn]; if (VInInfo.DFSNum < LastLinked) return VIn; - SmallVector<typename GraphT::NodeRef, 32> Work; - SmallPtrSet<typename GraphT::NodeRef, 32> Visited; + SmallVector<NodePtr, 32> Work; + SmallPtrSet<NodePtr, 32> 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 @@ typename GraphT::NodeRef Eval(DominatorTreeBaseByGraphTraits<GraphT> &DT, 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 @@ typename GraphT::NodeRef Eval(DominatorTreeBaseByGraphTraits<GraphT> &DT, template <class FuncT, class NodeT> void Calculate(DominatorTreeBaseByGraphTraits<GraphTraits<NodeT>> &DT, FuncT &F) { - typedef GraphTraits<NodeT> GraphT; - static_assert(std::is_pointer<typename GraphT::NodeRef>::value, + using GraphT = GraphTraits<NodeT>; + using NodePtr = typename GraphT::NodeRef; + static_assert(std::is_pointer<NodePtr>::value, "NodeRef should be pointer type"); - typedef typename std::remove_pointer<typename GraphT::NodeRef>::type NodeType; + using NodeType = typename std::remove_pointer<NodePtr>::type; unsigned N = 0; bool MultipleRoots = (DT.Roots.size() > 1); @@ -186,13 +189,13 @@ void Calculate(DominatorTreeBaseByGraphTraits<GraphTraits<NodeT>> &DT, 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<GraphT>(DT, V, i + 1); + NodePtr V = DT.Vertex[Buckets[j]]; + NodePtr U = Eval<GraphT>(DT, V, i + 1); DT.IDoms[V] = DT.Info[U].Semi < i ? U : W; } @@ -219,17 +222,17 @@ void Calculate(DominatorTreeBaseByGraphTraits<GraphTraits<NodeT>> &DT, } 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 @@ void Calculate(DominatorTreeBaseByGraphTraits<GraphTraits<NodeT>> &DT, // 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 @@ void Calculate(DominatorTreeBaseByGraphTraits<GraphTraits<NodeT>> &DT, // 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]); |