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< PTACallGraph * > CallGraphSCC
 
typedef PTACallGraphEdge::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 PAGNode *pagNode) 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;
 
PTACallGraph_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 (PTACallGraph *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 47 of file DDAVFSolver.h.

Member Typedef Documentation

◆ CallGraphSCC

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

Definition at line 52 of file DDAVFSolver.h.

◆ CallInstSet

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

Definition at line 53 of file DDAVFSolver.h.

◆ CallSiteSet

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

Definition at line 54 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 60 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 56 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 57 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 58 of file DDAVFSolver.h.

◆ DPTItemSet

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

Definition at line 55 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 59 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 62 of file DDAVFSolver.h.

◆ SVFGEdgeSet

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

Definition at line 61 of file DDAVFSolver.h.

◆ SVFGSCC

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

Definition at line 51 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 65 of file DDAVFSolver.h.

65 : outOfBudgetQuery(false),_pag(nullptr),_svfg(nullptr),_ander(nullptr),_callGraph(nullptr), _callGraphSCC(nullptr), _svfgSCC(nullptr), ddaStat(nullptr)
66 {
67 }
CallGraphSCC * _callGraphSCC
SCC for PTACallGraph.
SVFGSCC * _svfgSCC
SCC for SVFG.
SVFIR * _pag
SVFIR.
SVFG * _svfg
SVFG.
AndersenWaveDiff * _ander
Andersen's analysis.
PTACallGraph * _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 69 of file DDAVFSolver.h.

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

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 113 of file DDAVFSolver.h.

114 {
115 pts.set(var);
116 }
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ 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:55
NodeBS _StrongUpdateStores
Definition DDAStat.h:66
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 374 of file DDAVFSolver.h.

375 {
376 const SVFGNode* node = oldDpm.getLoc();
377 const SVFGEdgeSet edgeSet(node->getInEdges());
378 for (SVFGNode::const_iterator it = edgeSet.begin(), eit = edgeSet.end(); it != eit; ++it)
379 {
380 if(const DirectSVFGEdge* dirEdge = SVFUtil::dyn_cast<DirectSVFGEdge>(*it))
381 {
382 DBOUT(DDDA, SVFUtil::outs() << "\t\t==backtrace directVF svfgNode " <<
383 dirEdge->getDstID() << " --> " << dirEdge->getSrcID() << "\n");
384 const SVFGNode* srcNode = dirEdge->getSrcNode();
385 backwardPropDpm(pts,getSVFG()->getLHSTopLevPtr(srcNode)->getId(),oldDpm,dirEdge);
386 }
387 }
388 }
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
Definition SVFType.h:484
#define DDDA
Definition SVFType.h:496
SVFGEdge::SVFGEdgeSetTy SVFGEdgeSet
Definition DDAVFSolver.h:61
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:50
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 352 of file DDAVFSolver.h.

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

◆ backtraceToStoreSrc()

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

Definition at line 413 of file DDAVFSolver.h.

414 {
415 const StoreSVFGNode* store = SVFUtil::cast<StoreSVFGNode>(oldDpm.getLoc());
416 const SVFGNode* storeSrc = getDefSVFGNode(store->getPAGSrcNode());
417 DBOUT(DDDA, SVFUtil::outs() << "++backtrace to storeSrc from svfgNode " << getLoadDpm(oldDpm).getLoc()->getId() << " to "<<
418 store->getId() << " to " << storeSrc->getId() <<"\n");
420 assert(edge && "Edge not found!!");
421 backwardPropDpm(pts,store->getPAGSrcNodeID(),oldDpm,edge);
422 }
const SVFGNode * getDefSVFGNode(const PAGNode *pagNode) 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:928
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 426 of file DDAVFSolver.h.

427 {
428 DPIm dpm(oldDpm);
429 dpm.setLocVar(edge->getSrcNode(),ptr);
430 DOTIMESTAT(double start = DDAStat::getClk(true));
432 if(handleBKCondition(dpm,edge)==false)
433 {
435 DBOUT(DDDA, SVFUtil::outs() << "\t!!! infeasible path svfgNode: " << edge->getDstID() << " --| " << edge->getSrcID() << "\n");
437 return;
438 }
439
441 if(SVFUtil::isa<IndirectSVFGEdge>(edge))
443
447 }
#define DOSTAT(X)
Definition SVFType.h:485
#define DOTIMESTAT(X)
Definition SVFType.h:486
u32_t _NumOfDPM
Definition DDAStat.h:54
u32_t _NumOfInfeasiblePath
Definition DDAStat.h:57
double _TotalTimeOfBKCondition
Definition DDAStat.h:64
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:48

◆ buildSVFG()

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

Build SVFG.

Definition at line 317 of file DDAVFSolver.h.

318 {
321 _pag = _svfg->getPAG();
322 }
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 128 of file DDAVFSolver.h.

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

◆ 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 138 of file DDAVFSolver.h.

139 {
140
141 if(isbkVisited(dpm))
142 {
143 const CPtSet& cpts = getCachedPointsTo(dpm);
144 DBOUT(DDDA, SVFUtil::outs() << "\t already backward visited dpm: ");
145 DBOUT(DDDA, dpm.dump());
146 DBOUT(DDDA, SVFUtil::outs() << "\t return points-to: ");
147 DBOUT(DDDA, dumpCPtSet(cpts));
148 return cpts;
149 }
150
151 DBOUT(DDDA, SVFUtil::outs() << "\t backward visit dpm: ");
152 DBOUT(DDDA, dpm.dump());
155
156 if(testOutOfBudget(dpm) == false)
157 {
158
159 CPtSet pts;
161
164 }
165 return getCachedPointsTo(dpm);
166 }
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 91 of file DDAVFSolver.h.

92 {
93 return candidateQueries;
94 }
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 PAGNode pagNode) const
inlineprotected

GetDefinition SVFG.

Definition at line 347 of file DDAVFSolver.h.

348 {
349 return getSVFG()->getDefSVFGNode(pagNode);
350 }
const SVFGNode * getDefSVFGNode(const PAGNode *pagNode) const
Given a pagNode, 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 96 of file DDAVFSolver.h.

97 {
98 DPIm dpm(var,loc);
99 return dpm;
100 }

◆ 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 118 of file DDAVFSolver.h.

119 {
120 return _svfg;
121 }

◆ getSVFGSCC()

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

Return SVFGSCC.

Definition at line 123 of file DDAVFSolver.h.

124 {
125 return _svfgSCC;
126 }

◆ 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 170 of file DDAVFSolver.h.

171 {
174
175 const SVFGNode* node = dpm.getLoc();
176 if(SVFUtil::isa<AddrSVFGNode>(node))
177 {
178 handleAddr(pts,dpm,SVFUtil::cast<AddrSVFGNode>(node));
179 }
183 {
185 }
186 else if(SVFUtil::isa<GepSVFGNode>(node))
187 {
188 CPtSet gepPts;
190 unionDDAPts(pts, processGepPts(SVFUtil::cast<GepSVFGNode>(node),gepPts));
191 }
192 else if(const LoadSVFGNode* load = SVFUtil::dyn_cast<LoadSVFGNode>(node))
193 {
194 if(load->getPAGDstNode()->isPointer() == false)
195 return;
196
197 CPtSet loadpts;
199 for(typename CPtSet::iterator it = loadpts.begin(), eit = loadpts.end(); it!=eit; ++it)
200 {
202 }
203 }
204 else if(const StoreSVFGNode* store = SVFUtil::dyn_cast<StoreSVFGNode>(node))
205 {
206 if(store->getPAGSrcNode()->isPointer() == false)
207 return;
208
210 {
211 DBOUT(DDDA, SVFUtil::outs() << "+++must alias for load and store:");
213 DBOUT(DDDA, dpm.dump());
214 DBOUT(DDDA, SVFUtil::outs() << "+++\n");
217 }
218 else
219 {
220 CPtSet storepts;
222 for(typename CPtSet::iterator it = storepts.begin(), eit = storepts.end(); it!=eit; ++it)
223 {
225 {
227
228 if(isStrongUpdate(storepts,store))
229 {
230 DBOUT(DDDA, SVFUtil::outs() << "backward strong update for obj " << dpm.getCurNodeID() << "\n");
231 DOSTAT(addSUStat(dpm,store);)
232 }
233 else
234 {
235 DOSTAT(rmSUStat(dpm,store);)
237 }
238 }
239 else
240 {
242 }
243 }
244 }
245 }
246 else if(SVFUtil::isa<MRSVFGNode>(node))
247 {
249 }
250 else
251 assert(false && "unexpected kind of SVFG nodes");
252 }
u32_t _NumOfMustAliases
Definition DDAStat.h:56
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 MemObj* mem = _pag->getObject(getPtrNodeID(var));
649 assert(mem && "memory object is null??");
650 return mem->isArray();
651 }
const MemObj * getObject(NodeID id) const
Definition SVFIR.h:396

◆ 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 MemObj* mem = _pag->getBaseObj(getPtrNodeID(var));
655 return mem->isFieldInsensitive();
656 }
bool isFieldInsensitive() const
Return true if its field limit is 0.
const MemObj * getBaseObj(NodeID id) const
Definition SVFIR.h:481

◆ 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 }
const BaseObjVar * getBaseObject(NodeID id) const
Definition SVFIR.h:405

◆ 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 471 of file DDAVFSolver.h.

472 {
473 NodeID id = getPtrNodeID(var);
474 const BaseObjVar* baseObj = _pag->getBaseObject(id);
475 assert(baseObj && "base object is null??");
476 const MemObj* obj = _pag->getObject(id);
477 assert(obj && "object not found!!");
478 if(SVFUtil::isa<StackObjVar>(baseObj))
479 {
480 if(const SVFFunction* svffun = _pag->getGNode(id)->getFunction())
481 {
482 return _callGraphSCC->isInCycle(_callGraph->getCallGraphNode(svffun)->getId());
483 }
484 }
485 return false;
486 }
NodeType * getGNode(NodeID id) const
Get a node.
PTACallGraphNode * getCallGraphNode(NodeID id) const
Get call graph node.
NodeID getId() const
Get ID.
virtual const SVFFunction * getFunction() const

◆ 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 449 of file DDAVFSolver.h.

450 {
451 return false;
452 }

◆ 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 454 of file DDAVFSolver.h.

455 {
456 if (dstCPSet.count() == 1)
457 {
459 typename CPtSet::iterator it = dstCPSet.begin();
460 const CVar& var = *it;
461 // Strong update can be made if this points-to target is not heap, array or field-insensitive.
464 {
465 return true;
466 }
467 }
468 return false;
469 }
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 336 of file DDAVFSolver.h.

337 {
338 for(typename LocToDPMVecMap::const_iterator it = locToDpmSetMap.begin(),eit = locToDpmSetMap.end(); it!=eit; ++it)
339 {
340 DPTItemSet dpmSet(it->second.begin(), it->second.end());
341 for(typename DPTItemSet::const_iterator dit = dpmSet.begin(),deit=dpmSet.end(); dit!=deit; ++dit)
342 if(isOutOfBudgetDpm(*dit)==false)
344 }
345 }
OrderedSet< DPIm > DPTItemSet
Definition DDAVFSolver.h:55
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 255 of file DDAVFSolver.h.

256 {
259 if(_pag->isFunPtr(dpm.getCurNodeID()))
260 {
261 const CallSiteSet& csSet = _pag->getIndCallSites(dpm.getCurNodeID());
262 for(CallSiteSet::const_iterator it = csSet.begin(), eit = csSet.end(); it!=eit; ++it)
264 }
266 if(!newIndirectEdges.empty())
267 _callGraphSCC->find();
269
271 SVFGEdgeSet edgeSet(dpm.getLoc()->getOutEdges());
273 }
SVFIR::CallSiteSet CallSiteSet
Definition DDAVFSolver.h:54
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:371
const CallSiteSet & getIndCallSites(NodeID funPtr) const
Definition SVFIR.h:361

◆ 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 276 of file DDAVFSolver.h.

277 {
278 for (SVFGNode::const_iterator it = edgeSet.begin(), eit = edgeSet.end(); it != eit; ++it)
279 {
280 const SVFGEdge* edge = *it;
281 const SVFGNode* dst = edge->getDstNode();
282 typename LocToDPMVecMap::const_iterator locIt = getLocToDPMVecMap().find(dst->getId());
284 if (locIt == getLocToDPMVecMap().end())
285 continue;
286 DPTItemSet dpmSet(locIt->second.begin(), locIt->second.end());
287 for(typename DPTItemSet::const_iterator it = dpmSet.begin(),eit = dpmSet.end(); it!=eit; ++it)
288 {
289 const DPIm& dstDpm = *it;
290 if(!indirectCall && SVFUtil::isa<IndirectSVFGEdge>(edge) && !SVFUtil::isa<LoadSVFGNode>(edge->getDstNode()))
291 {
292 if(dstDpm.getCurNodeID() == dpm.getCurNodeID())
293 {
294 DBOUT(DDDA,SVFUtil::outs() << "\t Recompute, forward from :");
295 DBOUT(DDDA, dpm.dump());
298 findPT(dstDpm);
299 }
300 }
301 else
302 {
303 if(indirectCall)
304 DBOUT(DDDA,SVFUtil::outs() << "\t Recompute for indirect call from :");
305 else
306 DBOUT(DDDA,SVFUtil::outs() << "\t Recompute forward from :");
307 DBOUT(DDDA, dpm.dump());
310 findPT(dstDpm);
311 }
312 }
313 }
314 }
u64_t _NumOfStepInCycle
Definition DDAStat.h:60
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 324 of file DDAVFSolver.h.

325 {
328
329 locToDpmSetMap.clear();
330 dpmToloadDpmMap.clear();
331 loadToPTCVarMap.clear();
332 outOfBudgetQuery = false;
333 ddaStat->_NumOfStep = 0;
334 }
u64_t _NumOfStep
Definition DDAStat.h:59
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 SVFFunction* fun = getSVFG()->isFunEntrySVFGNode(dpm.getLoc()))
507 {
511 for(CallInstSet::const_iterator it = csSet.begin(), eit = csSet.end(); it!=eit; ++it)
512 {
514 DPIm funPtrDpm(dpm);
517 }
518 }
519 }
PTACallGraphEdge::CallInstSet CallInstSet
Definition DDAVFSolver.h:53
void getIndCallSitesInvokingCallee(const SVFFunction *callee, PTACallGraphEdge::CallInstSet &csSet)
PTACallGraph * getCallGraph() const
Return call graph.
NodeID getFunPtr(const CallICFGNode *cs) const
Definition SVFIR.h:355
bool isIndirectCallSites(const CallICFGNode *cs) const
Definition SVFIR.h:367

◆ 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 ( PTACallGraph 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 392 of file DDAVFSolver.h.

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

◆ startNewPTCompFromStoreDst()

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

Definition at line 403 of file DDAVFSolver.h.

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

◆ 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:51

◆ 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 102 of file DDAVFSolver.h.

103 {
104 return (pts |= targetPts);
105 }

◆ 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 107 of file DDAVFSolver.h.

108 {
110 return pts |= targetPts;
111 }

◆ 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:62
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 49 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 >
PTACallGraph* 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: