|
Static Value-Flow Analysis
|
AbstractInterpretation is same as Abstract Execution. More...
#include <AbstractInterpretation.h>
Public Types | |
| enum | AESparsity { Dense , SemiSparse , Sparse } |
| enum | HandleRecur { TOP , WIDEN_ONLY , WIDEN_NARROW } |
Static Public Member Functions | |
| static AbstractInterpretation & | getAEInstance () |
Private Member Functions | |
| virtual void | handleGlobalNode () |
| Initialize abstract state for the global ICFG node and process global statements. | |
| bool | mergeStatesFromPredecessors (const ICFGNode *node) |
| bool | isBranchFeasible (const IntraCFGEdge *edge, AbstractState &as) |
| Returns true if the branch is reachable; narrows as in-place. | |
| virtual void | handleCallSite (const ICFGNode *node) |
| Handle a call site node: dispatch to ext-call, direct-call, or indirect-call handling. | |
| virtual void | handleLoopOrRecursion (const ICFGCycleWTO *cycle, const CallICFGNode *caller=nullptr) |
| Handle a WTO cycle (loop or recursive function) using widening/narrowing iteration. | |
| AbstractState | getFullCycleHeadState (const ICFGCycleWTO *cycle) |
| bool | widenCycleState (const AbstractState &prev, const AbstractState &cur, const ICFGCycleWTO *cycle) |
| bool | narrowCycleState (const AbstractState &prev, const AbstractState &cur, const ICFGCycleWTO *cycle) |
| Narrow prev with cur; write the narrowed state back and scatter. | |
| void | handleFunction (const ICFGNode *funEntry, const CallICFGNode *caller=nullptr) |
| Handle a function body via worklist-driven WTO traversal starting from funEntry. | |
| bool | handleICFGNode (const ICFGNode *node) |
| Handle an ICFG node: execute statements; return true if state changed. | |
| virtual void | handleSVFStatement (const SVFStmt *stmt) |
| Dispatch an SVF statement (Addr/Binary/Cmp/Load/Store/Copy/Gep/Select/Phi/Call/Ret) to its handler. | |
| bool | isCmpBranchFeasible (const IntraCFGEdge *edge, AbstractState &as) |
| Returns true if the cmp-conditional branch is feasible; narrows as in-place. | |
| bool | isSwitchBranchFeasible (const IntraCFGEdge *edge, AbstractState &as) |
| Returns true if the switch branch is feasible; narrows as in-place. | |
| void | updateStateOnAddr (const AddrStmt *addr) |
| void | updateStateOnBinary (const BinaryOPStmt *binary) |
| void | updateStateOnCmp (const CmpStmt *cmp) |
| void | updateStateOnLoad (const LoadStmt *load) |
| void | updateStateOnStore (const StoreStmt *store) |
| void | updateStateOnCopy (const CopyStmt *copy) |
| void | updateStateOnCall (const CallPE *callPE) |
| void | updateStateOnRet (const RetPE *retPE) |
| void | updateStateOnGep (const GepStmt *gep) |
| void | updateStateOnSelect (const SelectStmt *select) |
| void | updateStateOnPhi (const PhiStmt *phi) |
| AbsExtAPI * | getUtils () |
| virtual bool | isExtCall (const CallICFGNode *callNode) |
| virtual void | handleExtCall (const CallICFGNode *callNode) |
| virtual bool | isRecursiveFun (const FunObjVar *fun) |
| Check if a function is recursive (part of a call graph SCC) | |
| virtual void | skipRecursionWithTop (const CallICFGNode *callNode) |
| virtual bool | isRecursiveCallSite (const CallICFGNode *callNode, const FunObjVar *) |
| Check if caller and callee are in the same CallGraph SCC (i.e. a recursive callsite) | |
| virtual void | handleFunCall (const CallICFGNode *callNode) |
| bool | skipRecursiveCall (const CallICFGNode *callNode) |
| Skip recursive callsites (within SCC); entry calls from outside SCC are not skipped. | |
| const FunObjVar * | getCallee (const CallICFGNode *callNode) |
| Get callee function: directly for direct calls, via pointer analysis for indirect calls. | |
| bool | shouldApplyNarrowing (const FunObjVar *fun) |
| Check if narrowing should be applied: always for regular loops, mode-dependent for recursion. | |
Private Attributes | |
| SVFIR * | svfir |
| protected data members, also used in subclasses | |
| AEAPI * | api {nullptr} |
| Execution State, used to store the Interval Value of every SVF variable. | |
| ICFG * | icfg |
| CallGraph * | callGraph |
| AEStat * | stat |
| PreAnalysis * | preAnalysis {nullptr} |
| Map< std::string, std::function< void(const CallICFGNode *)> > | func_map |
| AbstractStateManager * | svfStateMgr {nullptr} |
| Set< const ICFGNode * > | allAnalyzedNodes |
| std::string | moduleName |
| std::vector< std::unique_ptr< AEDetector > > | detectors |
| AbsExtAPI * | utils |
Friends | |
| class | AEStat |
| class | AEAPI |
| class | BufOverflowDetector |
| class | NullptrDerefDetector |
AbstractInterpretation is same as Abstract Execution.
Definition at line 54 of file AbstractInterpretation.h.
| Enumerator | |
|---|---|
| Dense | |
| SemiSparse | |
| Sparse | |
Definition at line 77 of file AbstractInterpretation.h.
| Enumerator | |
|---|---|
| TOP | |
| WIDEN_ONLY | |
| WIDEN_NARROW | |
Definition at line 84 of file AbstractInterpretation.h.
| AbstractInterpretation::AbstractInterpretation | ( | ) |
|
virtual |
Destructor.
Definition at line 88 of file AbstractInterpretation.cpp.
|
inline |
Definition at line 115 of file AbstractInterpretation.h.
| void AbstractInterpretation::analyse | ( | ) |
Program entry.
Program entry - analyze from all entry points (multi-entry analysis is the default)
Definition at line 132 of file AbstractInterpretation.cpp.
| void AbstractInterpretation::analyzeFromAllProgEntries | ( | ) |
Analyze all entry points (functions without callers)
Analyze all entry points (functions without callers) - for whole-program analysis. Abstract state is shared across entry points so that functions analyzed from earlier entries are not re-analyzed from scratch.
Definition at line 141 of file AbstractInterpretation.cpp.
Get all entry point functions (functions without callers)
Collect entry point functions for analysis. Entry points are functions without callers (no incoming edges in CallGraph). Uses a deque to allow efficient insertion at front for prioritizing main()
Definition at line 99 of file AbstractInterpretation.cpp.
|
inline |
Read-only access to a node's AbstractState. Mutations must go through updateAbsState (to replace) or updateAbsValue (to update one variable).
Definition at line 137 of file AbstractInterpretation.h.
|
inline |
Definition at line 157 of file AbstractInterpretation.h.
|
inlinestatic |
Definition at line 109 of file AbstractInterpretation.h.
|
private |
Get callee function: directly for direct calls, via pointer analysis for indirect calls.
Definition at line 724 of file AbstractInterpretation.cpp.
|
private |
Build a full cycle-head AbstractState: the ObjVars currently at cycle_head combined with every cycle ValVar pulled from its def-site. Skips ValVars without a stored value to avoid the top-fallback contamination. In dense mode this is equivalent to trace[cycle_head] since ValVars already live there.
Handle WTO cycle (loop or recursive function) using widening/narrowing iteration.
Widening is applied at the cycle head to ensure termination of the analysis. The cycle head's abstract state is iteratively updated until a fixpoint is reached.
== What is being widened == The abstract state at the cycle head node, which includes:
i starting at 0 and incrementing each iteration== Regular loops (non-recursive functions) == All modes (TOP/WIDEN_ONLY/WIDEN_NARROW) behave the same for regular loops:
== Recursive function cycles == Behavior depends on Options::HandleRecur():
Definition at line 889 of file AbstractInterpretation.cpp.
|
inline |
Get the state manager instance.
Definition at line 127 of file AbstractInterpretation.h.
|
inlineprivate |
Definition at line 260 of file AbstractInterpretation.h.
Handle a call site node: dispatch to ext-call, direct-call, or indirect-call handling.
Definition at line 626 of file AbstractInterpretation.cpp.
|
privatevirtual |
Definition at line 649 of file AbstractInterpretation.cpp.
|
privatevirtual |
Handle direct or indirect call: get callee(s), process function body, set return state.
For direct calls, the callee is known statically. For indirect calls, the previous implementation resolved callees from the abstract state's address domain, which only picked the first address and missed other targets. Since the abstract state's address domain is not an over-approximation for function pointers (it may be uninitialized or incomplete), we now use Andersen's pointer analysis results from the pre-computed call graph, which soundly resolves all possible indirect call targets.
Definition at line 799 of file AbstractInterpretation.cpp.
|
private |
Handle a function body via worklist-driven WTO traversal starting from funEntry.
Handle a function using worklist algorithm guided by WTO order. All top-level WTO components are pushed into the worklist upfront, so the traversal order is exactly the WTO order — each node is visited once, and cycles are handled as whole components.
Definition at line 598 of file AbstractInterpretation.cpp.
|
privatevirtual |
Initialize abstract state for the global ICFG node and process global statements.
handle global node Initializes the abstract state for the global ICFG node and processes all global statements. This includes setting up the null pointer and black hole pointer (blkPtr). BlkPtr is initialized to point to the BlackHole object, representing an unknown memory location that cannot be statically resolved.
Definition at line 165 of file AbstractInterpretation.cpp.
Handle an ICFG node: execute statements; return true if state changed.
Handle an ICFG node: execute statements on the current abstract state. The node's pre-state must already be in getAbsState(node) (set by mergeStatesFromPredecessors, or by handleGlobalNode for the global node). Returns true if the abstract state has changed, false if fixpoint reached or unreachable.
Definition at line 539 of file AbstractInterpretation.cpp.
|
privatevirtual |
Handle a WTO cycle (loop or recursive function) using widening/narrowing iteration.
Definition at line 962 of file AbstractInterpretation.cpp.
Dispatch an SVF statement (Addr/Binary/Cmp/Load/Store/Copy/Gep/Select/Phi/Call/Ret) to its handler.
Definition at line 1028 of file AbstractInterpretation.cpp.
Definition at line 142 of file AbstractInterpretation.h.
Definition at line 152 of file AbstractInterpretation.h.
|
private |
Returns true if the branch is reachable; narrows as in-place.
Definition at line 523 of file AbstractInterpretation.cpp.
|
private |
Returns true if the cmp-conditional branch is feasible; narrows as in-place.
Definition at line 427 of file AbstractInterpretation.cpp.
|
privatevirtual |
Definition at line 644 of file AbstractInterpretation.cpp.
|
privatevirtual |
Check if caller and callee are in the same CallGraph SCC (i.e. a recursive callsite)
Definition at line 716 of file AbstractInterpretation.cpp.
Check if a function is recursive (part of a call graph SCC)
Definition at line 659 of file AbstractInterpretation.cpp.
|
private |
Returns true if the switch branch is feasible; narrows as in-place.
Definition at line 486 of file AbstractInterpretation.cpp.
Pull-based state merge: read abstractTrace[pred] for each predecessor, apply branch refinement for conditional IntraCFGEdges, and join into abstractTrace[node]. Returns true if at least one predecessor had state.
Pull-based state merge: for each predecessor that has an abstract state, copy its state, apply branch refinement for conditional IntraCFGEdges, and join all feasible states into getAbsState(node). The join semantics are sparsity-aware (see AbstractState::joinWith). Returns true if at least one predecessor contributed state.
Definition at line 204 of file AbstractInterpretation.cpp.
|
private |
Narrow prev with cur; write the narrowed state back and scatter.
Definition at line 940 of file AbstractInterpretation.cpp.
Propagate an ObjVar's abstract value from defSite to all its use-sites.
Definition at line 77 of file AbstractInterpretation.cpp.
|
virtual |
collect checkpoint
Definition at line 43 of file AbstractInterpretation.cpp.
Check if narrowing should be applied: always for regular loops, mode-dependent for recursion.
Definition at line 768 of file AbstractInterpretation.cpp.
|
privatevirtual |
TOP mode for recursive calls: skip the function body entirely and conservatively set all reachable stores and the return value to TOP.
Definition at line 666 of file AbstractInterpretation.cpp.
|
private |
Skip recursive callsites (within SCC); entry calls from outside SCC are not skipped.
Definition at line 750 of file AbstractInterpretation.cpp.
|
inline |
Definition at line 147 of file AbstractInterpretation.h.
|
inline |
Definition at line 162 of file AbstractInterpretation.h.
Definition at line 1182 of file AbstractInterpretation.cpp.
|
private |
Definition at line 1200 of file AbstractInterpretation.cpp.
Handle CallPE: phi-like merging of actual parameters from all call sites into the formal parameter at FunEntryICFGNode (e.g., formal = join(actual1@cs1, actual2@cs2, ...))
Definition at line 1157 of file AbstractInterpretation.cpp.
Definition at line 1257 of file AbstractInterpretation.cpp.
Definition at line 1496 of file AbstractInterpretation.cpp.
Definition at line 1095 of file AbstractInterpretation.cpp.
Definition at line 1482 of file AbstractInterpretation.cpp.
Definition at line 1122 of file AbstractInterpretation.cpp.
Definition at line 1174 of file AbstractInterpretation.cpp.
|
private |
Definition at line 1103 of file AbstractInterpretation.cpp.
Definition at line 1489 of file AbstractInterpretation.cpp.
|
private |
Widen prev with cur; write the widened state to trace[cycle_head] and scatter its ValVars back to their def-sites. Returns true when the widened result equals prev (fixpoint).
Definition at line 921 of file AbstractInterpretation.cpp.
Definition at line 57 of file AbstractInterpretation.h.
Definition at line 56 of file AbstractInterpretation.h.
|
friend |
Definition at line 58 of file AbstractInterpretation.h.
|
friend |
Definition at line 59 of file AbstractInterpretation.h.
Definition at line 281 of file AbstractInterpretation.h.
Execution State, used to store the Interval Value of every SVF variable.
Definition at line 252 of file AbstractInterpretation.h.
|
private |
Definition at line 255 of file AbstractInterpretation.h.
|
private |
Definition at line 284 of file AbstractInterpretation.h.
|
private |
Definition at line 278 of file AbstractInterpretation.h.
|
private |
Definition at line 254 of file AbstractInterpretation.h.
|
private |
Definition at line 282 of file AbstractInterpretation.h.
|
private |
Definition at line 258 of file AbstractInterpretation.h.
|
private |
Definition at line 256 of file AbstractInterpretation.h.
|
private |
protected data members, also used in subclasses
Definition at line 250 of file AbstractInterpretation.h.
|
private |
Definition at line 280 of file AbstractInterpretation.h.
|
private |
Definition at line 285 of file AbstractInterpretation.h.