[PATCH] D153493: [dataflow] avoid more accidental copies of Environment
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 21 20:19:39 PDT 2023
sammccall created this revision.
Herald added subscribers: martong, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
sammccall requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
This is clunky but greatly improves debugging of flow conditions - each
copy adds more indirections in the form of flow condition tokens.
(LatticeEffect presumably once did something here, but it's now both
unused and untested.)
For the exit flow condition of:
void target(base::Optional<int*> opt) {
if (opt.value_or(nullptr) != nullptr) {
opt.value();
} else {
opt.value(); // unsafe
}
}
Before:
(B0:1 = V15)
(B1:1 = V8)
(B2:1 = V10)
(B3:1 = (V4 & (!V7 => V6)))
(V10 = (B3:1 & !V7))
(V12 = B1:1)
(V13 = B2:1)
(V15 = (V12 | V13))
(V3 = V2)
(V4 = V3)
(V8 = (B3:1 & !!V7))
B0:1
V2
After D153491 <https://reviews.llvm.org/D153491>:
(B0:1 = (V9 | V10))
(B1:1 = (B3:1 & !!V6))
(B2:1 = (B3:1 & !V6))
(B3:1 = (V3 & (!V6 => V5)))
(V10 = B2:1)
(V3 = V2)
(V9 = B1:1)
B0:1
V2
After this patch, we can finally see the relations between the flow
conditions directly:
(B0:1 = (B2:1 | B1:1))
(B1:1 = (B3:1 & !!V6))
(B2:1 = (B3:1 & !V6))
(B3:1 = (V3 & (!V6 => V5)))
(V3 = V2)
B0:1
V2
(I believe V2 is the FC for the InitEnv, and V3 is introduced when
computing the input state for B3 <https://reviews.llvm.org/B3> - not sure how to eliminate it)
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D153493
Files:
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153493.533462.patch
Type: text/x-patch
Size: 7163 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230622/fcc42c3f/attachment.bin>
More information about the cfe-commits
mailing list