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

#include <FlowDDA.h>

Inheritance diagram for SVF::FlowDDA:
SVF::BVDataPTAImpl SVF::DDAVFSolver< NodeID, PointsTo, LocDPItem > SVF::PointerAnalysis

Public Types

typedef BVDataPTAImpl::CallSiteSet CallSiteSet
 
typedef BVDataPTAImpl::CallEdgeMap CallEdgeMap
 
typedef BVDataPTAImpl::FunctionSet FunctionSet
 
- Public Types inherited from SVF::BVDataPTAImpl
enum  PTBackingType { Mutable , Persistent }
 How the PTData used is implemented. More...
 
typedef PTData< NodeID, NodeSet, NodeID, PointsToPTDataTy
 
typedef DiffPTData< NodeID, NodeSet, NodeID, PointsToDiffPTDataTy
 
typedef DFPTData< NodeID, NodeSet, NodeID, PointsToDFPTDataTy
 
typedef VersionedPTData< NodeID, NodeSet, NodeID, PointsTo, VersionedVar, Set< VersionedVar > > VersionedPTDataTy
 
typedef MutablePTData< NodeID, NodeSet, NodeID, PointsToMutPTDataTy
 
typedef MutableDiffPTData< NodeID, NodeSet, NodeID, PointsToMutDiffPTDataTy
 
typedef MutableDFPTData< NodeID, NodeSet, NodeID, PointsToMutDFPTDataTy
 
typedef MutableIncDFPTData< NodeID, NodeSet, NodeID, PointsToMutIncDFPTDataTy
 
typedef MutableVersionedPTData< NodeID, NodeSet, NodeID, PointsTo, VersionedVar, Set< VersionedVar > > MutVersionedPTDataTy
 
typedef PersistentPTData< NodeID, NodeSet, NodeID, PointsToPersPTDataTy
 
typedef PersistentDiffPTData< NodeID, NodeSet, NodeID, PointsToPersDiffPTDataTy
 
typedef PersistentDFPTData< NodeID, NodeSet, NodeID, PointsToPersDFPTDataTy
 
typedef PersistentIncDFPTData< NodeID, NodeSet, NodeID, PointsToPersIncDFPTDataTy
 
typedef PersistentVersionedPTData< NodeID, NodeSet, NodeID, PointsTo, VersionedVar, Set< VersionedVar > > PersVersionedPTDataTy
 
- 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< NodeID, PointsTo, LocDPItem >
typedef SCCDetection< SVFG * > SVFGSCC
 
typedef SCCDetection< PTACallGraph * > CallGraphSCC
 
typedef PTACallGraphEdge::CallInstSet CallInstSet
 
typedef SVFIR::CallSiteSet CallSiteSet
 
typedef OrderedSet< LocDPItemDPTItemSet
 
typedef OrderedMap< LocDPItem, PointsToDPImToCPtSetMap
 
typedef OrderedMap< LocDPItem, NodeIDDPMToCVarMap
 
typedef OrderedMap< LocDPItem, LocDPItemDPMToDPMMap
 
typedef OrderedMap< NodeID, DPTItemSetLocToDPMVecMap
 
typedef OrderedSet< const SVFGEdge * > ConstSVFGEdgeSet
 
typedef SVFGEdge::SVFGEdgeSetTy SVFGEdgeSet
 
typedef OrderedMap< const SVFGNode *, DPTItemSetStoreToPMSetMap
 

Public Member Functions

 FlowDDA (SVFIR *_pag, DDAClient *client)
 Constructor. More...
 
virtual ~FlowDDA ()
 Destructor. More...
 
virtual void analyze () override
 dummy analyze method More...
 
void computeDDAPts (NodeID id) override
 Compute points-to set for all top variable. More...
 
void handleOutOfBudgetDpm (const LocDPItem &dpm)
 Handle out-of-budget dpm. More...
 
virtual bool handleBKCondition (LocDPItem &dpm, const SVFGEdge *edge) override
 Handle condition for flow analysis (backward analysis) More...
 
bool testIndCallReachability (LocDPItem &dpm, const SVFFunction *callee, CallSiteID csId)
 refine indirect call edge More...
 
virtual void initialize () override
 Initialization of the analysis. More...
 
virtual void finalize () override
 Finalize analysis. More...
 
virtual bool isHeapCondMemObj (const NodeID &var, const StoreSVFGNode *store) override
 
virtual PointsTo getConservativeCPts (const LocDPItem &dpm) override
 Override parent method. More...
 
virtual NodeID getPtrNodeID (const NodeID &var) const override
 Override parent method. More...
 
virtual void handleAddr (PointsTo &pts, const LocDPItem &dpm, const AddrSVFGNode *addr) override
 Handle Address SVFGNode to add proper points-to. More...
 
virtual PointsTo processGepPts (const GepSVFGNode *gep, const PointsTo &srcPts) override
 processGep node More...
 
virtual void updateCallGraphAndSVFG (const LocDPItem &dpm, const CallICFGNode *cs, SVFGEdgeSet &svfgEdges) override
 Update call graph. More...
 
virtual const PointsTogetCachedTLPointsTo (const LocDPItem &dpm) override
 Override parent class functions to get/add cached points-to directly via PAGNode ID. More...
 
bool unionDDAPts (LocDPItem dpm, const PointsTo &targetPts) override
 Union pts. More...
 
virtual const std::string PTAName () const override
 Return PTA name. More...
 
- Public Member Functions inherited from SVF::BVDataPTAImpl
 BVDataPTAImpl (SVFIR *pag, PointerAnalysis::PTATY type, bool alias_check=true)
 Constructor. More...
 
 ~BVDataPTAImpl () override=default
 Destructor. More...
 
PersistentPointsToCache< PointsTo > & getPtCache ()
 
const PointsTogetPts (NodeID id) override
 
const NodeSetgetRevPts (NodeID nodeId) override
 
virtual void clearPts (NodeID id, NodeID element)
 Remove element from the points-to set of id. More...
 
virtual void clearFullPts (NodeID id)
 Clear points-to set of id. More...
 
virtual bool unionPts (NodeID id, const PointsTo &target)
 
virtual bool unionPts (NodeID id, NodeID ptd)
 
virtual bool addPts (NodeID id, NodeID ptd)
 
virtual void clearAllPts ()
 Clear all data. More...
 
virtual void expandFIObjs (const PointsTo &pts, PointsTo &expandedPts)
 Expand FI objects. More...
 
virtual void expandFIObjs (const NodeBS &pts, NodeBS &expandedPts)
 TODO: remove repetition. More...
 
void remapPointsToSets (void)
 Remap all points-to sets to use the current mapping. More...
 
virtual void writeToFile (const std::string &filename)
 Interface for analysis result storage on filesystem. More...
 
virtual void writeObjVarToFile (const std::string &filename)
 
virtual void writePtsResultToFile (std::fstream &f)
 
virtual void writeGepObjVarMapToFile (std::fstream &f)
 
virtual bool readFromFile (const std::string &filename)
 
virtual void readPtsResultFromFile (std::ifstream &f)
 
virtual void readGepObjVarMapFromFile (std::ifstream &f)
 
virtual void readAndSetObjFieldSensitivity (std::ifstream &f, const std::string &delimiterStr)
 
AliasResult alias (const SVFValue *V1, const SVFValue *V2) override
 Interface expose to users of our pointer analysis, given Value infos. More...
 
AliasResult alias (NodeID node1, NodeID node2) override
 Interface expose to users of our pointer analysis, given PAGNodeID. More...
 
virtual AliasResult alias (const PointsTo &pts1, const PointsTo &pts2)
 Interface expose to users of our pointer analysis, given two pts. More...
 
void dumpCPts () override
 dump and debug, print out conditional pts More...
 
void dumpTopLevelPtsTo () override
 
void dumpAllPts () override
 
- 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 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< NodeID, PointsTo, LocDPItem >
 DDAVFSolver ()
 Constructor. More...
 
virtual ~DDAVFSolver ()
 Destructor. More...
 
NodeBSgetCandidateQueries ()
 Return candidate pointers for DDA. More...
 
virtual LocDPItem getDPIm (const NodeID &var, const SVFGNode *loc) const
 Given CVar and location (SVFGNode) return a new DPItem. More...
 
virtual bool unionDDAPts (PointsTo &pts, const PointsTo &targetPts)
 Union pts. More...
 
virtual void addDDAPts (PointsTo &pts, const NodeID &var)
 Add pts. More...
 
SVFGgetSVFG () const
 Return SVFG. More...
 
SVFGSCCgetSVFGSCC () const
 Return SVFGSCC. More...
 
void dumpCPtSet (const PointsTo &cpts) const
 
virtual const PointsTofindPT (const LocDPItem &dpm)
 Compute points-to. More...
 

Private Attributes

DDAClient_client
 DDA client. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from SVF::BVDataPTAImpl
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::BVDataPTAImpl
PTDataTygetPTDataTy () const
 Get points-to data structure. More...
 
void finalize () override
 Finalization of pointer analysis, and normalize points-to information to Bit Vector representation. More...
 
virtual bool updateCallGraph (const CallSiteToFunPtrMap &)
 Update callgraph. This should be implemented by its subclass. More...
 
DiffPTDataTygetDiffPTDataTy () const
 
DFPTDataTygetDFPTDataTy () const
 
MutDFPTDataTygetMutDFPTDataTy () const
 
VersionedPTDataTygetVersionedPTDataTy () const
 
virtual void onTheFlyCallGraphSolve (const CallSiteToFunPtrMap &callsites, CallEdgeMap &newEdges)
 On the fly call graph construction. More...
 
virtual void onTheFlyThreadCallGraphSolve (const CallSiteToFunPtrMap &callsites, CallEdgeMap &newForkEdges)
 On the fly thread call graph construction respecting forksite. More...
 
virtual void normalizePointsTo ()
 
- 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< NodeID, PointsTo, LocDPItem >
virtual void handleSingleStatement (const LocDPItem &dpm, PointsTo &pts)
 Handle single statement. More...
 
void reCompute (const LocDPItem &dpm)
 recompute points-to for value-flow cycles and indirect calls More...
 
void reComputeForEdges (const LocDPItem &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 (PointsTo &pts, const LocDPItem &oldDpm)
 Backward traverse along indirect value flows. More...
 
void backtraceAlongDirectVF (PointsTo &pts, const LocDPItem &oldDpm)
 Backward traverse along direct value flows. More...
 
void startNewPTCompFromLoadSrc (PointsTo &pts, const LocDPItem &oldDpm)
 
void startNewPTCompFromStoreDst (PointsTo &pts, const LocDPItem &oldDpm)
 
void backtraceToStoreSrc (PointsTo &pts, const LocDPItem &oldDpm)
 
virtual void backwardPropDpm (PointsTo &pts, NodeID ptr, const LocDPItem &oldDpm, const SVFGEdge *edge)
 dpm transit during backward tracing More...
 
virtual bool isMustAlias (const LocDPItem &, const LocDPItem &)
 whether load and store are aliased More...
 
virtual bool isStrongUpdate (const PointsTo &dstCPSet, const StoreSVFGNode *store)
 Return TRUE if this is a strong update STORE statement. More...
 
virtual bool isLocalCVarInRecursion (const NodeID &var) const
 Whether a local variable is in function recursions. More...
 
virtual bool propagateViaObj (const NodeID &storeObj, const NodeID &loadObj)
 If the points-to contain the object obj, we could move forward along indirect value-flow edge. More...
 
void resolveFunPtr (const LocDPItem &dpm)
 resolve function pointer More...
 
void markbkVisited (const LocDPItem &dpm)
 Visited flags to avoid cycles. More...
 
bool isbkVisited (const LocDPItem &dpm)
 
void clearbkVisited (const LocDPItem &dpm)
 
virtual const PointsTogetCachedPointsTo (const LocDPItem &dpm)
 Points-to Caching for top-level pointers and address-taken objects. More...
 
virtual void updateCachedPointsTo (const LocDPItem &dpm, const PointsTo &pts)
 
virtual const PointsTogetCachedADPointsTo (const LocDPItem &dpm)
 
bool isTopLevelPtrStmt (const SVFGNode *stmt)
 Whether this is a top-level pointer statement. More...
 
virtual LocDPItem getDPImWithOldCond (const LocDPItem &oldDpm, const NodeID &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 NodeID &var) const
 
bool isFieldInsenCondMemObj (const NodeID &var) const
 
void addLoadDpmAndCVar (const LocDPItem &dpm, const LocDPItem &loadDpm, const NodeID &loadVar)
 LoadDpm for must-alias analysis. More...
 
void addLoadDpm (const LocDPItem &dpm, const LocDPItem &loadDpm)
 Note that simply use "dpmToloadDpmMap[dpm]=loadDpm", requires DPIm have a default constructor. More...
 
const LocDPItemgetLoadDpm (const LocDPItem &dpm) const
 
void addLoadCVar (const LocDPItem &dpm, const NodeID &loadVar)
 
const NodeIDgetLoadCVar (const LocDPItem &dpm) const
 
AndersenWaveDiffgetAndersenAnalysis () const
 Return Andersen's analysis. More...
 
void handleOutOfBudgetDpm (const LocDPItem &dpm)
 handle out-of-budget queries More...
 
bool testOutOfBudget (const LocDPItem &dpm)
 
bool isOutOfBudgetQuery () const
 
void addOutOfBudgetDpm (const LocDPItem &dpm)
 
bool isOutOfBudgetDpm (const LocDPItem &dpm) const
 
DDAStatsetDDAStat (DDAStat *s)
 Set DDAStat. More...
 
void addSUStat (const LocDPItem &dpm, const SVFGNode *node)
 stat strong updates num More...
 
void rmSUStat (const LocDPItem &dpm, const SVFGNode *node)
 remove strong updates num if the dpm goes to weak updates branch 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< NodeID, PointsTo, LocDPItem >
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

Flow sensitive demand-driven analysis on value-flow graph

Definition at line 53 of file FlowDDA.h.

Member Typedef Documentation

◆ CallEdgeMap

Definition at line 58 of file FlowDDA.h.

◆ CallSiteSet

Definition at line 57 of file FlowDDA.h.

◆ FunctionSet

Definition at line 59 of file FlowDDA.h.

Constructor & Destructor Documentation

◆ FlowDDA()

SVF::FlowDDA::FlowDDA ( SVFIR _pag,
DDAClient client 
)
inline

Constructor.

Definition at line 61 of file FlowDDA.h.

62  DDAVFSolver<NodeID,PointsTo,LocDPItem>(),
63  _client(client)
64  {
65  }
BVDataPTAImpl(SVFIR *pag, PointerAnalysis::PTATY type, bool alias_check=true)
Constructor.
DDAClient * _client
DDA client.
Definition: FlowDDA.h:173
@ FlowS_DDA
Flow sensitive DDA.

◆ ~FlowDDA()

virtual SVF::FlowDDA::~FlowDDA ( )
inlinevirtual

Destructor.

Definition at line 67 of file FlowDDA.h.

68  {
69  }

Member Function Documentation

◆ analyze()

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

dummy analyze method

Implements SVF::PointerAnalysis.

Definition at line 71 of file FlowDDA.h.

71 {}

◆ computeDDAPts()

void FlowDDA::computeDDAPts ( NodeID  id)
overridevirtual

Compute points-to set for all top variable.

Compute points-to set for queries

start DDA analysis

Reimplemented from SVF::PointerAnalysis.

Definition at line 43 of file FlowDDA.cpp.

44 {
45  resetQuery();
47 
48  PAGNode* node = getPAG()->getGNode(id);
49  LocDPItem dpm = getDPIm(node->getId(),getDefSVFGNode(node));
50 
52  DOTIMESTAT(double start = DDAStat::getClk(true));
53  const PointsTo& pts = findPT(dpm);
56 
57  if(isOutOfBudgetQuery() == false)
58  unionPts(node->getId(),pts);
59  else
61 
62  if(this->printStat())
64 
66 }
#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
const PointsTo & getPts(NodeID id) override
virtual bool unionPts(NodeID id, const PointsTo &target)
double _AnaTimePerQuery
Definition: DDAStat.h:61
double _TotalTimeOfQueries
Definition: DDAStat.h:63
virtual const PointsTo & findPT(const LocDPItem &dpm)
Compute points-to.
Definition: DDAVFSolver.h:138
const SVFGNode * getDefSVFGNode(const PAGNode *pagNode) const
GetDefinition SVFG.
Definition: DDAVFSolver.h:347
virtual LocDPItem getDPIm(const NodeID &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
void handleOutOfBudgetDpm(const LocDPItem &dpm)
Handle out-of-budget dpm.
Definition: FlowDDA.cpp:72
NodeType * getGNode(NodeID id) const
Get a node.
Definition: GenericGraph.h:653
static const Option< u32_t > FlowBudget
Definition: Options.h:96
SVFIR * getPAG() const
bool printStat()
Whether print statistics.
PTAStat * stat
Statistics.
NodeID getId() const
Get ID.
Definition: GenericGraph.h:260
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

◆ finalize()

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

Finalize analysis.

Reimplemented from SVF::PointerAnalysis.

Definition at line 96 of file FlowDDA.h.

97  {
99  }
void finalize() override
Finalization of pointer analysis, and normalize points-to information to Bit Vector representation.

◆ getCachedTLPointsTo()

virtual const PointsTo& SVF::FlowDDA::getCachedTLPointsTo ( const LocDPItem dpm)
inlineoverridevirtual

Override parent class functions to get/add cached points-to directly via PAGNode ID.

Reimplemented from SVF::DDAVFSolver< NodeID, PointsTo, LocDPItem >.

Definition at line 154 of file FlowDDA.h.

155  {
156  return getPts(dpm.getCurNodeID());
157  }

◆ getConservativeCPts()

virtual PointsTo SVF::FlowDDA::getConservativeCPts ( const LocDPItem dpm)
inlineoverridevirtual

Override parent method.

Implements SVF::DDAVFSolver< NodeID, PointsTo, LocDPItem >.

Definition at line 109 of file FlowDDA.h.

110  {
111  return getAndersenAnalysis()->getPts(dpm.getCurNodeID());
112  }
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

◆ getPtrNodeID()

virtual NodeID SVF::FlowDDA::getPtrNodeID ( const NodeID var) const
inlineoverridevirtual

Override parent method.

Implements SVF::DDAVFSolver< NodeID, PointsTo, LocDPItem >.

Definition at line 114 of file FlowDDA.h.

115  {
116  return var;
117  }

◆ handleAddr()

virtual void SVF::FlowDDA::handleAddr ( PointsTo pts,
const LocDPItem dpm,
const AddrSVFGNode addr 
)
inlineoverridevirtual

Handle Address SVFGNode to add proper points-to.

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

Implements SVF::DDAVFSolver< NodeID, PointsTo, LocDPItem >.

Definition at line 119 of file FlowDDA.h.

120  {
121  NodeID srcID = addr->getPAGSrcNodeID();
123  if (isFieldInsensitive(srcID))
124  srcID = getFIObjVar(srcID);
125 
126  addDDAPts(pts,srcID);
127  DBOUT(DDDA, SVFUtil::outs() << "\t add points-to target " << srcID << " to dpm ");
128  DBOUT(DDDA, dpm.dump());
129  }
#define DDDA
Definition: SVFType.h:496
virtual void addDDAPts(PointsTo &pts, const NodeID &var)
Add pts.
Definition: DDAVFSolver.h:113
bool isFieldInsensitive(NodeID id) const
NodeID getFIObjVar(NodeID id)
std::ostream & outs()
Overwrite llvm::outs()
Definition: SVFUtil.h:50
u32_t NodeID
Definition: GeneralType.h:55

◆ handleBKCondition()

bool FlowDDA::handleBKCondition ( LocDPItem dpm,
const SVFGEdge edge 
)
overridevirtual

Handle condition for flow analysis (backward analysis)

Reimplemented from SVF::DDAVFSolver< NodeID, PointsTo, LocDPItem >.

Definition at line 102 of file FlowDDA.cpp.

103 {
105 // CallSiteID csId = 0;
106 //
107 // if (edge->isCallVFGEdge()) {
108 // /// we don't handle context in recursions, they treated as assignments
109 // if (const CallDirSVFGEdge* callEdge = SVFUtil::dyn_cast<CallDirSVFGEdge>(edge))
110 // csId = callEdge->getCallSiteId();
111 // else
112 // csId = SVFUtil::cast<CallIndSVFGEdge>(edge)->getCallSiteId();
113 //
114 // const SVFFunction* callee = edge->getDstNode()->getBB()->getParent();
115 // if(testIndCallReachability(dpm,callee,csId)==false){
116 // return false;
117 // }
118 //
119 // }
120 //
121 // else if (edge->isRetVFGEdge()) {
122 // /// we don't handle context in recursions, they treated as assignments
123 // if (const RetDirSVFGEdge* retEdge = SVFUtil::dyn_cast<RetDirSVFGEdge>(edge))
124 // csId = retEdge->getCallSiteId();
125 // else
126 // csId = SVFUtil::cast<RetIndSVFGEdge>(edge)->getCallSiteId();
127 //
128 // const SVFFunction* callee = edge->getSrcNode()->getBB()->getParent();
129 // if(testIndCallReachability(dpm,callee,csId)==false){
130 // return false;
131 // }
132 //
133 // }
134 
135  return true;
136 }
virtual void handleStatement(const SVFGNode *, NodeID)
Call back used by DDAVFSolver.
Definition: DDAClient.h:77
NodeID getCurNodeID() const
Definition: DPItem.h:77
NodeType * getSrcNode() const
Definition: GenericGraph.h:97

◆ handleOutOfBudgetDpm()

void FlowDDA::handleOutOfBudgetDpm ( const LocDPItem dpm)

Handle out-of-budget dpm.

Handle out-of-budget dpm

Definition at line 72 of file FlowDDA.cpp.

73 {
74  DBOUT(DGENERAL,outs() << "~~~Out of budget query, downgrade to andersen analysis \n");
75  const PointsTo& anderPts = getAndersenAnalysis()->getPts(dpm.getCurNodeID());
76  updateCachedPointsTo(dpm,anderPts);
77  unionPts(dpm.getCurNodeID(),anderPts);
78  addOutOfBudgetDpm(dpm);
79 }
virtual void updateCachedPointsTo(const LocDPItem &dpm, const PointsTo &pts)
Definition: DDAVFSolver.h:563
void addOutOfBudgetDpm(const LocDPItem &dpm)
Definition: DDAVFSolver.h:736

◆ initialize()

virtual void SVF::FlowDDA::initialize ( )
inlineoverridevirtual

Initialization of the analysis.

Reimplemented from SVF::PointerAnalysis.

Definition at line 86 of file FlowDDA.h.

87  {
89  buildSVFG(pag);
92  stat = setDDAStat(new DDAStat(this));
93  }
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
CallGraphSCC * getCallGraphSCC() const
Return call graph SCC.
virtual void initialize()
Initialization of a pointer analysis, including building symbol table and SVFIR etc.
PTACallGraph * getCallGraph() const
Return call graph.
static SVFIR * pag
SVFIR.

◆ isHeapCondMemObj()

bool FlowDDA::isHeapCondMemObj ( const NodeID var,
const StoreSVFGNode store 
)
overridevirtual

we exclude concrete heap here following the conditions: (1) local allocated heap and (2) not escaped to the scope outside the current function (3) not inside loop (4) not involved in recursion

Reimplemented from SVF::DDAVFSolver< NodeID, PointsTo, LocDPItem >.

Definition at line 177 of file FlowDDA.cpp.

178 {
179  const MemObj* mem = _pag->getObject(getPtrNodeID(var));
180  assert(mem && "memory object is null??");
181  if(mem->isHeap())
182  {
183 // if(const Instruction* mallocSite = SVFUtil::dyn_cast<Instruction>(mem->getValue())) {
184 // const SVFFunction* fun = mallocSite->getParent()->getParent();
185 // const SVFFunction* curFun = store->getBB() ? store->getBB()->getParent() : nullptr;
186 // if(fun!=curFun)
187 // return true;
188 // if(_callGraphSCC->isInCycle(_callGraph->getCallGraphNode(fun)->getId()))
189 // return true;
190 // if(_pag->getICFG()->isInLoop(mallocSite))
191 // return true;
192 //
193 // return false;
194 // }
195  return true;
196  }
197  return false;
198 }
virtual NodeID getPtrNodeID(const NodeID &var) const override
Override parent method.
Definition: FlowDDA.h:114
bool isHeap() const
const MemObj * getObject(NodeID id) const
Definition: SVFIR.h:395

◆ processGepPts()

PointsTo FlowDDA::processGepPts ( const GepSVFGNode gep,
const PointsTo srcPts 
)
overridevirtual

processGep node

Generate field objects for structs

Implements SVF::DDAVFSolver< NodeID, PointsTo, LocDPItem >.

Definition at line 141 of file FlowDDA.cpp.

142 {
143  PointsTo tmpDstPts;
144  for (PointsTo::iterator piter = srcPts.begin(); piter != srcPts.end(); ++piter)
145  {
146  NodeID ptd = *piter;
147  if (isBlkObjOrConstantObj(ptd))
148  tmpDstPts.set(ptd);
149  else
150  {
151  const GepStmt* gepStmt = SVFUtil::cast<GepStmt>(gep->getPAGEdge());
152  if (gepStmt->isVariantFieldGep())
153  {
155  tmpDstPts.set(getFIObjVar(ptd));
156  }
157  else
158  {
159  NodeID fieldSrcPtdNode = getGepObjVar(ptd, gepStmt->getAccessPath().getConstantStructFldIdx());
160  tmpDstPts.set(fieldSrcPtdNode);
161  }
162  }
163  }
164  DBOUT(DDDA, outs() << "\t return created gep objs {");
165  DBOUT(DDDA, SVFUtil::dumpSet(srcPts));
166  DBOUT(DDDA, outs() << "} --> {");
167  DBOUT(DDDA, SVFUtil::dumpSet(tmpDstPts));
168  DBOUT(DDDA, outs() << "}\n");
169  return tmpDstPts;
170 }
APOffset getConstantStructFldIdx() const
Get methods.
Definition: AccessPath.h:100
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_iterator end() const
Definition: PointsTo.h:132
void set(u32_t n)
Inserts n in the set.
Definition: PointsTo.cpp:157
const_iterator begin() const
Definition: PointsTo.h:128
const PAGEdge * getPAGEdge() const
Definition: VFGNode.h:147
void dumpSet(NodeBS To, OutStream &O=SVFUtil::outs())
Dump sparse bitvector set.
Definition: SVFUtil.cpp:147

◆ PTAName()

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

Return PTA name.

Reimplemented from SVF::PointerAnalysis.

Definition at line 167 of file FlowDDA.h.

168  {
169  return "FlowSensitive DDA";
170  }

◆ testIndCallReachability()

bool FlowDDA::testIndCallReachability ( LocDPItem dpm,
const SVFFunction callee,
CallSiteID  csId 
)

refine indirect call edge

Definition at line 81 of file FlowDDA.cpp.

82 {
83 
84  const CallICFGNode* cbn = getSVFG()->getCallSite(csId);
85 
86  if(getPAG()->isIndirectCallSites(cbn))
87  {
88  if(getCallGraph()->hasIndCSCallees(cbn))
89  {
90  const FunctionSet& funset = getCallGraph()->getIndCSCallees(cbn);
91  if(funset.find(callee)!=funset.end())
92  return true;
93  }
94 
95  return false;
96  }
97  else // if this is an direct call
98  return true;
99 
100 }
BVDataPTAImpl::FunctionSet FunctionSet
Definition: FlowDDA.h:59
const FunctionSet & getIndCSCallees(const CallICFGNode *cs) const
Definition: PTACallGraph.h:312
bool hasIndCSCallees(const CallICFGNode *cs) const
const CallICFGNode * getCallSite(CallSiteID id) const
Definition: VFG.h:182

◆ unionDDAPts()

bool SVF::FlowDDA::unionDDAPts ( LocDPItem  dpm,
const PointsTo targetPts 
)
inlineoverridevirtual

Union pts.

Reimplemented from SVF::DDAVFSolver< NodeID, PointsTo, LocDPItem >.

Definition at line 161 of file FlowDDA.h.

162  {
163  if (isTopLevelPtrStmt(dpm.getLoc())) return unionPts(dpm.getCurNodeID(), targetPts);
164  else return dpmToADCPtSetMap[dpm] |= targetPts;
165  }
DPImToCPtSetMap dpmToADCPtSetMap
points-to caching map for address-taken vars
Definition: DDAVFSolver.h:783
bool isTopLevelPtrStmt(const SVFGNode *stmt)
Whether this is a top-level pointer statement.
Definition: DDAVFSolver.h:583

◆ updateCallGraphAndSVFG()

virtual void SVF::FlowDDA::updateCallGraphAndSVFG ( const LocDPItem dpm,
const CallICFGNode cs,
SVFGEdgeSet svfgEdges 
)
inlineoverridevirtual

Update call graph.

Reimplemented from SVF::DDAVFSolver< NodeID, PointsTo, LocDPItem >.

Definition at line 135 of file FlowDDA.h.

136  {
137  CallEdgeMap newEdges;
138  resolveIndCalls(cs, getCachedPointsTo(dpm), newEdges);
139  for (CallEdgeMap::const_iterator iter = newEdges.begin(),eiter = newEdges.end(); iter != eiter; iter++)
140  {
141  const CallICFGNode* newcs = iter->first;
142  const FunctionSet & functions = iter->second;
143  for (FunctionSet::const_iterator func_iter = functions.begin(); func_iter != functions.end(); func_iter++)
144  {
145  const SVFFunction* func = *func_iter;
146  getSVFG()->connectCallerAndCallee(newcs, func, svfgEdges);
147  }
148  }
149  }
virtual const PointsTo & getCachedPointsTo(const LocDPItem &dpm)
Points-to Caching for top-level pointers and address-taken objects.
Definition: DDAVFSolver.h:556
BVDataPTAImpl::CallEdgeMap CallEdgeMap
Definition: FlowDDA.h:58
virtual void resolveIndCalls(const CallICFGNode *cs, const PointsTo &target, CallEdgeMap &newEdges)
Resolve indirect call edges.
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::FlowDDA::_client
private

DDA client.

Definition at line 173 of file FlowDDA.h.


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