Static Value-Flow Analysis
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
SVF::DDAVFSolver< CVar, CPtSet, DPIm > Class Template Referenceabstract

#include <DDAVFSolver.h>

Public Types

typedef SCCDetection< SVFG * > SVFGSCC
 
typedef SCCDetection< CallGraph * > CallGraphSCC
 
typedef CallGraphEdge::CallInstSet CallInstSet
 
typedef SVFIR::CallSiteSet CallSiteSet
 
typedef OrderedSet< DPIm > DPTItemSet
 
typedef OrderedMap< DPIm, CPtSet > DPImToCPtSetMap
 
typedef OrderedMap< DPIm, CVar > DPMToCVarMap
 
typedef OrderedMap< DPIm, DPIm > DPMToDPMMap
 
typedef OrderedMap< NodeID, DPTItemSetLocToDPMVecMap
 
typedef OrderedSet< const SVFGEdge * > ConstSVFGEdgeSet
 
typedef SVFGEdge::SVFGEdgeSetTy SVFGEdgeSet
 
typedef OrderedMap< const SVFGNode *, DPTItemSetStoreToPMSetMap
 

Public Member Functions

 DDAVFSolver ()
 Constructor.
 
virtual ~DDAVFSolver ()
 Destructor.
 
NodeBSgetCandidateQueries ()
 Return candidate pointers for DDA.
 
virtual DPIm getDPIm (const CVar &var, const SVFGNode *loc) const
 Given CVar and location (SVFGNode) return a new DPItem.
 
virtual bool unionDDAPts (CPtSet &pts, const CPtSet &targetPts)
 Union pts.
 
virtual bool unionDDAPts (DPIm dpm, const CPtSet &targetPts)
 Union pts.
 
virtual void addDDAPts (CPtSet &pts, const CVar &var)
 Add pts.
 
SVFGgetSVFG () const
 Return SVFG.
 
SVFGSCCgetSVFGSCC () const
 Return SVFGSCC.
 
void dumpCPtSet (const CPtSet &cpts) const
 
virtual const CPtSet & findPT (const DPIm &dpm)
 Compute points-to.
 

Protected Member Functions

virtual void handleSingleStatement (const DPIm &dpm, CPtSet &pts)
 Handle single statement.
 
void reCompute (const DPIm &dpm)
 recompute points-to for value-flow cycles and indirect calls
 
void reComputeForEdges (const DPIm &dpm, const SVFGEdgeSet &edgeSet, bool indirectCall=false)
 Traverse along out edges to find all nodes which may be affected by locDPM.
 
virtual void buildSVFG (SVFIR *pag)
 Build SVFG.
 
virtual void resetQuery ()
 Reset visited map for next points-to query.
 
void OOBResetVisited ()
 Reset visited map if the current query is out-of-budget.
 
const SVFGNodegetDefSVFGNode (const ValVar *valVar) const
 GetDefinition SVFG.
 
void backtraceAlongIndirectVF (CPtSet &pts, const DPIm &oldDpm)
 Backward traverse along indirect value flows.
 
void backtraceAlongDirectVF (CPtSet &pts, const DPIm &oldDpm)
 Backward traverse along direct value flows.
 

Friends

class DDAStat
 
bool outOfBudgetQuery
 Whether the current query is out of step limits.
 
SVFIR_pag
 SVFIR.
 
SVFG_svfg
 SVFG.
 
AndersenWaveDiff_ander
 Andersen's analysis.
 
NodeBS candidateQueries
 candidate pointers;
 
CallGraph_callGraph
 PTACallGraph.
 
CallGraphSCC_callGraphSCC
 SCC for PTACallGraph.
 
SVFGSCC_svfgSCC
 SCC for SVFG.
 
DPTItemSet backwardVisited
 visited map during backward traversing
 
DPImToCPtSetMap dpmToTLCPtSetMap
 points-to caching map for top-level vars
 
DPImToCPtSetMap dpmToADCPtSetMap
 points-to caching map for address-taken vars
 
LocToDPMVecMap locToDpmSetMap
 map location to its dpms
 
DPMToDPMMap dpmToloadDpmMap
 dpms at loads for may/must-alias analysis with stores
 
DPMToCVarMap loadToPTCVarMap
 map a load dpm to its cvar pointed by its pointer operand
 
DPTItemSet outOfBudgetDpms
 out of budget dpm set
 
StoreToPMSetMap storeToDPMs
 map store to set of DPM which have been stong updated there
 
DDAStatddaStat
 DDA stat.
 
SVFGBuilder svfgBuilder
 SVFG Builder.
 
void startNewPTCompFromLoadSrc (CPtSet &pts, const DPIm &oldDpm)
 
void startNewPTCompFromStoreDst (CPtSet &pts, const DPIm &oldDpm)
 
void backtraceToStoreSrc (CPtSet &pts, const DPIm &oldDpm)
 
virtual void backwardPropDpm (CPtSet &pts, NodeID ptr, const DPIm &oldDpm, const SVFGEdge *edge)
 dpm transit during backward tracing
 
virtual bool isMustAlias (const DPIm &, const DPIm &)
 whether load and store are aliased
 
virtual bool isStrongUpdate (const CPtSet &dstCPSet, const StoreSVFGNode *store)
 Return TRUE if this is a strong update STORE statement.
 
virtual bool isLocalCVarInRecursion (const CVar &var) const
 Whether a local variable is in function recursions.
 
virtual bool propagateViaObj (const CVar &storeObj, const CVar &loadObj)
 If the points-to contain the object obj, we could move forward along indirect value-flow edge.
 
void resolveFunPtr (const DPIm &dpm)
 resolve function pointer
 
virtual NodeID getPtrNodeID (const CVar &var) const =0
 Methods to be implemented in child class.
 
virtual CPtSet processGepPts (const GepSVFGNode *gep, const CPtSet &srcPts)=0
 ProcessGep node to generate field object nodes of a struct.
 
virtual void handleAddr (CPtSet &pts, const DPIm &dpm, const AddrSVFGNode *addr)=0
 Handle AddrSVFGNode to add proper points-to.
 
virtual CPtSet getConservativeCPts (const DPIm &dpm)=0
 Get conservative points-to results when the query is out of budget.
 
virtual bool handleBKCondition (DPIm &, const SVFGEdge *)
 Handle condition for context or path analysis (backward analysis)
 
virtual void updateCallGraphAndSVFG (const DPIm &, const CallICFGNode *, SVFGEdgeSet &)
 Update call graph.
 
void markbkVisited (const DPIm &dpm)
 Visited flags to avoid cycles.
 
bool isbkVisited (const DPIm &dpm)
 
void clearbkVisited (const DPIm &dpm)
 
virtual const CPtSet & getCachedPointsTo (const DPIm &dpm)
 Points-to Caching for top-level pointers and address-taken objects.
 
virtual void updateCachedPointsTo (const DPIm &dpm, const CPtSet &pts)
 
virtual const CPtSet & getCachedTLPointsTo (const DPIm &dpm)
 
virtual const CPtSet & getCachedADPointsTo (const DPIm &dpm)
 
bool isTopLevelPtrStmt (const SVFGNode *stmt)
 Whether this is a top-level pointer statement.
 
virtual DPIm getDPImWithOldCond (const DPIm &oldDpm, const CVar &var, const SVFGNode *loc)
 Return dpm with old context and path conditions.
 
void SVFGSCCDetection ()
 SVFG SCC detection.
 
NodeID getSVFGSCCRepNode (NodeID id)
 Get SCC rep node of a SVFG node.
 
bool isSVFGNodeInCycle (const SVFGNode *node)
 Return whether this SVFGNode is in cycle.
 
bool edgeInSVFGSCC (const SVFGEdge *edge)
 Return TRUE if this edge is inside a SVFG SCC, i.e., src node and dst node are in the same SCC on the SVFG.
 
void setCallGraph (CallGraph *cg)
 Set callgraph.
 
void setCallGraphSCC (CallGraphSCC *scc)
 Set callgraphSCC.
 
virtual bool isHeapCondMemObj (const CVar &var, const StoreSVFGNode *)
 Check heap and array object.
 
bool isArrayCondMemObj (const CVar &var) const
 
bool isFieldInsenCondMemObj (const CVar &var) const
 
void addLoadDpmAndCVar (const DPIm &dpm, const DPIm &loadDpm, const CVar &loadVar)
 LoadDpm for must-alias analysis.
 
void addLoadDpm (const DPIm &dpm, const DPIm &loadDpm)
 Note that simply use "dpmToloadDpmMap[dpm]=loadDpm", requires DPIm have a default constructor.
 
const DPIm & getLoadDpm (const DPIm &dpm) const
 
void addLoadCVar (const DPIm &dpm, const CVar &loadVar)
 
const CVar & getLoadCVar (const DPIm &dpm) const
 
AndersenWaveDiffgetAndersenAnalysis () const
 Return Andersen's analysis.
 
void handleOutOfBudgetDpm (const DPIm &dpm)
 handle out-of-budget queries
 
bool testOutOfBudget (const DPIm &dpm)
 
bool isOutOfBudgetQuery () const
 
void addOutOfBudgetDpm (const DPIm &dpm)
 
bool isOutOfBudgetDpm (const DPIm &dpm) const
 
DDAStatsetDDAStat (DDAStat *s)
 Set DDAStat.
 
void addSUStat (const DPIm &dpm, const SVFGNode *node)
 stat strong updates num
 
void rmSUStat (const DPIm &dpm, const SVFGNode *node)
 remove strong updates num if the dpm goes to weak updates branch
 
const LocToDPMVecMapgetLocToDPMVecMap () const
 Map a SVFGNode to its dpms for handling value-flow cycles.
 
const DPTItemSetgetDpmSetAtLoc (const SVFGNode *loc)
 
void addDpmToLoc (const DPIm &dpm)
 
void removeDpmFromLoc (const DPIm &dpm)
 

Detailed Description

template<class CVar, class CPtSet, class DPIm>
class SVF::DDAVFSolver< CVar, CPtSet, DPIm >

Value-Flow Based Demand-Driven Points-to Analysis

Definition at line 49 of file DDAVFSolver.h.

Member Typedef Documentation

◆ CallGraphSCC

template<class CVar , class CPtSet , class DPIm >
typedef SCCDetection<CallGraph*> SVF::DDAVFSolver< CVar, CPtSet, DPIm >::CallGraphSCC

Definition at line 54 of file DDAVFSolver.h.

◆ CallInstSet

template<class CVar , class CPtSet , class DPIm >
typedef CallGraphEdge::CallInstSet SVF::DDAVFSolver< CVar, CPtSet, DPIm >::CallInstSet

Definition at line 55 of file DDAVFSolver.h.

◆ CallSiteSet

template<class CVar , class CPtSet , class DPIm >
typedef SVFIR::CallSiteSet SVF::DDAVFSolver< CVar, CPtSet, DPIm >::CallSiteSet

Definition at line 56 of file DDAVFSolver.h.

◆ ConstSVFGEdgeSet

template<class CVar , class CPtSet , class DPIm >
typedef OrderedSet<const SVFGEdge* > SVF::DDAVFSolver< CVar, CPtSet, DPIm >::ConstSVFGEdgeSet

Definition at line 62 of file DDAVFSolver.h.

◆ DPImToCPtSetMap

template<class CVar , class CPtSet , class DPIm >
typedef OrderedMap<DPIm, CPtSet> SVF::DDAVFSolver< CVar, CPtSet, DPIm >::DPImToCPtSetMap

Definition at line 58 of file DDAVFSolver.h.

◆ DPMToCVarMap

template<class CVar , class CPtSet , class DPIm >
typedef OrderedMap<DPIm,CVar> SVF::DDAVFSolver< CVar, CPtSet, DPIm >::DPMToCVarMap

Definition at line 59 of file DDAVFSolver.h.

◆ DPMToDPMMap

template<class CVar , class CPtSet , class DPIm >
typedef OrderedMap<DPIm,DPIm> SVF::DDAVFSolver< CVar, CPtSet, DPIm >::DPMToDPMMap

Definition at line 60 of file DDAVFSolver.h.

◆ DPTItemSet

template<class CVar , class CPtSet , class DPIm >
typedef OrderedSet<DPIm> SVF::DDAVFSolver< CVar, CPtSet, DPIm >::DPTItemSet

Definition at line 57 of file DDAVFSolver.h.

◆ LocToDPMVecMap

template<class CVar , class CPtSet , class DPIm >
typedef OrderedMap<NodeID, DPTItemSet> SVF::DDAVFSolver< CVar, CPtSet, DPIm >::LocToDPMVecMap

Definition at line 61 of file DDAVFSolver.h.

◆ StoreToPMSetMap

template<class CVar , class CPtSet , class DPIm >
typedef OrderedMap<const SVFGNode*, DPTItemSet> SVF::DDAVFSolver< CVar, CPtSet, DPIm >::StoreToPMSetMap

Definition at line 64 of file DDAVFSolver.h.

◆ SVFGEdgeSet

template<class CVar , class CPtSet , class DPIm >
typedef SVFGEdge::SVFGEdgeSetTy SVF::DDAVFSolver< CVar, CPtSet, DPIm >::SVFGEdgeSet

Definition at line 63 of file DDAVFSolver.h.

◆ SVFGSCC

template<class CVar , class CPtSet , class DPIm >
typedef SCCDetection<SVFG*> SVF::DDAVFSolver< CVar, CPtSet, DPIm >::SVFGSCC

Definition at line 53 of file DDAVFSolver.h.

Constructor & Destructor Documentation

◆ DDAVFSolver()

template<class CVar , class CPtSet , class DPIm >
SVF::DDAVFSolver< CVar, CPtSet, DPIm >::DDAVFSolver ( )
inline

Constructor.

Definition at line 67 of file DDAVFSolver.h.

67 : outOfBudgetQuery(false),_pag(nullptr),_svfg(nullptr),_ander(nullptr),_callGraph(nullptr), _callGraphSCC(nullptr), _svfgSCC(nullptr), ddaStat(nullptr)
68 {
69 }
CallGraphSCC * _callGraphSCC
SCC for PTACallGraph.
SVFGSCC * _svfgSCC
SCC for SVFG.
SVFIR * _pag
SVFIR.
SVFG * _svfg
SVFG.
AndersenWaveDiff * _ander
Andersen's analysis.
CallGraph * _callGraph
PTACallGraph.
DDAStat * ddaStat
DDA stat.
bool outOfBudgetQuery
Whether the current query is out of step limits.

◆ ~DDAVFSolver()

template<class CVar , class CPtSet , class DPIm >
virtual SVF::DDAVFSolver< CVar, CPtSet, DPIm >::~DDAVFSolver ( )
inlinevirtual

Destructor.

Definition at line 71 of file DDAVFSolver.h.

72 {
73 if(_ander != nullptr)
74 {
75 // AndersenWaveDiff::releaseAndersenWaveDiff();
76 _ander = nullptr;
77 }
78
79 if (_svfg != nullptr)
80 {
81 // DDASVFGBuilder::releaseDDASVFG();
82 _svfg = nullptr;
83 }
84
85 if (_svfgSCC != nullptr)
86 delete _svfgSCC;
87 _svfgSCC = nullptr;
88
89 _callGraph = nullptr;
90 _callGraphSCC = nullptr;
91 }

Member Function Documentation

◆ addDDAPts()

template<class CVar , class CPtSet , class DPIm >
virtual void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::addDDAPts ( CPtSet &  pts,
const CVar &  var 
)
inlinevirtual

Add pts.

Definition at line 115 of file DDAVFSolver.h.

116 {
117 pts.set(var);
118 }
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

◆ addDpmToLoc()

template<class CVar , class CPtSet , class DPIm >
void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::addDpmToLoc ( const DPIm &  dpm)
inlineprivate

Definition at line 669 of file DDAVFSolver.h.

670 {
671 locToDpmSetMap[dpm.getLoc()->getId()].insert(dpm);
672 }
LocToDPMVecMap locToDpmSetMap
map location to its dpms

◆ addLoadCVar()

template<class CVar , class CPtSet , class DPIm >
void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::addLoadCVar ( const DPIm &  dpm,
const CVar &  loadVar 
)
inlineprotected

Definition at line 702 of file DDAVFSolver.h.

703 {
704 typename DPMToCVarMap::iterator it = loadToPTCVarMap.find(dpm);
705 if(it!=loadToPTCVarMap.end())
706 it->second = loadVar;
707 else
708 loadToPTCVarMap.insert(std::make_pair(dpm,loadVar));
709 }
DPMToCVarMap loadToPTCVarMap
map a load dpm to its cvar pointed by its pointer operand

◆ addLoadDpm()

template<class CVar , class CPtSet , class DPIm >
void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::addLoadDpm ( const DPIm &  dpm,
const DPIm &  loadDpm 
)
inlineprotected

Note that simply use "dpmToloadDpmMap[dpm]=loadDpm", requires DPIm have a default constructor.

Definition at line 688 of file DDAVFSolver.h.

689 {
690 typename DPMToDPMMap::iterator it = dpmToloadDpmMap.find(dpm);
691 if(it!=dpmToloadDpmMap.end())
692 it->second = loadDpm;
693 else
694 dpmToloadDpmMap.insert(std::make_pair(dpm,loadDpm));
695 }
DPMToDPMMap dpmToloadDpmMap
dpms at loads for may/must-alias analysis with stores

◆ addLoadDpmAndCVar()

template<class CVar , class CPtSet , class DPIm >
void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::addLoadDpmAndCVar ( const DPIm &  dpm,
const DPIm &  loadDpm,
const CVar &  loadVar 
)
inlineprotected

LoadDpm for must-alias analysis.

Definition at line 682 of file DDAVFSolver.h.

683 {
686 }
void addLoadDpm(const DPIm &dpm, const DPIm &loadDpm)
Note that simply use "dpmToloadDpmMap[dpm]=loadDpm", requires DPIm have a default constructor.
void addLoadCVar(const DPIm &dpm, const CVar &loadVar)

◆ addOutOfBudgetDpm()

template<class CVar , class CPtSet , class DPIm >
void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::addOutOfBudgetDpm ( const DPIm &  dpm)
inlineprotected

Definition at line 737 of file DDAVFSolver.h.

738 {
739 outOfBudgetDpms.insert(dpm);
740 }
DPTItemSet outOfBudgetDpms
out of budget dpm set

◆ addSUStat()

template<class CVar , class CPtSet , class DPIm >
void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::addSUStat ( const DPIm &  dpm,
const SVFGNode node 
)
inlineprotected

stat strong updates num

Definition at line 754 of file DDAVFSolver.h.

755 {
756 if (storeToDPMs[node].insert(dpm).second)
757 {
759 ddaStat->_StrongUpdateStores.set(node->getId());
760 }
761 }
u32_t _NumOfStrongUpdates
Definition DDAStat.h:56
NodeBS _StrongUpdateStores
Definition DDAStat.h:67
StoreToPMSetMap storeToDPMs
map store to set of DPM which have been stong updated there
void set(unsigned Idx)

◆ backtraceAlongDirectVF()

template<class CVar , class CPtSet , class DPIm >
void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::backtraceAlongDirectVF ( CPtSet &  pts,
const DPIm &  oldDpm 
)
inlineprotected

Backward traverse along direct value flows.

Definition at line 376 of file DDAVFSolver.h.

377 {
378 const SVFGNode* node = oldDpm.getLoc();
379 const SVFGEdgeSet edgeSet(node->getInEdges());
380 for (SVFGNode::const_iterator it = edgeSet.begin(), eit = edgeSet.end(); it != eit; ++it)
381 {
382 if(const DirectSVFGEdge* dirEdge = SVFUtil::dyn_cast<DirectSVFGEdge>(*it))
383 {
384 DBOUT(DDDA, SVFUtil::outs() << "\t\t==backtrace directVF svfgNode " <<
385 dirEdge->getDstID() << " --> " << dirEdge->getSrcID() << "\n");
386 const SVFGNode* srcNode = dirEdge->getSrcNode();
387 backwardPropDpm(pts,getSVFG()->getLHSTopLevPtr(srcNode)->getId(),oldDpm,dirEdge);
388 }
389 }
390 }
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
Definition SVFType.h:576
#define DDDA
Definition SVFType.h:588
SVFGEdge::SVFGEdgeSetTy SVFGEdgeSet
Definition DDAVFSolver.h:63
SVFG * getSVFG() const
Return SVFG.
virtual void backwardPropDpm(CPtSet &pts, NodeID ptr, const DPIm &oldDpm, const SVFGEdge *edge)
dpm transit during backward tracing
VFGEdge::VFGEdgeSetTy::const_iterator const_iterator
Definition VFGNode.h:55
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:52
VFGNode SVFGNode
Definition SVFG.h:43

◆ backtraceAlongIndirectVF()

template<class CVar , class CPtSet , class DPIm >
void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::backtraceAlongIndirectVF ( CPtSet &  pts,
const DPIm &  oldDpm 
)
inlineprotected

Backward traverse along indirect value flows.

Definition at line 354 of file DDAVFSolver.h.

355 {
356 const SVFGNode* node = oldDpm.getLoc();
357 NodeID obj = oldDpm.getCurNodeID();
358 if (_pag->isConstantObj(obj))
359 return;
360 const SVFGEdgeSet edgeSet(node->getInEdges());
361 for (SVFGNode::const_iterator it = edgeSet.begin(), eit = edgeSet.end(); it != eit; ++it)
362 {
363 if(const IndirectSVFGEdge* indirEdge = SVFUtil::dyn_cast<IndirectSVFGEdge>(*it))
364 {
365 const NodeBS& guard = indirEdge->getPointsTo();
366 if(guard.test(obj))
367 {
368 DBOUT(DDDA, SVFUtil::outs() << "\t\t==backtrace indirectVF svfgNode " <<
369 indirEdge->getDstID() << " --> " << indirEdge->getSrcID() << "\n");
370 backwardPropDpm(pts,oldDpm.getCurNodeID(),oldDpm,indirEdge);
371 }
372 }
373 }
374 }
bool isConstantObj(NodeID id) const
Definition SVFIR.h:542
u32_t NodeID
Definition GeneralType.h:76
SparseBitVector NodeBS
Definition GeneralType.h:82

◆ backtraceToStoreSrc()

template<class CVar , class CPtSet , class DPIm >
void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::backtraceToStoreSrc ( CPtSet &  pts,
const DPIm &  oldDpm 
)
inlineprotected

Definition at line 415 of file DDAVFSolver.h.

416 {
417 const StoreSVFGNode* store = SVFUtil::cast<StoreSVFGNode>(oldDpm.getLoc());
418 const SVFGNode* storeSrc = getDefSVFGNode(store->getSrcNode());
419 DBOUT(DDDA, SVFUtil::outs() << "++backtrace to storeSrc from svfgNode " << getLoadDpm(oldDpm).getLoc()->getId() << " to "<<
420 store->getId() << " to " << storeSrc->getId() <<"\n");
422 assert(edge && "Edge not found!!");
423 backwardPropDpm(pts,store->getSrcNodeID(),oldDpm,edge);
424 }
const SVFGNode * getDefSVFGNode(const ValVar *valVar) const
GetDefinition SVFG.
const DPIm & getLoadDpm(const DPIm &dpm) const
@ IntraDirectVF
Definition VFGEdge.h:53
VFGEdge * getIntraVFGEdge(const VFGNode *src, const VFGNode *dst, VFGEdge::VFGEdgeK kind)
Get a SVFG edge according to src and dst.
Definition VFG.cpp:908
StoreVFGNode StoreSVFGNode
Definition SVFG.h:53
VFGEdge SVFGEdge
Definition SVFG.h:42

◆ backwardPropDpm()

template<class CVar , class CPtSet , class DPIm >
virtual void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::backwardPropDpm ( CPtSet &  pts,
NodeID  ptr,
const DPIm &  oldDpm,
const SVFGEdge edge 
)
inlineprotectedvirtual

dpm transit during backward tracing

handle context-/path- sensitivity

record the source of load dpm

handle out of budget case

Definition at line 428 of file DDAVFSolver.h.

429 {
430 DPIm dpm(oldDpm);
431 dpm.setLocVar(edge->getSrcNode(),ptr);
432 DOTIMESTAT(double start = DDAStat::getClk(true));
434 if(handleBKCondition(dpm,edge)==false)
435 {
437 DBOUT(DDDA, SVFUtil::outs() << "\t!!! infeasible path svfgNode: " << edge->getDstID() << " --| " << edge->getSrcID() << "\n");
439 return;
440 }
441
443 if(SVFUtil::isa<IndirectSVFGEdge>(edge))
445
449 }
#define DOSTAT(X)
Definition SVFType.h:577
#define DOTIMESTAT(X)
Definition SVFType.h:578
u32_t _NumOfDPM
Definition DDAStat.h:55
u32_t _NumOfInfeasiblePath
Definition DDAStat.h:58
double _TotalTimeOfBKCondition
Definition DDAStat.h:65
void addLoadDpmAndCVar(const DPIm &dpm, const DPIm &loadDpm, const CVar &loadVar)
LoadDpm for must-alias analysis.
const CVar & getLoadCVar(const DPIm &dpm) const
virtual bool handleBKCondition(DPIm &, const SVFGEdge *)
Handle condition for context or path analysis (backward analysis)
virtual bool unionDDAPts(CPtSet &pts, const CPtSet &targetPts)
Union pts.
virtual const CPtSet & findPT(const DPIm &dpm)
Compute points-to.
static double getClk(bool mark=false)
Definition SVFStat.cpp:51

◆ buildSVFG()

template<class CVar , class CPtSet , class DPIm >
virtual void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::buildSVFG ( SVFIR pag)
inlineprotectedvirtual

Build SVFG.

Definition at line 319 of file DDAVFSolver.h.

320 {
323 _pag = _svfg->getPAG();
324 }
static AndersenWaveDiff * createAndersenWaveDiff(SVFIR *_pag)
Create an singleton instance directly instead of invoking llvm pass manager.
Definition Andersen.h:408
SVFGBuilder svfgBuilder
SVFG Builder.
SVFG * buildPTROnlySVFG(BVDataPTAImpl *pta)
SVFIR * getPAG() const
Return SVFIR.
Definition VFG.h:133

◆ clearbkVisited()

template<class CVar , class CPtSet , class DPIm >
void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::clearbkVisited ( const DPIm &  dpm)
inlineprotected

Definition at line 549 of file DDAVFSolver.h.

550 {
551 assert(backwardVisited.find(dpm)!=backwardVisited.end() && "dpm not found!");
552 backwardVisited.erase(dpm);
553 }
DPTItemSet backwardVisited
visited map during backward traversing

◆ dumpCPtSet()

template<class CVar , class CPtSet , class DPIm >
void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::dumpCPtSet ( const CPtSet &  cpts) const
inline

Definition at line 130 of file DDAVFSolver.h.

131 {
132 SVFUtil::outs() << "{";
133 for(typename CPtSet::iterator it = cpts.begin(), eit = cpts.end(); it!=eit; ++it)
134 {
135 SVFUtil::outs() << (*it) << " ";
136 }
137 SVFUtil::outs() << "}\n";
138 }

◆ edgeInSVFGSCC()

template<class CVar , class CPtSet , class DPIm >
bool SVF::DDAVFSolver< CVar, CPtSet, DPIm >::edgeInSVFGSCC ( const SVFGEdge edge)
inlineprotected

Return TRUE if this edge is inside a SVFG SCC, i.e., src node and dst node are in the same SCC on the SVFG.

Definition at line 624 of file DDAVFSolver.h.

625 {
626 return (getSVFGSCCRepNode(edge->getSrcID()) == getSVFGSCCRepNode(edge->getDstID()));
627 }
NodeID getSVFGSCCRepNode(NodeID id)
Get SCC rep node of a SVFG node.

◆ findPT()

template<class CVar , class CPtSet , class DPIm >
virtual const CPtSet & SVF::DDAVFSolver< CVar, CPtSet, DPIm >::findPT ( const DPIm &  dpm)
inlinevirtual

Compute points-to.

Add successors of current stmt if its pts has been changed.

Definition at line 140 of file DDAVFSolver.h.

141 {
142
143 if(isbkVisited(dpm))
144 {
145 const CPtSet& cpts = getCachedPointsTo(dpm);
146 DBOUT(DDDA, SVFUtil::outs() << "\t already backward visited dpm: ");
147 DBOUT(DDDA, dpm.dump());
148 DBOUT(DDDA, SVFUtil::outs() << "\t return points-to: ");
149 DBOUT(DDDA, dumpCPtSet(cpts));
150 return cpts;
151 }
152
153 DBOUT(DDDA, SVFUtil::outs() << "\t backward visit dpm: ");
154 DBOUT(DDDA, dpm.dump());
157
158 if(testOutOfBudget(dpm) == false)
159 {
160
161 CPtSet pts;
163
166 }
167 return getCachedPointsTo(dpm);
168 }
virtual void updateCachedPointsTo(const DPIm &dpm, const CPtSet &pts)
bool testOutOfBudget(const DPIm &dpm)
void markbkVisited(const DPIm &dpm)
Visited flags to avoid cycles.
virtual void handleSingleStatement(const DPIm &dpm, CPtSet &pts)
Handle single statement.
bool isbkVisited(const DPIm &dpm)
void dumpCPtSet(const CPtSet &cpts) const
virtual const CPtSet & getCachedPointsTo(const DPIm &dpm)
Points-to Caching for top-level pointers and address-taken objects.
void addDpmToLoc(const DPIm &dpm)

◆ getAndersenAnalysis()

template<class CVar , class CPtSet , class DPIm >
AndersenWaveDiff * SVF::DDAVFSolver< CVar, CPtSet, DPIm >::getAndersenAnalysis ( ) const
inlineprotected

Return Andersen's analysis.

Definition at line 718 of file DDAVFSolver.h.

719 {
720 return _ander;
721 }

◆ getCachedADPointsTo()

template<class CVar , class CPtSet , class DPIm >
virtual const CPtSet & SVF::DDAVFSolver< CVar, CPtSet, DPIm >::getCachedADPointsTo ( const DPIm &  dpm)
inlineprotectedvirtual

Definition at line 578 of file DDAVFSolver.h.

579 {
580 return dpmToADCPtSetMap[dpm];
581 }
DPImToCPtSetMap dpmToADCPtSetMap
points-to caching map for address-taken vars

◆ getCachedPointsTo()

template<class CVar , class CPtSet , class DPIm >
virtual const CPtSet & SVF::DDAVFSolver< CVar, CPtSet, DPIm >::getCachedPointsTo ( const DPIm &  dpm)
inlineprotectedvirtual

Points-to Caching for top-level pointers and address-taken objects.

Definition at line 558 of file DDAVFSolver.h.

559 {
560 if (isTopLevelPtrStmt(dpm.getLoc()))
561 return getCachedTLPointsTo(dpm);
562 else
563 return getCachedADPointsTo(dpm);
564 }
virtual const CPtSet & getCachedADPointsTo(const DPIm &dpm)
bool isTopLevelPtrStmt(const SVFGNode *stmt)
Whether this is a top-level pointer statement.
virtual const CPtSet & getCachedTLPointsTo(const DPIm &dpm)

◆ getCachedTLPointsTo()

template<class CVar , class CPtSet , class DPIm >
virtual const CPtSet & SVF::DDAVFSolver< CVar, CPtSet, DPIm >::getCachedTLPointsTo ( const DPIm &  dpm)
inlineprotectedvirtual

Reimplemented in SVF::FlowDDA.

Definition at line 574 of file DDAVFSolver.h.

575 {
576 return dpmToTLCPtSetMap[dpm];
577 }
DPImToCPtSetMap dpmToTLCPtSetMap
points-to caching map for top-level vars

◆ getCandidateQueries()

template<class CVar , class CPtSet , class DPIm >
NodeBS & SVF::DDAVFSolver< CVar, CPtSet, DPIm >::getCandidateQueries ( )
inline

Return candidate pointers for DDA.

Definition at line 93 of file DDAVFSolver.h.

94 {
95 return candidateQueries;
96 }
NodeBS candidateQueries
candidate pointers;

◆ getConservativeCPts()

template<class CVar , class CPtSet , class DPIm >
virtual CPtSet SVF::DDAVFSolver< CVar, CPtSet, DPIm >::getConservativeCPts ( const DPIm &  dpm)
protectedpure virtual

Get conservative points-to results when the query is out of budget.

Implemented in SVF::ContextDDA, and SVF::FlowDDA.

◆ getDefSVFGNode()

template<class CVar , class CPtSet , class DPIm >
const SVFGNode * SVF::DDAVFSolver< CVar, CPtSet, DPIm >::getDefSVFGNode ( const ValVar valVar) const
inlineprotected

GetDefinition SVFG.

Definition at line 349 of file DDAVFSolver.h.

350 {
351 return getSVFG()->getDefSVFGNode(valVar);
352 }
const SVFGNode * getDefSVFGNode(const ValVar *valVar) const
Given a valVar, return its definition site.
Definition SVFG.h:171

◆ getDPIm()

template<class CVar , class CPtSet , class DPIm >
virtual DPIm SVF::DDAVFSolver< CVar, CPtSet, DPIm >::getDPIm ( const CVar &  var,
const SVFGNode loc 
) const
inlinevirtual

Given CVar and location (SVFGNode) return a new DPItem.

Definition at line 98 of file DDAVFSolver.h.

99 {
100 DPIm dpm(var,loc);
101 return dpm;
102 }

◆ getDPImWithOldCond()

template<class CVar , class CPtSet , class DPIm >
virtual DPIm SVF::DDAVFSolver< CVar, CPtSet, DPIm >::getDPImWithOldCond ( const DPIm &  oldDpm,
const CVar &  var,
const SVFGNode loc 
)
inlineprotectedvirtual

Return dpm with old context and path conditions.

Definition at line 590 of file DDAVFSolver.h.

591 {
592 DPIm dpm(oldDpm);
593 dpm.setLocVar(loc,getPtrNodeID(var));
594
595 if(SVFUtil::isa<StoreSVFGNode>(loc))
597
598 if(SVFUtil::isa<LoadSVFGNode>(loc))
600
602 return dpm;
603 }
virtual NodeID getPtrNodeID(const CVar &var) const =0
Methods to be implemented in child class.

◆ getDpmSetAtLoc()

template<class CVar , class CPtSet , class DPIm >
const DPTItemSet & SVF::DDAVFSolver< CVar, CPtSet, DPIm >::getDpmSetAtLoc ( const SVFGNode loc)
inlineprivate

Definition at line 665 of file DDAVFSolver.h.

666 {
667 return locToDpmSetMap[loc->getId()];
668 }

◆ getLoadCVar()

template<class CVar , class CPtSet , class DPIm >
const CVar & SVF::DDAVFSolver< CVar, CPtSet, DPIm >::getLoadCVar ( const DPIm &  dpm) const
inlineprotected

Definition at line 710 of file DDAVFSolver.h.

711 {
712 typename DPMToCVarMap::const_iterator it = loadToPTCVarMap.find(dpm);
713 assert(it!=loadToPTCVarMap.end() && "not found??");
714 return it->second;
715 }

◆ getLoadDpm()

template<class CVar , class CPtSet , class DPIm >
const DPIm & SVF::DDAVFSolver< CVar, CPtSet, DPIm >::getLoadDpm ( const DPIm &  dpm) const
inlineprotected

Definition at line 696 of file DDAVFSolver.h.

697 {
698 typename DPMToDPMMap::const_iterator it = dpmToloadDpmMap.find(dpm);
699 assert(it!=dpmToloadDpmMap.end() && "not found??");
700 return it->second;
701 }

◆ getLocToDPMVecMap()

template<class CVar , class CPtSet , class DPIm >
const LocToDPMVecMap & SVF::DDAVFSolver< CVar, CPtSet, DPIm >::getLocToDPMVecMap ( ) const
inlineprivate

Map a SVFGNode to its dpms for handling value-flow cycles.

Definition at line 661 of file DDAVFSolver.h.

662 {
663 return locToDpmSetMap;
664 }

◆ getPtrNodeID()

template<class CVar , class CPtSet , class DPIm >
virtual NodeID SVF::DDAVFSolver< CVar, CPtSet, DPIm >::getPtrNodeID ( const CVar &  var) const
protectedpure virtual

Methods to be implemented in child class.

Get variable ID (PAGNodeID) according to CVar

Implemented in SVF::ContextDDA, and SVF::FlowDDA.

◆ getSVFG()

template<class CVar , class CPtSet , class DPIm >
SVFG * SVF::DDAVFSolver< CVar, CPtSet, DPIm >::getSVFG ( ) const
inline

Return SVFG.

Definition at line 120 of file DDAVFSolver.h.

121 {
122 return _svfg;
123 }

◆ getSVFGSCC()

template<class CVar , class CPtSet , class DPIm >
SVFGSCC * SVF::DDAVFSolver< CVar, CPtSet, DPIm >::getSVFGSCC ( ) const
inline

Return SVFGSCC.

Definition at line 125 of file DDAVFSolver.h.

126 {
127 return _svfgSCC;
128 }

◆ getSVFGSCCRepNode()

template<class CVar , class CPtSet , class DPIm >
NodeID SVF::DDAVFSolver< CVar, CPtSet, DPIm >::getSVFGSCCRepNode ( NodeID  id)
inlineprotected

Get SCC rep node of a SVFG node.

Definition at line 614 of file DDAVFSolver.h.

615 {
616 return _svfgSCC->repNode(id);
617 }

◆ handleAddr()

template<class CVar , class CPtSet , class DPIm >
virtual void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::handleAddr ( CPtSet &  pts,
const DPIm &  dpm,
const AddrSVFGNode addr 
)
protectedpure virtual

Handle AddrSVFGNode to add proper points-to.

Implemented in SVF::ContextDDA, and SVF::FlowDDA.

◆ handleBKCondition()

template<class CVar , class CPtSet , class DPIm >
virtual bool SVF::DDAVFSolver< CVar, CPtSet, DPIm >::handleBKCondition ( DPIm &  ,
const SVFGEdge  
)
inlineprotectedvirtual

Handle condition for context or path analysis (backward analysis)

Reimplemented in SVF::ContextDDA, and SVF::FlowDDA.

Definition at line 531 of file DDAVFSolver.h.

532 {
533 return true;
534 }

◆ handleOutOfBudgetDpm()

template<class CVar , class CPtSet , class DPIm >
void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::handleOutOfBudgetDpm ( const DPIm &  dpm)
inlineprotected

handle out-of-budget queries

Handle out-of-budget dpm

Definition at line 725 of file DDAVFSolver.h.

725{}

◆ handleSingleStatement()

template<class CVar , class CPtSet , class DPIm >
virtual void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::handleSingleStatement ( const DPIm &  dpm,
CPtSet &  pts 
)
inlineprotectedvirtual

Handle single statement.

resolve function pointer first at indirect callsite

Definition at line 172 of file DDAVFSolver.h.

173 {
176
177 const SVFGNode* node = dpm.getLoc();
178 if(SVFUtil::isa<AddrSVFGNode>(node))
179 {
180 handleAddr(pts,dpm,SVFUtil::cast<AddrSVFGNode>(node));
181 }
185 {
187 }
188 else if(SVFUtil::isa<GepSVFGNode>(node))
189 {
190 CPtSet gepPts;
192 unionDDAPts(pts, processGepPts(SVFUtil::cast<GepSVFGNode>(node),gepPts));
193 }
194 else if(const LoadSVFGNode* load = SVFUtil::dyn_cast<LoadSVFGNode>(node))
195 {
196 if(load->getDstNode()->isPointer() == false)
197 return;
198
199 CPtSet loadpts;
201 for(typename CPtSet::iterator it = loadpts.begin(), eit = loadpts.end(); it!=eit; ++it)
202 {
204 }
205 }
206 else if(const StoreSVFGNode* store = SVFUtil::dyn_cast<StoreSVFGNode>(node))
207 {
208 if(store->getSrcNode()->isPointer() == false)
209 return;
210
212 {
213 DBOUT(DDDA, SVFUtil::outs() << "+++must alias for load and store:");
215 DBOUT(DDDA, dpm.dump());
216 DBOUT(DDDA, SVFUtil::outs() << "+++\n");
219 }
220 else
221 {
222 CPtSet storepts;
224 for(typename CPtSet::iterator it = storepts.begin(), eit = storepts.end(); it!=eit; ++it)
225 {
227 {
229
230 if(isStrongUpdate(storepts,store))
231 {
232 DBOUT(DDDA, SVFUtil::outs() << "backward strong update for obj " << dpm.getCurNodeID() << "\n");
233 DOSTAT(addSUStat(dpm,store);)
234 }
235 else
236 {
237 DOSTAT(rmSUStat(dpm,store);)
239 }
240 }
241 else
242 {
244 }
245 }
246 }
247 }
248 else if(SVFUtil::isa<MRSVFGNode>(node))
249 {
251 }
252 else
253 assert(false && "unexpected kind of SVFG nodes");
254 }
u32_t _NumOfMustAliases
Definition DDAStat.h:57
void backtraceAlongIndirectVF(CPtSet &pts, const DPIm &oldDpm)
Backward traverse along indirect value flows.
virtual bool isMustAlias(const DPIm &, const DPIm &)
whether load and store are aliased
void backtraceAlongDirectVF(CPtSet &pts, const DPIm &oldDpm)
Backward traverse along direct value flows.
void rmSUStat(const DPIm &dpm, const SVFGNode *node)
remove strong updates num if the dpm goes to weak updates branch
virtual bool isStrongUpdate(const CPtSet &dstCPSet, const StoreSVFGNode *store)
Return TRUE if this is a strong update STORE statement.
virtual CPtSet processGepPts(const GepSVFGNode *gep, const CPtSet &srcPts)=0
ProcessGep node to generate field object nodes of a struct.
virtual DPIm getDPImWithOldCond(const DPIm &oldDpm, const CVar &var, const SVFGNode *loc)
Return dpm with old context and path conditions.
void startNewPTCompFromLoadSrc(CPtSet &pts, const DPIm &oldDpm)
virtual bool propagateViaObj(const CVar &storeObj, const CVar &loadObj)
If the points-to contain the object obj, we could move forward along indirect value-flow edge.
virtual void handleAddr(CPtSet &pts, const DPIm &dpm, const AddrSVFGNode *addr)=0
Handle AddrSVFGNode to add proper points-to.
void backtraceToStoreSrc(CPtSet &pts, const DPIm &oldDpm)
void addSUStat(const DPIm &dpm, const SVFGNode *node)
stat strong updates num
void resolveFunPtr(const DPIm &dpm)
resolve function pointer
void startNewPTCompFromStoreDst(CPtSet &pts, const DPIm &oldDpm)
LLVM_NODISCARD bool isa(const Y &Val)
Definition Casting.h:241
ActualParmVFGNode ActualParmSVFGNode
Definition SVFG.h:44
LoadVFGNode LoadSVFGNode
Definition SVFG.h:54
PHIVFGNode PHISVFGNode
Definition SVFG.h:56
ActualRetVFGNode ActualRetSVFGNode
Definition SVFG.h:45
void dump(const SparseBitVector< ElementSize > &LHS, std::ostream &out)
CopyVFGNode CopySVFGNode
Definition SVFG.h:52
FormalParmVFGNode FormalParmSVFGNode
Definition SVFG.h:46
FormalRetVFGNode FormalRetSVFGNode
Definition SVFG.h:47
NullPtrVFGNode NullPtrSVFGNode
Definition SVFG.h:49

◆ isArrayCondMemObj()

template<class CVar , class CPtSet , class DPIm >
bool SVF::DDAVFSolver< CVar, CPtSet, DPIm >::isArrayCondMemObj ( const CVar &  var) const
inlineprotected

Definition at line 646 of file DDAVFSolver.h.

647 {
648 const BaseObjVar* obj = _pag->getBaseObject(getPtrNodeID(var));
649 assert(obj && "base object is null??");
650 return obj->isArray();
651 }
const BaseObjVar * getBaseObject(NodeID id) const
Definition SVFIR.h:498

◆ isbkVisited()

template<class CVar , class CPtSet , class DPIm >
bool SVF::DDAVFSolver< CVar, CPtSet, DPIm >::isbkVisited ( const DPIm &  dpm)
inlineprotected

Definition at line 545 of file DDAVFSolver.h.

546 {
547 return backwardVisited.find(dpm)!=backwardVisited.end();
548 }

◆ isFieldInsenCondMemObj()

template<class CVar , class CPtSet , class DPIm >
bool SVF::DDAVFSolver< CVar, CPtSet, DPIm >::isFieldInsenCondMemObj ( const CVar &  var) const
inlineprotected

Definition at line 652 of file DDAVFSolver.h.

653 {
654 const BaseObjVar* baseObj = _pag->getBaseObject(getPtrNodeID(var));
655 return baseObj->isFieldInsensitive();
656 }
bool isFieldInsensitive() const
Return true if its field limit is 0.

◆ isHeapCondMemObj()

template<class CVar , class CPtSet , class DPIm >
virtual bool SVF::DDAVFSolver< CVar, CPtSet, DPIm >::isHeapCondMemObj ( const CVar &  var,
const StoreSVFGNode  
)
inlineprotectedvirtual

Check heap and array object.

Reimplemented in SVF::ContextDDA, and SVF::FlowDDA.

Definition at line 640 of file DDAVFSolver.h.

641 {
642 const BaseObjVar* pVar = _pag->getBaseObject(getPtrNodeID(var));
643 return pVar && SVFUtil::isa<HeapObjVar, DummyObjVar>(pVar);
644 }

◆ isLocalCVarInRecursion()

template<class CVar , class CPtSet , class DPIm >
virtual bool SVF::DDAVFSolver< CVar, CPtSet, DPIm >::isLocalCVarInRecursion ( const CVar &  var) const
inlineprotectedvirtual

Whether a local variable is in function recursions.

Definition at line 473 of file DDAVFSolver.h.

474 {
475 NodeID id = getPtrNodeID(var);
476 const BaseObjVar* baseObj = _pag->getBaseObject(id);
477 assert(baseObj && "base object is null??");
478 if(SVFUtil::isa<StackObjVar>(baseObj))
479 {
480 if(const FunObjVar* svffun = _pag->getSVFVar(id)->getFunction())
481 {
482 return _callGraphSCC->isInCycle(_callGraph->getCallGraphNode(svffun)->getId());
483 }
484 }
485 return false;
486 }
const CallGraphNode * getCallGraphNode(const std::string &name) const
Get call graph node.
const SVFVar * getSVFVar(NodeID id) const
ObjVar/GepObjVar/BaseObjVar.
Definition SVFIR.h:135
NodeID getId() const
Get ID.
Definition SVFValue.h:158
virtual const FunObjVar * getFunction() const
Get containing function, or null for globals/constants.

◆ isMustAlias()

template<class CVar , class CPtSet , class DPIm >
virtual bool SVF::DDAVFSolver< CVar, CPtSet, DPIm >::isMustAlias ( const DPIm &  ,
const DPIm &   
)
inlineprotectedvirtual

whether load and store are aliased

Definition at line 451 of file DDAVFSolver.h.

452 {
453 return false;
454 }

◆ isOutOfBudgetDpm()

template<class CVar , class CPtSet , class DPIm >
bool SVF::DDAVFSolver< CVar, CPtSet, DPIm >::isOutOfBudgetDpm ( const DPIm &  dpm) const
inlineprotected

Definition at line 741 of file DDAVFSolver.h.

742 {
743 return outOfBudgetDpms.find(dpm) != outOfBudgetDpms.end();
744 }

◆ isOutOfBudgetQuery()

template<class CVar , class CPtSet , class DPIm >
bool SVF::DDAVFSolver< CVar, CPtSet, DPIm >::isOutOfBudgetQuery ( ) const
inlineprotected

Definition at line 733 of file DDAVFSolver.h.

734 {
735 return outOfBudgetQuery;
736 }

◆ isStrongUpdate()

template<class CVar , class CPtSet , class DPIm >
virtual bool SVF::DDAVFSolver< CVar, CPtSet, DPIm >::isStrongUpdate ( const CPtSet &  dstCPSet,
const StoreSVFGNode store 
)
inlineprotectedvirtual

Return TRUE if this is a strong update STORE statement.

Find the unique element in cpts

Definition at line 456 of file DDAVFSolver.h.

457 {
458 if (dstCPSet.count() == 1)
459 {
461 typename CPtSet::iterator it = dstCPSet.begin();
462 const CVar& var = *it;
463 // Strong update can be made if this points-to target is not heap, array or field-insensitive.
466 {
467 return true;
468 }
469 }
470 return false;
471 }
virtual bool isLocalCVarInRecursion(const CVar &var) const
Whether a local variable is in function recursions.
bool isFieldInsenCondMemObj(const CVar &var) const
virtual bool isHeapCondMemObj(const CVar &var, const StoreSVFGNode *)
Check heap and array object.
bool isArrayCondMemObj(const CVar &var) const

◆ isSVFGNodeInCycle()

template<class CVar , class CPtSet , class DPIm >
bool SVF::DDAVFSolver< CVar, CPtSet, DPIm >::isSVFGNodeInCycle ( const SVFGNode node)
inlineprotected

Return whether this SVFGNode is in cycle.

Definition at line 619 of file DDAVFSolver.h.

620 {
621 return _svfgSCC->isInCycle(node->getId());
622 }

◆ isTopLevelPtrStmt()

template<class CVar , class CPtSet , class DPIm >
bool SVF::DDAVFSolver< CVar, CPtSet, DPIm >::isTopLevelPtrStmt ( const SVFGNode stmt)
inlineprotected

Whether this is a top-level pointer statement.

Definition at line 585 of file DDAVFSolver.h.

586 {
587 return !SVFUtil::isa<StoreSVFGNode, MRSVFGNode>(stmt);
588 }

◆ markbkVisited()

template<class CVar , class CPtSet , class DPIm >
void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::markbkVisited ( const DPIm &  dpm)
inlineprotected

Visited flags to avoid cycles.

Definition at line 541 of file DDAVFSolver.h.

542 {
543 backwardVisited.insert(dpm);
544 }

◆ OOBResetVisited()

template<class CVar , class CPtSet , class DPIm >
void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::OOBResetVisited ( )
inlineprotected

Reset visited map if the current query is out-of-budget.

Definition at line 338 of file DDAVFSolver.h.

339 {
340 for(typename LocToDPMVecMap::const_iterator it = locToDpmSetMap.begin(),eit = locToDpmSetMap.end(); it!=eit; ++it)
341 {
342 DPTItemSet dpmSet(it->second.begin(), it->second.end());
343 for(typename DPTItemSet::const_iterator dit = dpmSet.begin(),deit=dpmSet.end(); dit!=deit; ++dit)
344 if(isOutOfBudgetDpm(*dit)==false)
346 }
347 }
OrderedSet< DPIm > DPTItemSet
Definition DDAVFSolver.h:57
bool isOutOfBudgetDpm(const DPIm &dpm) const
void clearbkVisited(const DPIm &dpm)

◆ processGepPts()

template<class CVar , class CPtSet , class DPIm >
virtual CPtSet SVF::DDAVFSolver< CVar, CPtSet, DPIm >::processGepPts ( const GepSVFGNode gep,
const CPtSet &  srcPts 
)
protectedpure virtual

ProcessGep node to generate field object nodes of a struct.

Implemented in SVF::ContextDDA, and SVF::FlowDDA.

◆ propagateViaObj()

template<class CVar , class CPtSet , class DPIm >
virtual bool SVF::DDAVFSolver< CVar, CPtSet, DPIm >::propagateViaObj ( const CVar &  storeObj,
const CVar &  loadObj 
)
inlineprotectedvirtual

If the points-to contain the object obj, we could move forward along indirect value-flow edge.

Reimplemented in SVF::ContextDDA.

Definition at line 489 of file DDAVFSolver.h.

490 {
492 }

◆ reCompute()

template<class CVar , class CPtSet , class DPIm >
void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::reCompute ( const DPIm &  dpm)
inlineprotected

recompute points-to for value-flow cycles and indirect calls

re-compute due to indirect calls

callgraph scc detection for local variable in recursion

re-compute for transitive closures

Definition at line 257 of file DDAVFSolver.h.

258 {
261 if(_pag->isFunPtr(dpm.getCurNodeID()))
262 {
263 const CallSiteSet& csSet = _pag->getIndCallSites(dpm.getCurNodeID());
264 for(CallSiteSet::const_iterator it = csSet.begin(), eit = csSet.end(); it!=eit; ++it)
266 }
268 if(!newIndirectEdges.empty())
269 _callGraphSCC->find();
271
273 SVFGEdgeSet edgeSet(dpm.getLoc()->getOutEdges());
275 }
SVFIR::CallSiteSet CallSiteSet
Definition DDAVFSolver.h:56
virtual void updateCallGraphAndSVFG(const DPIm &, const CallICFGNode *, SVFGEdgeSet &)
Update call graph.
void reComputeForEdges(const DPIm &dpm, const SVFGEdgeSet &edgeSet, bool indirectCall=false)
Traverse along out edges to find all nodes which may be affected by locDPM.
bool isFunPtr(NodeID id) const
Definition SVFIR.h:473
const CallSiteSet & getIndCallSites(NodeID funPtr) const
Definition SVFIR.h:463

◆ reComputeForEdges()

template<class CVar , class CPtSet , class DPIm >
void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::reComputeForEdges ( const DPIm &  dpm,
const SVFGEdgeSet edgeSet,
bool  indirectCall = false 
)
inlineprotected

Traverse along out edges to find all nodes which may be affected by locDPM.

Only collect nodes we have traversed

Definition at line 278 of file DDAVFSolver.h.

279 {
280 for (SVFGNode::const_iterator it = edgeSet.begin(), eit = edgeSet.end(); it != eit; ++it)
281 {
282 const SVFGEdge* edge = *it;
283 const SVFGNode* dst = edge->getDstNode();
284 typename LocToDPMVecMap::const_iterator locIt = getLocToDPMVecMap().find(dst->getId());
286 if (locIt == getLocToDPMVecMap().end())
287 continue;
288 DPTItemSet dpmSet(locIt->second.begin(), locIt->second.end());
289 for(typename DPTItemSet::const_iterator it = dpmSet.begin(),eit = dpmSet.end(); it!=eit; ++it)
290 {
291 const DPIm& dstDpm = *it;
292 if(!indirectCall && SVFUtil::isa<IndirectSVFGEdge>(edge) && !SVFUtil::isa<LoadSVFGNode>(edge->getDstNode()))
293 {
294 if(dstDpm.getCurNodeID() == dpm.getCurNodeID())
295 {
296 DBOUT(DDDA,SVFUtil::outs() << "\t Recompute, forward from :");
297 DBOUT(DDDA, dpm.dump());
300 findPT(dstDpm);
301 }
302 }
303 else
304 {
305 if(indirectCall)
306 DBOUT(DDDA,SVFUtil::outs() << "\t Recompute for indirect call from :");
307 else
308 DBOUT(DDDA,SVFUtil::outs() << "\t Recompute forward from :");
309 DBOUT(DDDA, dpm.dump());
312 findPT(dstDpm);
313 }
314 }
315 }
316 }
u64_t _NumOfStepInCycle
Definition DDAStat.h:61
const LocToDPMVecMap & getLocToDPMVecMap() const
Map a SVFGNode to its dpms for handling value-flow cycles.

◆ removeDpmFromLoc()

template<class CVar , class CPtSet , class DPIm >
void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::removeDpmFromLoc ( const DPIm &  dpm)
inlineprivate

Definition at line 673 of file DDAVFSolver.h.

674 {
675 assert(dpm == locToDpmSetMap[dpm.getLoc()].back() && "dpm not match with the end of vector");
676 locToDpmSetMap[dpm.getLoc()->getId()].erase(dpm);
677 }

◆ resetQuery()

template<class CVar , class CPtSet , class DPIm >
virtual void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::resetQuery ( )
inlineprotectedvirtual

Reset visited map for next points-to query.

Definition at line 326 of file DDAVFSolver.h.

327 {
330
331 locToDpmSetMap.clear();
332 dpmToloadDpmMap.clear();
333 loadToPTCVarMap.clear();
334 outOfBudgetQuery = false;
335 ddaStat->_NumOfStep = 0;
336 }
u64_t _NumOfStep
Definition DDAStat.h:60
void OOBResetVisited()
Reset visited map if the current query is out-of-budget.

◆ resolveFunPtr()

template<class CVar , class CPtSet , class DPIm >
void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::resolveFunPtr ( const DPIm &  dpm)
inlineprotected

resolve function pointer

use pre-analysis call graph to approximate all potential callsites

Definition at line 494 of file DDAVFSolver.h.

495 {
496 if(const CallICFGNode* cbn= getSVFG()->isCallSiteRetSVFGNode(dpm.getLoc()))
497 {
499 {
501 DPIm funPtrDpm(dpm);
504 }
505 }
506 else if(const FunObjVar* fun = getSVFG()->isFunEntrySVFGNode(dpm.getLoc()))
507 {
511 for(CallInstSet::const_iterator it = csSet.begin(), eit = csSet.end(); it!=eit; ++it)
512 {
513 NodeID funPtr = _pag->getFunPtr(*it);
514 DPIm funPtrDpm(dpm);
517 }
518 }
519 }
void getIndCallSitesInvokingCallee(const FunObjVar *callee, CallGraphEdge::CallInstSet &csSet)
CallGraphEdge::CallInstSet CallInstSet
Definition DDAVFSolver.h:55
CallGraph * getCallGraph() const
Return call graph.
NodeID getFunPtr(const CallICFGNode *cs) const
Definition SVFIR.h:457
bool isIndirectCallSites(const CallICFGNode *cs) const
Definition SVFIR.h:469
const ValVar * getValVar(NodeID id) const
Definition SVFIR.h:139

◆ rmSUStat()

template<class CVar , class CPtSet , class DPIm >
void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::rmSUStat ( const DPIm &  dpm,
const SVFGNode node 
)
inlineprotected

remove strong updates num if the dpm goes to weak updates branch

Definition at line 763 of file DDAVFSolver.h.

764 {
766 if (dpmSet.erase(dpm))
767 {
769 if(dpmSet.empty())
770 ddaStat->_StrongUpdateStores.reset(node->getId());
771 }
772 }
void reset(unsigned Idx)

◆ setCallGraph()

template<class CVar , class CPtSet , class DPIm >
void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::setCallGraph ( CallGraph cg)
inlineprotected

Set callgraph.

Definition at line 629 of file DDAVFSolver.h.

630 {
631 _callGraph = cg;
632 }

◆ setCallGraphSCC()

template<class CVar , class CPtSet , class DPIm >
void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::setCallGraphSCC ( CallGraphSCC scc)
inlineprotected

Set callgraphSCC.

Definition at line 634 of file DDAVFSolver.h.

635 {
636 _callGraphSCC = scc;
637 }

◆ setDDAStat()

template<class CVar , class CPtSet , class DPIm >
DDAStat * SVF::DDAVFSolver< CVar, CPtSet, DPIm >::setDDAStat ( DDAStat s)
inlineprotected

Set DDAStat.

Definition at line 748 of file DDAVFSolver.h.

749 {
750 ddaStat = s;
751 return ddaStat;
752 }

◆ startNewPTCompFromLoadSrc()

template<class CVar , class CPtSet , class DPIm >
void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::startNewPTCompFromLoadSrc ( CPtSet &  pts,
const DPIm &  oldDpm 
)
inlineprotected

Backward traverse for top-level pointers of load/store statements

Definition at line 394 of file DDAVFSolver.h.

395 {
396 const LoadSVFGNode* load = SVFUtil::cast<LoadSVFGNode>(oldDpm.getLoc());
397 const SVFGNode* loadSrc = getDefSVFGNode(load->getSrcNode());
398 DBOUT(DDDA, SVFUtil::outs() << "!##start new computation from loadSrc svfgNode " <<
399 load->getId() << " --> " << loadSrc->getId() << "\n");
401 assert(edge && "Edge not found!!");
402 backwardPropDpm(pts,load->getSrcNodeID(),oldDpm,edge);
403
404 }

◆ startNewPTCompFromStoreDst()

template<class CVar , class CPtSet , class DPIm >
void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::startNewPTCompFromStoreDst ( CPtSet &  pts,
const DPIm &  oldDpm 
)
inlineprotected

Definition at line 405 of file DDAVFSolver.h.

406 {
407 const StoreSVFGNode* store = SVFUtil::cast<StoreSVFGNode>(oldDpm.getLoc());
408 const SVFGNode* storeDst = getDefSVFGNode(store->getDstNode());
409 DBOUT(DDDA, SVFUtil::outs() << "!##start new computation from storeDst svfgNode " <<
410 store->getId() << " --> " << storeDst->getId() << "\n");
412 assert(edge && "Edge not found!!");
413 backwardPropDpm(pts,store->getDstNodeID(),oldDpm,edge);
414 }

◆ SVFGSCCDetection()

template<class CVar , class CPtSet , class DPIm >
void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::SVFGSCCDetection ( )
inlineprotected

SVFG SCC detection.

Definition at line 605 of file DDAVFSolver.h.

606 {
607 if(_svfgSCC==nullptr)
608 {
609 _svfgSCC = new SVFGSCC(getSVFG());
610 }
611 _svfgSCC->find();
612 }
SCCDetection< SVFG * > SVFGSCC
Definition DDAVFSolver.h:53

◆ testOutOfBudget()

template<class CVar , class CPtSet , class DPIm >
bool SVF::DDAVFSolver< CVar, CPtSet, DPIm >::testOutOfBudget ( const DPIm &  dpm)
inlineprotected

Definition at line 726 of file DDAVFSolver.h.

727 {
728 if(outOfBudgetQuery) return true;
729 if(++ddaStat->_NumOfStep > DPIm::getMaxBudget())
730 outOfBudgetQuery = true;
732 }

◆ unionDDAPts() [1/2]

template<class CVar , class CPtSet , class DPIm >
virtual bool SVF::DDAVFSolver< CVar, CPtSet, DPIm >::unionDDAPts ( CPtSet &  pts,
const CPtSet &  targetPts 
)
inlinevirtual

Union pts.

Definition at line 104 of file DDAVFSolver.h.

105 {
106 return (pts |= targetPts);
107 }

◆ unionDDAPts() [2/2]

template<class CVar , class CPtSet , class DPIm >
virtual bool SVF::DDAVFSolver< CVar, CPtSet, DPIm >::unionDDAPts ( DPIm  dpm,
const CPtSet &  targetPts 
)
inlinevirtual

Union pts.

Reimplemented in SVF::FlowDDA.

Definition at line 109 of file DDAVFSolver.h.

110 {
112 return pts |= targetPts;
113 }

◆ updateCachedPointsTo()

template<class CVar , class CPtSet , class DPIm >
virtual void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::updateCachedPointsTo ( const DPIm &  dpm,
const CPtSet &  pts 
)
inlineprotectedvirtual

Definition at line 565 of file DDAVFSolver.h.

566 {
567 if (unionDDAPts(dpm, pts))
568 {
569 DOSTAT(double start = DDAStat::getClk(true));
570 reCompute(dpm);
572 }
573 }
double _AnaTimeCyclePerQuery
Definition DDAStat.h:63
void reCompute(const DPIm &dpm)
recompute points-to for value-flow cycles and indirect calls

◆ updateCallGraphAndSVFG()

template<class CVar , class CPtSet , class DPIm >
virtual void SVF::DDAVFSolver< CVar, CPtSet, DPIm >::updateCallGraphAndSVFG ( const DPIm &  ,
const CallICFGNode ,
SVFGEdgeSet  
)
inlineprotectedvirtual

Update call graph.

Reimplemented in SVF::ContextDDA, and SVF::FlowDDA.

Definition at line 536 of file DDAVFSolver.h.

536{}

Friends And Related Symbol Documentation

◆ DDAStat

template<class CVar , class CPtSet , class DPIm >
friend class DDAStat
friend

Definition at line 51 of file DDAVFSolver.h.

Member Data Documentation

◆ _ander

template<class CVar , class CPtSet , class DPIm >
AndersenWaveDiff* SVF::DDAVFSolver< CVar, CPtSet, DPIm >::_ander
protected

Andersen's analysis.

Definition at line 777 of file DDAVFSolver.h.

◆ _callGraph

template<class CVar , class CPtSet , class DPIm >
CallGraph* SVF::DDAVFSolver< CVar, CPtSet, DPIm >::_callGraph
protected

PTACallGraph.

Definition at line 779 of file DDAVFSolver.h.

◆ _callGraphSCC

template<class CVar , class CPtSet , class DPIm >
CallGraphSCC* SVF::DDAVFSolver< CVar, CPtSet, DPIm >::_callGraphSCC
protected

SCC for PTACallGraph.

Definition at line 780 of file DDAVFSolver.h.

◆ _pag

template<class CVar , class CPtSet , class DPIm >
SVFIR* SVF::DDAVFSolver< CVar, CPtSet, DPIm >::_pag
protected

SVFIR.

Definition at line 775 of file DDAVFSolver.h.

◆ _svfg

template<class CVar , class CPtSet , class DPIm >
SVFG* SVF::DDAVFSolver< CVar, CPtSet, DPIm >::_svfg
protected

SVFG.

Definition at line 776 of file DDAVFSolver.h.

◆ _svfgSCC

template<class CVar , class CPtSet , class DPIm >
SVFGSCC* SVF::DDAVFSolver< CVar, CPtSet, DPIm >::_svfgSCC
protected

SCC for SVFG.

Definition at line 781 of file DDAVFSolver.h.

◆ backwardVisited

template<class CVar , class CPtSet , class DPIm >
DPTItemSet SVF::DDAVFSolver< CVar, CPtSet, DPIm >::backwardVisited
protected

visited map during backward traversing

Definition at line 782 of file DDAVFSolver.h.

◆ candidateQueries

template<class CVar , class CPtSet , class DPIm >
NodeBS SVF::DDAVFSolver< CVar, CPtSet, DPIm >::candidateQueries
protected

candidate pointers;

Definition at line 778 of file DDAVFSolver.h.

◆ ddaStat

template<class CVar , class CPtSet , class DPIm >
DDAStat* SVF::DDAVFSolver< CVar, CPtSet, DPIm >::ddaStat
protected

DDA stat.

Definition at line 790 of file DDAVFSolver.h.

◆ dpmToADCPtSetMap

template<class CVar , class CPtSet , class DPIm >
DPImToCPtSetMap SVF::DDAVFSolver< CVar, CPtSet, DPIm >::dpmToADCPtSetMap
protected

points-to caching map for address-taken vars

Definition at line 784 of file DDAVFSolver.h.

◆ dpmToloadDpmMap

template<class CVar , class CPtSet , class DPIm >
DPMToDPMMap SVF::DDAVFSolver< CVar, CPtSet, DPIm >::dpmToloadDpmMap
protected

dpms at loads for may/must-alias analysis with stores

Definition at line 786 of file DDAVFSolver.h.

◆ dpmToTLCPtSetMap

template<class CVar , class CPtSet , class DPIm >
DPImToCPtSetMap SVF::DDAVFSolver< CVar, CPtSet, DPIm >::dpmToTLCPtSetMap
protected

points-to caching map for top-level vars

Definition at line 783 of file DDAVFSolver.h.

◆ loadToPTCVarMap

template<class CVar , class CPtSet , class DPIm >
DPMToCVarMap SVF::DDAVFSolver< CVar, CPtSet, DPIm >::loadToPTCVarMap
protected

map a load dpm to its cvar pointed by its pointer operand

Definition at line 787 of file DDAVFSolver.h.

◆ locToDpmSetMap

template<class CVar , class CPtSet , class DPIm >
LocToDPMVecMap SVF::DDAVFSolver< CVar, CPtSet, DPIm >::locToDpmSetMap
protected

map location to its dpms

Definition at line 785 of file DDAVFSolver.h.

◆ outOfBudgetDpms

template<class CVar , class CPtSet , class DPIm >
DPTItemSet SVF::DDAVFSolver< CVar, CPtSet, DPIm >::outOfBudgetDpms
protected

out of budget dpm set

Definition at line 788 of file DDAVFSolver.h.

◆ outOfBudgetQuery

template<class CVar , class CPtSet , class DPIm >
bool SVF::DDAVFSolver< CVar, CPtSet, DPIm >::outOfBudgetQuery
protected

Whether the current query is out of step limits.

Definition at line 774 of file DDAVFSolver.h.

◆ storeToDPMs

template<class CVar , class CPtSet , class DPIm >
StoreToPMSetMap SVF::DDAVFSolver< CVar, CPtSet, DPIm >::storeToDPMs
protected

map store to set of DPM which have been stong updated there

Definition at line 789 of file DDAVFSolver.h.

◆ svfgBuilder

template<class CVar , class CPtSet , class DPIm >
SVFGBuilder SVF::DDAVFSolver< CVar, CPtSet, DPIm >::svfgBuilder
protected

SVFG Builder.

Definition at line 791 of file DDAVFSolver.h.


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