[llvm] r305715 - [Dominators] Clean up typedefs in GenericDomTreeConstruction. NFC.

Jakub Kuderski via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 19 10:24:57 PDT 2017


Author: kuhar
Date: Mon Jun 19 12:24:56 2017
New Revision: 305715

URL: http://llvm.org/viewvc/llvm-project?rev=305715&view=rev
Log:
[Dominators] Clean up typedefs in GenericDomTreeConstruction. NFC.

Summary: This patch cleans up GenericDomTreeConstruction by replacing typedefs with usings and replaces `typename GraphT::NodeRef` with `NodePtr` to make the file more readable.

Reviewers: sanjoy, dberlin, chandlerc

Reviewed By: dberlin

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D34254

Modified:
    llvm/trunk/include/llvm/Support/GenericDomTreeConstruction.h

Modified: llvm/trunk/include/llvm/Support/GenericDomTreeConstruction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/GenericDomTreeConstruction.h?rev=305715&r1=305714&r2=305715&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/GenericDomTreeConstruction.h (original)
+++ llvm/trunk/include/llvm/Support/GenericDomTreeConstruction.h Mon Jun 19 12:24:56 2017
@@ -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(DominatorT
       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(DominatorT
 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(DominatorTreeBaseByGraphT
     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(DominatorTreeBaseByGraphT
   }
 
   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(DominatorTreeBaseByGraphT
   // 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(DominatorTreeBaseByGraphT
 
   // 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]);
 




More information about the llvm-commits mailing list