Make AE pointer comparisons conservative - #1887
Open
bjjwwang wants to merge 2 commits into
Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1887 +/- ##
==========================================
+ Coverage 67.89% 68.01% +0.11%
==========================================
Files 261 261
Lines 26682 26653 -29
Branches 5109 5122 +13
==========================================
+ Hits 18117 18127 +10
+ Misses 8565 8526 -39
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A points-to set records alternative targets for one runtime pointer, not targets held simultaneously. A known single target such as
{a}identifies the pointer's exact target. A multi-target set such as{a, b}means that either target may be selected at runtime. Consequently, two equal multi-target sets do not by themselves prove that the two concrete pointers are equal.This PR makes AE pointer comparison conservative and predicate-aware:
{NULL}, or{BlackHole};eq/neresults only when known targets prove the outcome;Problem
AbstractInterpretation::updateStateOnCmppreviously handled every comparison between two address values as if it were equality. As a result,icmp neon the same known target evaluated to true, whileicmp neon disjoint targets evaluated to false. The predicate-aware address switch later in the function never ran because the earlier address branch had already consumed those operands.The old logic also treated equality of two abstract address sets as concrete pointer equality. This is valid for
{a}compared with{a}, but not for{a, b}compared with{a, b}: the two runtime pointers may independently select different targets. Similarly,BlackHoleis a statically unresolved target and must not be compared as if it were one concrete address.Finally, pointer-ordering cases compared abstract object IDs, whose numeric order does not represent runtime address order.
isCmpBranchEdgeFeasiblealso bypassed pointer and null comparisons, preventing a sound comparison result from controlling branch reachability.Formal semantics
Let
N(i, v)normalize operandv, whose SVF variable ID isi, into an abstract address set:BlackHoleis SVF's existing sentinel for a statically unresolved pointer target. For pointer comparison only, a set containingBlackHoleis conservatively interpreted as the top of the address domain:This scoped definition does not claim that every existing
AddressValueoperation implementsBlackHoleas an absorbing lattice-top element.For equality, the possible concrete outcomes are:
The Boolean outcomes are abstracted to an interval:
where
[1,1]is definitely true,[0,0]is definitely false, and[0,1]retains both outcomes.Equivalently, the implementation uses:
This yields:
==!={a}{a}[1,1][0,0]{a}{b}, wherea != b[0,0][1,1]{a, b}{c}, where the sets are disjoint[0,0][1,1]{a, b}{a}[0,1][0,1]{a, b}{a, b}[0,1][0,1]BlackHole[0,1][0,1]NULLis a known distinguished target, so two null operands follow the same-known-target case.Pointer-ordering predicates conservatively produce
[0,1]. SVF object IDs identify abstract objects; their numeric order cannot justify pruning a concrete program path.For a branch edge labelled by$b \in {0,1}$ and comparison result $R$ :
Thus, an edge is removed only when every concrete pointer pair represented by the operands produces the opposite outcome. Branch feasibility does not need separate pointer or null cases.
Implementation
normalizePointerAddressesgives null, known addresses, and unresolved operands one address-set representation.comparePointerValuesimplements the cases above as an explicit decision tree.updateStateOnCmpdispatches pointer operands to that helper and keeps the existing interval comparison for non-pointer operands.isCmpBranchEdgeFeasibleconsumes the stored comparison interval and remains conservative when no interval result is available.Validation
aetarget builds successfully with LLVM 21.1.8 and Z3 4.16.0.