Revert "Revert "[clang][dataflow] Only model struct fields that are used in the funct...
authorYitzhak Mandelbaum <yitzhakm@google.com>
Fri, 6 Jan 2023 13:34:12 +0000 (13:34 +0000)
committerYitzhak Mandelbaum <yitzhakm@google.com>
Mon, 9 Jan 2023 19:32:10 +0000 (19:32 +0000)
commit01ccf7b3cee58dbe02fd97696cae1781746b6137
tree38b7cd89721ced1436ba91c696a27fbc4b9e2d30
parent3df27e974166183df3c09b0f717ec86391231e79
Revert "Revert "[clang][dataflow] Only model struct fields that are used in the function being analyzed.""

This reverts commit 2b1a517a92bfdfa3b692a660e19a2bb22513a567. It's a fix forward
with two memory errors fixed, one of which was the cause of the build breakage
in the buildbots.

Original message:

Previously, the model for structs modeled all fields in a struct when
`createValue` was called for that type. This patch adds a prepass on the
function under analysis to discover the fields referenced in the scope and then
limits modeling to only those fields. This reduces wasted memory usage
(modeling unused fields) which can be important for programs that use large
structs.

Note: This patch obviates the need for https://reviews.llvm.org/D123032.
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/lib/Analysis/FlowSensitive/Transfer.cpp
clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
clang/unittests/Analysis/FlowSensitive/TestingSupport.h
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp