Static Value-Flow Analysis
Public Member Functions | Private Attributes | List of all members
SVF::ContextDDA Class Reference

#include <ContextDDA.h>

Inheritance diagram for SVF::ContextDDA:
SVF::CondPTAImpl< ContextCond > SVF::DDAVFSolver< CxtVar, CxtPtSet, CxtLocDPItem > SVF::PointerAnalysis

Public Member Functions

 ContextDDA (SVFIR *_pag, DDAClient *client)
 Constructor. More...
 
virtual ~ContextDDA ()
 Destructor. More...
 
virtual void initialize () override
 Initialization of the analysis. More...
 
virtual void finalize () override
 Finalize analysis. More...
 
virtual void analyze () override
 dummy analyze method More...
 
virtual void computeDDAPts (NodeID id) override
 Compute points-to set for an unconditional pointer. More...
 
virtual const CxtPtSetcomputeDDAPts (const CxtVar &cxtVar)
 Compute points-to set for a context-sensitive pointer. More...
 
void handleOutOfBudgetDpm (const CxtLocDPItem &dpm)
 Handle out-of-budget dpm. More...
 
virtual CxtPtSet getConservativeCPts (const CxtLocDPItem &dpm) override
 Override parent method. More...
 
virtual NodeID getPtrNodeID (const CxtVar &var) const override
 Override parent method. More...
 
virtual bool handleBKCondition (CxtLocDPItem &dpm, const SVFGEdge *edge) override
 Handle condition for context or path analysis (backward analysis) More...
 
virtual bool isHeapCondMemObj (const CxtVar &var, const StoreSVFGNode *store) override
 
bool testIndCallReachability (CxtLocDPItem &dpm, const SVFFunction *callee, const CallICFGNode *cs)
 refine indirect call edge More...
 
CallSiteID getCSIDAtCall (CxtLocDPItem &dpm, const SVFGEdge *edge)
 get callsite id from call, return 0 if it is a spurious call edge More...
 
CallSiteID getCSIDAtRet (CxtLocDPItem &dpm, const SVFGEdge *edge)
 get callsite id from return, return 0 if it is a spurious return edge More...
 
virtual void popRecursiveCallSites (CxtLocDPItem &dpm)
 Pop recursive callsites. More...
 
virtual bool isEdgeInRecursion (CallSiteID csId)
 Whether call/return inside recursion. More...
 
virtual void updateCallGraphAndSVFG (const CxtLocDPItem &dpm, const CallICFGNode *cs, SVFGEdgeSet &svfgEdges) override
 Update call graph. More...
 
bool edgeInCallGraphSCC (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. More...
 
virtual CxtPtSet processGepPts (const GepSVFGNode *gep, const CxtPtSet &srcPts) override
 processGep node More...
 
virtual void handleAddr (CxtPtSet &pts, const CxtLocDPItem &dpm, const AddrSVFGNode *addr) override
 Handle Address SVFGNode to add proper conditional points-to. More...
 
virtual bool propagateViaObj (const CxtVar &storeObj, const CxtVar &loadObj) override
 Propagate along indirect value-flow if two objects of load and store are same. More...
 
virtual bool isCondCompatible (const ContextCond &cxt1, const ContextCond &cxt2, bool singleton) const override
 
bool isInsensitiveCallRet (const SVFGEdge *edge)
 Whether this edge is treated context-insensitively. More...
 
ConstSVFGEdgeSetgetInsensitiveEdgeSet ()
 Return insensitive edge set. More...
 
virtual void dumpContexts (const ContextCond &cxts)
 dump context call strings More...
 
virtual const std::string PTAName () const override
 Return PTA name. More...
 
- Public Member Functions inherited from SVF::CondPTAImpl< ContextCond >
 CondPTAImpl (SVFIR *pag, PointerAnalysis::PTATY type)
 map a pointer to its conditional points-to set More...
 
virtual ~CondPTAImpl ()
 Destructor. More...
 
void destroy ()
 Release memory. More...
 
PTDataTygetPTDataTy () const
 Get points-to data. More...
 
MutPTDataTygetMutPTDataTy () const
 
bool hasPtsMap (void) const
 
const MutPTDataTy::PtsMapgetPtsMap () const
 
virtual const CPtSetgetPts (CVar id)
 
virtual PointsTogetPts (NodeID ptr)
 Given a pointer return its bit vector points-to. More...
 
virtual const Set< CVar > & getRevPts (CVar nodeId)
 
virtual NodeSetgetRevPts (NodeID obj)
 Given an object return all pointers points to this object. More...
 
virtual void clearPts ()
 Clear all data. More...
 
bool overlap (const CPtSet &cpts1, const CPtSet &cpts2) const
 Whether cpts1 and cpts2 have overlap points-to targets. More...
 
void expandFIObjs (const CPtSet &cpts, CPtSet &expandedCpts)
 Expand all fields of an aggregate in all points-to sets. More...
 
virtual void dumpCPts ()
 Print out conditional pts. More...
 
virtual PointsTo getBVPointsTo (const CPtSet &cpts) const
 Given a conditional pts return its bit vector points-to. More...
 
virtual const CPtSetgetCondPointsTo (NodeID ptr)
 Given a pointer return its conditional points-to. More...
 
virtual AliasResult alias (const SVFValue *V1, const SVFValue *V2)
 Interface expose to users of our pointer analysis, given Value infos. More...
 
virtual AliasResult alias (NodeID node1, NodeID node2)
 Interface expose to users of our pointer analysis, given two pointers. More...
 
virtual AliasResult alias (const CVar &var1, const CVar &var2)
 Interface expose to users of our pointer analysis, given conditional variables. More...
 
virtual AliasResult alias (const CPtSet &pts1, const CPtSet &pts2)
 Interface expose to users of our pointer analysis, given two conditional points-to sets. More...
 
bool containBlackHoleNode (const CPtSet &cpts)
 Test blk node for cpts. More...
 
bool containConstantNode (const CPtSet &cpts)
 Test constant node for cpts. More...
 
void dumpTopLevelPtsTo ()
 Dump points-to information of top-level pointers. More...
 
- Public Member Functions inherited from SVF::PointerAnalysis
ICFGgetICFG () const
 Get ICFG. More...
 
u32_t getNumOfResolvedIndCallEdge () const
 Return number of resolved indirect call edges. More...
 
PTACallGraphgetCallGraph () const
 Return call graph. More...
 
CallGraphSCCgetCallGraphSCC () const
 Return call graph SCC. More...
 
 PointerAnalysis (SVFIR *pag, PTATY ty=Default_PTA, bool alias_check=true)
 Constructor. More...
 
PTATY getAnalysisTy () const
 Type of pointer analysis. More...
 
PTAImplTy getImplTy () const
 Return implementation type of the pointer analysis. More...
 
bool printStat ()
 Whether print statistics. More...
 
void disablePrintStat ()
 Whether print statistics. More...
 
CallEdgeMapgetIndCallMap ()
 Get callees from an indirect callsite. More...
 
bool hasIndCSCallees (const CallICFGNode *cs) const
 
const FunctionSetgetIndCSCallees (const CallICFGNode *cs) const
 
virtual void resolveIndCalls (const CallICFGNode *cs, const PointsTo &target, CallEdgeMap &newEdges)
 Resolve indirect call edges. More...
 
void callGraphSCCDetection ()
 PTACallGraph SCC related methods. More...
 
NodeID getCallGraphSCCRepNode (NodeID id) const
 Get SCC rep node of a SVFG node. More...
 
bool inSameCallGraphSCC (const SVFFunction *fun1, const SVFFunction *fun2)
 Return TRUE if this edge is inside a PTACallGraph SCC, i.e., src node and dst node are in the same SCC on the SVFG. More...
 
bool isInRecursion (const SVFFunction *fun) const
 
bool isLocalVarInRecursiveFun (NodeID id) const
 Whether a local variable is in function recursions. More...
 
CommonCHGraphgetCHGraph () const
 get CHGraph More...
 
void getVFnsFromCHA (const CallICFGNode *cs, VFunSet &vfns)
 
void getVFnsFromPts (const CallICFGNode *cs, const PointsTo &target, VFunSet &vfns)
 
void connectVCallToVFns (const CallICFGNode *cs, const VFunSet &vfns, CallEdgeMap &newEdges)
 
virtual void resolveCPPIndCalls (const CallICFGNode *cs, const PointsTo &target, CallEdgeMap &newEdges)
 Resolve cpp indirect call edges. More...
 
SVFIRgetPAG () const
 
PTAStatgetStat () const
 Get PTA stat. More...
 
SVFModulegetModule () const
 Module. More...
 
OrderedNodeSetgetAllValidPtrs ()
 Get all Valid Pointers for resolution. More...
 
virtual ~PointerAnalysis ()
 Destructor. More...
 
void printIndCSTargets (const CallICFGNode *cs, const FunctionSet &targets)
 Print targets of a function pointer. More...
 
virtual void dumpAllPts ()
 
virtual void dumpPts (NodeID ptr, const PointsTo &pts)
 
void printIndCSTargets ()
 
void dumpAllTypes ()
 
void dumpStat ()
 Dump the statistics. More...
 
bool containBlackHoleNode (const PointsTo &pts)
 Determine whether a points-to contains a black hole or constant node. More...
 
bool containConstantNode (const PointsTo &pts)
 
virtual bool isBlkObjOrConstantObj (NodeID ptd) const
 
bool isHeapMemObj (NodeID id) const
 Whether this object is heap or array. More...
 
bool isArrayMemObj (NodeID id) const
 
bool isFIObjNode (NodeID id) const
 
NodeID getBaseObjVar (NodeID id)
 
NodeID getFIObjVar (NodeID id)
 
NodeID getGepObjVar (NodeID id, const APOffset &ap)
 
virtual const NodeBSgetAllFieldsObjVars (NodeID id)
 
void setObjFieldInsensitive (NodeID id)
 
bool isFieldInsensitive (NodeID id) const
 
- Public Member Functions inherited from SVF::DDAVFSolver< CxtVar, CxtPtSet, CxtLocDPItem >
 DDAVFSolver ()
 Constructor. More...
 
virtual ~DDAVFSolver ()
 Destructor. More...
 
NodeBSgetCandidateQueries ()
 Return candidate pointers for DDA. More...
 
virtual CxtLocDPItem getDPIm (const CxtVar &var, const SVFGNode *loc) const
 Given CVar and location (SVFGNode) return a new DPItem. More...
 
virtual bool unionDDAPts (CxtPtSet &pts, const CxtPtSet &targetPts)
 Union pts. More...
 
virtual bool unionDDAPts (CxtLocDPItem dpm, const CxtPtSet &targetPts)
 Union pts. More...
 
virtual void addDDAPts (CxtPtSet &pts, const CxtVar &var)
 Add pts. More...
 
SVFGgetSVFG () const
 Return SVFG. More...
 
SVFGSCCgetSVFGSCC () const
 Return SVFGSCC. More...
 
void dumpCPtSet (const CxtPtSet &cpts) const
 
virtual const CxtPtSetfindPT (const CxtLocDPItem &dpm)
 Compute points-to. More...
 

Private Attributes

ConstSVFGEdgeSet insensitveEdges
 insensitive call-return edges More...
 
FlowDDAflowDDA
 downgrade to flowDDA if out-of-budget More...
 
DDAClient_client
 DDA client. More...
 

Additional Inherited Members

- Public Types inherited from SVF::CondPTAImpl< ContextCond >
typedef CondVar< ContextCondCVar
 
typedef CondStdSet< CVarCPtSet
 
typedef PTData< CVar, Set< CVar >, CVar, CPtSetPTDataTy
 
typedef MutablePTData< CVar, Set< CVar >, CVar, CPtSetMutPTDataTy
 
typedef Map< NodeID, PointsToPtrToBVPtsMap
 
typedef Map< NodeID, NodeSetPtrToNSMap
 map a pointer to its BitVector points-to representation More...
 
typedef Map< NodeID, CPtSetPtrToCPtsMap
 
- Public Types inherited from SVF::PointerAnalysis
enum  PTATY {
  Andersen_BASE , Andersen_WPA , AndersenSCD_WPA , AndersenSFR_WPA ,
  AndersenWaveDiff_WPA , Steensgaard_WPA , CSCallString_WPA , CSSummary_WPA ,
  FSDATAFLOW_WPA , FSSPARSE_WPA , VFS_WPA , FSCS_WPA ,
  CFLFICI_WPA , CFLFSCI_WPA , CFLFSCS_WPA , TypeCPP_WPA ,
  FieldS_DDA , FlowS_DDA , PathS_DDA , Cxt_DDA ,
  Default_PTA
}
 Pointer analysis type list. More...
 
enum  PTAImplTy { BaseImpl , BVDataImpl , CondImpl }
 Implementation type: BVDataPTAImpl or CondPTAImpl. More...
 
typedef Set< const CallICFGNode * > CallSiteSet
 Indirect call edges type, map a callsite to a set of callees. More...
 
typedef SVFIR::CallSiteToFunPtrMap CallSiteToFunPtrMap
 
typedef Set< const SVFFunction * > FunctionSet
 
typedef OrderedMap< const CallICFGNode *, FunctionSetCallEdgeMap
 
typedef SCCDetection< PTACallGraph * > CallGraphSCC
 
typedef Set< const SVFGlobalValue * > VTableSet
 
typedef Set< const SVFFunction * > VFunSet
 
- Public Types inherited from SVF::DDAVFSolver< CxtVar, CxtPtSet, CxtLocDPItem >
typedef SCCDetection< SVFG * > SVFGSCC
 
typedef SCCDetection< PTACallGraph * > CallGraphSCC
 
typedef PTACallGraphEdge::CallInstSet CallInstSet
 
typedef SVFIR::CallSiteSet CallSiteSet
 
typedef OrderedSet< CxtLocDPItemDPTItemSet
 
typedef OrderedMap< CxtLocDPItem, CxtPtSetDPImToCPtSetMap
 
typedef OrderedMap< CxtLocDPItem, CxtVarDPMToCVarMap
 
typedef OrderedMap< CxtLocDPItem, CxtLocDPItemDPMToDPMMap
 
typedef OrderedMap< NodeID, DPTItemSetLocToDPMVecMap
 
typedef OrderedSet< const SVFGEdge * > ConstSVFGEdgeSet
 
typedef SVFGEdge::SVFGEdgeSetTy SVFGEdgeSet
 
typedef OrderedMap< const SVFGNode *, DPTItemSetStoreToPMSetMap
 
- Static Public Member Functions inherited from SVF::CondPTAImpl< ContextCond >
static bool classof (const PointerAnalysis *pta)
 
- Static Public Attributes inherited from SVF::PointerAnalysis
static const std::string aliasTestMayAlias = "MAYALIAS"
 
static const std::string aliasTestMayAliasMangled = "_Z8MAYALIASPvS_"
 
static const std::string aliasTestNoAlias = "NOALIAS"
 
static const std::string aliasTestNoAliasMangled = "_Z7NOALIASPvS_"
 
static const std::string aliasTestPartialAlias = "PARTIALALIAS"
 
static const std::string aliasTestPartialAliasMangled = "_Z12PARTIALALIASPvS_"
 
static const std::string aliasTestMustAlias = "MUSTALIAS"
 
static const std::string aliasTestMustAliasMangled = "_Z9MUSTALIASPvS_"
 
static const std::string aliasTestFailMayAlias = "EXPECTEDFAIL_MAYALIAS"
 
static const std::string aliasTestFailMayAliasMangled = "_Z21EXPECTEDFAIL_MAYALIASPvS_"
 
static const std::string aliasTestFailNoAlias = "EXPECTEDFAIL_NOALIAS"
 
static const std::string aliasTestFailNoAliasMangled = "_Z20EXPECTEDFAIL_NOALIASPvS_"
 
- Protected Member Functions inherited from SVF::CondPTAImpl< ContextCond >
virtual bool unionPts (CVar id, const CPtSet &target)
 
virtual bool unionPts (CVar id, CVar ptd)
 
virtual bool addPts (CVar id, CVar ptd)
 
bool mustAlias (const CVar &var1, const CVar &var2)
 Internal interface to be used for conditional points-to set queries. More...
 
bool contains (const CPtSet &cpts1, const CPtSet &cpts2)
 
bool isSameVar (const CVar &var1, const CVar &var2) const
 Whether two pointers/objects are the same one by considering their conditions. More...
 
virtual void normalizePointsTo ()
 Normalize points-to information to BitVector/conditional representation. More...
 
- Protected Member Functions inherited from SVF::PointerAnalysis
const CallSiteToFunPtrMapgetIndirectCallsites () const
 Return all indirect callsites. More...
 
NodeID getFunPtr (const CallICFGNode *cs) const
 Return function pointer PAGNode at a callsite cs. More...
 
virtual void validateTests ()
 Alias check functions to verify correctness of pointer analysis. More...
 
virtual void validateSuccessTests (std::string fun)
 
virtual void validateExpectedFailureTests (std::string fun)
 
void resetObjFieldSensitive ()
 Reset all object node as field-sensitive. More...
 
- Protected Member Functions inherited from SVF::DDAVFSolver< CxtVar, CxtPtSet, CxtLocDPItem >
virtual void handleSingleStatement (const CxtLocDPItem &dpm, CxtPtSet &pts)
 Handle single statement. More...
 
void reCompute (const CxtLocDPItem &dpm)
 recompute points-to for value-flow cycles and indirect calls More...
 
void reComputeForEdges (const CxtLocDPItem &dpm, const SVFGEdgeSet &edgeSet, bool indirectCall=false)
 Traverse along out edges to find all nodes which may be affected by locDPM. More...
 
virtual void buildSVFG (SVFIR *pag)
 Build SVFG. More...
 
virtual void resetQuery ()
 Reset visited map for next points-to query. More...
 
void OOBResetVisited ()
 Reset visited map if the current query is out-of-budget. More...
 
const SVFGNodegetDefSVFGNode (const PAGNode *pagNode) const
 GetDefinition SVFG. More...
 
void backtraceAlongIndirectVF (CxtPtSet &pts, const CxtLocDPItem &oldDpm)
 Backward traverse along indirect value flows. More...
 
void backtraceAlongDirectVF (CxtPtSet &pts, const CxtLocDPItem &oldDpm)
 Backward traverse along direct value flows. More...
 
void startNewPTCompFromLoadSrc (CxtPtSet &pts, const CxtLocDPItem &oldDpm)
 
void startNewPTCompFromStoreDst (CxtPtSet &pts, const CxtLocDPItem &oldDpm)
 
void backtraceToStoreSrc (CxtPtSet &pts, const CxtLocDPItem &oldDpm)
 
virtual void backwardPropDpm (CxtPtSet &pts, NodeID ptr, const CxtLocDPItem &oldDpm, const SVFGEdge *edge)
 dpm transit during backward tracing More...
 
virtual bool isMustAlias (const CxtLocDPItem &, const CxtLocDPItem &)
 whether load and store are aliased More...
 
virtual bool isStrongUpdate (const CxtPtSet &dstCPSet, const StoreSVFGNode *store)
 Return TRUE if this is a strong update STORE statement. More...
 
virtual bool isLocalCVarInRecursion (const CxtVar &var) const
 Whether a local variable is in function recursions. More...
 
void resolveFunPtr (const CxtLocDPItem &dpm)
 resolve function pointer More...
 
void markbkVisited (const CxtLocDPItem &dpm)
 Visited flags to avoid cycles. More...
 
bool isbkVisited (const CxtLocDPItem &dpm)
 
void clearbkVisited (const CxtLocDPItem &dpm)
 
virtual const CxtPtSetgetCachedPointsTo (const CxtLocDPItem &dpm)
 Points-to Caching for top-level pointers and address-taken objects. More...
 
virtual void updateCachedPointsTo (const CxtLocDPItem &dpm, const CxtPtSet &pts)
 
virtual const CxtPtSetgetCachedTLPointsTo (const CxtLocDPItem &dpm)
 
virtual const CxtPtSetgetCachedADPointsTo (const CxtLocDPItem &dpm)
 
bool isTopLevelPtrStmt (const SVFGNode *stmt)
 Whether this is a top-level pointer statement. More...
 
virtual CxtLocDPItem getDPImWithOldCond (const CxtLocDPItem &oldDpm, const CxtVar &var, const SVFGNode *loc)
 Return dpm with old context and path conditions. More...
 
void SVFGSCCDetection ()
 SVFG SCC detection. More...
 
NodeID getSVFGSCCRepNode (NodeID id)
 Get SCC rep node of a SVFG node. More...
 
bool isSVFGNodeInCycle (const SVFGNode *node)
 Return whether this SVFGNode is in cycle. More...
 
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. More...
 
void setCallGraph (PTACallGraph *cg)
 Set callgraph. More...
 
void setCallGraphSCC (CallGraphSCC *scc)
 Set callgraphSCC. More...
 
bool isArrayCondMemObj (const CxtVar &var) const
 
bool isFieldInsenCondMemObj (const CxtVar &var) const
 
void addLoadDpmAndCVar (const CxtLocDPItem &dpm, const CxtLocDPItem &loadDpm, const CxtVar &loadVar)
 LoadDpm for must-alias analysis. More...
 
void addLoadDpm (const CxtLocDPItem &dpm, const CxtLocDPItem &loadDpm)
 Note that simply use "dpmToloadDpmMap[dpm]=loadDpm", requires DPIm have a default constructor. More...
 
const CxtLocDPItemgetLoadDpm (const CxtLocDPItem &dpm) const
 
void addLoadCVar (const CxtLocDPItem &dpm, const CxtVar &loadVar)
 
const CxtVargetLoadCVar (const CxtLocDPItem &dpm) const
 
AndersenWaveDiffgetAndersenAnalysis () const
 Return Andersen's analysis. More...
 
void handleOutOfBudgetDpm (const CxtLocDPItem &dpm)
 handle out-of-budget queries More...
 
bool testOutOfBudget (const CxtLocDPItem &dpm)
 
bool isOutOfBudgetQuery () const
 
void addOutOfBudgetDpm (const CxtLocDPItem &dpm)
 
bool isOutOfBudgetDpm (const CxtLocDPItem &dpm) const
 
DDAStatsetDDAStat (DDAStat *s)
 Set DDAStat. More...
 
void addSUStat (const CxtLocDPItem &dpm, const SVFGNode *node)
 stat strong updates num More...
 
void rmSUStat (const CxtLocDPItem &dpm, const SVFGNode *node)
 remove strong updates num if the dpm goes to weak updates branch More...
 
- Protected Attributes inherited from SVF::CondPTAImpl< ContextCond >
PTDataTyptD
 Points-to data. More...
 
bool normalized
 Normalized flag. More...
 
PtrToBVPtsMap ptrToBVPtsMap
 Normal points-to representation (without conditions) More...
 
PtrToNSMap objToNSRevPtsMap
 Normal points-to representation (without conditions) More...
 
PtrToCPtsMap ptrToCPtsMap
 Conditional points-to representation (with conditions) More...
 
- Protected Attributes inherited from SVF::PointerAnalysis
bool print_stat
 User input flags. More...
 
bool alias_validation
 Flag for validating points-to/alias results. More...
 
u32_t OnTheFlyIterBudgetForStat
 Flag for iteration budget for on-the-fly statistics. More...
 
SVFModulesvfMod
 Module. More...
 
PTATY ptaTy
 Pointer analysis Type. More...
 
PTAImplTy ptaImplTy
 PTA implementation type. More...
 
PTAStatstat
 Statistics. More...
 
PTACallGraphcallgraph
 Call graph used for pointer analysis. More...
 
CallGraphSCCcallGraphSCC
 SCC for PTACallGraph. More...
 
ICFGicfg
 Interprocedural control-flow graph. More...
 
CommonCHGraphchgraph
 CHGraph. More...
 
- Protected Attributes inherited from SVF::DDAVFSolver< CxtVar, CxtPtSet, CxtLocDPItem >
bool outOfBudgetQuery
 Whether the current query is out of step limits. More...
 
SVFIR_pag
 SVFIR. More...
 
SVFG_svfg
 SVFG. More...
 
AndersenWaveDiff_ander
 Andersen's analysis. More...
 
NodeBS candidateQueries
 candidate pointers; More...
 
PTACallGraph_callGraph
 PTACallGraph. More...
 
CallGraphSCC_callGraphSCC
 SCC for PTACallGraph. More...
 
SVFGSCC_svfgSCC
 SCC for SVFG. More...
 
DPTItemSet backwardVisited
 visited map during backward traversing More...
 
DPImToCPtSetMap dpmToTLCPtSetMap
 points-to caching map for top-level vars More...
 
DPImToCPtSetMap dpmToADCPtSetMap
 points-to caching map for address-taken vars More...
 
LocToDPMVecMap locToDpmSetMap
 map location to its dpms More...
 
DPMToDPMMap dpmToloadDpmMap
 dpms at loads for may/must-alias analysis with stores More...
 
DPMToCVarMap loadToPTCVarMap
 map a load dpm to its cvar pointed by its pointer operand More...
 
DPTItemSet outOfBudgetDpms
 out of budget dpm set More...
 
StoreToPMSetMap storeToDPMs
 map store to set of DPM which have been stong updated there More...
 
DDAStatddaStat
 DDA stat. More...
 
SVFGBuilder svfgBuilder
 SVFG Builder. More...
 
- Static Protected Attributes inherited from SVF::PointerAnalysis
static SVFIRpag = nullptr
 SVFIR. More...
 

Detailed Description

Context-, Flow- Sensitive Demand-driven Analysis

Definition at line 54 of file ContextDDA.h.

Constructor & Destructor Documentation

◆ ContextDDA()

ContextDDA::ContextDDA ( SVFIR _pag,
DDAClient client 
)

Constructor.

Constructor

Definition at line 42 of file ContextDDA.cpp.

◆ ~ContextDDA()

ContextDDA::~ContextDDA ( )
virtual

Destructor.

Destructor

Definition at line 52 of file ContextDDA.cpp.

53 {
54  if(flowDDA)
55  delete flowDDA;
56  flowDDA = nullptr;
57 }

Member Function Documentation

◆ analyze()

virtual void SVF::ContextDDA::analyze ( )
inlineoverridevirtual

dummy analyze method

Implements SVF::PointerAnalysis.

Definition at line 74 of file ContextDDA.h.

74 {}

◆ computeDDAPts() [1/2]

const CxtPtSet & ContextDDA::computeDDAPts ( const CxtVar var)
virtual

Compute points-to set for a context-sensitive pointer.

Compute points-to set for a context-sensitive pointer

Definition at line 75 of file ContextDDA.cpp.

76 {
77 
78  resetQuery();
80 
81  NodeID id = var.get_id();
82  PAGNode* node = getPAG()->getGNode(id);
83  CxtLocDPItem dpm = getDPIm(var, getDefSVFGNode(node));
84 
85  // start DDA analysis
86  DOTIMESTAT(double start = DDAStat::getClk(true));
87  const CxtPtSet& cpts = findPT(dpm);
90 
91  if(isOutOfBudgetQuery() == false)
92  unionPts(var,cpts);
93  else
95 
96  if (this->printStat())
99  return this->getPts(var);
100 }
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
Definition: SVFType.h:484
#define DGENERAL
Definition: SVFType.h:490
#define DOSTAT(X)
Definition: SVFType.h:485
#define DOTIMESTAT(X)
Definition: SVFType.h:486
virtual bool unionPts(CVar id, const CPtSet &target)
virtual const CPtSet & getPts(CVar id)
virtual PointsTo getBVPointsTo(const CPtSet &cpts) const
Given a conditional pts return its bit vector points-to.
NodeID get_id() const
void handleOutOfBudgetDpm(const CxtLocDPItem &dpm)
Handle out-of-budget dpm.
Definition: ContextDDA.cpp:115
double _AnaTimePerQuery
Definition: DDAStat.h:61
double _TotalTimeOfQueries
Definition: DDAStat.h:63
virtual const CxtPtSet & findPT(const CxtLocDPItem &dpm)
Compute points-to.
Definition: DDAVFSolver.h:138
const SVFGNode * getDefSVFGNode(const PAGNode *pagNode) const
GetDefinition SVFG.
Definition: DDAVFSolver.h:347
virtual CxtLocDPItem getDPIm(const CxtVar &var, const SVFGNode *loc) const
Given CVar and location (SVFGNode) return a new DPItem.
Definition: DDAVFSolver.h:96
virtual void resetQuery()
Reset visited map for next points-to query.
Definition: DDAVFSolver.h:324
static void setMaxBudget(u32_t max)
set max step budge per query
Definition: DPItem.h:86
NodeType * getGNode(NodeID id) const
Get a node.
Definition: GenericGraph.h:653
static const Option< u32_t > CxtBudget
Definition: Options.h:81
SVFIR * getPAG() const
bool printStat()
Whether print statistics.
PTAStat * stat
Statistics.
virtual void printStatPerQuery(NodeID, const PointsTo &)
Definition: SVFStat.h:89
virtual void performStatPerQuery(NodeID)
Definition: SVFStat.h:87
static double getClk(bool mark=false)
Definition: SVFStat.cpp:47
u32_t NodeID
Definition: GeneralType.h:55

◆ computeDDAPts() [2/2]

void ContextDDA::computeDDAPts ( NodeID  id)
overridevirtual

Compute points-to set for an unconditional pointer.

Compute points-to set for an unconditional pointer

Reimplemented from SVF::PointerAnalysis.

Definition at line 105 of file ContextDDA.cpp.

106 {
107  ContextCond cxt;
108  CxtVar var(cxt, id);
109  computeDDAPts(var);
110 }
virtual void computeDDAPts(NodeID id) override
Compute points-to set for an unconditional pointer.
Definition: ContextDDA.cpp:105

◆ dumpContexts()

virtual void SVF::ContextDDA::dumpContexts ( const ContextCond cxts)
inlinevirtual

dump context call strings

Definition at line 212 of file ContextDDA.h.

213  {
214  SVFUtil::outs() << cxts.toString() << "\n";
215  }
std::ostream & outs()
Overwrite llvm::outs()
Definition: SVFUtil.h:50

◆ edgeInCallGraphSCC()

bool SVF::ContextDDA::edgeInCallGraphSCC ( const SVFGEdge edge)
inline

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 160 of file ContextDDA.h.

161  {
162  const SVFFunction* srcfun = edge->getSrcNode()->getFun();
163  const SVFFunction* dstfun = edge->getDstNode()->getFun();
164 
165  if(srcfun && dstfun)
166  return inSameCallGraphSCC(srcfun,dstfun);
167 
168  assert(edge->isRetVFGEdge() == false && "should not be an inter-procedural return edge" );
169 
170  return false;
171  }
bool inSameCallGraphSCC(const SVFFunction *fun1, const SVFFunction *fun2)
Return TRUE if this edge is inside a PTACallGraph SCC, i.e., src node and dst node are in the same SC...

◆ finalize()

virtual void SVF::ContextDDA::finalize ( )
inlineoverridevirtual

Finalize analysis.

Reimplemented from SVF::CondPTAImpl< ContextCond >.

Definition at line 68 of file ContextDDA.h.

69  {
71  }
virtual void finalize()
Finalization of pointer analysis, and normalize points-to information to Bit Vector representation.

◆ getConservativeCPts()

virtual CxtPtSet SVF::ContextDDA::getConservativeCPts ( const CxtLocDPItem dpm)
inlineoverridevirtual

Override parent method.

Implements SVF::DDAVFSolver< CxtVar, CxtPtSet, CxtLocDPItem >.

Definition at line 86 of file ContextDDA.h.

87  {
88  const PointsTo& pts = getAndersenAnalysis()->getPts(dpm.getCurNodeID());
89  CxtPtSet tmpCPts;
90  ContextCond cxt;
91  for (PointsTo::iterator piter = pts.begin(); piter != pts.end(); ++piter)
92  {
93  CxtVar var(cxt,*piter);
94  tmpCPts.set(var);
95  }
96  return tmpCPts;
97  }
virtual const PointsTo & getPts(NodeID id)
Operation of points-to set.
Definition: Andersen.h:239
AndersenWaveDiff * getAndersenAnalysis() const
Return Andersen's analysis.
Definition: DDAVFSolver.h:717
const_iterator iterator
Definition: PointsTo.h:40
CondVar< ContextCond > CxtVar
Definition: DPItem.h:385
CondStdSet< CxtVar > CxtPtSet
Definition: DPItem.h:386

◆ getCSIDAtCall()

CallSiteID ContextDDA::getCSIDAtCall ( CxtLocDPItem dpm,
const SVFGEdge edge 
)

get callsite id from call, return 0 if it is a spurious call edge

get callsite id from call, return 0 if it is a spurious call edge translate the callsite id from pre-computed callgraph on SVFG to the one on current callgraph

Definition at line 210 of file ContextDDA.cpp.

211 {
212 
213  CallSiteID svfg_csId = 0;
214  if (const CallDirSVFGEdge* callEdge = SVFUtil::dyn_cast<CallDirSVFGEdge>(edge))
215  svfg_csId = callEdge->getCallSiteId();
216  else
217  svfg_csId = SVFUtil::cast<CallIndSVFGEdge>(edge)->getCallSiteId();
218 
219  const CallICFGNode* cbn = getSVFG()->getCallSite(svfg_csId);
220  const SVFFunction* callee = edge->getDstNode()->getFun();
221 
222  if(getCallGraph()->hasCallSiteID(cbn,callee))
223  {
224  return getCallGraph()->getCallSiteID(cbn,callee);
225  }
226 
227  return 0;
228 }
NodeType * getDstNode() const
Definition: GenericGraph.h:101
CallSiteID getCallSiteID(const CallICFGNode *cs, const SVFFunction *callee) const
Definition: PTACallGraph.h:368
PTACallGraph * getCallGraph() const
Return call graph.
const CallICFGNode * getCallSite(CallSiteID id) const
Definition: VFG.h:182
unsigned CallSiteID
Definition: GeneralType.h:58

◆ getCSIDAtRet()

CallSiteID ContextDDA::getCSIDAtRet ( CxtLocDPItem dpm,
const SVFGEdge edge 
)

get callsite id from return, return 0 if it is a spurious return edge

get callsite id from return, return 0 if it is a spurious return edge translate the callsite id from pre-computed callgraph on SVFG to the one on current callgraph

Definition at line 234 of file ContextDDA.cpp.

235 {
236 
237  CallSiteID svfg_csId = 0;
238  if (const RetDirSVFGEdge* retEdge = SVFUtil::dyn_cast<RetDirSVFGEdge>(edge))
239  svfg_csId = retEdge->getCallSiteId();
240  else
241  svfg_csId = SVFUtil::cast<RetIndSVFGEdge>(edge)->getCallSiteId();
242 
243  const CallICFGNode* cbn = getSVFG()->getCallSite(svfg_csId);
244  const SVFFunction* callee = edge->getSrcNode()->getFun();
245 
246  if(getCallGraph()->hasCallSiteID(cbn,callee))
247  {
248  return getCallGraph()->getCallSiteID(cbn,callee);
249  }
250 
251  return 0;
252 }
NodeType * getSrcNode() const
Definition: GenericGraph.h:97

◆ getInsensitiveEdgeSet()

ConstSVFGEdgeSet& SVF::ContextDDA::getInsensitiveEdgeSet ( )
inline

Return insensitive edge set.

Definition at line 207 of file ContextDDA.h.

208  {
209  return insensitveEdges;
210  }
ConstSVFGEdgeSet insensitveEdges
insensitive call-return edges
Definition: ContextDDA.h:223

◆ getPtrNodeID()

virtual NodeID SVF::ContextDDA::getPtrNodeID ( const CxtVar var) const
inlineoverridevirtual

Override parent method.

Implements SVF::DDAVFSolver< CxtVar, CxtPtSet, CxtLocDPItem >.

Definition at line 100 of file ContextDDA.h.

101  {
102  return var.get_id();
103  }

◆ handleAddr()

virtual void SVF::ContextDDA::handleAddr ( CxtPtSet pts,
const CxtLocDPItem dpm,
const AddrSVFGNode addr 
)
inlineoverridevirtual

Handle Address SVFGNode to add proper conditional points-to.

whether this object is set field-insensitive during pre-analysis

Implements SVF::DDAVFSolver< CxtVar, CxtPtSet, CxtLocDPItem >.

Definition at line 177 of file ContextDDA.h.

178  {
179  NodeID srcID = addr->getPAGSrcNodeID();
181  if (isFieldInsensitive(srcID))
182  srcID = getFIObjVar(srcID);
183 
184  CxtVar var(dpm.getCond(),srcID);
185  addDDAPts(pts,var);
186  DBOUT(DDDA, SVFUtil::outs() << "\t add points-to target " << var << " to dpm ");
187  DBOUT(DDDA, dpm.dump());
188  }
#define DDDA
Definition: SVFType.h:496
virtual void addDDAPts(CxtPtSet &pts, const CxtVar &var)
Add pts.
Definition: DDAVFSolver.h:113
bool isFieldInsensitive(NodeID id) const
NodeID getFIObjVar(NodeID id)

◆ handleBKCondition()

bool ContextDDA::handleBKCondition ( CxtLocDPItem dpm,
const SVFGEdge edge 
)
overridevirtual

Handle condition for context or path analysis (backward analysis)

Handle conditions during backward traversing.

we don't handle context in recursions, they treated as assignments

we don't handle context in recursions, they treated as assignments

TODO: When this call site id is contained in current call string, we may find a recursion. Try to solve this later.

Reimplemented from SVF::DDAVFSolver< CxtVar, CxtPtSet, CxtLocDPItem >.

Definition at line 256 of file ContextDDA.cpp.

257 {
259 
260  if (edge->isCallVFGEdge())
261  {
263  if(CallSiteID csId = getCSIDAtCall(dpm,edge))
264  {
265 
266  if(isEdgeInRecursion(csId))
267  {
268  DBOUT(DDDA,outs() << "\t\t call edge " << getCallGraph()->getCallerOfCallSite(csId)->getName() <<
269  "=>" << getCallGraph()->getCalleeOfCallSite(csId)->getName() << "in recursion \n");
271  }
272  else
273  {
274  if (dpm.matchContext(csId) == false)
275  {
276  DBOUT(DDDA, outs() << "\t\t context not match, edge "
277  << edge->getDstID() << " --| " << edge->getSrcID() << " \t");
278  DBOUT(DDDA, dumpContexts(dpm.getCond()));
279  return false;
280  }
281 
282  DBOUT(DDDA, outs() << "\t\t match contexts ");
283  DBOUT(DDDA, dumpContexts(dpm.getCond()));
284  }
285  }
286  }
287 
288  else if (edge->isRetVFGEdge())
289  {
291  if(CallSiteID csId = getCSIDAtRet(dpm,edge))
292  {
293 
294  if(isEdgeInRecursion(csId))
295  {
296  DBOUT(DDDA,outs() << "\t\t return edge " << getCallGraph()->getCalleeOfCallSite(csId)->getName() <<
297  "=>" << getCallGraph()->getCallerOfCallSite(csId)->getName() << "in recursion \n");
299  }
300  else
301  {
304  if (dpm.getCond().containCallStr(csId))
305  {
306  outOfBudgetQuery = true;
307  SVFUtil::writeWrnMsg("Call site ID is contained in call string. Is this a recursion?");
308  return false;
309  }
310  else
311  {
312  assert(dpm.getCond().containCallStr(csId) ==false && "contain visited call string ??");
313  if(dpm.pushContext(csId))
314  {
315  DBOUT(DDDA, outs() << "\t\t push context ");
316  DBOUT(DDDA, dumpContexts(dpm.getCond()));
317  }
318  else
319  {
320  DBOUT(DDDA, outs() << "\t\t context is full ");
321  DBOUT(DDDA, dumpContexts(dpm.getCond()));
322  }
323  }
324  }
325  }
326  }
327 
328  return true;
329 }
bool containCallStr(NodeID cxt) const
Whether contains callstring cxt.
Definition: DPItem.h:255
virtual void popRecursiveCallSites(CxtLocDPItem &dpm)
Pop recursive callsites.
Definition: ContextDDA.h:123
CallSiteID getCSIDAtCall(CxtLocDPItem &dpm, const SVFGEdge *edge)
get callsite id from call, return 0 if it is a spurious call edge
Definition: ContextDDA.cpp:210
virtual bool isEdgeInRecursion(CallSiteID csId)
Whether call/return inside recursion.
Definition: ContextDDA.h:134
CallSiteID getCSIDAtRet(CxtLocDPItem &dpm, const SVFGEdge *edge)
get callsite id from return, return 0 if it is a spurious return edge
Definition: ContextDDA.cpp:234
virtual void dumpContexts(const ContextCond &cxts)
dump context call strings
Definition: ContextDDA.h:212
bool matchContext(NodeID cxt)
Match context.
Definition: DPItem.h:430
bool pushContext(NodeID cxt)
Push context.
Definition: DPItem.h:424
const ContextCond & getCond() const
Get context.
Definition: DPItem.h:414
virtual void handleStatement(const SVFGNode *, NodeID)
Call back used by DDAVFSolver.
Definition: DDAClient.h:77
bool outOfBudgetQuery
Whether the current query is out of step limits.
Definition: DDAVFSolver.h:773
NodeID getCurNodeID() const
Definition: DPItem.h:77
NodeID getDstID() const
Definition: GenericGraph.h:85
NodeID getSrcID() const
get methods of the components
Definition: GenericGraph.h:81
bool isRetVFGEdge() const
Definition: VFGEdge.h:88
bool isCallVFGEdge() const
Definition: VFGEdge.h:84
void writeWrnMsg(const std::string &msg)
Writes a message run through wrnMsg.
Definition: SVFUtil.cpp:66

◆ handleOutOfBudgetDpm()

void ContextDDA::handleOutOfBudgetDpm ( const CxtLocDPItem dpm)

Handle out-of-budget dpm.

Handle out-of-budget dpm

Definition at line 115 of file ContextDDA.cpp.

116 {
117 
118  DBOUT(DGENERAL,outs() << "~~~Out of budget query, downgrade to flow sensitive analysis \n");
120  const PointsTo& flowPts = flowDDA->getPts(dpm.getCurNodeID());
121  CxtPtSet cxtPts;
122  for(PointsTo::iterator it = flowPts.begin(), eit = flowPts.end(); it!=eit; ++it)
123  {
124  ContextCond cxt;
125  CxtVar var(cxt, *it);
126  cxtPts.set(var);
127  }
128  updateCachedPointsTo(dpm,cxtPts);
129  unionPts(dpm.getCondVar(),cxtPts);
130  addOutOfBudgetDpm(dpm);
131 }
const PointsTo & getPts(NodeID id) override
void set(const Element &var)
Add the element into set.
CxtVar getCondVar() const
Get context var.
Definition: DPItem.h:408
virtual void updateCachedPointsTo(const CxtLocDPItem &dpm, const CxtPtSet &pts)
Definition: DDAVFSolver.h:563
void addOutOfBudgetDpm(const CxtLocDPItem &dpm)
Definition: DDAVFSolver.h:736
void computeDDAPts(NodeID id) override
Compute points-to set for all top variable.
Definition: FlowDDA.cpp:43
const_iterator end() const
Definition: PointsTo.h:132
const_iterator begin() const
Definition: PointsTo.h:128

◆ initialize()

void ContextDDA::initialize ( )
overridevirtual

Initialization of the analysis.

Analysis initialization

Reimplemented from SVF::PointerAnalysis.

Definition at line 62 of file ContextDDA.cpp.

63 {
65  buildSVFG(pag);
68  stat = setDDAStat(new DDAStat(this));
70 }
void setCallGraphSCC(CallGraphSCC *scc)
Set callgraphSCC.
Definition: DDAVFSolver.h:632
DDAStat * setDDAStat(DDAStat *s)
Set DDAStat.
Definition: DDAVFSolver.h:747
virtual void buildSVFG(SVFIR *pag)
Build SVFG.
Definition: DDAVFSolver.h:317
void setCallGraph(PTACallGraph *cg)
Set callgraph.
Definition: DDAVFSolver.h:627
virtual void initialize() override
Initialization of the analysis.
Definition: FlowDDA.h:86
CallGraphSCC * getCallGraphSCC() const
Return call graph SCC.
virtual void initialize()
Initialization of a pointer analysis, including building symbol table and SVFIR etc.
static SVFIR * pag
SVFIR.

◆ isCondCompatible()

bool ContextDDA::isCondCompatible ( const ContextCond cxt1,
const ContextCond cxt2,
bool  singleton 
) const
inlineoverridevirtual

Whether two call string contexts are compatible which may represent the same memory object compare with call strings from last few callsite ids (most recent ids to objects): compatible : (e.g., 123 == 123, 123 == 23). not compatible (e.g., 123 != 423)

context conditions of local(not in recursion) and global variables are compatible

Implements SVF::CondPTAImpl< ContextCond >.

Definition at line 136 of file ContextDDA.cpp.

137 {
138  if(singleton)
139  return true;
140 
141  int i = cxt1.cxtSize() - 1;
142  int j = cxt2.cxtSize() - 1;
143  for(; i >= 0 && j>=0; i--, j--)
144  {
145  if(cxt1[i] != cxt2[j])
146  return false;
147  }
148  return true;
149 }
u32_t cxtSize() const
Get context size.
Definition: DPItem.h:260

◆ isEdgeInRecursion()

virtual bool SVF::ContextDDA::isEdgeInRecursion ( CallSiteID  csId)
inlinevirtual

Whether call/return inside recursion.

Definition at line 134 of file ContextDDA.h.

135  {
136  const SVFFunction* caller = getCallGraph()->getCallerOfCallSite(csId);
137  const SVFFunction* callee = getCallGraph()->getCalleeOfCallSite(csId);
138  return inSameCallGraphSCC(caller, callee);
139  }
const SVFFunction * getCallerOfCallSite(CallSiteID id) const
Definition: PTACallGraph.h:391
const SVFFunction * getCalleeOfCallSite(CallSiteID id) const
Definition: PTACallGraph.h:395

◆ isHeapCondMemObj()

bool ContextDDA::isHeapCondMemObj ( const CxtVar var,
const StoreSVFGNode store 
)
overridevirtual

we exclude concrete heap given the following conditions: (1) concrete calling context (not involved in recursion and not exceed the maximum context limit) (2) not inside loop

Reimplemented from SVF::DDAVFSolver< CxtVar, CxtPtSet, CxtLocDPItem >.

Definition at line 335 of file ContextDDA.cpp.

336 {
337  const MemObj* mem = _pag->getObject(getPtrNodeID(var));
338  assert(mem && "memory object is null??");
339  if (mem->isHeap())
340  {
341  if (!mem->getValue())
342  {
343  PAGNode *pnode = _pag->getGNode(getPtrNodeID(var));
344  GepObjVar* gepobj = SVFUtil::dyn_cast<GepObjVar>(pnode);
345  if (gepobj != nullptr)
346  {
347  assert(SVFUtil::isa<DummyObjVar>(_pag->getGNode(gepobj->getBaseNode()))
348  && "empty refVal in a gep object whose base is a non-dummy object");
349  }
350  else
351  {
352  assert((SVFUtil::isa<DummyObjVar, DummyValVar>(pnode))
353  && "empty refVal in non-dummy object");
354  }
355  return true;
356  }
357  else if(const SVFBaseNode* gNode = mem->getGNode())
358  {
359  if (const auto& node =
360  SVFUtil::dyn_cast<ICFGNode>(gNode))
361  {
362  const SVFFunction* svfFun = node->getFun();
363  if(_ander->isInRecursion(svfFun))
364  return true;
365  if(var.get_cond().isConcreteCxt() == false)
366  return true;
367  if(_pag->getICFG()->isInLoop(node))
368  return true;
369  }
370  }
371  }
372  return false;
373 }
const Cond & get_cond() const
virtual NodeID getPtrNodeID(const CxtVar &var) const override
Override parent method.
Definition: ContextDDA.h:100
AndersenWaveDiff * _ander
Andersen's analysis.
Definition: DDAVFSolver.h:776
NodeID getBaseNode(void) const
Return the base object from which this GEP node came from.
Definition: SVFVariables.h:512
bool isInLoop(const ICFGNode *node)
Whether node is in a loop.
Definition: ICFG.h:117
const SVFValue * getValue() const
Get the reference value to this object.
bool isHeap() const
const SVFBaseNode * getGNode() const
Get the reference value to this object.
bool isInRecursion(const SVFFunction *fun) const
const MemObj * getObject(NodeID id) const
Definition: SVFIR.h:395
ICFG * getICFG() const
Definition: SVFIR.h:171

◆ isInsensitiveCallRet()

bool SVF::ContextDDA::isInsensitiveCallRet ( const SVFGEdge edge)
inline

Whether this edge is treated context-insensitively.

Definition at line 202 of file ContextDDA.h.

203  {
204  return insensitveEdges.find(edge) != insensitveEdges.end();
205  }

◆ popRecursiveCallSites()

virtual void SVF::ContextDDA::popRecursiveCallSites ( CxtLocDPItem dpm)
inlinevirtual

Pop recursive callsites.

Definition at line 123 of file ContextDDA.h.

124  {
125  ContextCond& cxtCond = dpm.getCond();
126  cxtCond.setNonConcreteCxt();
127  CallStrCxt& cxt = cxtCond.getContexts();
128  while(!cxt.empty() && isEdgeInRecursion(cxt.back()))
129  {
130  cxt.pop_back();
131  }
132  }
std::vector< u32_t > CallStrCxt
Definition: GeneralType.h:122

◆ processGepPts()

CxtPtSet ContextDDA::processGepPts ( const GepSVFGNode gep,
const CxtPtSet srcPts 
)
overridevirtual

processGep node

Generate field objects for structs

Implements SVF::DDAVFSolver< CxtVar, CxtPtSet, CxtLocDPItem >.

Definition at line 154 of file ContextDDA.cpp.

155 {
156  CxtPtSet tmpDstPts;
157  for (CxtPtSet::iterator piter = srcPts.begin(); piter != srcPts.end(); ++piter)
158  {
159 
160  CxtVar ptd = *piter;
161  if (isBlkObjOrConstantObj(ptd.get_id()))
162  tmpDstPts.set(ptd);
163  else
164  {
165  const GepStmt* gepStmt = SVFUtil::cast<GepStmt>(gep->getPAGEdge());
166  if (gepStmt->isVariantFieldGep())
167  {
169  CxtVar var(ptd.get_cond(),getFIObjVar(ptd.get_id()));
170  tmpDstPts.set(var);
171  }
172  else
173  {
174  CxtVar var(ptd.get_cond(),getGepObjVar(ptd.get_id(),
175  gepStmt->getAccessPath().getConstantStructFldIdx()));
176  tmpDstPts.set(var);
177  }
178  }
179  }
180 
181  DBOUT(DDDA, outs() << "\t return created gep objs ");
182  DBOUT(DDDA, outs() << srcPts.toString());
183  DBOUT(DDDA, outs() << " --> ");
184  DBOUT(DDDA, outs() << tmpDstPts.toString());
185  DBOUT(DDDA, outs() << "\n");
186  return tmpDstPts;
187 }
APOffset getConstantStructFldIdx() const
Get methods.
Definition: AccessPath.h:100
std::string toString() const
OrderedSet< Element >::iterator iterator
iterator end()
iterator begin()
Iterators.
bool isVariantFieldGep() const
Gep statement with a variant field index (pointer arithmetic) for struct field access.
const AccessPath & getAccessPath() const
virtual bool isBlkObjOrConstantObj(NodeID ptd) const
NodeID getGepObjVar(NodeID id, const APOffset &ap)
void setObjFieldInsensitive(NodeID id)
const PAGEdge * getPAGEdge() const
Definition: VFGNode.h:147

◆ propagateViaObj()

virtual bool SVF::ContextDDA::propagateViaObj ( const CxtVar storeObj,
const CxtVar loadObj 
)
inlineoverridevirtual

Propagate along indirect value-flow if two objects of load and store are same.

Reimplemented from SVF::DDAVFSolver< CxtVar, CxtPtSet, CxtLocDPItem >.

Definition at line 191 of file ContextDDA.h.

192  {
193  return isSameVar(storeObj,loadObj);
194  }
bool isSameVar(const CVar &var1, const CVar &var2) const
Whether two pointers/objects are the same one by considering their conditions.

◆ PTAName()

virtual const std::string SVF::ContextDDA::PTAName ( ) const
inlineoverridevirtual

Return PTA name.

Reimplemented from SVF::PointerAnalysis.

Definition at line 217 of file ContextDDA.h.

218  {
219  return "Context Sensitive DDA";
220  }

◆ testIndCallReachability()

bool ContextDDA::testIndCallReachability ( CxtLocDPItem dpm,
const SVFFunction callee,
const CallICFGNode cs 
)

refine indirect call edge

Definition at line 189 of file ContextDDA.cpp.

190 {
191  if(getPAG()->isIndirectCallSites(cs))
192  {
193  NodeID id = getPAG()->getFunPtr(cs);
194  PAGNode* node = getPAG()->getGNode(id);
195  CxtVar funptrVar(dpm.getCondVar().get_cond(), id);
196  CxtLocDPItem funptrDpm = getDPIm(funptrVar,getDefSVFGNode(node));
197  PointsTo pts = getBVPointsTo(findPT(funptrDpm));
198  if(pts.test(getPAG()->getObjectNode(callee)))
199  return true;
200  else
201  return false;
202  }
203  return true;
204 }
bool test(u32_t n) const
Returns true if n is in this set.
Definition: PointsTo.cpp:131
NodeID getFunPtr(const CallICFGNode *cs) const
Definition: SVFIR.h:354

◆ updateCallGraphAndSVFG()

virtual void SVF::ContextDDA::updateCallGraphAndSVFG ( const CxtLocDPItem dpm,
const CallICFGNode cs,
SVFGEdgeSet svfgEdges 
)
inlineoverridevirtual

Update call graph.

Reimplemented from SVF::DDAVFSolver< CxtVar, CxtPtSet, CxtLocDPItem >.

Definition at line 142 of file ContextDDA.h.

143  {
144  CallEdgeMap newEdges;
145  resolveIndCalls(cs, getBVPointsTo(getCachedPointsTo(dpm)), newEdges);
146  for (CallEdgeMap::const_iterator iter = newEdges.begin(),eiter = newEdges.end(); iter != eiter; iter++)
147  {
148  const CallICFGNode* newcs = iter->first;
149  const FunctionSet & functions = iter->second;
150  for (FunctionSet::const_iterator func_iter = functions.begin(); func_iter != functions.end(); func_iter++)
151  {
152  const SVFFunction* func = *func_iter;
153  getSVFG()->connectCallerAndCallee(newcs, func, svfgEdges);
154  }
155  }
156  }
virtual const CxtPtSet & getCachedPointsTo(const CxtLocDPItem &dpm)
Points-to Caching for top-level pointers and address-taken objects.
Definition: DDAVFSolver.h:556
OrderedMap< const CallICFGNode *, FunctionSet > CallEdgeMap
virtual void resolveIndCalls(const CallICFGNode *cs, const PointsTo &target, CallEdgeMap &newEdges)
Resolve indirect call edges.
Set< const SVFFunction * > FunctionSet
virtual void connectCallerAndCallee(const CallICFGNode *cs, const SVFFunction *callee, SVFGEdgeSetTy &edges)
Connect SVFG nodes between caller and callee for indirect call site.
Definition: SVFG.cpp:658

Member Data Documentation

◆ _client

DDAClient* SVF::ContextDDA::_client
private

DDA client.

Definition at line 225 of file ContextDDA.h.

◆ flowDDA

FlowDDA* SVF::ContextDDA::flowDDA
private

downgrade to flowDDA if out-of-budget

Definition at line 224 of file ContextDDA.h.

◆ insensitveEdges

ConstSVFGEdgeSet SVF::ContextDDA::insensitveEdges
private

insensitive call-return edges

Definition at line 223 of file ContextDDA.h.


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