SVF
Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
SVF::PAG Class Reference

#include <PAG.h>

Inheritance diagram for SVF::PAG:
SVF::GenericGraph< PAGNode, PAGEdge >

Public Types

typedef Set< const CallBlockNode * > CallSiteSet
 
typedef OrderedMap< const CallBlockNode *, NodeIDCallSiteToFunPtrMap
 
typedef Map< NodeID, CallSiteSetFunPtrToCallSitesMap
 
typedef Map< NodeID, NodeBSMemObjToFieldsMap
 
typedef Set< const PAGEdge * > PAGEdgeSet
 
typedef std::vector< const PAGEdge * > PAGEdgeList
 
typedef std::vector< const PAGNode * > PAGNodeList
 
typedef std::vector< const CopyPE * > CopyPEList
 
typedef std::vector< const BinaryOPPE * > BinaryOPList
 
typedef std::vector< const UnaryOPPE * > UnaryOPList
 
typedef std::vector< const CmpPE * > CmpPEList
 
typedef Map< const PAGNode *, CopyPEListPHINodeMap
 
typedef Map< const PAGNode *, BinaryOPListBinaryNodeMap
 
typedef Map< const PAGNode *, UnaryOPListUnaryNodeMap
 
typedef Map< const PAGNode *, CmpPEListCmpNodeMap
 
typedef Map< const SVFFunction *, PAGNodeListFunToArgsListMap
 
typedef Map< const CallBlockNode *, PAGNodeListCSToArgsListMap
 
typedef Map< const RetBlockNode *, const PAGNode * > CSToRetMap
 
typedef Map< const SVFFunction *, const PAGNode * > FunToRetMap
 
typedef Map< const SVFFunction *, PAGEdgeSetFunToPAGEdgeSetMap
 
typedef Map< const ICFGNode *, PAGEdgeListInst2PAGEdgesMap
 
typedef Map< NodeID, NodeIDNodeToNodeMap
 
typedef std::pair< NodeID, Size_tNodeOffset
 
typedef std::pair< NodeID, LocationSetNodeLocationSet
 
typedef Map< NodeOffset, NodeIDNodeOffsetMap
 
typedef Map< NodeLocationSet, NodeIDNodeLocationSetMap
 
typedef Map< const Value *, NodeLocationSetMapGepValPNMap
 
typedef Map< NodePair, NodeIDNodePairSetMap
 
- Public Types inherited from SVF::GenericGraph< PAGNode, PAGEdge >
typedef PAGNode NodeType
 
typedef PAGEdge EdgeType
 
typedef Map< NodeID, NodeType *> IDToNodeMapTy
 NodeID to GenericNode map. More...
 
typedef IDToNodeMapTy::iterator iterator
 Node Iterators. More...
 
typedef IDToNodeMapTy::const_iterator const_iterator
 

Public Member Functions

MemObjToFieldsMapgetMemToFieldsMap ()
 Return memToFieldsMap. More...
 
NodeLocationSetMapgetGepObjNodeMap ()
 Return GepObjNodeMap. More...
 
ICFGgetICFG ()
 Return ICFG. More...
 
OrderedNodeSetgetAllValidPtrs ()
 Return valid pointers. More...
 
void initialiseCandidatePointers ()
 Initialize candidate pointers. More...
 
virtual ~PAG ()
 Destructor. More...
 
bool isBuiltFromFile ()
 Whether this PAG built from a txt file. More...
 
SVFModulegetModule ()
 Get LLVM Module. More...
 
void addCallSite (const CallBlockNode *call)
 
const CallSiteSetgetCallSiteSet () const
 
NodeID getGepValNode (const Value *curInst, NodeID base, const LocationSet &ls) const
 Due to constaint expression, curInst is used to distinguish different instructions (e.g., memorycpy) when creating GepValPN. More...
 
bool findPAGNode (NodeID id) const
 Get a pag node according to its ID. More...
 
PAGNodegetPAGNode (NodeID id) const
 Get PAGNode ID. More...
 
NodeID getReturnNode (const SVFFunction *func) const
 GetReturnNode - Return the unique node representing the return value of a function. More...
 
NodeID getVarargNode (const SVFFunction *func) const
 getVarargNode - Return the unique node representing the variadic argument of a variadic function. More...
 
NodeID getGepObjNode (const MemObj *obj, const LocationSet &ls)
 Get a field PAG Object node according to base mem obj and offset. More...
 
NodeID getGepObjNode (NodeID id, const LocationSet &ls)
 Get a field obj PAG node according to a mem obj and a given offset. More...
 
u32_t getNodeNumAfterPAGBuild () const
 
void setNodeNumAfterPAGBuild (u32_t num)
 
NodeID addValNode (const Value *, PAGNode *node, NodeID i)
 Add a value (pointer) node. More...
 
NodeID addObjNode (const Value *, PAGNode *node, NodeID i)
 Add a memory obj node. More...
 
NodeID addRetNode (const SVFFunction *, PAGNode *node, NodeID i)
 Add a unique return node for a procedure. More...
 
NodeID addVarargNode (const SVFFunction *, PAGNode *node, NodeID i)
 Add a unique vararg node for a procedure. More...
 
PAGEdgeaddBlackHoleAddrPE (NodeID node)
 Set a pointer points-to black hole (e.g. int2ptr) More...
 
std::string getGraphName () const
 Return graph name. More...
 
void print ()
 Print PAG. More...
 
void dump (std::string name)
 Dump PAG. More...
 
void view ()
 View graph from the debugger. More...
 
PAGEdge::PAGEdgeSetTygetEdgeSet (PAGEdge::PEDGEK kind)
 Get/set methods to get control flow information of a PAGEdge. More...
 
PAGEdge::PAGEdgeSetTygetPTAEdgeSet (PAGEdge::PEDGEK kind)
 Get PTA edges set according to its kind. More...
 
bool hasPAGEdgeList (const ICFGNode *inst) const
 Whether this instruction has PAG Edge. More...
 
bool hasPTAPAGEdgeList (const ICFGNode *inst) const
 
PAGEdgeListgetInstPAGEdgeList (const ICFGNode *inst)
 Given an instruction, get all its PAGEdges. More...
 
PAGEdgeListgetInstPTAPAGEdgeList (const ICFGNode *inst)
 Given an instruction, get all its PTA PAGEdges. More...
 
void addToInstPAGEdgeList (ICFGNode *inst, PAGEdge *edge)
 Add a PAGEdge into instruction map. More...
 
void addGlobalPAGEdge (const PAGEdge *edge)
 Get global PAGEdges (not in a procedure) More...
 
PAGEdgeSetgetGlobalPAGEdgeSet ()
 Get global PAGEdges (not in a procedure) More...
 
void addPhiNode (const PAGNode *res, const CopyPE *edge)
 Add phi node information. More...
 
bool isPhiNode (const PAGNode *node) const
 Whether this PAGNode is a result operand a of phi node. More...
 
PHINodeMapgetPhiNodeMap ()
 Get all phi copy edges. More...
 
void addBinaryNode (const PAGNode *res, const BinaryOPPE *edge)
 Add phi node information. More...
 
bool isBinaryNode (const PAGNode *node) const
 Whether this PAGNode is a result operand a of phi node. More...
 
BinaryNodeMapgetBinaryNodeMap ()
 Get all phi copy edges. More...
 
void addUnaryNode (const PAGNode *res, const UnaryOPPE *edge)
 Add unary node information. More...
 
bool isUnaryNode (const PAGNode *node) const
 Whether this PAGNode is an unary node. More...
 
UnaryNodeMapgetUnaryNodeMap ()
 Get all unary edges. More...
 
void addCmpNode (const PAGNode *res, const CmpPE *edge)
 Add phi node information. More...
 
bool isCmpNode (const PAGNode *node) const
 Whether this PAGNode is a result operand a of phi node. More...
 
CmpNodeMapgetCmpNodeMap ()
 Get all phi copy edges. More...
 
void addFunArgs (const SVFFunction *fun, const PAGNode *arg)
 Get/set method for function/callsite arguments and returns. More...
 
void addFunRet (const SVFFunction *fun, const PAGNode *ret)
 Add function returns. More...
 
void addCallSiteArgs (CallBlockNode *callBlockNode, const PAGNode *arg)
 Add callsite arguments. More...
 
void addCallSiteRets (RetBlockNode *retBlockNode, const PAGNode *arg)
 Add callsite returns. More...
 
bool hasFunArgsList (const SVFFunction *func) const
 Function has arguments list. More...
 
FunToArgsListMapgetFunArgsMap ()
 Get function arguments list. More...
 
const PAGNodeListgetFunArgsList (const SVFFunction *func) const
 Get function arguments list. More...
 
bool hasCallSiteArgsMap (const CallBlockNode *cs) const
 Callsite has argument list. More...
 
CSToArgsListMapgetCallSiteArgsMap ()
 Get callsite argument list. More...
 
const PAGNodeListgetCallSiteArgsList (const CallBlockNode *cs) const
 Get callsite argument list. More...
 
CSToRetMapgetCallSiteRets ()
 Get callsite return. More...
 
const PAGNodegetCallSiteRet (const RetBlockNode *cs) const
 Get callsite return. More...
 
bool callsiteHasRet (const RetBlockNode *cs) const
 
FunToRetMapgetFunRets ()
 Get function return list. More...
 
const PAGNodegetFunRet (const SVFFunction *func) const
 Get function return list. More...
 
bool funHasRet (const SVFFunction *func) const
 
Size_t getPAGNodeNum () const
 Node and edge statistics. More...
 
Size_t getPAGEdgeNum () const
 
Size_t getValueNodeNum () const
 
Size_t getObjectNodeNum () const
 
Size_t getFieldValNodeNum () const
 
Size_t getFieldObjNodeNum () const
 
const CallSiteToFunPtrMapgetIndirectCallsites () const
 Add/get indirect callsites. More...
 
void addIndirectCallsites (const CallBlockNode *cs, NodeID funPtr)
 
NodeID getFunPtr (const CallBlockNode *cs) const
 
const CallSiteSetgetIndCallSites (NodeID funPtr) const
 
bool isIndirectCallSites (const CallBlockNode *cs) const
 
bool isFunPtr (NodeID id) const
 
PAGEdgegetIntraPAGEdge (NodeID src, NodeID dst, PAGEdge::PEDGEK kind)
 Get an edge according to src, dst and kind. More...
 
PAGEdgegetIntraPAGEdge (PAGNode *src, PAGNode *dst, PAGEdge::PEDGEK kind)
 
NodeID getValueNode (const Value *V)
 Get PAG Node according to LLVM value. More...
 
bool hasValueNode (const Value *V)
 
NodeID getObjectNode (const Value *V)
 
NodeID getObjectNode (const MemObj *mem)
 getObject - return mem object id More...
 
const MemObjgetObject (NodeID id) const
 
const MemObjgetObject (const ObjPN *node) const
 
NodeID getFIObjNode (const MemObj *obj) const
 Get a field-insensitive obj PAG node according to a mem obj. More...
 
NodeID getFIObjNode (NodeID id) const
 
NodeID getBlackHoleNode () const
 Get black hole and constant id. More...
 
NodeID getConstantNode () const
 
NodeID getBlkPtr () const
 
NodeID getNullPtr () const
 
bool isBlkPtr (NodeID id) const
 
bool isNullPtr (NodeID id) const
 
bool isBlkObjOrConstantObj (NodeID id) const
 
bool isBlkObj (NodeID id) const
 
bool isConstantObj (NodeID id) const
 
bool isNonPointerObj (NodeID id) const
 
const MemObjgetBlackHoleObj () const
 
const MemObjgetConstantObj () const
 
NodeID getBaseValNode (NodeID nodeId)
 Base and Offset methods for Value and Object node. More...
 
LocationSet getLocationSetFromBaseNode (NodeID nodeId)
 
NodeID getBaseObjNode (NodeID id) const
 
const MemObjgetBaseObj (NodeID id) const
 
NodeBSgetAllFieldsObjNode (const MemObj *obj)
 Get all fields of an object. More...
 
NodeBSgetAllFieldsObjNode (NodeID id)
 
NodeBS getFieldsAfterCollapse (NodeID id)
 
NodeID addNode (PAGNode *node, NodeID i)
 add node into PAG More...
 
NodeID addValNode (const Value *val, NodeID i)
 Add a value (pointer) node. More...
 
NodeID addObjNode (const Value *val, NodeID i)
 Add a memory obj node. More...
 
NodeID addRetNode (const SVFFunction *val, NodeID i)
 Add a unique return node for a procedure. More...
 
NodeID addVarargNode (const SVFFunction *val, NodeID i)
 Add a unique vararg node for a procedure. More...
 
NodeID addGepValNode (const Value *curInst, const Value *val, const LocationSet &ls, NodeID i, const Type *type, u32_t fieldidx)
 Add a temp field value node, this method can only invoked by getGepValNode. More...
 
NodeID addGepObjNode (const MemObj *obj, const LocationSet &ls)
 Add a field obj node, this method can only invoked by getGepObjNode. More...
 
NodeID addFIObjNode (const MemObj *obj)
 Add a field-insensitive node, this method can only invoked by getFIGepObjNode. More...
 
NodeID addDummyValNode ()
 Add a dummy value/object node according to node ID (llvm value is null) More...
 
NodeID addDummyValNode (NodeID i)
 
NodeID addDummyObjNode (const Type *type=nullptr)
 
NodeID addDummyObjNode (NodeID i, const Type *type)
 
const MemObjaddDummyMemObj (NodeID i, const Type *type)
 
NodeID addBlackholeObjNode ()
 
NodeID addConstantObjNode ()
 
NodeID addBlackholePtrNode ()
 
bool addEdge (PAGNode *src, PAGNode *dst, PAGEdge *edge)
 Add an edge into PAG. More...
 
PAGEdgehasNonlabeledEdge (PAGNode *src, PAGNode *dst, PAGEdge::PEDGEK kind)
 
PAGEdgehasLabeledEdge (PAGNode *src, PAGNode *dst, PAGEdge::PEDGEK kind, const ICFGNode *cs)
 
AddrPEaddAddrPE (NodeID src, NodeID dst)
 Add Address edge. More...
 
CopyPEaddCopyPE (NodeID src, NodeID dst)
 Add Copy edge. More...
 
CmpPEaddCmpPE (NodeID src, NodeID dst)
 Add Copy edge. More...
 
BinaryOPPEaddBinaryOPPE (NodeID src, NodeID dst)
 Add Copy edge. More...
 
UnaryOPPEaddUnaryOPPE (NodeID src, NodeID dst)
 Add Unary edge. More...
 
LoadPEaddLoadPE (NodeID src, NodeID dst)
 Add Load edge. More...
 
StorePEaddStorePE (NodeID src, NodeID dst, const IntraBlockNode *val)
 Add Store edge. More...
 
CallPEaddCallPE (NodeID src, NodeID dst, const CallBlockNode *cs)
 Add Call edge. More...
 
RetPEaddRetPE (NodeID src, NodeID dst, const CallBlockNode *cs)
 Add Return edge. More...
 
GepPEaddGepPE (NodeID src, NodeID dst, const LocationSet &ls, bool constGep)
 Add Gep edge. More...
 
NormalGepPEaddNormalGepPE (NodeID src, NodeID dst, const LocationSet &ls)
 Add Offset(Gep) edge. More...
 
VariantGepPEaddVariantGepPE (NodeID src, NodeID dst)
 Add Variant(Gep) edge. More...
 
TDForkPEaddThreadForkPE (NodeID src, NodeID dst, const CallBlockNode *cs)
 Add Thread fork edge for parameter passing. More...
 
TDJoinPEaddThreadJoinPE (NodeID src, NodeID dst, const CallBlockNode *cs)
 Add Thread join edge for parameter passing. More...
 
bool isValidPointer (NodeID nodeId) const
 Whether a node is a valid pointer. More...
 
bool isValidTopLevelPtr (const PAGNode *node)
 
- Public Member Functions inherited from SVF::GenericGraph< PAGNode, PAGEdge >
 GenericGraph ()
 Constructor. More...
 
virtual ~GenericGraph ()
 Destructor. More...
 
void destroy ()
 Release memory. More...
 
iterator begin ()
 Iterators. More...
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
void addGNode (NodeID id, NodeType *node)
 Add a Node. More...
 
NodeTypegetGNode (NodeID id) const
 Get a node. More...
 
bool hasGNode (NodeID id) const
 Has a node. More...
 
void removeGNode (NodeType *node)
 Delete a node. More...
 
u32_t getTotalNodeNum () const
 Get total number of node/edge. More...
 
u32_t getTotalEdgeNum () const
 
void incNodeNum ()
 Increase number of node/edge. More...
 
void incEdgeNum ()
 

Static Public Member Functions

static PAGgetPAG (bool buildFromFile=false)
 Singleton design here to make sure we only have one instance during any analysis. More...
 
static void releasePAG ()
 
static void handleBlackHole (bool b)
 PAG build configurations. More...
 

Public Attributes

u32_t totalPTAPAGEdge
 
- Public Attributes inherited from SVF::GenericGraph< PAGNode, PAGEdge >
u32_t edgeNum
 total num of node More...
 
u32_t nodeNum
 total num of edge More...
 

Private Member Functions

 PAG (bool buildFromFile)
 all the callsites of a program More...
 
void destroy ()
 Clean up memory. More...
 

Private Attributes

SymbolTableInfosymInfo
 
PAGEdge::PAGKindToEdgeSetMapTy PAGEdgeKindToSetMap
 
PAGEdge::PAGKindToEdgeSetMapTy PTAPAGEdgeKindToSetMap
 
Inst2PAGEdgesMap inst2PAGEdgesMap
 Map a instruction to its PAGEdges. More...
 
Inst2PAGEdgesMap inst2PTAPAGEdgesMap
 Map a instruction to its PointerAnalysis related PAGEdges. More...
 
GepValPNMap GepValNodeMap
 Map a pair<base,off> to a gep value node id. More...
 
NodeLocationSetMap GepObjNodeMap
 Map a pair<base,off> to a gep obj node id. More...
 
MemObjToFieldsMap memToFieldsMap
 Map a mem object id to all its fields. More...
 
PAGEdgeSet globPAGEdgesSet
 Global PAGEdges without control flow information. More...
 
PHINodeMap phiNodeMap
 A set of phi copy edges. More...
 
BinaryNodeMap binaryNodeMap
 A set of binary edges. More...
 
UnaryNodeMap unaryNodeMap
 A set of unary edges. More...
 
CmpNodeMap cmpNodeMap
 A set of comparision edges. More...
 
FunToArgsListMap funArgsListMap
 Map a function to a list of all its formal parameters. More...
 
CSToArgsListMap callSiteArgsListMap
 Map a callsite to a list of all its actual parameters. More...
 
CSToRetMap callSiteRetMap
 Map a callsite to its callsite returns PAGNodes. More...
 
FunToRetMap funRetMap
 Map a function to its unique function return PAGNodes. More...
 
CallSiteToFunPtrMap indCallSiteToFunPtrMap
 Map an indirect callsite to its function pointer. More...
 
FunPtrToCallSitesMap funPtrToCallSitesMap
 Map a function pointer to the callsites where it is used. More...
 
bool fromFile
 
OrderedNodeSet candidatePointers
 
NodeID nodeNumAfterPAGBuild
 
ICFGicfg
 
CallSiteSet callSiteSet
 

Static Private Attributes

static PAGpag = nullptr
 Singleton pattern here to enable instance of PAG can only be created once. More...
 

Additional Inherited Members

- Protected Attributes inherited from SVF::GenericGraph< PAGNode, PAGEdge >
IDToNodeMapTy IDToNodeMap
 node map More...
 

Detailed Description

Program Assignment Graph for pointer analysis SymID and NodeID are equal here (same numbering).

Definition at line 47 of file PAG.h.

Member Typedef Documentation

◆ BinaryNodeMap

Definition at line 63 of file PAG.h.

◆ BinaryOPList

typedef std::vector<const BinaryOPPE*> SVF::PAG::BinaryOPList

Definition at line 59 of file PAG.h.

◆ CallSiteSet

Definition at line 51 of file PAG.h.

◆ CallSiteToFunPtrMap

Definition at line 52 of file PAG.h.

◆ CmpNodeMap

Definition at line 65 of file PAG.h.

◆ CmpPEList

typedef std::vector<const CmpPE*> SVF::PAG::CmpPEList

Definition at line 61 of file PAG.h.

◆ CopyPEList

typedef std::vector<const CopyPE*> SVF::PAG::CopyPEList

Definition at line 58 of file PAG.h.

◆ CSToArgsListMap

Definition at line 67 of file PAG.h.

◆ CSToRetMap

typedef Map<const RetBlockNode*,const PAGNode*> SVF::PAG::CSToRetMap

Definition at line 68 of file PAG.h.

◆ FunPtrToCallSitesMap

Definition at line 53 of file PAG.h.

◆ FunToArgsListMap

Definition at line 66 of file PAG.h.

◆ FunToPAGEdgeSetMap

Definition at line 70 of file PAG.h.

◆ FunToRetMap

typedef Map<const SVFFunction*,const PAGNode*> SVF::PAG::FunToRetMap

Definition at line 69 of file PAG.h.

◆ GepValPNMap

Definition at line 77 of file PAG.h.

◆ Inst2PAGEdgesMap

Definition at line 71 of file PAG.h.

◆ MemObjToFieldsMap

Definition at line 54 of file PAG.h.

◆ NodeLocationSet

Definition at line 74 of file PAG.h.

◆ NodeLocationSetMap

Definition at line 76 of file PAG.h.

◆ NodeOffset

typedef std::pair<NodeID, Size_t> SVF::PAG::NodeOffset

Definition at line 73 of file PAG.h.

◆ NodeOffsetMap

Definition at line 75 of file PAG.h.

◆ NodePairSetMap

Definition at line 78 of file PAG.h.

◆ NodeToNodeMap

Definition at line 72 of file PAG.h.

◆ PAGEdgeList

typedef std::vector<const PAGEdge*> SVF::PAG::PAGEdgeList

Definition at line 56 of file PAG.h.

◆ PAGEdgeSet

typedef Set<const PAGEdge*> SVF::PAG::PAGEdgeSet

Definition at line 55 of file PAG.h.

◆ PAGNodeList

typedef std::vector<const PAGNode*> SVF::PAG::PAGNodeList

Definition at line 57 of file PAG.h.

◆ PHINodeMap

Definition at line 62 of file PAG.h.

◆ UnaryNodeMap

Definition at line 64 of file PAG.h.

◆ UnaryOPList

typedef std::vector<const UnaryOPPE*> SVF::PAG::UnaryOPList

Definition at line 60 of file PAG.h.

Constructor & Destructor Documentation

◆ PAG()

PAG::PAG ( bool  buildFromFile)
private

all the callsites of a program

Constructor

Definition at line 362 of file PAG.cpp.

362  : fromFile(buildFromFile), nodeNumAfterPAGBuild(0), totalPTAPAGEdge(0)
363 {
365  icfg = new ICFG();
366  ICFGBuilder builder(icfg);
367  builder.build(getModule());
368 }
u32_t totalPTAPAGEdge
Definition: PAG.h:118
ICFG * icfg
Definition: PAG.h:108
static SymbolTableInfo * SymbolInfo()
Singleton design here to make sure we only have one instance during any analysis. ...
Definition: ICFG.h:46
bool fromFile
Definition: PAG.h:103
SVFModule * getModule()
Get LLVM Module.
Definition: PAG.h:193
SymbolTableInfo * symInfo
Definition: PAG.h:81
NodeID nodeNumAfterPAGBuild
Definition: PAG.h:107

◆ ~PAG()

virtual SVF::PAG::~PAG ( )
inlinevirtual

Destructor.

Definition at line 177 of file PAG.h.

178  {
179  destroy();
180  }
void destroy()
Clean up memory.
Definition: PAG.cpp:866

Member Function Documentation

◆ addAddrPE()

AddrPE * PAG::addAddrPE ( NodeID  src,
NodeID  dst 
)

Add Address edge.

Add Address edge

Definition at line 373 of file PAG.cpp.

374 {
375  PAGNode* srcNode = getPAGNode(src);
376  PAGNode* dstNode = getPAGNode(dst);
377  if(PAGEdge* edge = hasNonlabeledEdge(srcNode,dstNode, PAGEdge::Addr))
378  return SVFUtil::cast<AddrPE>(edge);
379  else
380  {
381  AddrPE* addrPE = new AddrPE(srcNode, dstNode);
382  addEdge(srcNode,dstNode, addrPE);
383  return addrPE;
384  }
385 }
bool addEdge(PAGNode *src, PAGNode *dst, PAGEdge *edge)
Add an edge into PAG.
Definition: PAG.cpp:754
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513
PAGEdge * hasNonlabeledEdge(PAGNode *src, PAGNode *dst, PAGEdge::PEDGEK kind)
Definition: PAG.cpp:725

◆ addBinaryNode()

void SVF::PAG::addBinaryNode ( const PAGNode res,
const BinaryOPPE edge 
)
inline

Add phi node information.

Definition at line 270 of file PAG.h.

271  {
272  binaryNodeMap[res].push_back(edge);
273  }
BinaryNodeMap binaryNodeMap
A set of binary edges.
Definition: PAG.h:93

◆ addBinaryOPPE()

BinaryOPPE * PAG::addBinaryOPPE ( NodeID  src,
NodeID  dst 
)

Add Copy edge.

Add Compare edge

Definition at line 425 of file PAG.cpp.

426 {
427  PAGNode* srcNode = getPAGNode(src);
428  PAGNode* dstNode = getPAGNode(dst);
429  if(PAGEdge* edge = hasNonlabeledEdge(srcNode,dstNode, PAGEdge::BinaryOp))
430  return SVFUtil::cast<BinaryOPPE>(edge);
431  else
432  {
433  BinaryOPPE* binaryOP = new BinaryOPPE(srcNode, dstNode);
434  addEdge(srcNode,dstNode, binaryOP);
435  return binaryOP;
436  }
437 }
bool addEdge(PAGNode *src, PAGNode *dst, PAGEdge *edge)
Add an edge into PAG.
Definition: PAG.cpp:754
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513
PAGEdge * hasNonlabeledEdge(PAGNode *src, PAGNode *dst, PAGEdge::PEDGEK kind)
Definition: PAG.cpp:725

◆ addBlackHoleAddrPE()

PAGEdge * PAG::addBlackHoleAddrPE ( NodeID  node)

Set a pointer points-to black hole (e.g. int2ptr)

Add blackhole/constant edge

Definition at line 528 of file PAG.cpp.

529 {
531  return pag->addAddrPE(pag->getBlackHoleNode(), node);
532  else
533  return pag->addCopyPE(pag->getNullPtr(), node);
534 }
static PAG * pag
Singleton pattern here to enable instance of PAG can only be created once.
Definition: PAG.h:100
AddrPE * addAddrPE(NodeID src, NodeID dst)
Add Address edge.
Definition: PAG.cpp:373
NodeID getBlackHoleNode() const
Get black hole and constant id.
Definition: PAG.h:589
NodeID getNullPtr() const
Definition: PAG.h:601
CopyPE * addCopyPE(NodeID src, NodeID dst)
Add Copy edge.
Definition: PAG.cpp:390
static llvm::cl::opt< bool > HandBlackHole
Definition: Options.h:66

◆ addBlackholeObjNode()

NodeID SVF::PAG::addBlackholeObjNode ( )
inline

Definition at line 757 of file PAG.h.

758  {
759  return addObjNode(nullptr, new DummyObjPN(getBlackHoleNode(),getBlackHoleObj()), getBlackHoleNode());
760  }
const MemObj * getBlackHoleObj() const
Definition: PAG.h:648
NodeID addObjNode(const Value *val, NodeID i)
Add a memory obj node.
Definition: PAG.h:707
NodeID getBlackHoleNode() const
Get black hole and constant id.
Definition: PAG.h:589

◆ addBlackholePtrNode()

NodeID SVF::PAG::addBlackholePtrNode ( )
inline

Definition at line 765 of file PAG.h.

766  {
767  return addDummyValNode(getBlkPtr());
768  }
NodeID addDummyValNode()
Add a dummy value/object node according to node ID (llvm value is null)
Definition: PAG.h:736
NodeID getBlkPtr() const
Definition: PAG.h:597

◆ addCallPE()

CallPE * PAG::addCallPE ( NodeID  src,
NodeID  dst,
const CallBlockNode cs 
)

Add Call edge.

Add Call edge

Definition at line 494 of file PAG.cpp.

495 {
496  PAGNode* srcNode = getPAGNode(src);
497  PAGNode* dstNode = getPAGNode(dst);
498  if(PAGEdge* edge = hasLabeledEdge(srcNode,dstNode, PAGEdge::Call, cs))
499  return SVFUtil::cast<CallPE>(edge);
500  else
501  {
502  CallPE* callPE = new CallPE(srcNode, dstNode, cs);
503  addEdge(srcNode,dstNode, callPE);
504  return callPE;
505  }
506 }
bool addEdge(PAGNode *src, PAGNode *dst, PAGEdge *edge)
Add an edge into PAG.
Definition: PAG.cpp:754
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513
PAGEdge * hasLabeledEdge(PAGNode *src, PAGNode *dst, PAGEdge::PEDGEK kind, const ICFGNode *cs)
Definition: PAG.cpp:739

◆ addCallSite()

void SVF::PAG::addCallSite ( const CallBlockNode call)
inline

Definition at line 197 of file PAG.h.

198  {
199  callSiteSet.insert(call);
200  }
CallSiteSet callSiteSet
Definition: PAG.h:109

◆ addCallSiteArgs()

void SVF::PAG::addCallSiteArgs ( CallBlockNode callBlockNode,
const PAGNode arg 
)
inline

Add callsite arguments.

Definition at line 333 of file PAG.h.

334  {
335  callBlockNode->addActualParms(arg);
336  callSiteArgsListMap[callBlockNode].push_back(arg);
337  }
CSToArgsListMap callSiteArgsListMap
Map a callsite to a list of all its actual parameters.
Definition: PAG.h:97

◆ addCallSiteRets()

void SVF::PAG::addCallSiteRets ( RetBlockNode retBlockNode,
const PAGNode arg 
)
inline

Add callsite returns.

Definition at line 339 of file PAG.h.

340  {
341  retBlockNode->addActualRet(arg);
342  callSiteRetMap[retBlockNode]= arg;
343  }
CSToRetMap callSiteRetMap
Map a callsite to its callsite returns PAGNodes.
Definition: PAG.h:98

◆ addCmpNode()

void SVF::PAG::addCmpNode ( const PAGNode res,
const CmpPE edge 
)
inline

Add phi node information.

Definition at line 300 of file PAG.h.

301  {
302  cmpNodeMap[res].push_back(edge);
303  }
CmpNodeMap cmpNodeMap
A set of comparision edges.
Definition: PAG.h:95

◆ addCmpPE()

CmpPE * PAG::addCmpPE ( NodeID  src,
NodeID  dst 
)

Add Copy edge.

Add Compare edge

Definition at line 407 of file PAG.cpp.

408 {
409  PAGNode* srcNode = getPAGNode(src);
410  PAGNode* dstNode = getPAGNode(dst);
411  if(PAGEdge* edge = hasNonlabeledEdge(srcNode,dstNode, PAGEdge::Cmp))
412  return SVFUtil::cast<CmpPE>(edge);
413  else
414  {
415  CmpPE* cmp = new CmpPE(srcNode, dstNode);
416  addEdge(srcNode,dstNode, cmp);
417  return cmp;
418  }
419 }
bool addEdge(PAGNode *src, PAGNode *dst, PAGEdge *edge)
Add an edge into PAG.
Definition: PAG.cpp:754
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513
PAGEdge * hasNonlabeledEdge(PAGNode *src, PAGNode *dst, PAGEdge::PEDGEK kind)
Definition: PAG.cpp:725

◆ addConstantObjNode()

NodeID SVF::PAG::addConstantObjNode ( )
inline

Definition at line 761 of file PAG.h.

762  {
763  return addObjNode(nullptr, new DummyObjPN(getConstantNode(),getConstantObj()), getConstantNode());
764  }
NodeID addObjNode(const Value *val, NodeID i)
Add a memory obj node.
Definition: PAG.h:707
const MemObj * getConstantObj() const
Definition: PAG.h:652
NodeID getConstantNode() const
Definition: PAG.h:593

◆ addCopyPE()

CopyPE * PAG::addCopyPE ( NodeID  src,
NodeID  dst 
)

Add Copy edge.

Add Copy edge

Definition at line 390 of file PAG.cpp.

391 {
392  PAGNode* srcNode = getPAGNode(src);
393  PAGNode* dstNode = getPAGNode(dst);
394  if(PAGEdge* edge = hasNonlabeledEdge(srcNode,dstNode, PAGEdge::Copy))
395  return SVFUtil::cast<CopyPE>(edge);
396  else
397  {
398  CopyPE* copyPE = new CopyPE(srcNode, dstNode);
399  addEdge(srcNode,dstNode, copyPE);
400  return copyPE;
401  }
402 }
bool addEdge(PAGNode *src, PAGNode *dst, PAGEdge *edge)
Add an edge into PAG.
Definition: PAG.cpp:754
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513
PAGEdge * hasNonlabeledEdge(PAGNode *src, PAGNode *dst, PAGEdge::PEDGEK kind)
Definition: PAG.cpp:725

◆ addDummyMemObj()

const MemObj* SVF::PAG::addDummyMemObj ( NodeID  i,
const Type type 
)
inline

Definition at line 753 of file PAG.h.

754  {
756  }
const MemObj * createDummyObj(SymID symId, const Type *type)
Can only be invoked by PAG::addDummyNode() when creaing PAG from file.
static SymbolTableInfo * SymbolInfo()
Singleton design here to make sure we only have one instance during any analysis. ...

◆ addDummyObjNode() [1/2]

NodeID SVF::PAG::addDummyObjNode ( const Type type = nullptr)
inline

Definition at line 744 of file PAG.h.

745  {
746  return addDummyObjNode(NodeIDAllocator::get()->allocateObjectId(), type);
747  }
NodeID addDummyObjNode(const Type *type=nullptr)
Definition: PAG.h:744
static NodeIDAllocator * get(void)
Return (singleton) allocator.

◆ addDummyObjNode() [2/2]

NodeID SVF::PAG::addDummyObjNode ( NodeID  i,
const Type type 
)
inline

Definition at line 748 of file PAG.h.

749  {
750  const MemObj* mem = addDummyMemObj(i, type);
751  return addObjNode(nullptr, new DummyObjPN(i,mem), i);
752  }
const MemObj * addDummyMemObj(NodeID i, const Type *type)
Definition: PAG.h:753
NodeID addObjNode(const Value *val, NodeID i)
Add a memory obj node.
Definition: PAG.h:707

◆ addDummyValNode() [1/2]

NodeID SVF::PAG::addDummyValNode ( )
inline

Add a dummy value/object node according to node ID (llvm value is null)

Definition at line 736 of file PAG.h.

737  {
738  return addDummyValNode(NodeIDAllocator::get()->allocateValueId());
739  }
NodeID addDummyValNode()
Add a dummy value/object node according to node ID (llvm value is null)
Definition: PAG.h:736
static NodeIDAllocator * get(void)
Return (singleton) allocator.

◆ addDummyValNode() [2/2]

NodeID SVF::PAG::addDummyValNode ( NodeID  i)
inline

Definition at line 740 of file PAG.h.

741  {
742  return addValNode(nullptr, new DummyValPN(i), i);
743  }
NodeID addValNode(const Value *val, NodeID i)
Add a value (pointer) node.
Definition: PAG.h:701

◆ addEdge()

bool PAG::addEdge ( PAGNode src,
PAGNode dst,
PAGEdge edge 
)

Add an edge into PAG.

Add a PAG edge

Add a PAG edge into edge map

Definition at line 754 of file PAG.cpp.

755 {
756 
758  outs() << "add edge from " << src->getId() << " kind :"
759  << src->getNodeKind() << " to " << dst->getId()
760  << " kind :" << dst->getNodeKind() << "\n");
761  src->addOutEdge(edge);
762  dst->addInEdge(edge);
763  bool added = PAGEdgeKindToSetMap[edge->getEdgeKind()].insert(edge).second;
764  assert(added && "duplicated edge, not added!!!");
765  if (edge->isPTAEdge())
766  {
767  totalPTAPAGEdge++;
768  PTAPAGEdgeKindToSetMap[edge->getEdgeKind()].insert(edge);
769  }
770  return true;
771 }
GEdgeKind getEdgeKind() const
Definition: GenericGraph.h:81
u32_t totalPTAPAGEdge
Definition: PAG.h:118
#define assert(ex)
Definition: util.h:141
PAGEdge::PAGKindToEdgeSetMapTy PTAPAGEdgeKindToSetMap
Definition: PAG.h:85
GNodeK getNodeKind() const
Get node kind.
Definition: GenericGraph.h:170
bool isPTAEdge() const
Whether src and dst nodes are both of pointer type.
Definition: PAG.cpp:1010
PAGEdge::PAGKindToEdgeSetMapTy PAGEdgeKindToSetMap
Definition: PAG.h:84
raw_ostream & outs()
Overwrite llvm::outs()
Definition: SVFUtil.h:47
void addInEdge(PAGEdge *inEdge)
add methods of the components
Definition: PAGNode.h:237
NodeID getId() const
Get ID.
Definition: GenericGraph.h:164
#define DPAGBuild
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DEBUG model of each pass.
void addOutEdge(PAGEdge *outEdge)
Definition: PAGNode.h:244

◆ addFIObjNode()

NodeID PAG::addFIObjNode ( const MemObj obj)

Add a field-insensitive node, this method can only invoked by getFIGepObjNode.

Add a field-insensitive node, this method can only invoked by getFIGepObjNode

Definition at line 712 of file PAG.cpp.

713 {
714  //assert(findPAGNode(i) == false && "this node should not be created before");
715  NodeID base = getObjectNode(obj);
716  memToFieldsMap[base].set(obj->getSymId());
717  FIObjPN *node = new FIObjPN(obj->getRefVal(), obj->getSymId(), obj);
718  return addObjNode(obj->getRefVal(), node, obj->getSymId());
719 }
u32_t NodeID
Definition: SVFBasicTypes.h:80
NodeID addObjNode(const Value *val, NodeID i)
Add a memory obj node.
Definition: PAG.h:707
MemObjToFieldsMap memToFieldsMap
Map a mem object id to all its fields.
Definition: PAG.h:90
NodeID getObjectNode(const Value *V)
Definition: PAG.h:531
const Value * getRefVal() const
Get the reference value to this object.
Definition: MemModel.h:325
SymID getSymId() const
Get the memory object id.
Definition: MemModel.h:331

◆ addFunArgs()

void SVF::PAG::addFunArgs ( const SVFFunction fun,
const PAGNode arg 
)
inline

Get/set method for function/callsite arguments and returns.

Add function arguments

Definition at line 319 of file PAG.h.

320  {
321  FunEntryBlockNode* funEntryBlockNode = icfg->getFunEntryBlockNode(fun);
322  funEntryBlockNode->addFormalParms(arg);
323  funArgsListMap[fun].push_back(arg);
324  }
ICFG * icfg
Definition: PAG.h:108
void addFormalParms(const PAGNode *fp)
Add formal parameters.
Definition: ICFGNode.h:274
FunToArgsListMap funArgsListMap
Map a function to a list of all its formal parameters.
Definition: PAG.h:96
FunEntryBlockNode * getFunEntryBlockNode(const SVFFunction *fun)
Add a function entry node.
Definition: ICFG.cpp:230

◆ addFunRet()

void SVF::PAG::addFunRet ( const SVFFunction fun,
const PAGNode ret 
)
inline

Add function returns.

Definition at line 326 of file PAG.h.

327  {
328  FunExitBlockNode* funExitBlockNode = icfg->getFunExitBlockNode(fun);
329  funExitBlockNode->addFormalRet(ret);
330  funRetMap[fun] = ret;
331  }
FunToRetMap funRetMap
Map a function to its unique function return PAGNodes.
Definition: PAG.h:99
ICFG * icfg
Definition: PAG.h:108
FunExitBlockNode * getFunExitBlockNode(const SVFFunction *fun)
Add a function exit node.
Definition: ICFG.cpp:239
void addFormalRet(const PAGNode *fr)
Add actual return parameter.
Definition: ICFGNode.h:330

◆ addGepObjNode()

NodeID PAG::addGepObjNode ( const MemObj obj,
const LocationSet ls 
)

Add a field obj node, this method can only invoked by getGepObjNode.

Add a field obj node, this method can only invoked by getGepObjNode

Definition at line 695 of file PAG.cpp.

696 {
697  //assert(findPAGNode(i) == false && "this node should not be created before");
698  NodeID base = getObjectNode(obj);
699  assert(0==GepObjNodeMap.count(std::make_pair(base, ls))
700  && "this node should not be created before");
701 
703  GepObjNodeMap[std::make_pair(base, ls)] = gepId;
704  GepObjPN *node = new GepObjPN(obj, gepId, ls);
705  memToFieldsMap[base].set(gepId);
706  return addObjNode(obj->getRefVal(), node, gepId);
707 }
u32_t NodeID
Definition: SVFBasicTypes.h:80
#define assert(ex)
Definition: util.h:141
NodeID addObjNode(const Value *val, NodeID i)
Add a memory obj node.
Definition: PAG.h:707
MemObjToFieldsMap memToFieldsMap
Map a mem object id to all its fields.
Definition: PAG.h:90
NodeID getObjectNode(const Value *V)
Definition: PAG.h:531
NodeID allocateGepObjectId(NodeID base, u32_t offset, u32_t maxFieldLimit)
const Value * getRefVal() const
Get the reference value to this object.
Definition: MemModel.h:325
static u32_t getMaxFieldLimit()
Definition: MemModel.h:88
Size_t getOffset() const
Get methods.
Definition: LocationSet.h:194
static NodeIDAllocator * get(void)
Return (singleton) allocator.
NodeLocationSetMap GepObjNodeMap
Map a pair<base,off> to a gep obj node id.
Definition: PAG.h:89

◆ addGepPE()

GepPE * PAG::addGepPE ( NodeID  src,
NodeID  dst,
const LocationSet ls,
bool  constGep 
)

Add Gep edge.

Add Offset(Gep) edge Find the base node id of src and connect base node to dst node Create gep offset: (offset + baseOff <nested struct="" gep="" size>="">)

Since the offset from base to src is variant, the new gep edge being created is also a VariantGepPE edge.

Definition at line 576 of file PAG.cpp.

577 {
578 
579  PAGNode* node = getPAGNode(src);
580  if (!constGep || node->hasIncomingVariantGepEdge())
581  {
584  return addVariantGepPE(src, dst);
585  }
586  else
587  {
588  return addNormalGepPE(src, dst, ls);
589  }
590 }
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513
NormalGepPE * addNormalGepPE(NodeID src, NodeID dst, const LocationSet &ls)
Add Offset(Gep) edge.
Definition: PAG.cpp:595
VariantGepPE * addVariantGepPE(NodeID src, NodeID dst)
Add Variant(Gep) edge.
Definition: PAG.cpp:614
bool hasIncomingVariantGepEdge() const
Has incoming VariantGepEdges.
Definition: PAGNode.h:182

◆ addGepValNode()

NodeID PAG::addGepValNode ( const Value curInst,
const Value gepVal,
const LocationSet ls,
NodeID  i,
const Type type,
u32_t  fieldidx 
)

Add a temp field value node, this method can only invoked by getGepValNode.

Add a temp field value node, this method can only invoked by getGepValNode due to constaint expression, curInst is used to distinguish different instructions (e.g., memorycpy) when creating GepValPN.

Definition at line 635 of file PAG.cpp.

636 {
637  NodeID base = getBaseValNode(getValueNode(gepVal));
638  //assert(findPAGNode(i) == false && "this node should not be created before");
639  assert(0==GepValNodeMap[curInst].count(std::make_pair(base, ls))
640  && "this node should not be created before");
641  GepValNodeMap[curInst][std::make_pair(base, ls)] = i;
642  GepValPN *node = new GepValPN(gepVal, i, ls, type, fieldidx);
643  return addValNode(gepVal, node, i);
644 }
NodeID addValNode(const Value *val, NodeID i)
Add a value (pointer) node.
Definition: PAG.h:701
NodeID getValueNode(const Value *V)
Get PAG Node according to LLVM value.
Definition: PAG.h:521
NodeID getBaseValNode(NodeID nodeId)
Base and Offset methods for Value and Object node.
Definition: PAG.cpp:818
u32_t NodeID
Definition: SVFBasicTypes.h:80
#define assert(ex)
Definition: util.h:141
GepValPNMap GepValNodeMap
Map a pair<base,off> to a gep value node id.
Definition: PAG.h:88

◆ addGlobalPAGEdge()

void SVF::PAG::addGlobalPAGEdge ( const PAGEdge edge)
inline

Get global PAGEdges (not in a procedure)

Definition at line 245 of file PAG.h.

246  {
247  globPAGEdgesSet.insert(edge);
248  }
PAGEdgeSet globPAGEdgesSet
Global PAGEdges without control flow information.
Definition: PAG.h:91

◆ addIndirectCallsites()

void SVF::PAG::addIndirectCallsites ( const CallBlockNode cs,
NodeID  funPtr 
)
inline

Definition at line 462 of file PAG.h.

463  {
464  bool added = indCallSiteToFunPtrMap.insert(std::make_pair(cs,funPtr)).second;
465  funPtrToCallSitesMap[funPtr].insert(cs);
466  assert(added && "adding the same indirect callsite twice?");
467  }
CallSiteToFunPtrMap indCallSiteToFunPtrMap
Map an indirect callsite to its function pointer.
Definition: PAG.h:101
#define assert(ex)
Definition: util.h:141
FunPtrToCallSitesMap funPtrToCallSitesMap
Map a function pointer to the callsites where it is used.
Definition: PAG.h:102

◆ addLoadPE()

LoadPE * PAG::addLoadPE ( NodeID  src,
NodeID  dst 
)

Add Load edge.

Add Load edge

Definition at line 459 of file PAG.cpp.

460 {
461  PAGNode* srcNode = getPAGNode(src);
462  PAGNode* dstNode = getPAGNode(dst);
463  if(PAGEdge* edge = hasNonlabeledEdge(srcNode,dstNode, PAGEdge::Load))
464  return SVFUtil::cast<LoadPE>(edge);
465  else
466  {
467  LoadPE* loadPE = new LoadPE(srcNode, dstNode);
468  addEdge(srcNode,dstNode, loadPE);
469  return loadPE;
470  }
471 }
bool addEdge(PAGNode *src, PAGNode *dst, PAGEdge *edge)
Add an edge into PAG.
Definition: PAG.cpp:754
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513
PAGEdge * hasNonlabeledEdge(PAGNode *src, PAGNode *dst, PAGEdge::PEDGEK kind)
Definition: PAG.cpp:725

◆ addNode()

NodeID SVF::PAG::addNode ( PAGNode node,
NodeID  i 
)
inline

add node into PAG

Add a PAG node into Node map

Definition at line 695 of file PAG.h.

696  {
697  addGNode(i,node);
698  return i;
699  }
void addGNode(NodeID id, NodeType *node)
Add a Node.
Definition: GenericGraph.h:384

◆ addNormalGepPE()

NormalGepPE * PAG::addNormalGepPE ( NodeID  src,
NodeID  dst,
const LocationSet ls 
)

Add Offset(Gep) edge.

Add normal (Gep) edge

Definition at line 595 of file PAG.cpp.

596 {
597  const LocationSet& baseLS = getLocationSetFromBaseNode(src);
598  PAGNode* baseNode = getPAGNode(getBaseValNode(src));
599  PAGNode* dstNode = getPAGNode(dst);
600  if(PAGEdge* edge = hasNonlabeledEdge(baseNode, dstNode, PAGEdge::NormalGep))
601  return SVFUtil::cast<NormalGepPE>(edge);
602  else
603  {
604  NormalGepPE* gepPE = new NormalGepPE(baseNode, dstNode, ls+baseLS);
605  addEdge(baseNode, dstNode, gepPE);
606  return gepPE;
607  }
608 }
NodeID getBaseValNode(NodeID nodeId)
Base and Offset methods for Value and Object node.
Definition: PAG.cpp:818
bool addEdge(PAGNode *src, PAGNode *dst, PAGEdge *edge)
Add an edge into PAG.
Definition: PAG.cpp:754
LocationSet getLocationSetFromBaseNode(NodeID nodeId)
Definition: PAG.cpp:847
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513
PAGEdge * hasNonlabeledEdge(PAGNode *src, PAGNode *dst, PAGEdge::PEDGEK kind)
Definition: PAG.cpp:725

◆ addObjNode() [1/2]

NodeID SVF::PAG::addObjNode ( const Value val,
NodeID  i 
)
inline

Add a memory obj node.

Definition at line 707 of file PAG.h.

708  {
709  MemObj* mem = symInfo->getObj(symInfo->getObjSym(val));
710  assert(((mem->getSymId() == i) || (symInfo->getGlobalRep(val)!=val)) && "not same object id?");
711  return addFIObjNode(mem);
712  }
#define assert(ex)
Definition: util.h:141
const Value * getGlobalRep(const Value *val) const
find the unique defined global across multiple modules
MemObj * getObj(SymID id) const
SymID getObjSym(const Value *val) const
NodeID addFIObjNode(const MemObj *obj)
Add a field-insensitive node, this method can only invoked by getFIGepObjNode.
Definition: PAG.cpp:712
SymbolTableInfo * symInfo
Definition: PAG.h:81

◆ addObjNode() [2/2]

NodeID SVF::PAG::addObjNode ( const Value ,
PAGNode node,
NodeID  i 
)
inline

Add a memory obj node.

Definition at line 778 of file PAG.h.

779  {
780  assert(hasGNode(i) == false && "This NodeID clashes here. Please check NodeIDAllocator. Switch Strategy::DEBUG to SEQ or DENSE");
781  return addNode(node,i);
782  }
#define assert(ex)
Definition: util.h:141
bool hasGNode(NodeID id) const
Has a node.
Definition: GenericGraph.h:399
NodeID addNode(PAGNode *node, NodeID i)
add node into PAG
Definition: PAG.h:695

◆ addPhiNode()

void SVF::PAG::addPhiNode ( const PAGNode res,
const CopyPE edge 
)
inline

Add phi node information.

Definition at line 255 of file PAG.h.

256  {
257  phiNodeMap[res].push_back(edge);
258  }
PHINodeMap phiNodeMap
A set of phi copy edges.
Definition: PAG.h:92

◆ addRetNode() [1/2]

NodeID SVF::PAG::addRetNode ( const SVFFunction val,
NodeID  i 
)
inline

Add a unique return node for a procedure.

Definition at line 714 of file PAG.h.

715  {
716  PAGNode *node = new RetPN(val,i);
717  return addRetNode(val, node, i);
718  }
NodeID addRetNode(const SVFFunction *val, NodeID i)
Add a unique return node for a procedure.
Definition: PAG.h:714

◆ addRetNode() [2/2]

NodeID SVF::PAG::addRetNode ( const SVFFunction ,
PAGNode node,
NodeID  i 
)
inline

Add a unique return node for a procedure.

Definition at line 784 of file PAG.h.

785  {
786  return addNode(node,i);
787  }
NodeID addNode(PAGNode *node, NodeID i)
add node into PAG
Definition: PAG.h:695

◆ addRetPE()

RetPE * PAG::addRetPE ( NodeID  src,
NodeID  dst,
const CallBlockNode cs 
)

Add Return edge.

Add Return edge

Definition at line 511 of file PAG.cpp.

512 {
513  PAGNode* srcNode = getPAGNode(src);
514  PAGNode* dstNode = getPAGNode(dst);
515  if(PAGEdge* edge = hasLabeledEdge(srcNode,dstNode, PAGEdge::Ret, cs))
516  return SVFUtil::cast<RetPE>(edge);
517  else
518  {
519  RetPE* retPE = new RetPE(srcNode, dstNode, cs);
520  addEdge(srcNode,dstNode, retPE);
521  return retPE;
522  }
523 }
bool addEdge(PAGNode *src, PAGNode *dst, PAGEdge *edge)
Add an edge into PAG.
Definition: PAG.cpp:754
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513
PAGEdge * hasLabeledEdge(PAGNode *src, PAGNode *dst, PAGEdge::PEDGEK kind, const ICFGNode *cs)
Definition: PAG.cpp:739

◆ addStorePE()

StorePE * PAG::addStorePE ( NodeID  src,
NodeID  dst,
const IntraBlockNode curVal 
)

Add Store edge.

Add Store edge Note that two store instructions may share the same Store PAGEdge

Definition at line 477 of file PAG.cpp.

478 {
479  PAGNode* srcNode = getPAGNode(src);
480  PAGNode* dstNode = getPAGNode(dst);
481  if(PAGEdge* edge = hasLabeledEdge(srcNode,dstNode, PAGEdge::Store, curVal))
482  return SVFUtil::cast<StorePE>(edge);
483  else
484  {
485  StorePE* storePE = new StorePE(srcNode, dstNode, curVal);
486  addEdge(srcNode,dstNode, storePE);
487  return storePE;
488  }
489 }
bool addEdge(PAGNode *src, PAGNode *dst, PAGEdge *edge)
Add an edge into PAG.
Definition: PAG.cpp:754
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513
PAGEdge * hasLabeledEdge(PAGNode *src, PAGNode *dst, PAGEdge::PEDGEK kind, const ICFGNode *cs)
Definition: PAG.cpp:739

◆ addThreadForkPE()

TDForkPE * PAG::addThreadForkPE ( NodeID  src,
NodeID  dst,
const CallBlockNode cs 
)

Add Thread fork edge for parameter passing.

Add Thread fork edge for parameter passing from a spawner to its spawnees

Definition at line 539 of file PAG.cpp.

540 {
541  PAGNode* srcNode = getPAGNode(src);
542  PAGNode* dstNode = getPAGNode(dst);
543  if(PAGEdge* edge = hasLabeledEdge(srcNode,dstNode, PAGEdge::ThreadFork, cs))
544  return SVFUtil::cast<TDForkPE>(edge);
545  else
546  {
547  TDForkPE* forkPE = new TDForkPE(srcNode, dstNode, cs);
548  addEdge(srcNode,dstNode, forkPE);
549  return forkPE;
550  }
551 }
bool addEdge(PAGNode *src, PAGNode *dst, PAGEdge *edge)
Add an edge into PAG.
Definition: PAG.cpp:754
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513
PAGEdge * hasLabeledEdge(PAGNode *src, PAGNode *dst, PAGEdge::PEDGEK kind, const ICFGNode *cs)
Definition: PAG.cpp:739

◆ addThreadJoinPE()

TDJoinPE * PAG::addThreadJoinPE ( NodeID  src,
NodeID  dst,
const CallBlockNode cs 
)

Add Thread join edge for parameter passing.

Add Thread fork edge for parameter passing from a spawnee back to its spawners

Definition at line 556 of file PAG.cpp.

557 {
558  PAGNode* srcNode = getPAGNode(src);
559  PAGNode* dstNode = getPAGNode(dst);
560  if(PAGEdge* edge = hasLabeledEdge(srcNode,dstNode, PAGEdge::ThreadJoin, cs))
561  return SVFUtil::cast<TDJoinPE>(edge);
562  else
563  {
564  TDJoinPE* joinPE = new TDJoinPE(srcNode, dstNode, cs);
565  addEdge(srcNode,dstNode, joinPE);
566  return joinPE;
567  }
568 }
bool addEdge(PAGNode *src, PAGNode *dst, PAGEdge *edge)
Add an edge into PAG.
Definition: PAG.cpp:754
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513
PAGEdge * hasLabeledEdge(PAGNode *src, PAGNode *dst, PAGEdge::PEDGEK kind, const ICFGNode *cs)
Definition: PAG.cpp:739

◆ addToInstPAGEdgeList()

void SVF::PAG::addToInstPAGEdgeList ( ICFGNode inst,
PAGEdge edge 
)
inline

Add a PAGEdge into instruction map.

Definition at line 237 of file PAG.h.

238  {
239  edge->setICFGNode(inst);
240  inst2PAGEdgesMap[inst].push_back(edge);
241  if (edge->isPTAEdge())
242  inst2PTAPAGEdgesMap[inst].push_back(edge);
243  }
Inst2PAGEdgesMap inst2PTAPAGEdgesMap
Map a instruction to its PointerAnalysis related PAGEdges.
Definition: PAG.h:87
Inst2PAGEdgesMap inst2PAGEdgesMap
Map a instruction to its PAGEdges.
Definition: PAG.h:86

◆ addUnaryNode()

void SVF::PAG::addUnaryNode ( const PAGNode res,
const UnaryOPPE edge 
)
inline

Add unary node information.

Definition at line 285 of file PAG.h.

286  {
287  unaryNodeMap[res].push_back(edge);
288  }
UnaryNodeMap unaryNodeMap
A set of unary edges.
Definition: PAG.h:94

◆ addUnaryOPPE()

UnaryOPPE * PAG::addUnaryOPPE ( NodeID  src,
NodeID  dst 
)

Add Unary edge.

Add Unary edge

Definition at line 442 of file PAG.cpp.

443 {
444  PAGNode* srcNode = getPAGNode(src);
445  PAGNode* dstNode = getPAGNode(dst);
446  if(PAGEdge* edge = hasNonlabeledEdge(srcNode,dstNode, PAGEdge::UnaryOp))
447  return SVFUtil::cast<UnaryOPPE>(edge);
448  else
449  {
450  UnaryOPPE* unaryOP = new UnaryOPPE(srcNode, dstNode);
451  addEdge(srcNode,dstNode, unaryOP);
452  return unaryOP;
453  }
454 }
bool addEdge(PAGNode *src, PAGNode *dst, PAGEdge *edge)
Add an edge into PAG.
Definition: PAG.cpp:754
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513
PAGEdge * hasNonlabeledEdge(PAGNode *src, PAGNode *dst, PAGEdge::PEDGEK kind)
Definition: PAG.cpp:725

◆ addValNode() [1/2]

NodeID SVF::PAG::addValNode ( const Value val,
NodeID  i 
)
inline

Add a value (pointer) node.

Definition at line 701 of file PAG.h.

702  {
703  PAGNode *node = new ValPN(val,i);
704  return addValNode(val, node, i);
705  }
NodeID addValNode(const Value *val, NodeID i)
Add a value (pointer) node.
Definition: PAG.h:701

◆ addValNode() [2/2]

NodeID SVF::PAG::addValNode ( const Value ,
PAGNode node,
NodeID  i 
)
inline

Add a value (pointer) node.

Definition at line 772 of file PAG.h.

773  {
774  assert(hasGNode(i) == false && "This NodeID clashes here. Please check NodeIDAllocator. Switch Strategy::DEBUG to SEQ or DENSE");
775  return addNode(node,i);
776  }
#define assert(ex)
Definition: util.h:141
bool hasGNode(NodeID id) const
Has a node.
Definition: GenericGraph.h:399
NodeID addNode(PAGNode *node, NodeID i)
add node into PAG
Definition: PAG.h:695

◆ addVarargNode() [1/2]

NodeID SVF::PAG::addVarargNode ( const SVFFunction val,
NodeID  i 
)
inline

Add a unique vararg node for a procedure.

Definition at line 720 of file PAG.h.

721  {
722  PAGNode *node = new VarArgPN(val,i);
723  return addNode(node,i);
724  }
NodeID addNode(PAGNode *node, NodeID i)
add node into PAG
Definition: PAG.h:695

◆ addVarargNode() [2/2]

NodeID SVF::PAG::addVarargNode ( const SVFFunction ,
PAGNode node,
NodeID  i 
)
inline

Add a unique vararg node for a procedure.

Definition at line 789 of file PAG.h.

790  {
791  return addNode(node,i);
792  }
NodeID addNode(PAGNode *node, NodeID i)
add node into PAG
Definition: PAG.h:695

◆ addVariantGepPE()

VariantGepPE * PAG::addVariantGepPE ( NodeID  src,
NodeID  dst 
)

Add Variant(Gep) edge.

Add variant(Gep) edge Find the base node id of src and connect base node to dst node

Definition at line 614 of file PAG.cpp.

615 {
616 
617  PAGNode* baseNode = getPAGNode(getBaseValNode(src));
618  PAGNode* dstNode = getPAGNode(dst);
619  if(PAGEdge* edge = hasNonlabeledEdge(baseNode, dstNode, PAGEdge::VariantGep))
620  return SVFUtil::cast<VariantGepPE>(edge);
621  else
622  {
623  VariantGepPE* gepPE = new VariantGepPE(baseNode, dstNode);
624  addEdge(baseNode, dstNode, gepPE);
625  return gepPE;
626  }
627 }
NodeID getBaseValNode(NodeID nodeId)
Base and Offset methods for Value and Object node.
Definition: PAG.cpp:818
bool addEdge(PAGNode *src, PAGNode *dst, PAGEdge *edge)
Add an edge into PAG.
Definition: PAG.cpp:754
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513
PAGEdge * hasNonlabeledEdge(PAGNode *src, PAGNode *dst, PAGEdge::PEDGEK kind)
Definition: PAG.cpp:725

◆ callsiteHasRet()

bool SVF::PAG::callsiteHasRet ( const RetBlockNode cs) const
inline

Definition at line 390 of file PAG.h.

391  {
392  return callSiteRetMap.find(cs) != callSiteRetMap.end();
393  }
CSToRetMap callSiteRetMap
Map a callsite to its callsite returns PAGNodes.
Definition: PAG.h:98

◆ destroy()

void PAG::destroy ( )
private

Clean up memory.

Clean up memory

Definition at line 866 of file PAG.cpp.

867 {
868  for (PAGEdge::PAGKindToEdgeSetMapTy::iterator I =
869  PAGEdgeKindToSetMap.begin(), E = PAGEdgeKindToSetMap.end(); I != E;
870  ++I)
871  {
872  for (PAGEdge::PAGEdgeSetTy::iterator edgeIt = I->second.begin(),
873  endEdgeIt = I->second.end(); edgeIt != endEdgeIt; ++edgeIt)
874  {
875  delete *edgeIt;
876  }
877  }
879  symInfo = nullptr;
880 }
PAGEdge::PAGKindToEdgeSetMapTy PAGEdgeKindToSetMap
Definition: PAG.h:84
static void releaseSymbolInfo()
SymbolTableInfo * symInfo
Definition: PAG.h:81

◆ dump()

void PAG::dump ( std::string  name)

Dump PAG.

Dump this PAG

Definition at line 1081 of file PAG.cpp.

1082 {
1083  GraphPrinter::WriteGraphToFile(outs(), name, this);
1084 }
raw_ostream & outs()
Overwrite llvm::outs()
Definition: SVFUtil.h:47
static void WriteGraphToFile(llvm::raw_ostream &O, const std::string &GraphName, const GraphType &GT, bool simple=false)
Definition: GraphPrinter.h:56

◆ findPAGNode()

bool SVF::PAG::findPAGNode ( NodeID  id) const
inline

Get a pag node according to its ID.

Definition at line 491 of file PAG.h.

492  {
493  return hasGNode(id);
494  }
bool hasGNode(NodeID id) const
Has a node.
Definition: GenericGraph.h:399

◆ funHasRet()

bool SVF::PAG::funHasRet ( const SVFFunction func) const
inline

Definition at line 406 of file PAG.h.

407  {
408  return funRetMap.find(func) != funRetMap.end();
409  }
FunToRetMap funRetMap
Map a function to its unique function return PAGNodes.
Definition: PAG.h:99

◆ getAllFieldsObjNode() [1/2]

NodeBS & PAG::getAllFieldsObjNode ( const MemObj obj)

Get all fields of an object.

Get all fields object nodes of an object

Definition at line 776 of file PAG.cpp.

777 {
778  NodeID base = getObjectNode(obj);
779  return memToFieldsMap[base];
780 }
u32_t NodeID
Definition: SVFBasicTypes.h:80
MemObjToFieldsMap memToFieldsMap
Map a mem object id to all its fields.
Definition: PAG.h:90
NodeID getObjectNode(const Value *V)
Definition: PAG.h:531

◆ getAllFieldsObjNode() [2/2]

NodeBS & PAG::getAllFieldsObjNode ( NodeID  id)

Get all fields object nodes of an object

Definition at line 785 of file PAG.cpp.

786 {
787  const PAGNode* node = pag->getPAGNode(id);
788  assert(SVFUtil::isa<ObjPN>(node) && "need an object node");
789  const ObjPN* obj = SVFUtil::cast<ObjPN>(node);
790  return getAllFieldsObjNode(obj->getMemObj());
791 }
static PAG * pag
Singleton pattern here to enable instance of PAG can only be created once.
Definition: PAG.h:100
const MemObj * getMemObj() const
Return memory object.
Definition: PAGNode.h:359
#define assert(ex)
Definition: util.h:141
NodeBS & getAllFieldsObjNode(const MemObj *obj)
Get all fields of an object.
Definition: PAG.cpp:776
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513

◆ getAllValidPtrs()

OrderedNodeSet& SVF::PAG::getAllValidPtrs ( )
inline

Return valid pointers.

Definition at line 139 of file PAG.h.

140  {
141  return candidatePointers;
142  }
OrderedNodeSet candidatePointers
Definition: PAG.h:106

◆ getBaseObj()

const MemObj* SVF::PAG::getBaseObj ( NodeID  id) const
inline

Definition at line 676 of file PAG.h.

677  {
678  const PAGNode* node = pag->getPAGNode(id);
679  assert(SVFUtil::isa<ObjPN>(node) && "need an object node");
680  const ObjPN* obj = SVFUtil::cast<ObjPN>(node);
681  return obj->getMemObj();
682  }
static PAG * pag
Singleton pattern here to enable instance of PAG can only be created once.
Definition: PAG.h:100
#define assert(ex)
Definition: util.h:141
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513

◆ getBaseObjNode()

NodeID SVF::PAG::getBaseObjNode ( NodeID  id) const
inline

Definition at line 672 of file PAG.h.

673  {
674  return getBaseObj(id)->getSymId();
675  }
SymID getSymId() const
Get the memory object id.
Definition: MemModel.h:331
const MemObj * getBaseObj(NodeID id) const
Definition: PAG.h:676

◆ getBaseValNode()

NodeID PAG::getBaseValNode ( NodeID  nodeId)

Base and Offset methods for Value and Object node.

Get a base pointer node given a field pointer

Get a base pointer given a pointer Return the source node of its connected gep edge if this pointer has Otherwise return the node id itself

Definition at line 818 of file PAG.cpp.

819 {
820  PAGNode* node = getPAGNode(nodeId);
822  {
825 
826  assert(((ngeps.size()+vgeps.size())==1) && "one node can only be connected by at most one gep edge!");
827 
829  if(!ngeps.empty())
830  it = ngeps.begin();
831  else
832  it = vgeps.begin();
833 
834  assert(SVFUtil::isa<GepPE>(*it) && "not a gep edge??");
835  return (*it)->getSrcID();
836  }
837  else
838  return nodeId;
839 }
bool hasIncomingEdges(PAGEdge::PEDGEK kind) const
Has incoming PAG edges.
Definition: PAGNode.h:172
#define assert(ex)
Definition: util.h:141
GenericNode< PAGNode, PAGEdge >::GEdgeSetTy PAGEdgeSetTy
Definition: PAGEdge.h:169
PAGEdge::PAGEdgeSetTy & getIncomingEdges(PAGEdge::PEDGEK kind)
Get incoming PAG edges.
Definition: PAGNode.h:160
GEdgeSetTy::iterator iterator
Definition: GenericGraph.h:139
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513

◆ getBinaryNodeMap()

BinaryNodeMap& SVF::PAG::getBinaryNodeMap ( )
inline

Get all phi copy edges.

Definition at line 280 of file PAG.h.

281  {
282  return binaryNodeMap;
283  }
BinaryNodeMap binaryNodeMap
A set of binary edges.
Definition: PAG.h:93

◆ getBlackHoleNode()

NodeID SVF::PAG::getBlackHoleNode ( ) const
inline

Get black hole and constant id.

Definition at line 589 of file PAG.h.

590  {
591  return symInfo->blackholeSymID();
592  }
SymID blackholeSymID() const
SymbolTableInfo * symInfo
Definition: PAG.h:81

◆ getBlackHoleObj()

const MemObj* SVF::PAG::getBlackHoleObj ( ) const
inline

Definition at line 648 of file PAG.h.

649  {
650  return symInfo->getBlkObj();
651  }
MemObj * getBlkObj() const
SymbolTableInfo * symInfo
Definition: PAG.h:81

◆ getBlkPtr()

NodeID SVF::PAG::getBlkPtr ( ) const
inline

Definition at line 597 of file PAG.h.

598  {
599  return symInfo->blkPtrSymID();
600  }
SymID blkPtrSymID() const
SymbolTableInfo * symInfo
Definition: PAG.h:81

◆ getCallSiteArgsList()

const PAGNodeList& SVF::PAG::getCallSiteArgsList ( const CallBlockNode cs) const
inline

Get callsite argument list.

Definition at line 372 of file PAG.h.

373  {
374  CSToArgsListMap::const_iterator it = callSiteArgsListMap.find(cs);
375  assert(it != callSiteArgsListMap.end() && "this call site doesn't have arguments");
376  return it->second;
377  }
#define assert(ex)
Definition: util.h:141
CSToArgsListMap callSiteArgsListMap
Map a callsite to a list of all its actual parameters.
Definition: PAG.h:97

◆ getCallSiteArgsMap()

CSToArgsListMap& SVF::PAG::getCallSiteArgsMap ( )
inline

Get callsite argument list.

Definition at line 367 of file PAG.h.

368  {
369  return callSiteArgsListMap;
370  }
CSToArgsListMap callSiteArgsListMap
Map a callsite to a list of all its actual parameters.
Definition: PAG.h:97

◆ getCallSiteRet()

const PAGNode* SVF::PAG::getCallSiteRet ( const RetBlockNode cs) const
inline

Get callsite return.

Definition at line 384 of file PAG.h.

385  {
386  CSToRetMap::const_iterator it = callSiteRetMap.find(cs);
387  assert(it != callSiteRetMap.end() && "this call site doesn't have return");
388  return it->second;
389  }
#define assert(ex)
Definition: util.h:141
CSToRetMap callSiteRetMap
Map a callsite to its callsite returns PAGNodes.
Definition: PAG.h:98

◆ getCallSiteRets()

CSToRetMap& SVF::PAG::getCallSiteRets ( )
inline

Get callsite return.

Definition at line 379 of file PAG.h.

380  {
381  return callSiteRetMap;
382  }
CSToRetMap callSiteRetMap
Map a callsite to its callsite returns PAGNodes.
Definition: PAG.h:98

◆ getCallSiteSet()

const CallSiteSet& SVF::PAG::getCallSiteSet ( ) const
inline

Definition at line 201 of file PAG.h.

202  {
203  return callSiteSet;
204  }
CallSiteSet callSiteSet
Definition: PAG.h:109

◆ getCmpNodeMap()

CmpNodeMap& SVF::PAG::getCmpNodeMap ( )
inline

Get all phi copy edges.

Definition at line 310 of file PAG.h.

311  {
312  return cmpNodeMap;
313  }
CmpNodeMap cmpNodeMap
A set of comparision edges.
Definition: PAG.h:95

◆ getConstantNode()

NodeID SVF::PAG::getConstantNode ( ) const
inline

Definition at line 593 of file PAG.h.

594  {
595  return symInfo->constantSymID();
596  }
SymID constantSymID() const
SymbolTableInfo * symInfo
Definition: PAG.h:81

◆ getConstantObj()

const MemObj* SVF::PAG::getConstantObj ( ) const
inline

Definition at line 652 of file PAG.h.

653  {
654  return symInfo->getConstantObj();
655  }
MemObj * getConstantObj() const
SymbolTableInfo * symInfo
Definition: PAG.h:81

◆ getEdgeSet()

PAGEdge::PAGEdgeSetTy& SVF::PAG::getEdgeSet ( PAGEdge::PEDGEK  kind)
inline

Get/set methods to get control flow information of a PAGEdge.

Get edges set according to its kind

Definition at line 208 of file PAG.h.

209  {
210  return PAGEdgeKindToSetMap[kind];
211  }
PAGEdge::PAGKindToEdgeSetMapTy PAGEdgeKindToSetMap
Definition: PAG.h:84

◆ getFieldObjNodeNum()

Size_t SVF::PAG::getFieldObjNodeNum ( ) const
inline

Definition at line 434 of file PAG.h.

435  {
436  return GepObjNodeMap.size();
437  }
NodeLocationSetMap GepObjNodeMap
Map a pair<base,off> to a gep obj node id.
Definition: PAG.h:89

◆ getFieldsAfterCollapse()

NodeBS PAG::getFieldsAfterCollapse ( NodeID  id)

Get all fields object nodes of an object If this object is collapsed into one field insensitive object Then only return this field insensitive object

Definition at line 798 of file PAG.cpp.

799 {
800  const PAGNode* node = pag->getPAGNode(id);
801  assert(SVFUtil::isa<ObjPN>(node) && "need an object node");
802  const MemObj* mem = SVFUtil::cast<ObjPN>(node)->getMemObj();
803  if(mem->isFieldInsensitive())
804  {
805  NodeBS bs;
806  bs.set(getFIObjNode(mem));
807  return bs;
808  }
809  else
810  return getAllFieldsObjNode(mem);
811 }
static PAG * pag
Singleton pattern here to enable instance of PAG can only be created once.
Definition: PAG.h:100
#define assert(ex)
Definition: util.h:141
bool isFieldInsensitive() const
Return true if its field limit is 0.
Definition: MemModel.h:337
NodeID getFIObjNode(const MemObj *obj) const
Get a field-insensitive obj PAG node according to a mem obj.
Definition: PAG.h:574
NodeBS & getAllFieldsObjNode(const MemObj *obj)
Get all fields of an object.
Definition: PAG.cpp:776
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513
llvm::SparseBitVector NodeBS
Definition: SVFBasicTypes.h:87

◆ getFieldValNodeNum()

Size_t SVF::PAG::getFieldValNodeNum ( ) const
inline

Definition at line 430 of file PAG.h.

431  {
432  return GepValNodeMap.size();
433  }
GepValPNMap GepValNodeMap
Map a pair<base,off> to a gep value node id.
Definition: PAG.h:88

◆ getFIObjNode() [1/2]

NodeID SVF::PAG::getFIObjNode ( const MemObj obj) const
inline

Get a field-insensitive obj PAG node according to a mem obj.

Definition at line 574 of file PAG.h.

575  {
576  return obj->getSymId();
577  }

◆ getFIObjNode() [2/2]

NodeID SVF::PAG::getFIObjNode ( NodeID  id) const
inline

Definition at line 578 of file PAG.h.

579  {
580  PAGNode* node = pag->getPAGNode(id);
581  assert(SVFUtil::isa<ObjPN>(node) && "need an object node");
582  ObjPN* obj = SVFUtil::cast<ObjPN>(node);
583  return getFIObjNode(obj->getMemObj());
584  }
static PAG * pag
Singleton pattern here to enable instance of PAG can only be created once.
Definition: PAG.h:100
#define assert(ex)
Definition: util.h:141
NodeID getFIObjNode(const MemObj *obj) const
Get a field-insensitive obj PAG node according to a mem obj.
Definition: PAG.h:574
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513

◆ getFunArgsList()

const PAGNodeList& SVF::PAG::getFunArgsList ( const SVFFunction func) const
inline

Get function arguments list.

Definition at line 355 of file PAG.h.

356  {
357  FunToArgsListMap::const_iterator it = funArgsListMap.find(func);
358  assert(it != funArgsListMap.end() && "this function doesn't have arguments");
359  return it->second;
360  }
#define assert(ex)
Definition: util.h:141
FunToArgsListMap funArgsListMap
Map a function to a list of all its formal parameters.
Definition: PAG.h:96

◆ getFunArgsMap()

FunToArgsListMap& SVF::PAG::getFunArgsMap ( )
inline

Get function arguments list.

Definition at line 350 of file PAG.h.

351  {
352  return funArgsListMap;
353  }
FunToArgsListMap funArgsListMap
Map a function to a list of all its formal parameters.
Definition: PAG.h:96

◆ getFunPtr()

NodeID SVF::PAG::getFunPtr ( const CallBlockNode cs) const
inline

Definition at line 468 of file PAG.h.

469  {
470  CallSiteToFunPtrMap::const_iterator it = indCallSiteToFunPtrMap.find(cs);
471  assert(it!=indCallSiteToFunPtrMap.end() && "indirect callsite not have a function pointer?");
472  return it->second;
473  }
CallSiteToFunPtrMap indCallSiteToFunPtrMap
Map an indirect callsite to its function pointer.
Definition: PAG.h:101
#define assert(ex)
Definition: util.h:141

◆ getFunRet()

const PAGNode* SVF::PAG::getFunRet ( const SVFFunction func) const
inline

Get function return list.

Definition at line 400 of file PAG.h.

401  {
402  FunToRetMap::const_iterator it = funRetMap.find(func);
403  assert(it != funRetMap.end() && "this function doesn't have return");
404  return it->second;
405  }
FunToRetMap funRetMap
Map a function to its unique function return PAGNodes.
Definition: PAG.h:99
#define assert(ex)
Definition: util.h:141

◆ getFunRets()

FunToRetMap& SVF::PAG::getFunRets ( )
inline

Get function return list.

Definition at line 395 of file PAG.h.

396  {
397  return funRetMap;
398  }
FunToRetMap funRetMap
Map a function to its unique function return PAGNodes.
Definition: PAG.h:99

◆ getGepObjNode() [1/2]

NodeID PAG::getGepObjNode ( const MemObj obj,
const LocationSet ls 
)

Get a field PAG Object node according to base mem obj and offset.

Get a field obj PAG node according to base mem obj and offset To support flexible field sensitive analysis with regard to MaxFieldOffset offset = offset % obj->getMaxFieldOffsetLimit() to create limited number of mem objects maximum number of field object creation is obj->getMaxFieldOffsetLimit()

if this obj is field-insensitive, just return the field-insensitive node.

Definition at line 671 of file PAG.cpp.

672 {
673  NodeID base = getObjectNode(obj);
674 
676  if (obj->isFieldInsensitive())
677  return getFIObjNode(obj);
678 
680 
681  // Base and first field are the same memory location.
682  if (Options::FirstFieldEqBase && newLS.getOffset() == 0) return base;
683 
684  NodeLocationSetMap::iterator iter = GepObjNodeMap.find(std::make_pair(base, newLS));
685  if (iter == GepObjNodeMap.end())
686  return addGepObjNode(obj, newLS);
687  else
688  return iter->second;
689 
690 }
NodeID addGepObjNode(const MemObj *obj, const LocationSet &ls)
Add a field obj node, this method can only invoked by getGepObjNode.
Definition: PAG.cpp:695
virtual LocationSet getModulusOffset(const MemObj *obj, const LocationSet &ls)
Given an offset from a Gep Instruction, return it modulus offset by considering memory layout...
u32_t NodeID
Definition: SVFBasicTypes.h:80
bool isFieldInsensitive() const
Return true if its field limit is 0.
Definition: MemModel.h:337
NodeID getObjectNode(const Value *V)
Definition: PAG.h:531
NodeID getFIObjNode(const MemObj *obj) const
Get a field-insensitive obj PAG node according to a mem obj.
Definition: PAG.h:574
static SymbolTableInfo * SymbolInfo()
Singleton design here to make sure we only have one instance during any analysis. ...
static const llvm::cl::opt< bool > FirstFieldEqBase
Definition: Options.h:67
Size_t getOffset() const
Get methods.
Definition: LocationSet.h:194
NodeLocationSetMap GepObjNodeMap
Map a pair<base,off> to a gep obj node id.
Definition: PAG.h:89

◆ getGepObjNode() [2/2]

NodeID PAG::getGepObjNode ( NodeID  id,
const LocationSet ls 
)

Get a field obj PAG node according to a mem obj and a given offset.

Given an object node, find its field object node

Definition at line 649 of file PAG.cpp.

650 {
651  PAGNode* node = pag->getPAGNode(id);
652  if (GepObjPN* gepNode = SVFUtil::dyn_cast<GepObjPN>(node))
653  return getGepObjNode(gepNode->getMemObj(), gepNode->getLocationSet() + ls);
654  else if (FIObjPN* baseNode = SVFUtil::dyn_cast<FIObjPN>(node))
655  return getGepObjNode(baseNode->getMemObj(), ls);
656  else if (DummyObjPN* baseNode = SVFUtil::dyn_cast<DummyObjPN>(node))
657  return getGepObjNode(baseNode->getMemObj(), ls);
658  else
659  {
660  assert(false && "new gep obj node kind?");
661  return id;
662  }
663 }
static PAG * pag
Singleton pattern here to enable instance of PAG can only be created once.
Definition: PAG.h:100
#define assert(ex)
Definition: util.h:141
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513
NodeID getGepObjNode(const MemObj *obj, const LocationSet &ls)
Get a field PAG Object node according to base mem obj and offset.
Definition: PAG.cpp:671

◆ getGepObjNodeMap()

NodeLocationSetMap& SVF::PAG::getGepObjNodeMap ( )
inline

Return GepObjNodeMap.

Definition at line 127 of file PAG.h.

128  {
129  return GepObjNodeMap;
130  }
NodeLocationSetMap GepObjNodeMap
Map a pair<base,off> to a gep obj node id.
Definition: PAG.h:89

◆ getGepValNode()

NodeID SVF::PAG::getGepValNode ( const Value curInst,
NodeID  base,
const LocationSet ls 
) const
inline

Due to constaint expression, curInst is used to distinguish different instructions (e.g., memorycpy) when creating GepValPN.

Definition at line 441 of file PAG.h.

442  {
443  GepValPNMap::const_iterator iter = GepValNodeMap.find(curInst);
444  if(iter==GepValNodeMap.end()){
445  return UINT_MAX;
446  }
447  else{
448  NodeLocationSetMap::const_iterator lit = iter->second.find(std::make_pair(base, ls));
449  if(lit==iter->second.end())
450  return UINT_MAX;
451  else
452  return lit->second;
453  }
454  }
GepValPNMap GepValNodeMap
Map a pair<base,off> to a gep value node id.
Definition: PAG.h:88

◆ getGlobalPAGEdgeSet()

PAGEdgeSet& SVF::PAG::getGlobalPAGEdgeSet ( )
inline

Get global PAGEdges (not in a procedure)

Definition at line 250 of file PAG.h.

251  {
252  return globPAGEdgesSet;
253  }
PAGEdgeSet globPAGEdgesSet
Global PAGEdges without control flow information.
Definition: PAG.h:91

◆ getGraphName()

std::string SVF::PAG::getGraphName ( ) const
inline

Return graph name.

Definition at line 846 of file PAG.h.

847  {
848  return "PAG";
849  }

◆ getICFG()

ICFG* SVF::PAG::getICFG ( )
inline

Return ICFG.

Definition at line 133 of file PAG.h.

134  {
135  return icfg;
136  }
ICFG * icfg
Definition: PAG.h:108

◆ getIndCallSites()

const CallSiteSet& SVF::PAG::getIndCallSites ( NodeID  funPtr) const
inline

Definition at line 474 of file PAG.h.

475  {
476  FunPtrToCallSitesMap::const_iterator it = funPtrToCallSitesMap.find(funPtr);
477  assert(it!=funPtrToCallSitesMap.end() && "function pointer not used at any indirect callsite?");
478  return it->second;
479  }
#define assert(ex)
Definition: util.h:141
FunPtrToCallSitesMap funPtrToCallSitesMap
Map a function pointer to the callsites where it is used.
Definition: PAG.h:102

◆ getIndirectCallsites()

const CallSiteToFunPtrMap& SVF::PAG::getIndirectCallsites ( ) const
inline

Add/get indirect callsites.

Definition at line 458 of file PAG.h.

459  {
460  return indCallSiteToFunPtrMap;
461  }
CallSiteToFunPtrMap indCallSiteToFunPtrMap
Map an indirect callsite to its function pointer.
Definition: PAG.h:101

◆ getInstPAGEdgeList()

PAGEdgeList& SVF::PAG::getInstPAGEdgeList ( const ICFGNode inst)
inline

Given an instruction, get all its PAGEdges.

Definition at line 227 of file PAG.h.

228  {
229  return inst2PAGEdgesMap[inst];
230  }
Inst2PAGEdgesMap inst2PAGEdgesMap
Map a instruction to its PAGEdges.
Definition: PAG.h:86

◆ getInstPTAPAGEdgeList()

PAGEdgeList& SVF::PAG::getInstPTAPAGEdgeList ( const ICFGNode inst)
inline

Given an instruction, get all its PTA PAGEdges.

Definition at line 232 of file PAG.h.

233  {
234  return inst2PTAPAGEdgesMap[inst];
235  }
Inst2PAGEdgesMap inst2PTAPAGEdgesMap
Map a instruction to its PointerAnalysis related PAGEdges.
Definition: PAG.h:87

◆ getIntraPAGEdge() [1/2]

PAGEdge* SVF::PAG::getIntraPAGEdge ( NodeID  src,
NodeID  dst,
PAGEdge::PEDGEK  kind 
)
inline

Get an edge according to src, dst and kind.

Definition at line 498 of file PAG.h.

499  {
500  return getIntraPAGEdge(getPAGNode(src), getPAGNode(dst), kind);
501  }
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513
PAGEdge * getIntraPAGEdge(NodeID src, NodeID dst, PAGEdge::PEDGEK kind)
Get an edge according to src, dst and kind.
Definition: PAG.h:498

◆ getIntraPAGEdge() [2/2]

PAGEdge* SVF::PAG::getIntraPAGEdge ( PAGNode src,
PAGNode dst,
PAGEdge::PEDGEK  kind 
)
inline

Definition at line 502 of file PAG.h.

503  {
504  PAGEdge edge(src,dst,kind);
505  const PAGEdge::PAGEdgeSetTy& edgeSet = getEdgeSet(kind);
506  PAGEdge::PAGEdgeSetTy::const_iterator it = edgeSet.find(&edge);
507  assert(it != edgeSet.end() && "can not find pag edge");
508  return (*it);
509  }
#define assert(ex)
Definition: util.h:141
GenericNode< PAGNode, PAGEdge >::GEdgeSetTy PAGEdgeSetTy
Definition: PAGEdge.h:169
PAGEdge::PAGEdgeSetTy & getEdgeSet(PAGEdge::PEDGEK kind)
Get/set methods to get control flow information of a PAGEdge.
Definition: PAG.h:208

◆ getLocationSetFromBaseNode()

LocationSet PAG::getLocationSetFromBaseNode ( NodeID  nodeId)

Get a base PAGNode given a pointer Return the source node of its connected normal gep edge Otherwise return the node id itself Size_t offset : gep offset

if this node is already a base node

Definition at line 847 of file PAG.cpp.

848 {
849  PAGNode* node = getPAGNode(nodeId);
852  if(geps.empty())
853  return LocationSet(0);
854 
855  assert(geps.size()==1 && "one node can only be connected by at most one gep edge!");
856  PAGNode::iterator it = geps.begin();
857  const PAGEdge* edge = *it;
858  assert(SVFUtil::isa<NormalGepPE>(edge) && "not a get edge??");
859  const NormalGepPE* gepEdge = SVFUtil::cast<NormalGepPE>(edge);
860  return gepEdge->getLocationSet();
861 }
const LocationSet & getLocationSet() const
Definition: PAGEdge.h:511
#define assert(ex)
Definition: util.h:141
GenericNode< PAGNode, PAGEdge >::GEdgeSetTy PAGEdgeSetTy
Definition: PAGEdge.h:169
PAGEdge::PAGEdgeSetTy & getIncomingEdges(PAGEdge::PEDGEK kind)
Get incoming PAG edges.
Definition: PAGNode.h:160
GEdgeSetTy::iterator iterator
Definition: GenericGraph.h:139
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513

◆ getMemToFieldsMap()

MemObjToFieldsMap& SVF::PAG::getMemToFieldsMap ( )
inline

Return memToFieldsMap.

Definition at line 121 of file PAG.h.

122  {
123  return memToFieldsMap;
124  }
MemObjToFieldsMap memToFieldsMap
Map a mem object id to all its fields.
Definition: PAG.h:90

◆ getModule()

SVFModule* SVF::PAG::getModule ( )
inline

Get LLVM Module.

Definition at line 193 of file PAG.h.

194  {
196  }
SVFModule * getModule()
Module.
static SymbolTableInfo * SymbolInfo()
Singleton design here to make sure we only have one instance during any analysis. ...

◆ getNodeNumAfterPAGBuild()

u32_t SVF::PAG::getNodeNumAfterPAGBuild ( ) const
inline

Definition at line 658 of file PAG.h.

659  {
660  return nodeNumAfterPAGBuild;
661  }
NodeID nodeNumAfterPAGBuild
Definition: PAG.h:107

◆ getNullPtr()

NodeID SVF::PAG::getNullPtr ( ) const
inline

Definition at line 601 of file PAG.h.

602  {
603  return symInfo->nullPtrSymID();
604  }
SymID nullPtrSymID() const
SymbolTableInfo * symInfo
Definition: PAG.h:81

◆ getObject() [1/2]

const MemObj* SVF::PAG::getObject ( NodeID  id) const
inline

Get memory object - Return memory object according to pag node id return whole allocated memory object if this node is a gep obj node return nullptr is this node is not a ObjPN type

Definition at line 544 of file PAG.h.

545  {
546  const PAGNode* node = getPAGNode(id);
547  if(const ObjPN* objPN = SVFUtil::dyn_cast<ObjPN>(node))
548  return getObject(objPN);
549  else
550  return nullptr;
551  }
const MemObj * getObject(NodeID id) const
Definition: PAG.h:544
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513

◆ getObject() [2/2]

const MemObj* SVF::PAG::getObject ( const ObjPN node) const
inline

Definition at line 552 of file PAG.h.

553  {
554  return node->getMemObj();
555  }

◆ getObjectNode() [1/2]

NodeID SVF::PAG::getObjectNode ( const Value V)
inline

getObject - Return the obj node id refer to the memory object for the specified global, heap or alloca instruction according to llvm value.

Definition at line 531 of file PAG.h.

532  {
533  return symInfo->getObjSym(V);
534  }
SymID getObjSym(const Value *val) const
SymbolTableInfo * symInfo
Definition: PAG.h:81

◆ getObjectNode() [2/2]

NodeID SVF::PAG::getObjectNode ( const MemObj mem)
inline

getObject - return mem object id

Definition at line 536 of file PAG.h.

537  {
538  return mem->getSymId();
539  }

◆ getObjectNodeNum()

Size_t SVF::PAG::getObjectNodeNum ( ) const
inline

Definition at line 426 of file PAG.h.

427  {
428  return symInfo->idToObjMap().size();
429  }
IDToMemMapTy & idToObjMap()
SymbolTableInfo * symInfo
Definition: PAG.h:81

◆ getPAG()

static PAG* SVF::PAG::getPAG ( bool  buildFromFile = false)
inlinestatic

Singleton design here to make sure we only have one instance during any analysis.

Definition at line 160 of file PAG.h.

161  {
162  if (pag == nullptr)
163  {
164  pag = new PAG(buildFromFile);
165  }
166  return pag;
167  }
static PAG * pag
Singleton pattern here to enable instance of PAG can only be created once.
Definition: PAG.h:100
PAG(bool buildFromFile)
all the callsites of a program
Definition: PAG.cpp:362

◆ getPAGEdgeNum()

Size_t SVF::PAG::getPAGEdgeNum ( ) const
inline

Definition at line 418 of file PAG.h.

419  {
420  return edgeNum;
421  }
u32_t edgeNum
total num of node
Definition: GenericGraph.h:439

◆ getPAGNode()

PAGNode* SVF::PAG::getPAGNode ( NodeID  id) const
inline

Get PAGNode ID.

Definition at line 513 of file PAG.h.

514  {
515  return getGNode(id);
516  }
NodeType * getGNode(NodeID id) const
Get a node.
Definition: GenericGraph.h:391

◆ getPAGNodeNum()

Size_t SVF::PAG::getPAGNodeNum ( ) const
inline

Node and edge statistics.

Definition at line 414 of file PAG.h.

415  {
416  return nodeNum;
417  }
u32_t nodeNum
total num of edge
Definition: GenericGraph.h:440

◆ getPhiNodeMap()

PHINodeMap& SVF::PAG::getPhiNodeMap ( )
inline

Get all phi copy edges.

Definition at line 265 of file PAG.h.

266  {
267  return phiNodeMap;
268  }
PHINodeMap phiNodeMap
A set of phi copy edges.
Definition: PAG.h:92

◆ getPTAEdgeSet()

PAGEdge::PAGEdgeSetTy& SVF::PAG::getPTAEdgeSet ( PAGEdge::PEDGEK  kind)
inline

Get PTA edges set according to its kind.

Definition at line 213 of file PAG.h.

214  {
215  return PTAPAGEdgeKindToSetMap[kind];
216  }
PAGEdge::PAGKindToEdgeSetMapTy PTAPAGEdgeKindToSetMap
Definition: PAG.h:85

◆ getReturnNode()

NodeID SVF::PAG::getReturnNode ( const SVFFunction func) const
inline

GetReturnNode - Return the unique node representing the return value of a function.

Definition at line 559 of file PAG.h.

560  {
561  return symInfo->getRetSym(func->getLLVMFun());
562  }
SymID getRetSym(const Function *val) const
SymbolTableInfo * symInfo
Definition: PAG.h:81

◆ getUnaryNodeMap()

UnaryNodeMap& SVF::PAG::getUnaryNodeMap ( )
inline

Get all unary edges.

Definition at line 295 of file PAG.h.

296  {
297  return unaryNodeMap;
298  }
UnaryNodeMap unaryNodeMap
A set of unary edges.
Definition: PAG.h:94

◆ getValueNode()

NodeID SVF::PAG::getValueNode ( const Value V)
inline

Get PAG Node according to LLVM value.

getNode - Return the node corresponding to the specified pointer.

Definition at line 521 of file PAG.h.

522  {
523  return symInfo->getValSym(V);
524  }
SymID getValSym(const Value *val)
Get different kinds of syms.
SymbolTableInfo * symInfo
Definition: PAG.h:81

◆ getValueNodeNum()

Size_t SVF::PAG::getValueNodeNum ( ) const
inline

Definition at line 422 of file PAG.h.

423  {
424  return symInfo->valSyms().size();
425  }
ValueToIDMapTy & valSyms()
Get different kinds of syms maps.
SymbolTableInfo * symInfo
Definition: PAG.h:81

◆ getVarargNode()

NodeID SVF::PAG::getVarargNode ( const SVFFunction func) const
inline

getVarargNode - Return the unique node representing the variadic argument of a variadic function.

Definition at line 564 of file PAG.h.

565  {
566  return symInfo->getVarargSym(func->getLLVMFun());
567  }
SymID getVarargSym(const Function *val) const
SymbolTableInfo * symInfo
Definition: PAG.h:81

◆ handleBlackHole()

void PAG::handleBlackHole ( bool  b)
static

PAG build configurations.

Whether to handle blackhole edge

Definition at line 1097 of file PAG.cpp.

1098 {
1100 }
static llvm::cl::opt< bool > HandBlackHole
Definition: Options.h:66

◆ hasCallSiteArgsMap()

bool SVF::PAG::hasCallSiteArgsMap ( const CallBlockNode cs) const
inline

Callsite has argument list.

Definition at line 362 of file PAG.h.

363  {
364  return (callSiteArgsListMap.find(cs) != callSiteArgsListMap.end());
365  }
CSToArgsListMap callSiteArgsListMap
Map a callsite to a list of all its actual parameters.
Definition: PAG.h:97

◆ hasFunArgsList()

bool SVF::PAG::hasFunArgsList ( const SVFFunction func) const
inline

Function has arguments list.

Definition at line 345 of file PAG.h.

346  {
347  return (funArgsListMap.find(func) != funArgsListMap.end());
348  }
FunToArgsListMap funArgsListMap
Map a function to a list of all its formal parameters.
Definition: PAG.h:96

◆ hasLabeledEdge()

PAGEdge * PAG::hasLabeledEdge ( PAGNode src,
PAGNode dst,
PAGEdge::PEDGEK  kind,
const ICFGNode callInst 
)

Return true if this labeled edge exits, including store, call and load two store edge can have same dst and src but located in different basic blocks, thus flags are needed to distinguish them

Return true if it is an inter-procedural edge

Definition at line 739 of file PAG.cpp.

740 {
741  PAGEdge edge(src,dst,PAGEdge::makeEdgeFlagWithCallInst(kind,callInst));
742  PAGEdge::PAGEdgeSetTy::iterator it = PAGEdgeKindToSetMap[kind].find(&edge);
743  if (it != PAGEdgeKindToSetMap[kind].end())
744  {
745  return *it;
746  }
747  return nullptr;
748 }
PAGEdge::PAGKindToEdgeSetMapTy PAGEdgeKindToSetMap
Definition: PAG.h:84
static GEdgeFlag makeEdgeFlagWithCallInst(GEdgeKind k, const ICFGNode *cs)
Compute the unique edgeFlag value from edge kind and call site Instruction.
Definition: PAGEdge.h:139

◆ hasNonlabeledEdge()

PAGEdge * PAG::hasNonlabeledEdge ( PAGNode src,
PAGNode dst,
PAGEdge::PEDGEK  kind 
)

Return true if it is an intra-procedural edge

Definition at line 725 of file PAG.cpp.

726 {
727  PAGEdge edge(src,dst,kind);
728  PAGEdge::PAGEdgeSetTy::iterator it = PAGEdgeKindToSetMap[kind].find(&edge);
729  if (it != PAGEdgeKindToSetMap[kind].end())
730  {
731  return *it;
732  }
733  return nullptr;
734 }
PAGEdge::PAGKindToEdgeSetMapTy PAGEdgeKindToSetMap
Definition: PAG.h:84

◆ hasPAGEdgeList()

bool SVF::PAG::hasPAGEdgeList ( const ICFGNode inst) const
inline

Whether this instruction has PAG Edge.

Definition at line 218 of file PAG.h.

219  {
220  return inst2PAGEdgesMap.find(inst)!=inst2PAGEdgesMap.end();
221  }
Inst2PAGEdgesMap inst2PAGEdgesMap
Map a instruction to its PAGEdges.
Definition: PAG.h:86

◆ hasPTAPAGEdgeList()

bool SVF::PAG::hasPTAPAGEdgeList ( const ICFGNode inst) const
inline

Definition at line 222 of file PAG.h.

223  {
224  return inst2PTAPAGEdgesMap.find(inst)!=inst2PTAPAGEdgesMap.end();
225  }
Inst2PAGEdgesMap inst2PTAPAGEdgesMap
Map a instruction to its PointerAnalysis related PAGEdges.
Definition: PAG.h:87

◆ hasValueNode()

bool SVF::PAG::hasValueNode ( const Value V)
inline

Definition at line 525 of file PAG.h.

526  {
527  return symInfo->hasValSym(V);
528  }
bool hasValSym(const Value *val)
SymbolTableInfo * symInfo
Definition: PAG.h:81

◆ initialiseCandidatePointers()

void SVF::PAG::initialiseCandidatePointers ( )
inline

Initialize candidate pointers.

Definition at line 144 of file PAG.h.

145  {
146  // collect candidate pointers for demand-driven analysis
147  for (iterator nIter = begin(); nIter != end(); ++nIter)
148  {
149  NodeID nodeId = nIter->first;
150  // do not compute points-to for isolated node
151  if (isValidPointer(nodeId) == false)
152  continue;
153 
154  candidatePointers.insert(nodeId);
155  }
156  }
u32_t NodeID
Definition: SVFBasicTypes.h:80
OrderedNodeSet candidatePointers
Definition: PAG.h:106
IDToNodeMapTy::iterator iterator
Node Iterators.
Definition: GenericGraph.h:337
bool isValidPointer(NodeID nodeId) const
Whether a node is a valid pointer.
Definition: PAG.cpp:976

◆ isBinaryNode()

bool SVF::PAG::isBinaryNode ( const PAGNode node) const
inline

Whether this PAGNode is a result operand a of phi node.

Definition at line 275 of file PAG.h.

276  {
277  return binaryNodeMap.find(node) != binaryNodeMap.end();
278  }
BinaryNodeMap binaryNodeMap
A set of binary edges.
Definition: PAG.h:93

◆ isBlkObj()

bool SVF::PAG::isBlkObj ( NodeID  id) const
inline

Definition at line 617 of file PAG.h.

618  {
619  return SymbolTableInfo::isBlkObj(id);
620  }
static bool isBlkObj(NodeID id)

◆ isBlkObjOrConstantObj()

bool SVF::PAG::isBlkObjOrConstantObj ( NodeID  id) const
inline

Definition at line 613 of file PAG.h.

614  {
615  return (isBlkObj(id) || isConstantObj(id));
616  }
bool isConstantObj(NodeID id) const
Definition: PAG.h:621
bool isBlkObj(NodeID id) const
Definition: PAG.h:617

◆ isBlkPtr()

bool SVF::PAG::isBlkPtr ( NodeID  id) const
inline

Definition at line 605 of file PAG.h.

606  {
607  return (SymbolTableInfo::isBlkPtr(id));
608  }
static bool isBlkPtr(NodeID id)

◆ isBuiltFromFile()

bool SVF::PAG::isBuiltFromFile ( )
inline

Whether this PAG built from a txt file.

Definition at line 183 of file PAG.h.

184  {
185  return fromFile;
186  }
bool fromFile
Definition: PAG.h:103

◆ isCmpNode()

bool SVF::PAG::isCmpNode ( const PAGNode node) const
inline

Whether this PAGNode is a result operand a of phi node.

Definition at line 305 of file PAG.h.

306  {
307  return cmpNodeMap.find(node) != cmpNodeMap.end();
308  }
CmpNodeMap cmpNodeMap
A set of comparision edges.
Definition: PAG.h:95

◆ isConstantObj()

bool SVF::PAG::isConstantObj ( NodeID  id) const
inline

Definition at line 621 of file PAG.h.

622  {
623  const MemObj* obj = getObject(id);
624  assert(obj && "not an object node?");
625  return SymbolTableInfo::isConstantObj(id) || obj->isConstant();
626  }
#define assert(ex)
Definition: util.h:141
static bool isConstantObj(NodeID id)
const MemObj * getObject(NodeID id) const
Definition: PAG.h:544

◆ isFunPtr()

bool SVF::PAG::isFunPtr ( NodeID  id) const
inline

Definition at line 484 of file PAG.h.

485  {
486  return (funPtrToCallSitesMap.find(id) != funPtrToCallSitesMap.end());
487  }
FunPtrToCallSitesMap funPtrToCallSitesMap
Map a function pointer to the callsites where it is used.
Definition: PAG.h:102

◆ isIndirectCallSites()

bool SVF::PAG::isIndirectCallSites ( const CallBlockNode cs) const
inline

Definition at line 480 of file PAG.h.

481  {
482  return (indCallSiteToFunPtrMap.find(cs) != indCallSiteToFunPtrMap.end());
483  }
CallSiteToFunPtrMap indCallSiteToFunPtrMap
Map an indirect callsite to its function pointer.
Definition: PAG.h:101

◆ isNonPointerObj()

bool SVF::PAG::isNonPointerObj ( NodeID  id) const
inline

Definition at line 627 of file PAG.h.

628  {
629  PAGNode* node = getPAGNode(id);
630  if (FIObjPN* fiNode = SVFUtil::dyn_cast<FIObjPN>(node))
631  {
632  return (fiNode->getMemObj()->hasPtrObj() == false);
633  }
634  else if (GepObjPN* gepNode = SVFUtil::dyn_cast<GepObjPN>(node))
635  {
636  return (gepNode->getMemObj()->isNonPtrFieldObj(gepNode->getLocationSet()));
637  }
638  else if (SVFUtil::isa<DummyObjPN>(node))
639  {
640  return false;
641  }
642  else
643  {
644  assert(false && "expecting a object node");
645  return false;
646  }
647  }
#define assert(ex)
Definition: util.h:141
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513

◆ isNullPtr()

bool SVF::PAG::isNullPtr ( NodeID  id) const
inline

Definition at line 609 of file PAG.h.

610  {
611  return (SymbolTableInfo::isNullPtr(id));
612  }
static bool isNullPtr(NodeID id)

◆ isPhiNode()

bool SVF::PAG::isPhiNode ( const PAGNode node) const
inline

Whether this PAGNode is a result operand a of phi node.

Definition at line 260 of file PAG.h.

261  {
262  return phiNodeMap.find(node) != phiNodeMap.end();
263  }
PHINodeMap phiNodeMap
A set of phi copy edges.
Definition: PAG.h:92

◆ isUnaryNode()

bool SVF::PAG::isUnaryNode ( const PAGNode node) const
inline

Whether this PAGNode is an unary node.

Definition at line 290 of file PAG.h.

291  {
292  return unaryNodeMap.find(node) != unaryNodeMap.end();
293  }
UnaryNodeMap unaryNodeMap
A set of unary edges.
Definition: PAG.h:94

◆ isValidPointer()

bool PAG::isValidPointer ( NodeID  nodeId) const

Whether a node is a valid pointer.

Definition at line 976 of file PAG.cpp.

977 {
978  PAGNode* node = pag->getPAGNode(nodeId);
979  if ((node->getInEdges().empty() && node->getOutEdges().empty()))
980  return false;
981  return node->isPointer();
982 }
static PAG * pag
Singleton pattern here to enable instance of PAG can only be created once.
Definition: PAG.h:100
const GEdgeSetTy & getInEdges() const
Definition: GenericGraph.h:181
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513
const GEdgeSetTy & getOutEdges() const
Definition: GenericGraph.h:177
virtual bool isPointer() const
Whether it is a pointer.
Definition: PAGNode.h:114

◆ isValidTopLevelPtr()

bool PAG::isValidTopLevelPtr ( const PAGNode node)

Definition at line 984 of file PAG.cpp.

985 {
986  if (node->isTopLevelPtr())
987  {
988  if (isValidPointer(node->getId()) && node->hasValue())
989  {
991  return false;
992  return true;
993  }
994  }
995  return false;
996 }
const Value * getValue() const
Get/has methods of the components.
Definition: PAGNode.h:93
bool hasValue() const
Definition: PAGNode.h:109
bool isTopLevelPtr() const
Whether it is a top-level pointer.
Definition: PAGNode.h:119
bool ArgInNoCallerFunction(const Value *val)
Return true if the argument in a function does not have a caller.
Definition: LLVMUtil.h:479
bool isValidPointer(NodeID nodeId) const
Whether a node is a valid pointer.
Definition: PAG.cpp:976
NodeID getId() const
Get ID.
Definition: GenericGraph.h:164

◆ print()

void PAG::print ( )

Print PAG.

Print this PAG graph including its nodes and edges

Definition at line 885 of file PAG.cpp.

886 {
887 
888  outs() << "-------------------PAG------------------------------------\n";
890  for (PAGEdge::PAGEdgeSetTy::iterator iter = addrs.begin(), eiter =
891  addrs.end(); iter != eiter; ++iter)
892  {
893  outs() << (*iter)->getSrcID() << " -- Addr --> " << (*iter)->getDstID()
894  << "\n";
895  }
896 
898  for (PAGEdge::PAGEdgeSetTy::iterator iter = copys.begin(), eiter =
899  copys.end(); iter != eiter; ++iter)
900  {
901  outs() << (*iter)->getSrcID() << " -- Copy --> " << (*iter)->getDstID()
902  << "\n";
903  }
904 
906  for (PAGEdge::PAGEdgeSetTy::iterator iter = calls.begin(), eiter =
907  calls.end(); iter != eiter; ++iter)
908  {
909  outs() << (*iter)->getSrcID() << " -- Call --> " << (*iter)->getDstID()
910  << "\n";
911  }
912 
914  for (PAGEdge::PAGEdgeSetTy::iterator iter = rets.begin(), eiter =
915  rets.end(); iter != eiter; ++iter)
916  {
917  outs() << (*iter)->getSrcID() << " -- Ret --> " << (*iter)->getDstID()
918  << "\n";
919  }
920 
922  for (PAGEdge::PAGEdgeSetTy::iterator iter = tdfks.begin(), eiter =
923  tdfks.end(); iter != eiter; ++iter)
924  {
925  outs() << (*iter)->getSrcID() << " -- ThreadFork --> "
926  << (*iter)->getDstID() << "\n";
927  }
928 
930  for (PAGEdge::PAGEdgeSetTy::iterator iter = tdjns.begin(), eiter =
931  tdjns.end(); iter != eiter; ++iter)
932  {
933  outs() << (*iter)->getSrcID() << " -- ThreadJoin --> "
934  << (*iter)->getDstID() << "\n";
935  }
936 
938  for (PAGEdge::PAGEdgeSetTy::iterator iter = ngeps.begin(), eiter =
939  ngeps.end(); iter != eiter; ++iter)
940  {
941  NormalGepPE* gep = SVFUtil::cast<NormalGepPE>(*iter);
942  outs() << gep->getSrcID() << " -- NormalGep (" << gep->getOffset()
943  << ") --> " << gep->getDstID() << "\n";
944  }
945 
947  for (PAGEdge::PAGEdgeSetTy::iterator iter = vgeps.begin(), eiter =
948  vgeps.end(); iter != eiter; ++iter)
949  {
950  outs() << (*iter)->getSrcID() << " -- VariantGep --> "
951  << (*iter)->getDstID() << "\n";
952  }
953 
955  for (PAGEdge::PAGEdgeSetTy::iterator iter = loads.begin(), eiter =
956  loads.end(); iter != eiter; ++iter)
957  {
958  outs() << (*iter)->getSrcID() << " -- Load --> " << (*iter)->getDstID()
959  << "\n";
960  }
961 
963  for (PAGEdge::PAGEdgeSetTy::iterator iter = stores.begin(), eiter =
964  stores.end(); iter != eiter; ++iter)
965  {
966  outs() << (*iter)->getSrcID() << " -- Store --> " << (*iter)->getDstID()
967  << "\n";
968  }
969  outs() << "----------------------------------------------------------\n";
970 
971 }
static PAG * pag
Singleton pattern here to enable instance of PAG can only be created once.
Definition: PAG.h:100
NodeID getDstID() const
Definition: GenericGraph.h:77
GenericNode< PAGNode, PAGEdge >::GEdgeSetTy PAGEdgeSetTy
Definition: PAGEdge.h:169
NodeID getSrcID() const
get methods of the components
Definition: GenericGraph.h:73
raw_ostream & outs()
Overwrite llvm::outs()
Definition: SVFUtil.h:47
PAGEdge::PAGEdgeSetTy & getEdgeSet(PAGEdge::PEDGEK kind)
Get/set methods to get control flow information of a PAGEdge.
Definition: PAG.h:208
u32_t getOffset() const
offset of the gep edge
Definition: PAGEdge.h:507

◆ releasePAG()

static void SVF::PAG::releasePAG ( )
inlinestatic

Definition at line 168 of file PAG.h.

169  {
170  if (pag)
171  delete pag;
172  pag = nullptr;
173  }
static PAG * pag
Singleton pattern here to enable instance of PAG can only be created once.
Definition: PAG.h:100

◆ setNodeNumAfterPAGBuild()

void SVF::PAG::setNodeNumAfterPAGBuild ( u32_t  num)
inline

Definition at line 662 of file PAG.h.

663  {
664  nodeNumAfterPAGBuild = num;
665  }
NodeID nodeNumAfterPAGBuild
Definition: PAG.h:107

◆ view()

void PAG::view ( )

View graph from the debugger.

View PAG

Definition at line 1089 of file PAG.cpp.

1090 {
1091  llvm::ViewGraph(this, "ProgramAssignmentGraph");
1092 }

Member Data Documentation

◆ binaryNodeMap

BinaryNodeMap SVF::PAG::binaryNodeMap
private

A set of binary edges.

Definition at line 93 of file PAG.h.

◆ callSiteArgsListMap

CSToArgsListMap SVF::PAG::callSiteArgsListMap
private

Map a callsite to a list of all its actual parameters.

Definition at line 97 of file PAG.h.

◆ callSiteRetMap

CSToRetMap SVF::PAG::callSiteRetMap
private

Map a callsite to its callsite returns PAGNodes.

Definition at line 98 of file PAG.h.

◆ callSiteSet

CallSiteSet SVF::PAG::callSiteSet
private

Definition at line 109 of file PAG.h.

◆ candidatePointers

OrderedNodeSet SVF::PAG::candidatePointers
private

Valid pointers for pointer analysis resolution connected by PAG edges (constraints) this set of candidate pointers can change during pointer resolution (e.g. adding new object nodes)

Definition at line 106 of file PAG.h.

◆ cmpNodeMap

CmpNodeMap SVF::PAG::cmpNodeMap
private

A set of comparision edges.

Definition at line 95 of file PAG.h.

◆ fromFile

bool SVF::PAG::fromFile
private

Whether the PAG is built according to user specified data from a txt file

Definition at line 103 of file PAG.h.

◆ funArgsListMap

FunToArgsListMap SVF::PAG::funArgsListMap
private

Map a function to a list of all its formal parameters.

Definition at line 96 of file PAG.h.

◆ funPtrToCallSitesMap

FunPtrToCallSitesMap SVF::PAG::funPtrToCallSitesMap
private

Map a function pointer to the callsites where it is used.

Definition at line 102 of file PAG.h.

◆ funRetMap

FunToRetMap SVF::PAG::funRetMap
private

Map a function to its unique function return PAGNodes.

Definition at line 99 of file PAG.h.

◆ GepObjNodeMap

NodeLocationSetMap SVF::PAG::GepObjNodeMap
private

Map a pair<base,off> to a gep obj node id.

Definition at line 89 of file PAG.h.

◆ GepValNodeMap

GepValPNMap SVF::PAG::GepValNodeMap
private

Map a pair<base,off> to a gep value node id.

Definition at line 88 of file PAG.h.

◆ globPAGEdgesSet

PAGEdgeSet SVF::PAG::globPAGEdgesSet
private

Global PAGEdges without control flow information.

Definition at line 91 of file PAG.h.

◆ icfg

ICFG* SVF::PAG::icfg
private

Definition at line 108 of file PAG.h.

◆ indCallSiteToFunPtrMap

CallSiteToFunPtrMap SVF::PAG::indCallSiteToFunPtrMap
private

Map an indirect callsite to its function pointer.

Definition at line 101 of file PAG.h.

◆ inst2PAGEdgesMap

Inst2PAGEdgesMap SVF::PAG::inst2PAGEdgesMap
private

Map a instruction to its PAGEdges.

Definition at line 86 of file PAG.h.

◆ inst2PTAPAGEdgesMap

Inst2PAGEdgesMap SVF::PAG::inst2PTAPAGEdgesMap
private

Map a instruction to its PointerAnalysis related PAGEdges.

Definition at line 87 of file PAG.h.

◆ memToFieldsMap

MemObjToFieldsMap SVF::PAG::memToFieldsMap
private

Map a mem object id to all its fields.

Definition at line 90 of file PAG.h.

◆ nodeNumAfterPAGBuild

NodeID SVF::PAG::nodeNumAfterPAGBuild
private

Definition at line 107 of file PAG.h.

◆ pag

PAG * PAG::pag = nullptr
staticprivate

Singleton pattern here to enable instance of PAG can only be created once.

Definition at line 100 of file PAG.h.

◆ PAGEdgeKindToSetMap

PAGEdge::PAGKindToEdgeSetMapTy SVF::PAG::PAGEdgeKindToSetMap
private

ValueNodes - This map indicates the Node that a particular Value* is represented by. This contains entries for all pointers.

Definition at line 84 of file PAG.h.

◆ phiNodeMap

PHINodeMap SVF::PAG::phiNodeMap
private

A set of phi copy edges.

Definition at line 92 of file PAG.h.

◆ PTAPAGEdgeKindToSetMap

PAGEdge::PAGKindToEdgeSetMapTy SVF::PAG::PTAPAGEdgeKindToSetMap
private

Definition at line 85 of file PAG.h.

◆ symInfo

SymbolTableInfo* SVF::PAG::symInfo
private

Definition at line 81 of file PAG.h.

◆ totalPTAPAGEdge

u32_t SVF::PAG::totalPTAPAGEdge

Definition at line 118 of file PAG.h.

◆ unaryNodeMap

UnaryNodeMap SVF::PAG::unaryNodeMap
private

A set of unary edges.

Definition at line 94 of file PAG.h.


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