[PATCH] D23704: [GraphTraits] Make nodes_iterator dereference to NodeType*

Daniel Berlin via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 19 14:47:41 PDT 2016


dberlin added a subscriber: dberlin.

================
Comment at: lib/Transforms/Scalar/NaryReassociate.cpp:212
@@ -211,3 +211,3 @@
   // ensures that all bases of a candidate are in Candidates when we process it.
   for (auto Node = GraphTraits<DominatorTree *>::nodes_begin(DT);
        Node != GraphTraits<DominatorTree *>::nodes_end(DT); ++Node) {
----------------
This is actually not preorder :)
It's depth first.

and could be replaced with the depth first iterator


================
Comment at: lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp:1155
@@ -1154,3 +1154,3 @@
        Node != GraphTraits<DominatorTree *>::nodes_end(DT); ++Node) {
-    BasicBlock *BB = Node->getBlock();
+    BasicBlock *BB = (*Node)->getBlock();
     for (auto I = BB->begin(); I != BB->end(); ) {
----------------
Ditto, this is just depth_first, and should use that.


================
Comment at: lib/Transforms/Scalar/StraightLineStrengthReduce.cpp:680
@@ -680,2 +679,3 @@
+    for (auto &I : *(*node)->getBlock())
       allocateCandidatesAndFindBasis(&I);
   }
----------------
This whole glop is just a fancy way of saying:

 for (const auto *Node : depth_first(DT)) { allocateCandidatesAndFindBasis(I->getBlock()); }

I'll fix it if you don't :)
 


https://reviews.llvm.org/D23704





More information about the llvm-commits mailing list