|
Static Value-Flow Analysis
|
#include <VFG.h>
Public Member Functions | |
| VFG (CallGraph *callgraph, VFGK k=FULLSVFG) | |
| Constructor. | |
| virtual | ~VFG () |
| Destructor. | |
| VFGK | getKind () const |
| Get VFG kind. | |
| bool | isPtrOnlySVFG () const |
| Return true if this VFG only contains pointer related SVFGNodes for pointer analysis. | |
| SVFIR * | getPAG () const |
| Return SVFIR. | |
| CallGraph * | getCallGraph () const |
| Return PTACallGraph. | |
| VFGNode * | getVFGNode (NodeID id) const |
| Get a VFG node. | |
| bool | hasVFGNode (NodeID id) const |
| Whether has the VFGNode. | |
| GlobalVFGNodeSet & | getGlobalVFGNodes () |
| Return global stores. | |
| VFGEdge * | getIntraVFGEdge (const VFGNode *src, const VFGNode *dst, VFGEdge::VFGEdgeK kind) |
| Get a SVFG edge according to src and dst. | |
| void | dump (const std::string &file, bool simple=false) |
| Dump graph into dot file. | |
| void | view () |
| Dump graph into dot file. | |
| void | updateCallGraph (PointerAnalysis *pta) |
| Update VFG based on pointer analysis results. | |
| virtual void | connectCallerAndCallee (const CallICFGNode *cs, const FunObjVar *callee, VFGEdgeSetTy &edges) |
| Connect VFG nodes between caller and callee for indirect call site. | |
| CallSiteID | getCallSiteID (const CallICFGNode *cs, const FunObjVar *func) const |
| Get callsite given a callsiteID. | |
| const CallICFGNode * | getCallSite (CallSiteID id) const |
| const VFGNode * | getDefVFGNode (const ValVar *valVar) const |
| Given a valVar, return its definition site. | |
| bool | hasLHSTopLevPtr (const VFGNode *node) const |
| const SVFVar * | getLHSTopLevPtr (const VFGNode *node) const |
| bool | hasStmtVFGNode (const SVFStmt *svfStmt) const |
| Existence checks for VFGNodes. | |
| bool | hasIntraPHIVFGNode (const SVFVar *svfVar) const |
| bool | hasBinaryOPVFGNode (const SVFVar *svfVar) const |
| bool | hasUnaryOPVFGNode (const SVFVar *svfVar) const |
| bool | hasBranchVFGNode (const SVFVar *svfVar) const |
| bool | hasCmpVFGNode (const SVFVar *svfVar) const |
| bool | hasActualParmVFGNode (const SVFVar *aparm, const CallICFGNode *cs) const |
| bool | hasActualRetVFGNode (const SVFVar *aret) const |
| bool | hasFormalParmVFGNode (const SVFVar *fparm) const |
| bool | hasFormalRetVFGNode (const SVFVar *fret) const |
| StmtVFGNode * | getStmtVFGNode (const SVFStmt *svfStmt) const |
| Get an VFGNode. | |
| IntraPHIVFGNode * | getIntraPHIVFGNode (const SVFVar *svfVar) const |
| BinaryOPVFGNode * | getBinaryOPVFGNode (const SVFVar *svfVar) const |
| UnaryOPVFGNode * | getUnaryOPVFGNode (const SVFVar *svfVar) const |
| BranchVFGNode * | getBranchVFGNode (const SVFVar *svfVar) const |
| CmpVFGNode * | getCmpVFGNode (const SVFVar *svfVar) const |
| ActualParmVFGNode * | getActualParmVFGNode (const SVFVar *aparm, const CallICFGNode *cs) const |
| ActualRetVFGNode * | getActualRetVFGNode (const SVFVar *aret) const |
| FormalParmVFGNode * | getFormalParmVFGNode (const SVFVar *fparm) const |
| FormalRetVFGNode * | getFormalRetVFGNode (const SVFVar *fret) const |
| const FunObjVar * | isFunEntryVFGNode (const VFGNode *node) const |
| Whether a node is function entry VFGNode. | |
| bool | hasBlackHoleConstObjAddrAsDef (const ValVar *valVar) const |
| Whether a SVFVar has a blackhole or const object as its definition. | |
| VFGEdge * | addIntraDirectVFEdge (NodeID srcId, NodeID dstId) |
| VFGEdge * | addCallEdge (NodeID srcId, NodeID dstId, CallSiteID csId) |
| VFGEdge * | addRetEdge (NodeID srcId, NodeID dstId, CallSiteID csId) |
| void | removeVFGEdge (VFGEdge *edge) |
| Remove a SVFG edge. | |
| void | removeVFGNode (VFGNode *node) |
| Remove a VFGNode. | |
| VFGEdge * | hasIntraVFGEdge (VFGNode *src, VFGNode *dst, VFGEdge::VFGEdgeK kind) |
| Whether we has a SVFG edge. | |
| VFGEdge * | hasInterVFGEdge (VFGNode *src, VFGNode *dst, VFGEdge::VFGEdgeK kind, CallSiteID csId) |
| VFGEdge * | hasThreadVFGEdge (VFGNode *src, VFGNode *dst, VFGEdge::VFGEdgeK kind) |
| bool | addVFGEdge (VFGEdge *edge) |
| Add VFG edge. | |
| VFGNodeSet & | getVFGNodes (const FunObjVar *fun) |
| bool | hasVFGNodes (const FunObjVar *fun) const |
| bool | VFGNodes (const FunObjVar *fun) const |
| VFGNodeSet::const_iterator | getVFGNodeBegin (const FunObjVar *fun) const |
| VFGNodeSet::const_iterator | getVFGNodeEnd (const FunObjVar *fun) const |
| Public Member Functions inherited from SVF::GenericGraph< VFGNode, VFGEdge > | |
| GenericGraph () | |
| Constructor. | |
| virtual | ~GenericGraph () |
| Destructor. | |
| void | destroy () |
| Release memory. | |
| iterator | begin () |
| Iterators. | |
| iterator | end () |
| const_iterator | begin () const |
| const_iterator | end () const |
| void | addGNode (NodeID id, NodeType *node) |
| Add a Node. | |
| NodeType * | getGNode (NodeID id) const |
| Get a node. | |
| bool | hasGNode (NodeID id) const |
| Has a node. | |
| void | removeGNode (NodeType *node) |
| Delete a node. | |
| u32_t | getTotalNodeNum () const |
| Get total number of node/edge. | |
| u32_t | getTotalEdgeNum () const |
| void | incNodeNum () |
| Increase number of node/edge. | |
| void | incEdgeNum () |
Protected Member Functions | |
| void | destroy () |
| Clean up memory. | |
| void | checkIntraEdgeParents (const VFGNode *srcNode, const VFGNode *dstNode) |
| sanitize Intra edges, verify that both nodes belong to the same function. | |
| VFGEdge * | addInterEdgeFromAPToFP (ActualParmVFGNode *src, FormalParmVFGNode *dst, CallSiteID csId) |
| Add inter VF edge from actual to formal parameters. | |
| VFGEdge * | addInterEdgeFromFRToAR (FormalRetVFGNode *src, ActualRetVFGNode *dst, CallSiteID csId) |
| Add inter VF edge from callee return to callsite receive parameter. | |
| VFGEdge * | addInterEdgeFromAPToFP (NodeID src, NodeID dst, CallSiteID csId) |
| Add inter VF edge from actual to formal parameters. | |
| VFGEdge * | addInterEdgeFromFRToAR (NodeID src, NodeID dst, CallSiteID csId) |
| Add inter VF edge from callee return to callsite receive parameter. | |
| virtual void | connectAParamAndFParam (const ValVar *csArg, const ValVar *funArg, const CallICFGNode *cbn, CallSiteID csId, VFGEdgeSetTy &edges) |
| Connect VFG nodes between caller and callee for indirect call site. | |
| virtual void | connectFRetAndARet (const ValVar *funReturn, const ValVar *csReturn, CallSiteID csId, VFGEdgeSetTy &edges) |
| Connect formal-ret and actual ret. | |
| void | setDef (const ValVar *valVar, const VFGNode *node) |
| Given a ValVar, set/get its def VFG node (definition of top level pointers). | |
| NodeID | getDef (const ValVar *valVar) const |
| bool | hasDef (const ValVar *valVar) const |
| void | addVFGNodes () |
| Create VFG nodes. | |
| virtual SVFStmt::SVFStmtSetTy & | getSVFStmtSet (SVFStmt::PEDGEK kind) |
| Get SVFStmt set. | |
| virtual bool | isInterestedSVFVar (const SVFVar *node) const |
| void | connectDirectVFGEdges () |
| Create edges between VFG nodes within a function. | |
| void | addVFGInterEdges (const CallICFGNode *cs, const FunObjVar *callee) |
| Create edges between VFG nodes across functions. | |
| bool | isPhiCopyEdge (const SVFStmt *copy) const |
| virtual void | addVFGNode (VFGNode *vfgNode, ICFGNode *icfgNode) |
| Add a VFG node. | |
| void | addStmtVFGNode (StmtVFGNode *node, const SVFStmt *svfStmt) |
| Add a VFG node for program statement. | |
| void | addNullPtrVFGNode (const ValVar *svfVar) |
| void | addAddrVFGNode (const AddrStmt *addr) |
| Add an Address VFG node. | |
| void | addCopyVFGNode (const CopyStmt *copy) |
| Add a Copy VFG node. | |
| void | addGepVFGNode (const GepStmt *gep) |
| Add a Gep VFG node. | |
| void | addLoadVFGNode (const LoadStmt *load) |
| Add a Load VFG node. | |
| void | addStoreVFGNode (const StoreStmt *store) |
| void | addActualParmVFGNode (const ValVar *aparm, const CallICFGNode *cs) |
| void | addFormalParmVFGNode (const ValVar *fparm, const FunObjVar *fun, const CallPE *callPE) |
| Add a formal parameter VFG node. | |
| void | addFormalRetVFGNode (const ValVar *uniqueFunRet, const FunObjVar *fun, RetPESet &retPEs) |
| void | addActualRetVFGNode (const ValVar *ret, const CallICFGNode *cs) |
| Add a callsite Receive VFG node. | |
| void | addIntraPHIVFGNode (const MultiOpndStmt *edge) |
| Add an llvm PHI VFG node. | |
| void | addCmpVFGNode (const CmpStmt *edge) |
| Add a Compare VFG node. | |
| void | addBinaryOPVFGNode (const BinaryOPStmt *edge) |
| Add a BinaryOperator VFG node. | |
| void | addUnaryOPVFGNode (const UnaryOPStmt *edge) |
| Add a UnaryOperator VFG node. | |
| void | addBranchVFGNode (const BranchStmt *edge) |
| Add a BranchVFGNode. | |
Additional Inherited Members | |
| Public Attributes inherited from SVF::GenericGraph< VFGNode, VFGEdge > | |
| u32_t | edgeNum |
| total num of node | |
| u32_t | nodeNum |
| total num of edge | |
| typedef VFGNodeIDToNodeMapTy::const_iterator SVF::VFG::const_iterator |
| typedef Map<const FunObjVar*, VFGNodeSet > SVF::VFG::FunToVFGNodesMapTy |
| typedef Set<const VFGNode*> SVF::VFG::GlobalVFGNodeSet |
| typedef VFGNodeIDToNodeMapTy::iterator SVF::VFG::iterator |
| typedef Map<const SVFStmt*, StmtVFGNode*> SVF::VFG::SVFStmtToStmtVFGNodeMapTy |
| typedef Set<const SVFVar*> SVF::VFG::SVFVarSet |
| typedef Map<std::pair<NodeID,const CallICFGNode*>, ActualParmVFGNode *> SVF::VFG::SVFVarToActualParmMapTy |
| typedef Map<const SVFVar*, ActualRetVFGNode *> SVF::VFG::SVFVarToActualRetMapTy |
| typedef Map<const SVFVar*, BinaryOPVFGNode*> SVF::VFG::SVFVarToBinaryOPVFGNodeMapTy |
| typedef Map<const SVFVar*, BranchVFGNode*> SVF::VFG::SVFVarToBranchVFGNodeMapTy |
| typedef Map<const SVFVar*, CmpVFGNode*> SVF::VFG::SVFVarToCmpVFGNodeMapTy |
| typedef Map<const SVFVar*, FormalParmVFGNode *> SVF::VFG::SVFVarToFormalParmMapTy |
| typedef Map<const SVFVar*, FormalRetVFGNode *> SVF::VFG::SVFVarToFormalRetMapTy |
| typedef Map<const SVFVar*, IntraPHIVFGNode*> SVF::VFG::SVFVarToPHIVFGNodeMapTy |
| typedef Map<const SVFVar*, UnaryOPVFGNode*> SVF::VFG::SVFVarToUnaryOPVFGNodeMapTy |
| typedef OrderedMap<NodeID, VFGNode *> SVF::VFG::VFGNodeIDToNodeMapTy |
| typedef VFGEdge::VFGEdgeSetTy::iterator SVF::VFG::VFGNodeIter |
| typedef Set<VFGNode*> SVF::VFG::VFGNodeSet |
| enum SVF::VFG::VFGK |
Constructor.
Constructor
Definition at line 428 of file VFG.cpp.
|
inlinevirtual |
Destructor.
|
inlineprotected |
Add an actual parameter VFG node To be noted that multiple actual parameters may have same value (SVFVar) So we need to make a pair <SVFVarID,CallSiteID> to find the right VFGParmNode
do not set def here, this node is not a variable definition
Definition at line 592 of file VFG.h.
|
inlineprotected |
Add a callsite Receive VFG node.
Definition at line 631 of file VFG.h.
|
inlineprotected |
Add an Address VFG node.
Definition at line 554 of file VFG.h.
|
inlineprotected |
Add a BinaryOperator VFG node.
Definition at line 667 of file VFG.h.
|
inlineprotected |
Add a BranchVFGNode.
Definition at line 690 of file VFG.h.
| VFGEdge * VFG::addCallEdge | ( | NodeID | srcId, |
| NodeID | dstId, | ||
| CallSiteID | csId ) |
Add interprocedural call edges for top level pointers
Definition at line 669 of file VFG.cpp.
|
inlineprotected |
Add a Compare VFG node.
Definition at line 653 of file VFG.h.
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
Add a callee Return VFG node To be noted that here we assume returns of a procedure have already been unified into one Otherwise, we need to handle formalRet using <SVFVarID,CallSiteID> pair to find FormalRetVFG node same as handling actual parameters
if this uniqueFunRet is a phi node, which means it will receive values from multiple return instructions of fun we will set this phi node's def later Ideally, every function uniqueFunRet should be a PhiNode (SVFIRBuilder.cpp), unless it does not have ret instruction
Definition at line 612 of file VFG.h.
|
inlineprotected |
Add a Gep VFG node.
|
inlineprotected |
Add inter VF edge from actual to formal parameters.
Definition at line 424 of file VFG.h.
|
inlineprotected |
Add inter VF edge from actual to formal parameters.
|
inlineprotected |
Add inter VF edge from callee return to callsite receive parameter.
|
inlineprotected |
Add inter VF edge from callee return to callsite receive parameter.
Add control-flow edges for top level pointers
Add def-use edges for top level pointers
Definition at line 643 of file VFG.cpp.
|
inlineprotected |
Add an llvm PHI VFG node.
Definition at line 639 of file VFG.h.
|
inlineprotected |
Add a Load VFG node.
|
inlineprotected |
| VFGEdge * VFG::addRetEdge | ( | NodeID | srcId, |
| NodeID | dstId, | ||
| CallSiteID | csId ) |
Add interprocedural return edges for top level pointers
Definition at line 689 of file VFG.cpp.
|
inlineprotected |
Add a VFG node for program statement.
Definition at line 539 of file VFG.h.
|
inlineprotected |
Add a Store VFG node, To be noted store does not create a new pointer, we do not set def for any SVFIR node
|
inlineprotected |
Add a UnaryOperator VFG node.
Definition at line 681 of file VFG.h.
|
inline |
|
protected |
Create edges between VFG nodes across functions.
Add a VFG node.
Definition at line 526 of file VFG.h.
|
protected |
Create VFG nodes.
Create VFG nodes for top level pointers
for external function we do not create acutalRet VFGNode they are in the formal of AddrVFGNode if the external function returns an allocated memory if fun has body, it may also exist in isExtCall, e.g., xmalloc() in bzip2, spec2000.
Definition at line 450 of file VFG.cpp.
|
inlineprotected |
sanitize Intra edges, verify that both nodes belong to the same function.
Definition at line 413 of file VFG.h.
|
inlineprotectedvirtual |
Connect VFG nodes between caller and callee for indirect call site.
Connect actual-param and formal param
Reimplemented in SVF::SVFGOPT.
Definition at line 448 of file VFG.h.
|
virtual |
Connect VFG nodes between caller and callee for indirect call site.
Connect actual params/return to formal params/return for top-level variables. Also connect indirect actual in/out and formal in/out.
Reimplemented in SVF::SVFG.
Definition at line 953 of file VFG.cpp.
|
protected |
Create edges between VFG nodes within a function.
Connect def-use chains for direct value-flow, (value-flow of top level pointers)
do not handle AddrSVFG node, as it is already the source of a definition
for all other cases, like copy/gep/load/ret, connect the RHS pointer to its def
for store, connect the RHS/LHS pointer to its def
connect formal ret to its definition node
connect formal ret to actual ret
Do not process FormalRetVFGNode, as they are connected by copy within callee We assume one procedure only has unique return
connect direct value-flow edges (parameter passing) for thread fork/join
add fork edge
add join edge
Definition at line 710 of file VFG.cpp.
|
inlineprotectedvirtual |
Connect formal-ret and actual ret.
Reimplemented in SVF::SVFGOPT.
Definition at line 457 of file VFG.h.
|
protected |
Clean up memory.
Memory has been cleaned up at GenericGraph
| void VFG::dump | ( | const std::string & | file, |
| bool | simple = false ) |
Dump graph into dot file.
Dump VFG
Definition at line 917 of file VFG.cpp.
|
inline |
Definition at line 297 of file VFG.h.
|
inline |
Definition at line 303 of file VFG.h.
|
inline |
Definition at line 273 of file VFG.h.
|
inline |
Definition at line 285 of file VFG.h.
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 291 of file VFG.h.
Definition at line 482 of file VFG.h.
Given a valVar, return its definition site.
|
inline |
Definition at line 309 of file VFG.h.
|
inline |
Definition at line 315 of file VFG.h.
|
inline |
|
inline |
Definition at line 267 of file VFG.h.
| VFGEdge * VFG::getIntraVFGEdge | ( | const VFGNode * | src, |
| const VFGNode * | dst, | ||
| VFGEdge::VFGEdgeK | kind ) |
|
inline |
Given a VFG node, return its left hand side top level pointer
Definition at line 1004 of file VFG.cpp.
|
inline |
|
inline |
Get an VFGNode.
Definition at line 261 of file VFG.h.
|
inlineprotectedvirtual |
|
inline |
Definition at line 279 of file VFG.h.
Get a VFG node.
|
inline |
Definition at line 360 of file VFG.h.
|
inline |
Definition at line 366 of file VFG.h.
|
inline |
Return all the VFGNodes of a function
|
inline |
Definition at line 241 of file VFG.h.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlineprotected |
|
inline |
|
inline |
| VFGEdge * VFG::hasInterVFGEdge | ( | VFGNode * | src, |
| VFGNode * | dst, | ||
| VFGEdge::VFGEdgeK | kind, | ||
| CallSiteID | csId ) |
Whether we has an inter VFG edge
Definition at line 890 of file VFG.cpp.
|
inline |
| VFGEdge * VFG::hasIntraVFGEdge | ( | VFGNode * | src, |
| VFGNode * | dst, | ||
| VFGEdge::VFGEdgeK | kind ) |
Whether we has a SVFG edge.
Whether we has an intra VFG edge
Definition at line 855 of file VFG.cpp.
|
inline |
|
inline |
Existence checks for VFGNodes.
| VFGEdge * VFG::hasThreadVFGEdge | ( | VFGNode * | src, |
| VFGNode * | dst, | ||
| VFGEdge::VFGEdgeK | kind ) |
Whether we has an thread VFG edge
Definition at line 873 of file VFG.cpp.
|
inline |
|
inline |
Whether has the VFGNode.
|
inline |
Whether a node is function entry VFGNode.
Whether this is an function entry VFGNode (formal parameter, formal In)
Definition at line 1041 of file VFG.cpp.
|
inlineprotectedvirtual |
|
inlineprotected |
|
inline |
Return true if this VFG only contains pointer related SVFGNodes for pointer analysis.
|
inline |
|
inline |
Remove a VFGNode.
Given a ValVar, set/get its def VFG node (definition of top level pointers).
Definition at line 469 of file VFG.h.
| void VFG::updateCallGraph | ( | PointerAnalysis * | pta | ) |
Update VFG based on pointer analysis results.
Definition at line 931 of file VFG.cpp.
|
inline |
| void VFG::view | ( | ) |
Dump graph into dot file.
View VFG from the debugger.
Definition at line 925 of file VFG.cpp.
|
protected |
|
protected |
|
protected |
map a SVFStmt to its StmtVFGNode
|
protected |
|
protected |
|
protected |
map a SVFVar to its BinaryOPVFGNode
|
protected |
map a SVFVar to its BranchVFGNode
|
protected |
map a SVFVar to its CmpVFGNode
|
protected |
|
protected |
|
protected |
map a SVFVar to its PHIVFGNode
|
protected |
map a SVFVar to its UnaryOPVFGNode
|
protected |