]> granicus.if.org Git - llvm/commitdiff
[PM] Rework a loop in the CGSCC update logic to be more conservative and
authorChandler Carruth <chandlerc@gmail.com>
Tue, 20 Dec 2016 03:32:17 +0000 (03:32 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Tue, 20 Dec 2016 03:32:17 +0000 (03:32 +0000)
clear. The current RefSCC can occur in exactly one position so we should
just enforce that and leverage the property rather than checking for it
anywhere.

This addresses review comments made on another patch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290162 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CGSCCPassManager.cpp

index b2bee0258d1c8054dce5928bc5b172ec568b8370..5c1485d02de50a7c9ae16e8f810c27fb77cc52a8 100644 (file)
@@ -329,13 +329,17 @@ LazyCallGraph::SCC &llvm::updateCGAndAnalysisManagerForFunctionPass(
       assert(G.lookupSCC(N) == C && "Changed the SCC when splitting RefSCCs!");
       RC = &C->getOuterRefSCC();
       assert(G.lookupRefSCC(N) == RC && "Failed to update current RefSCC!");
-      for (RefSCC *NewRC : reverse(NewRefSCCs))
-        if (NewRC != RC) {
-          UR.RCWorklist.insert(NewRC);
-          if (DebugLogging)
-            dbgs() << "Enqueuing a new RefSCC in the update worklist: "
-                   << *NewRC << "\n";
-        }
+      assert(NewRefSCCs.front() == RC &&
+             "New current RefSCC not first in the returned list!");
+      for (RefSCC *NewRC : reverse(
+               make_range(std::next(NewRefSCCs.begin()), NewRefSCCs.end()))) {
+        assert(NewRC != RC && "Should not encounter the current RefSCC further "
+                              "in the postorder list of new RefSCCs.");
+        UR.RCWorklist.insert(NewRC);
+        if (DebugLogging)
+          dbgs() << "Enqueuing a new RefSCC in the update worklist: " << *NewRC
+                 << "\n";
+      }
     }
   }