[PATCH] D87519: [analyzer][Liveness][NFC] Enqueue the CFGBlocks post-order

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 11 09:12:12 PDT 2020


Szelethus created this revision.
Szelethus added reviewers: xazax.hun, NoQ, vsavchenko, balazske, martong, baloghadamsoftware, steakhal.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, gamesh411, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, whisperity.
Szelethus requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87519

Files:
  clang/lib/Analysis/LiveVariables.cpp


Index: clang/lib/Analysis/LiveVariables.cpp
===================================================================
--- clang/lib/Analysis/LiveVariables.cpp
+++ clang/lib/Analysis/LiveVariables.cpp
@@ -13,6 +13,7 @@
 #include "clang/Analysis/Analyses/LiveVariables.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/StmtVisitor.h"
+#include "clang/Analysis/Analyses/PostOrderCFGView.h"
 #include "clang/Analysis/AnalysisDeclContext.h"
 #include "clang/Analysis/CFG.h"
 #include "clang/Analysis/FlowSensitive/DataflowWorklist.h"
@@ -502,6 +503,9 @@
   CFG *cfg = AC.getCFG();
   if (!cfg)
     return nullptr;
+  assert(AC.getAnalysis<PostOrderCFGView>() &&
+         "If the CFG exists, we should be able to create a post order view of "
+         "it!");
 
   // The analysis currently has scalability issues for very large CFGs.
   // Bail out if it looks too large.
@@ -510,13 +514,12 @@
 
   LiveVariablesImpl *LV = new LiveVariablesImpl(AC, killAtAssign);
 
-  // Construct the dataflow worklist.  Enqueue the exit block as the
+  // Construct the dataflow worklist. Enqueue the exit block as the
   // start of the analysis.
   BackwardDataflowWorklist worklist(*cfg, AC);
   llvm::BitVector everAnalyzedBlock(cfg->getNumBlockIDs());
 
-  // FIXME: we should enqueue using post order.
-  for (const CFGBlock *B : cfg->nodes()) {
+  for (const CFGBlock *B : *AC.getAnalysis<PostOrderCFGView>()) {
     worklist.enqueueBlock(B);
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87519.291241.patch
Type: text/x-patch
Size: 1438 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200911/bcea00b2/attachment.bin>


More information about the cfe-commits mailing list