Static Value-Flow Analysis
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SVF::FullSparseAbstractInterpretation Class Reference

#include <SparseAbstractInterpretation.h>

Inheritance diagram for SVF::FullSparseAbstractInterpretation:
SVF::SemiSparseAbstractInterpretation SVF::AbstractInterpretation

Public Member Functions

 FullSparseAbstractInterpretation ()
 
 ~FullSparseAbstractInterpretation () override
 
const AbstractValuegetAbsValue (const ValVar *var, const ICFGNode *node) override
 
bool hasAbsValue (const ValVar *var, const ICFGNode *node) const override
 Side-effect-free existence check.
 
const Set< const ICFGNode * > getUseSitesOfValVar (const ValVar *var) const
 
const ICFGNodegetDefSiteOfValVar (const ValVar *var) const
 
const Set< const ICFGNode * > getDefSiteOfObjVar (const ObjVar *obj, const ICFGNode *node) const
 
const Set< const ICFGNode * > getUseSitesOfObjVar (const ObjVar *obj, const ICFGNode *node) const
 
const AbstractValuegetAbsValue (const ValVar *var, const ICFGNode *node) override
 
virtual const AbstractValuegetAbsValue (const ValVar *var, const ICFGNode *node)
 
virtual const AbstractValuegetAbsValue (const ObjVar *var, const ICFGNode *node)
 
virtual const AbstractValuegetAbsValue (const SVFVar *var, const ICFGNode *node)
 
bool hasAbsValue (const ValVar *var, const ICFGNode *node) const override
 Side-effect-free existence check.
 
virtual bool hasAbsValue (const ValVar *var, const ICFGNode *node) const
 Side-effect-free existence check.
 
virtual bool hasAbsValue (const ObjVar *var, const ICFGNode *node) const
 
virtual bool hasAbsValue (const SVFVar *var, const ICFGNode *node) const
 
- Public Member Functions inherited from SVF::SemiSparseAbstractInterpretation
 SemiSparseAbstractInterpretation ()
 
 ~SemiSparseAbstractInterpretation () override=default
 
- Public Member Functions inherited from SVF::AbstractInterpretation
virtual void runOnModule ()
 
virtual ~AbstractInterpretation ()
 Destructor.
 
void analyse ()
 Program entry.
 
void analyzeFromAllProgEntries ()
 Analyze all entry points (functions without callers)
 
std::deque< const FunObjVar * > collectProgEntryFuns ()
 Get all entry point functions (functions without callers)
 
void addDetector (std::unique_ptr< AEDetector > detector)
 
const SVFVargetSVFVar (NodeID varId) const
 Retrieve SVFVar given its ID; asserts if no such variable exists.
 
AbstractStategetAbsState (const ICFGNode *node)
 
bool hasAbsState (const ICFGNode *node)
 
void getAbsState (const Set< const ValVar * > &vars, AbstractState &result, const ICFGNode *node)
 
void getAbsState (const Set< const ObjVar * > &vars, AbstractState &result, const ICFGNode *node)
 
void getAbsState (const Set< const SVFVar * > &vars, AbstractState &result, const ICFGNode *node)
 
IntervalValue getGepElementIndex (const GepStmt *gep)
 
IntervalValue getGepByteOffset (const GepStmt *gep)
 
AddressValue getGepObjAddrs (const ValVar *pointer, IntervalValue offset)
 
AbstractValue loadValue (const ValVar *pointer, const ICFGNode *node)
 
void storeValue (const ValVar *pointer, const AbstractValue &val, const ICFGNode *node)
 
const SVFTypegetPointeeElement (const ObjVar *var, const ICFGNode *node)
 
u32_t getAllocaInstByteSize (const AddrStmt *addr)
 
Map< const ICFGNode *, AbstractState > & getTrace ()
 
AbstractStateoperator[] (const ICFGNode *node)
 

Protected Member Functions

void buildSVFG ()
 Build the SVFG on top of the semi-sparse precompute.
 
- Protected Member Functions inherited from SVF::SemiSparseAbstractInterpretation
AbstractState getFullCycleHeadState (const ICFGCycleWTO *cycle) override
 
bool widenCycleState (const AbstractState &prev, const AbstractState &cur, const ICFGCycleWTO *cycle) override
 
bool narrowCycleState (const AbstractState &prev, const AbstractState &cur, const ICFGCycleWTO *cycle) override
 
const AbstractValuegetAbsValue (const ValVar *var, const ICFGNode *node) override
 
bool hasAbsValue (const ValVar *var, const ICFGNode *node) const override
 Side-effect-free existence check.
 
void updateAbsValue (const ValVar *var, const AbstractValue &val, const ICFGNode *node) override
 
void updateAbsState (const ICFGNode *node, const AbstractState &state) override
 
void joinStates (AbstractState &dst, const AbstractState &src) override
 
const ICFGNodegetICFGNode (const ValVar *var) const
 
virtual const AbstractValuegetAbsValue (const ValVar *var, const ICFGNode *node)
 
virtual const AbstractValuegetAbsValue (const ObjVar *var, const ICFGNode *node)
 
virtual const AbstractValuegetAbsValue (const SVFVar *var, const ICFGNode *node)
 
virtual bool hasAbsValue (const ValVar *var, const ICFGNode *node) const
 Side-effect-free existence check.
 
virtual bool hasAbsValue (const ObjVar *var, const ICFGNode *node) const
 
virtual bool hasAbsValue (const SVFVar *var, const ICFGNode *node) const
 
virtual void updateAbsValue (const ValVar *var, const AbstractValue &val, const ICFGNode *node)
 
virtual void updateAbsValue (const ObjVar *var, const AbstractValue &val, const ICFGNode *node)
 
virtual void updateAbsValue (const SVFVar *var, const AbstractValue &val, const ICFGNode *node)
 
- Protected Member Functions inherited from SVF::AbstractInterpretation
 AbstractInterpretation ()
 
bool shouldApplyNarrowing (const FunObjVar *fun)
 Check if narrowing should be applied: always for regular loops, mode-dependent for recursion.
 

Protected Attributes

SVFGsvfg {nullptr}
 
- Protected Attributes inherited from SVF::AbstractInterpretation
SVFIRsvfir {nullptr}
 Data and helpers reachable from SparseAbstractInterpretation.
 
AEWTOpreAnalysis {nullptr}
 
Map< const ICFGNode *, AbstractStateabstractTrace
 per-node trace; owned here
 

Additional Inherited Members

- Public Types inherited from SVF::AbstractInterpretation
enum  AESparsity { Dense , SemiSparse , Sparse }
 
enum  HandleRecur { TOP , WIDEN_ONLY , WIDEN_NARROW }
 
- Static Public Member Functions inherited from SVF::AbstractInterpretation
static AbstractInterpretationgetAEInstance ()
 

Detailed Description

Abstract Interpretation for Options::AESparsity::Sparse (full-sparse).

In full-sparse mode both ValVars and ObjVars live at their SVFG def-sites; reads query the SVFG for the reaching-def site, writes happen at def-sites. ValVar reads currently assert(false) until the SVFG-backed resolution lands (see doc/plan-full-sparse.md); cycle helpers are inherited from the semi-sparse parent and will also need extension for ObjVars.

Definition at line 83 of file SparseAbstractInterpretation.h.

Constructor & Destructor Documentation

◆ FullSparseAbstractInterpretation()

SVF::FullSparseAbstractInterpretation::FullSparseAbstractInterpretation ( )
inline

Definition at line 86 of file SparseAbstractInterpretation.h.

87 {
88 buildSVFG();
89 }
void buildSVFG()
Build the SVFG on top of the semi-sparse precompute.

◆ ~FullSparseAbstractInterpretation()

FullSparseAbstractInterpretation::~FullSparseAbstractInterpretation ( )
override

Member Function Documentation

◆ buildSVFG()

void FullSparseAbstractInterpretation::buildSVFG ( )
protected

Build the SVFG on top of the semi-sparse precompute.

Definition at line 47 of file SparseAbstractInterpretation.cpp.

48{
49 SVFGBuilder memSSA(true);
50 svfg = memSSA.buildFullSVFG(preAnalysis->getPointerAnalysis());
51}
AndersenWaveDiff * getPointerAnalysis() const
Accessors for Andersen's results.
Definition AEWTO.h:56

◆ getAbsValue() [1/5]

const AbstractValue & AbstractInterpretation::getAbsValue ( const ObjVar var,
const ICFGNode node 
)
virtual

Reimplemented from SVF::AbstractInterpretation.

Definition at line 60 of file AbstractStateManager.cpp.

91{
94 return as.load(addr);
95}
unsigned u32_t
Definition CommandLine.h:18
AbstractState & getAbsState(const ICFGNode *node)
static u32_t getVirtualMemAddress(u32_t idx)
The physical address starts with 0x7f...... + idx.
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

◆ getAbsValue() [2/5]

const AbstractValue & AbstractInterpretation::getAbsValue ( const SVFVar var,
const ICFGNode node 
)
virtual

Reimplemented from SVF::AbstractInterpretation.

Definition at line 60 of file AbstractStateManager.cpp.

98{
99 if (const ObjVar* objVar = SVFUtil::dyn_cast<ObjVar>(var))
100 return getAbsValue(objVar, node);
101 if (const ValVar* valVar = SVFUtil::dyn_cast<ValVar>(var))
102 return getAbsValue(valVar, node);
103 assert(false && "Unknown SVFVar kind");
104 abort();
105}
const AbstractValue & getAbsValue(const ValVar *var, const ICFGNode *node) override

◆ getAbsValue() [3/5]

const AbstractValue & AbstractInterpretation::getAbsValue ( const ValVar var,
const ICFGNode node 
)
virtual

Read a top-level variable's abstract value. Dense base does a direct trace lookup; sparse subclasses override with their own resolution chain (def-site walk, call-result fallback, etc.). All three overloads are virtual so full-sparse can route ObjVar reads through the SVFG.

Dense base: direct trace lookup, with a top sentinel for genuinely missing entries (e.g. function parameters like argc, never written before first read). Sparse subclasses override with a def-site resolution chain.

The "in map" check is a raw map.count — NOT inVarToValTable / inVarToAddrsTable, which gate on isInterval / isAddr. SVF canonically represents uninit and null-pointer shapes as (interval=bottom ∧ addrs=∅); those predicates would falsely report such an entry as "not present", and the top fallback below would then clobber the very signal NullptrDerefDetector::isUninit keys off.

Reimplemented from SVF::AbstractInterpretation.

Definition at line 60 of file AbstractStateManager.cpp.

81{
82 u32_t id = var->getId();
84 if (as.getVarToVal().count(id))
85 return as[id];
86 as[id] = IntervalValue::top();
87 return as[id];
88}
Map< const ICFGNode *, AbstractState > abstractTrace
per-node trace; owned here
static IntervalValue top()
Create the IntervalValue [-inf, +inf].

◆ getAbsValue() [4/5]

const AbstractValue & FullSparseAbstractInterpretation::getAbsValue ( const ValVar var,
const ICFGNode node 
)
overridevirtual

Read a top-level variable's abstract value. Dense base does a direct trace lookup; sparse subclasses override with their own resolution chain (def-site walk, call-result fallback, etc.). All three overloads are virtual so full-sparse can route ObjVar reads through the SVFG.

Dense base: direct trace lookup, with a top sentinel for genuinely missing entries (e.g. function parameters like argc, never written before first read). Sparse subclasses override with a def-site resolution chain.

The "in map" check is a raw map.count — NOT inVarToValTable / inVarToAddrsTable, which gate on isInterval / isAddr. SVF canonically represents uninit and null-pointer shapes as (interval=bottom ∧ addrs=∅); those predicates would falsely report such an entry as "not present", and the top fallback below would then clobber the very signal NullptrDerefDetector::isUninit keys off.

Reimplemented from SVF::AbstractInterpretation.

Definition at line 63 of file SparseAbstractInterpretation.cpp.

65{
66 assert(false && "FullSparseAbstractInterpretation::getAbsValue not implemented");
67 abort();
68}

◆ getAbsValue() [5/5]

const AbstractValue & SemiSparseAbstractInterpretation::getAbsValue ( const ValVar var,
const ICFGNode node 
)
overridevirtual

Read a top-level variable's abstract value. Dense base does a direct trace lookup; sparse subclasses override with their own resolution chain (def-site walk, call-result fallback, etc.). All three overloads are virtual so full-sparse can route ObjVar reads through the SVFG.

Dense base: direct trace lookup, with a top sentinel for genuinely missing entries (e.g. function parameters like argc, never written before first read). Sparse subclasses override with a def-site resolution chain.

The "in map" check is a raw map.count — NOT inVarToValTable / inVarToAddrsTable, which gate on isInterval / isAddr. SVF canonically represents uninit and null-pointer shapes as (interval=bottom ∧ addrs=∅); those predicates would falsely report such an entry as "not present", and the top fallback below would then clobber the very signal NullptrDerefDetector::isUninit keys off.

Reimplemented from SVF::AbstractInterpretation.

Definition at line 59 of file AbstractStateManager.cpp.

449{
451}
virtual const AbstractValue & getAbsValue(const ValVar *var, const ICFGNode *node)
const ICFGNode * getICFGNode(const ValVar *var) const

◆ getDefSiteOfObjVar()

const Set< const ICFGNode * > FullSparseAbstractInterpretation::getDefSiteOfObjVar ( const ObjVar obj,
const ICFGNode node 
) const

Given an ObjVar and its def-site ICFGNode, find all use-site ICFGNodes by following outgoing IndirectSVFGEdges whose pts contains the ObjVar

Definition at line 96 of file SparseAbstractInterpretation.cpp.

98{
99 assert(svfg && "SVFG is not built for full-sparse AE");
101 for(auto* vNode : node->getVFGNodes())
102 {
104 {
105 defSites.insert(svfgNode->getICFGNode());
106 }
107 }
108 return defSites;
109}
const Set< const ICFGNode * > getDefSiteOfObjVar(const ObjVar *obj, const ICFGNode *node) const

◆ getDefSiteOfValVar()

const ICFGNode * FullSparseAbstractInterpretation::getDefSiteOfValVar ( const ValVar var) const

Definition at line 89 of file SparseAbstractInterpretation.cpp.

91{
92 assert(svfg && "SVFG is not built for full-sparse AE");
94}
const SVFGNode * getDefSiteOfValVar(const ValVar *var) const
Definition SVFG.cpp:765
virtual const ICFGNode * getICFGNode() const
Return corresponding ICFG node.
Definition VFGNode.h:67

◆ getUseSitesOfObjVar()

const Set< const ICFGNode * > FullSparseAbstractInterpretation::getUseSitesOfObjVar ( const ObjVar obj,
const ICFGNode node 
) const

Given an ObjVar and its def-site ICFGNode, find all use-site ICFGNodes by following outgoing IndirectSVFGEdges whose pts contains the ObjVar

Definition at line 111 of file SparseAbstractInterpretation.cpp.

113{
114 assert(svfg && "SVFG is not built for full-sparse AE");
116 for(auto* vNode : node->getVFGNodes())
117 {
119 {
120 useSites.insert(svfgNode->getICFGNode());
121 }
122 }
123 return useSites;
124}
const Set< const ICFGNode * > getUseSitesOfObjVar(const ObjVar *obj, const ICFGNode *node) const

◆ getUseSitesOfValVar()

const Set< const ICFGNode * > FullSparseAbstractInterpretation::getUseSitesOfValVar ( const ValVar var) const

Definition at line 77 of file SparseAbstractInterpretation.cpp.

79{
80 assert(svfg && "SVFG is not built for full-sparse AE");
83 {
84 useSites.insert(svfgNode->getICFGNode());
85 }
86 return useSites;
87}
const Set< const ICFGNode * > getUseSitesOfValVar(const ValVar *var) const

◆ hasAbsValue() [1/5]

bool AbstractInterpretation::hasAbsValue ( const ObjVar var,
const ICFGNode node 
) const
virtual

Reimplemented from SVF::AbstractInterpretation.

Definition at line 63 of file AbstractStateManager.cpp.

120{
121 auto it = abstractTrace.find(node);
122 if (it == abstractTrace.end())
123 return false;
124 return it->second.getLocToVal().count(var->getId()) != 0;
125}

◆ hasAbsValue() [2/5]

bool AbstractInterpretation::hasAbsValue ( const SVFVar var,
const ICFGNode node 
) const
virtual

Reimplemented from SVF::AbstractInterpretation.

Definition at line 63 of file AbstractStateManager.cpp.

128{
129 if (const ObjVar* objVar = SVFUtil::dyn_cast<ObjVar>(var))
130 return hasAbsValue(objVar, node);
131 if (const ValVar* valVar = SVFUtil::dyn_cast<ValVar>(var))
132 return hasAbsValue(valVar, node);
133 return false;
134}
bool hasAbsValue(const ValVar *var, const ICFGNode *node) const override
Side-effect-free existence check.

◆ hasAbsValue() [3/5]

bool AbstractInterpretation::hasAbsValue ( const ValVar var,
const ICFGNode node 
) const
virtual

Side-effect-free existence check.

Dense base: direct existence check at node. Mirrors the simplified getAbsValue lookup — uses raw map.contains rather than inVar*Table predicates, which would falsely report neutral (interval=bottom ∧ addrs=∅) entries as "not present".

Reimplemented from SVF::AbstractInterpretation.

Definition at line 63 of file AbstractStateManager.cpp.

112{
113 auto it = abstractTrace.find(node);
114 if (it == abstractTrace.end())
115 return false;
116 return it->second.getVarToVal().count(var->getId()) != 0;
117}

◆ hasAbsValue() [4/5]

bool FullSparseAbstractInterpretation::hasAbsValue ( const ValVar var,
const ICFGNode node 
) const
overridevirtual

Side-effect-free existence check.

Dense base: direct existence check at node. Mirrors the simplified getAbsValue lookup — uses raw map.contains rather than inVar*Table predicates, which would falsely report neutral (interval=bottom ∧ addrs=∅) entries as "not present".

Reimplemented from SVF::AbstractInterpretation.

Definition at line 70 of file SparseAbstractInterpretation.cpp.

72{
73 assert(false && "FullSparseAbstractInterpretation::hasAbsValue not implemented");
74 abort();
75}

◆ hasAbsValue() [5/5]

bool SemiSparseAbstractInterpretation::hasAbsValue ( const ValVar var,
const ICFGNode node 
) const
overridevirtual

Side-effect-free existence check.

Dense base: direct existence check at node. Mirrors the simplified getAbsValue lookup — uses raw map.contains rather than inVar*Table predicates, which would falsely report neutral (interval=bottom ∧ addrs=∅) entries as "not present".

Reimplemented from SVF::AbstractInterpretation.

Definition at line 62 of file AbstractStateManager.cpp.

455{
457}
virtual bool hasAbsValue(const ValVar *var, const ICFGNode *node) const
Side-effect-free existence check.

Member Data Documentation

◆ svfg

SVFG* SVF::FullSparseAbstractInterpretation::svfg {nullptr}
protected

Definition at line 114 of file SparseAbstractInterpretation.h.

114{nullptr};

The documentation for this class was generated from the following files: