[PATCH] D26997: [StructurizeCFG] Refactor OrderNodes.

Justin Lebar via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 22 15:24:07 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL287721: [StructurizeCFG] Refactor OrderNodes. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D26997?vs=78941&id=78962#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26997

Files:
  llvm/trunk/lib/Transforms/Scalar/StructurizeCFG.cpp


Index: llvm/trunk/lib/Transforms/Scalar/StructurizeCFG.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/StructurizeCFG.cpp
+++ llvm/trunk/lib/Transforms/Scalar/StructurizeCFG.cpp
@@ -175,7 +175,7 @@
   DominatorTree *DT;
   LoopInfo *LI;
 
-  RNVector Order;
+  SmallVector<RegionNode *, 8> Order;
   BBSet Visited;
 
   BBPhiMap DeletedPhis;
@@ -288,26 +288,21 @@
 
 /// \brief Build up the general order of nodes
 void StructurizeCFG::orderNodes() {
-  RNVector TempOrder;
   ReversePostOrderTraversal<Region*> RPOT(ParentRegion);
-  TempOrder.append(RPOT.begin(), RPOT.end());
-
-  std::map<Loop*, unsigned> LoopBlocks;
-
+  SmallDenseMap<Loop*, unsigned, 8> LoopBlocks;
 
   // The reverse post-order traversal of the list gives us an ordering close
   // to what we want.  The only problem with it is that sometimes backedges
   // for outer loops will be visited before backedges for inner loops.
-  for (RegionNode *RN : TempOrder) {
+  for (RegionNode *RN : RPOT) {
     BasicBlock *BB = RN->getEntry();
     Loop *Loop = LI->getLoopFor(BB);
     ++LoopBlocks[Loop];
   }
 
   unsigned CurrentLoopDepth = 0;
   Loop *CurrentLoop = nullptr;
-  BBSet TempVisited;
-  for (RNVector::iterator I = TempOrder.begin(), E = TempOrder.end(); I != E; ++I) {
+  for (auto I = RPOT.begin(), E = RPOT.end(); I != E; ++I) {
     BasicBlock *BB = (*I)->getEntry();
     unsigned LoopDepth = LI->getLoopDepth(BB);
 
@@ -318,7 +313,7 @@
       // Make sure we have visited all blocks in this loop before moving back to
       // the outer loop.
 
-      RNVector::iterator LoopI = I;
+      auto LoopI = I;
       while (unsigned &BlockCount = LoopBlocks[CurrentLoop]) {
         LoopI++;
         BasicBlock *LoopBB = (*LoopI)->getEntry();
@@ -330,9 +325,8 @@
     }
 
     CurrentLoop = LI->getLoopFor(BB);
-    if (CurrentLoop) {
+    if (CurrentLoop)
       LoopBlocks[CurrentLoop]--;
-    }
 
     CurrentLoopDepth = LoopDepth;
     Order.push_back(*I);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26997.78962.patch
Type: text/x-patch
Size: 2010 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161122/0f579650/attachment.bin>


More information about the llvm-commits mailing list