[PATCH] D131644: [clang][dataflow] Don't skip the entry block

Eric Li via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 10 21:53:00 PDT 2022


li.zhe.hua created this revision.
Herald added subscribers: martong, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
li.zhe.hua requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In DXXXXXXX, we implement widen by taking the block state upon entry
into the loop and copying it to the block that represents the
back-edge in order to initialize the state for the "0th" iteration of
the loop. If the loop is the first thing after the entry block,
skipping the entry block means we don't have an opportunity to do this
initialization, so we want to analyze the entry block, even as it has
zero statements, to keep the logic consistent.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131644

Files:
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp


Index: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
===================================================================
--- clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -342,11 +342,8 @@
   std::vector<llvm::Optional<TypeErasedDataflowAnalysisState>> BlockStates(
       CFCtx.getCFG().size(), llvm::None);
 
-  // The entry basic block doesn't contain statements so it can be skipped.
   const CFGBlock &Entry = CFCtx.getCFG().getEntry();
-  BlockStates[Entry.getBlockID()] = {Analysis.typeErasedInitialElement(),
-                                     InitEnv};
-  Worklist.enqueueSuccessors(&Entry);
+  Worklist.enqueueBlock(&Entry);
 
   // Bugs in lattices and transfer functions can prevent the analysis from
   // converging. To limit the damage (infinite loops) that these bugs can cause,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131644.451717.patch
Type: text/x-patch
Size: 905 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220811/56b4215c/attachment.bin>


More information about the cfe-commits mailing list