[PATCH] D156658: [clang][dataflow] When checking `ExprToLoc` convergence, only consider children of block terminator.

Martin Böhme via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 31 02:38:32 PDT 2023


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

The only entries in `ExprToLoc` that will be read by a different block are the
direct children of the block terminator (if one exists). For the purposes of
determining whether `ExprToLoc` has converged, it is therefore sufficient to
look at these entries, as any differences in other entries will not be seen by
other blocks.

The other entries in `ExprToLoc` are only read during processing of the block
that contains the corresponding expressions. To be clear, these entries can
affect the results of the block, but only indirectly, in one of two ways:

- If they are indirect descendants of the terminator and therefore affect the values of the terminator's direct children.

- If they affect the entries in one of the other mappings in `Environment`.

Before this patch, we were comparing all entries in `ExprToLoc`, even if they
were never accessed by other blocks, which could cause non-convergence. This
patch adds two tests that demonstrate this; they do not converge without the
other changes in this patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156658

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156658.545555.patch
Type: text/x-patch
Size: 6441 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230731/54b31518/attachment.bin>


More information about the cfe-commits mailing list