[clang][dataflow] Only model struct fields that are used in the function being analyzed.
authorYitzhak Mandelbaum <yitzhakm@google.com>
Tue, 27 Dec 2022 14:21:29 +0000 (14:21 +0000)
committerYitzhak Mandelbaum <yitzhakm@google.com>
Thu, 5 Jan 2023 21:46:39 +0000 (21:46 +0000)
commit5e8f597c2fedc740b71f07dfdb1ef3c2d348b193
tree8ef2f0a7db76686b8faad09f0dc7a051b99440ff
parent69f2b5fcf1be2226181cce21066f072279ba5d14
[clang][dataflow] Only model struct fields that are used in the function being analyzed.

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 programss that use large
structs.

Note: This patch obviates the need for https://reviews.llvm.org/D123032.

Differential Revision: https://reviews.llvm.org/D140694
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