]> granicus.if.org Git - clang/commitdiff
For reverse data flow analyses, enqueue the blocks in reverse order.
authorTed Kremenek <kremenek@apple.com>
Wed, 31 Mar 2010 18:45:04 +0000 (18:45 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 31 Mar 2010 18:45:04 +0000 (18:45 +0000)
This more likely matches with the ideal order the blocks should be visited.
This shaves another 1% off the -fsyntax-only time for compare.c (403.gcc).

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

include/clang/Analysis/FlowSensitive/DataflowSolver.h

index ebfa4e997b826c91ff8b031cd7c7fa98cf9804b8..3c762011a6575c6bd7c9b75bbadd93940f8763cd 100644 (file)
@@ -196,10 +196,7 @@ private:
   /// SolveDataflowEquations - Perform the actual worklist algorithm
   ///  to compute dataflow values.
   void SolveDataflowEquations(CFG& cfg, bool recordStmtValues) {
-    // Enqueue all blocks to ensure the dataflow values are computed
-    // for every block.  Not all blocks are guaranteed to reach the exit block.
-    for (CFG::iterator I=cfg.begin(), E=cfg.end(); I!=E; ++I)
-      WorkList.enqueue(&**I);
+    EnqueueBlocksOnWorklist(cfg, AnalysisDirTag());
 
     while (!WorkList.isEmpty()) {
       const CFGBlock* B = WorkList.dequeue();
@@ -209,6 +206,22 @@ private:
     }
   }
 
+  void EnqueueBlocksOnWorklist(CFG &cfg, dataflow::forward_analysis_tag) {
+    // Enqueue all blocks to ensure the dataflow values are computed
+    // for every block.  Not all blocks are guaranteed to reach the exit block.
+    for (CFG::iterator I=cfg.begin(), E=cfg.end(); I!=E; ++I)
+      WorkList.enqueue(&**I);
+  }
+
+  void EnqueueBlocksOnWorklist(CFG &cfg, dataflow::backward_analysis_tag) {
+    // Enqueue all blocks to ensure the dataflow values are computed
+    // for every block.  Not all blocks are guaranteed to reach the exit block.
+    // Enqueue in reverse order since that will more likely match with
+    // the order they should ideally processed by the dataflow algorithm.
+    for (CFG::reverse_iterator I=cfg.rbegin(), E=cfg.rend(); I!=E; ++I)
+      WorkList.enqueue(&**I);
+  }
+
   void ProcessMerge(CFG& cfg, const CFGBlock* B) {
     ValTy& V = TF.getVal();
     TF.SetTopValue(V);