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

#include <SVFIR.h>

Inheritance diagram for SVF::SVFIR:
SVF::IRGraph SVF::GenericGraph< SVFVar, SVFStmt >

Public Types

typedef Set< const CallICFGNode * > CallSiteSet
 
typedef OrderedMap< const CallICFGNode *, NodeIDCallSiteToFunPtrMap
 
typedef Map< NodeID, CallSiteSetFunPtrToCallSitesMap
 
typedef Map< NodeID, NodeBSMemObjToFieldsMap
 
typedef std::vector< const SVFStmt * > SVFStmtList
 
typedef std::vector< const SVFVar * > SVFVarList
 
typedef Map< const SVFVar *, PhiStmt * > PHINodeMap
 
typedef Map< const SVFFunction *, SVFVarListFunToArgsListMap
 
typedef Map< const CallICFGNode *, SVFVarListCSToArgsListMap
 
typedef Map< const RetICFGNode *, const SVFVar * > CSToRetMap
 
typedef Map< const SVFFunction *, const SVFVar * > FunToRetMap
 
typedef Map< const SVFFunction *, SVFStmtSetFunToPAGEdgeSetMap
 
typedef Map< const ICFGNode *, SVFStmtListICFGNode2SVFStmtsMap
 
typedef Map< NodeID, NodeIDNodeToNodeMap
 
typedef std::pair< NodeID, APOffsetNodeOffset
 
typedef std::pair< NodeID, AccessPathNodeAccessPath
 
typedef Map< NodeOffset, NodeIDNodeOffsetMap
 
typedef Map< NodeAccessPath, NodeIDNodeAccessPathMap
 
typedef Map< const SVFValue *, NodeAccessPathMapGepValueVarMap
 
typedef std::pair< const SVFType *, std::vector< AccessPath > > SVFTypeLocSetsPair
 
typedef Map< NodeID, SVFTypeLocSetsPairTypeLocSetsMap
 
typedef Map< NodePair, NodeIDNodePairSetMap
 
- Public Types inherited from SVF::IRGraph
typedef Set< const SVFStmt * > SVFStmtSet
 
typedef Map< const SVFValue *, SVFStmtSetValueToEdgeMap
 
- Public Types inherited from SVF::GenericGraph< SVFVar, SVFStmt >
typedef SVFVar NodeType
 
typedef SVFStmt EdgeType
 
typedef OrderedMap< 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...
 
NodeOffsetMapgetGepObjNodeMap ()
 Return GepObjVarMap. More...
 
OrderedNodeSetgetAllValidPtrs ()
 Return valid pointers. More...
 
void initialiseCandidatePointers ()
 Initialize candidate pointers. More...
 
virtual ~SVFIR ()
 Destructor. More...
 
void setModule (SVFModule *mod)
 Set/Get LLVM Module. More...
 
SVFModulegetModule ()
 
void setICFG (ICFG *i)
 Set/Get ICFG. More...
 
ICFGgetICFG () const
 
void setCHG (CommonCHGraph *c)
 Set/Get CHG. More...
 
CommonCHGraphgetCHG ()
 
void setCallGraph (PTACallGraph *c)
 Set/Get CG. More...
 
PTACallGraphgetCallGraph ()
 
SVFStmt::SVFStmtSetTygetSVFStmtSet (SVFStmt::PEDGEK kind)
 Get/set methods to get SVFStmts based on their kinds and ICFGNodes. More...
 
SVFStmt::SVFStmtSetTygetPTASVFStmtSet (SVFStmt::PEDGEK kind)
 Get PTA edges set according to its kind. More...
 
bool hasSVFStmtList (const ICFGNode *inst) const
 Whether this instruction has SVFIR Edge. More...
 
bool hasPTASVFStmtList (const ICFGNode *inst) const
 
SVFStmtListgetSVFStmtList (const ICFGNode *inst)
 Given an instruction, get all its PAGEdges. More...
 
SVFStmtListgetPTASVFStmtList (const ICFGNode *inst)
 Given an instruction, get all its PTA PAGEdges. More...
 
void addToSVFStmtList (ICFGNode *inst, SVFStmt *edge)
 Add a SVFStmt into instruction map. More...
 
void addToTypeLocSetsMap (NodeID argId, SVFTypeLocSetsPair &locSets)
 Add a base SVFType* and all its field location sets to an arg NodeId. More...
 
SVFTypeLocSetsPairgetTypeLocSetsMap (NodeID argId)
 Given an arg NodeId, get its base SVFType* and all its field location sets. More...
 
SVFStmtSetgetGlobalSVFStmtSet ()
 Get global PAGEdges (not in a procedure) More...
 
const CallSiteSetgetCallSiteSet () const
 Get all callsites. More...
 
bool isPhiNode (const SVFVar *node) const
 Whether this SVFVar is a result operand a of phi node. More...
 
bool hasFunArgsList (const SVFFunction *func) const
 Function has arguments list. More...
 
FunToArgsListMapgetFunArgsMap ()
 Get function arguments list. More...
 
const SVFVarListgetFunArgsList (const SVFFunction *func) const
 Get function arguments list. More...
 
bool hasCallSiteArgsMap (const CallICFGNode *cs) const
 Callsite has argument list. More...
 
CSToArgsListMapgetCallSiteArgsMap ()
 Get callsite argument list. More...
 
const SVFVarListgetCallSiteArgsList (const CallICFGNode *cs) const
 Get callsite argument list. More...
 
CSToRetMapgetCallSiteRets ()
 Get callsite return. More...
 
const SVFVargetCallSiteRet (const RetICFGNode *cs) const
 Get callsite return. More...
 
bool callsiteHasRet (const RetICFGNode *cs) const
 
FunToRetMapgetFunRets ()
 Get function return list. More...
 
const SVFVargetFunRet (const SVFFunction *func) const
 Get function return list. More...
 
bool funHasRet (const SVFFunction *func) const
 
u32_t getFieldValNodeNum () const
 Node and edge statistics. More...
 
u32_t getFieldObjNodeNum () const
 
NodeID getGepValVar (const SVFValue *curInst, NodeID base, const AccessPath &ap) const
 Due to constraint expression, curInst is used to distinguish different instructions (e.g., memorycpy) when creating GepValVar. More...
 
const CallSiteToFunPtrMapgetIndirectCallsites () const
 Add/get indirect callsites. More...
 
NodeID getFunPtr (const CallICFGNode *cs) const
 
const CallSiteSetgetIndCallSites (NodeID funPtr) const
 
bool isIndirectCallSites (const CallICFGNode *cs) const
 
bool isFunPtr (NodeID id) const
 
SVFStmtgetIntraPAGEdge (NodeID src, NodeID dst, SVFStmt::PEDGEK kind)
 Get an edge according to src, dst and kind. More...
 
SVFStmtgetIntraPAGEdge (SVFVar *src, SVFVar *dst, SVFStmt::PEDGEK kind)
 
const MemObjgetObject (NodeID id) const
 
const MemObjgetObject (const ObjVar *node) const
 
NodeID getGepObjVar (const MemObj *obj, const APOffset &ap)
 Get a field SVFIR Object node according to base mem obj and offset. More...
 
NodeID getGepObjVar (NodeID id, const APOffset &ap)
 Get a field obj SVFIR node according to a mem obj and a given offset. More...
 
NodeID getFIObjVar (const MemObj *obj) const
 Get a field-insensitive obj SVFIR node according to a mem obj. More...
 
NodeID getFIObjVar (NodeID id) const
 
bool isBlkPtr (NodeID id) const
 Get black hole and constant id. More...
 
bool isNullPtr (NodeID id) const
 
bool isBlkObjOrConstantObj (NodeID id) const
 
bool isBlkObj (NodeID id) const
 
bool isConstantObj (NodeID id) const
 
NodeID getBaseObjVar (NodeID id) const
 Base and Offset methods for Value and Object node. More...
 
const MemObjgetBaseObj (NodeID id) const
 
NodeBSgetAllFieldsObjVars (const MemObj *obj)
 Get all fields of an object. More...
 
NodeBSgetAllFieldsObjVars (NodeID id)
 
NodeBS getFieldsAfterCollapse (NodeID id)
 
NodeID addDummyValNode ()
 
NodeID addDummyObjNode (const SVFType *type)
 
bool isValidPointer (NodeID nodeId) const
 Whether a node is a valid pointer. More...
 
bool isValidTopLevelPtr (const SVFVar *node)
 
void print ()
 Print SVFIR. More...
 
- Public Member Functions inherited from SVF::IRGraph
 IRGraph (bool buildFromFile)
 
virtual ~IRGraph ()
 
SymbolTableInfogetSymbolInfo () const
 
bool isBuiltFromFile ()
 Whether this SVFIR built from a txt file. More...
 
const SVFStmtSetgetValueEdges (const SVFValue *V)
 Get all SVFIR Edges that corresponds to an LLVM value. More...
 
NodeID getValueNode (const SVFValue *V)
 
bool hasValueNode (const SVFValue *V)
 
NodeID getObjectNode (const SVFValue *V)
 
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 getBlackHoleNode () const
 
NodeID getConstantNode () const
 
NodeID getBlkPtr () const
 
NodeID getNullPtr () const
 
const MemObjgetBlackHoleObj () const
 
const MemObjgetConstantObj () const
 
u32_t getValueNodeNum () const
 
u32_t getObjectNodeNum () const
 
u32_t getNodeNumAfterPAGBuild () const
 
void setNodeNumAfterPAGBuild (u32_t num)
 
u32_t getPAGNodeNum () const
 
u32_t getPAGEdgeNum () const
 
u32_t getPTAPAGEdgeNum () const
 
std::string getGraphName () const
 Return graph name. More...
 
void dump (std::string name)
 Dump SVFIR. More...
 
void view ()
 View graph from the debugger. More...
 
- Public Member Functions inherited from SVF::GenericGraph< SVFVar, SVFStmt >
 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 SVFIRgetPAG (bool buildFromFile=false)
 Singleton design here to make sure we only have one instance during any analysis. More...
 
static void releaseSVFIR ()
 
static void handleBlackHole (bool b)
 SVFIR build configurations. More...
 

Private Member Functions

 SVFIR (bool buildFromFile)
 Constructor. More...
 
void destroy ()
 Clean up memory. More...
 
void addToStmt2TypeMap (SVFStmt *edge)
 Map a SVFStatement type to a set of corresponding SVF statements. More...
 
void addFunArgs (const SVFFunction *fun, const SVFVar *arg)
 Get/set method for function/callsite arguments and returns. More...
 
void addFunRet (const SVFFunction *fun, const SVFVar *ret)
 Add function returns. More...
 
void addCallSiteArgs (CallICFGNode *callBlockNode, const SVFVar *arg)
 Add callsite arguments. More...
 
void addCallSiteRets (RetICFGNode *retBlockNode, const SVFVar *arg)
 Add callsite returns. More...
 
void addIndirectCallsites (const CallICFGNode *cs, NodeID funPtr)
 Add indirect callsites. More...
 
NodeID addValNode (const SVFValue *val, NodeID i, const SVFBaseNode *gNode)
 add node into SVFIR More...
 
NodeID addObjNode (const SVFValue *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 SVFValue *curInst, const SVFValue *val, const AccessPath &ap, NodeID i, const SVFType *type)
 Add a temp field value node, this method can only invoked by getGepValVar. More...
 
NodeID addGepObjNode (const MemObj *obj, const APOffset &apOffset, const NodeID gepId)
 Add a field obj node, this method can only invoked by getGepObjVar. More...
 
NodeID addFIObjNode (const MemObj *obj)
 Add a field-insensitive node, this method can only invoked by getFIGepObjNode. More...
 
NodeID addDummyValNode (NodeID i)
 Add a dummy value/object node according to node ID (llvm value is null) More...
 
NodeID addDummyObjNode (NodeID i, const SVFType *type)
 
const MemObjaddDummyMemObj (NodeID i, const SVFType *type)
 
NodeID addBlackholeObjNode ()
 
NodeID addConstantObjNode ()
 
NodeID addBlackholePtrNode ()
 
NodeID addValNode (const SVFValue *, SVFVar *node, NodeID i)
 Add a value (pointer) node. More...
 
NodeID addObjNode (const SVFValue *, SVFVar *node, NodeID i)
 Add a memory obj node. More...
 
NodeID addRetNode (const SVFFunction *, SVFVar *node, NodeID i)
 Add a unique return node for a procedure. More...
 
NodeID addVarargNode (const SVFFunction *, SVFVar *node, NodeID i)
 Add a unique vararg node for a procedure. More...
 
void addGlobalPAGEdge (const SVFStmt *edge)
 Add global PAGEdges (not in a procedure) More...
 
void addCallSite (const CallICFGNode *call)
 Add callsites. More...
 
AddrStmtaddAddrStmt (NodeID src, NodeID dst)
 Add an edge into SVFIR. More...
 
CopyStmtaddCopyStmt (NodeID src, NodeID dst, CopyStmt::CopyKind type)
 Add Copy edge. More...
 
PhiStmtaddPhiStmt (NodeID res, NodeID opnd, const ICFGNode *pred)
 Add phi node information. More...
 
SelectStmtaddSelectStmt (NodeID res, NodeID op1, NodeID op2, NodeID cond)
 Add SelectStmt. More...
 
CmpStmtaddCmpStmt (NodeID op1, NodeID op2, NodeID dst, u32_t predict)
 Add Copy edge. More...
 
BinaryOPStmtaddBinaryOPStmt (NodeID op1, NodeID op2, NodeID dst, u32_t opcode)
 Add Copy edge. More...
 
UnaryOPStmtaddUnaryOPStmt (NodeID src, NodeID dst, u32_t opcode)
 Add Unary edge. More...
 
BranchStmtaddBranchStmt (NodeID br, NodeID cond, const BranchStmt::SuccAndCondPairVec &succs)
 Add BranchStmt. More...
 
LoadStmtaddLoadStmt (NodeID src, NodeID dst)
 Add Load edge. More...
 
StoreStmtaddStoreStmt (NodeID src, NodeID dst, const ICFGNode *val)
 Add Store edge. More...
 
CallPEaddCallPE (NodeID src, NodeID dst, const CallICFGNode *cs, const FunEntryICFGNode *entry)
 Add Call edge. More...
 
RetPEaddRetPE (NodeID src, NodeID dst, const CallICFGNode *cs, const FunExitICFGNode *exit)
 Add Return edge. More...
 
GepStmtaddGepStmt (NodeID src, NodeID dst, const AccessPath &ap, bool constGep)
 Add Gep edge. More...
 
GepStmtaddNormalGepStmt (NodeID src, NodeID dst, const AccessPath &ap)
 Add Offset(Gep) edge. More...
 
GepStmtaddVariantGepStmt (NodeID src, NodeID dst, const AccessPath &ap)
 Add Variant(Gep) edge. More...
 
TDForkPEaddThreadForkPE (NodeID src, NodeID dst, const CallICFGNode *cs, const FunEntryICFGNode *entry)
 Add Thread fork edge for parameter passing. More...
 
TDJoinPEaddThreadJoinPE (NodeID src, NodeID dst, const CallICFGNode *cs, const FunExitICFGNode *exit)
 Add Thread join edge for parameter passing. More...
 
SVFStmtaddBlackHoleAddrStmt (NodeID node)
 Set a pointer points-to black hole (e.g. int2ptr) More...
 

Private Attributes

ICFGNode2SVFStmtsMap icfgNode2SVFStmtsMap
 Map an ICFGNode to its SVFStmts. More...
 
ICFGNode2SVFStmtsMap icfgNode2PTASVFStmtsMap
 Map an ICFGNode to its PointerAnalysis related SVFStmts. More...
 
GepValueVarMap GepValObjMap
 Map a pair<base,off> to a gep value node id. More...
 
TypeLocSetsMap typeLocSetsMap
 Map an arg to its base SVFType* and all its field location sets. More...
 
NodeOffsetMap GepObjVarMap
 Map a pair<base,off> to a gep obj node id. More...
 
MemObjToFieldsMap memToFieldsMap
 Map a mem object id to all its fields. More...
 
SVFStmtSet globSVFStmtSet
 Global PAGEdges without control flow information. More...
 
PHINodeMap phiNodeMap
 A set of phi copy 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
 
OrderedNodeSet candidatePointers
 
SVFModulesvfModule
 
ICFGicfg
 SVF Module. More...
 
CommonCHGraphchgraph
 
CallSiteSet callSiteSet
 
PTACallGraphcallGraph
 all the callsites of a program More...
 

Static Private Attributes

static std::unique_ptr< SVFIRpag
 call graph More...
 

Friends

class SVFIRBuilder
 
class ExternalPAG
 
class PAGBuilderFromFile
 
class TypeBasedHeapCloning
 
class SVFIRWriter
 
class SVFIRReader
 
class BVDataPTAImpl
 

Additional Inherited Members

- Public Attributes inherited from SVF::GenericGraph< SVFVar, SVFStmt >
u32_t edgeNum
 total num of node More...
 
u32_t nodeNum
 total num of edge More...
 
- Protected Member Functions inherited from SVF::IRGraph
NodeID addNode (SVFVar *node, NodeID i)
 Add a node into the graph. More...
 
bool addEdge (SVFVar *src, SVFVar *dst, SVFStmt *edge)
 Add an edge into the graph. More...
 
SVFStmthasNonlabeledEdge (SVFVar *src, SVFVar *dst, SVFStmt::PEDGEK kind)
 
SVFStmthasLabeledEdge (SVFVar *src, SVFVar *dst, SVFStmt::PEDGEK kind, const ICFGNode *cs)
 
SVFStmthasLabeledEdge (SVFVar *src, SVFVar *op1, SVFStmt::PEDGEK kind, const SVFVar *op2)
 
void mapValueToEdge (const SVFValue *V, SVFStmt *edge)
 Map a value to a set of edges. More...
 
const MemObjgetMemObj (const SVFValue *val) const
 get MemObj according to LLVM value More...
 
- Protected Attributes inherited from SVF::IRGraph
SVFStmt::KindToSVFStmtMapTy KindToSVFStmtSetMap
 SVFIR edge map containing all PAGEdges. More...
 
SVFStmt::KindToSVFStmtMapTy KindToPTASVFStmtSetMap
 SVFIR edge map containing only pointer-related edges, i.e., both LHS and RHS are of pointer type. More...
 
bool fromFile
 Whether the SVFIR is built according to user specified data from a txt file. More...
 
NodeID nodeNumAfterPAGBuild
 initial node number after building SVFIR, excluding later added nodes, e.g., gepobj nodes More...
 
u32_t totalPTAPAGEdge
 
ValueToEdgeMap valueToEdgeMap
 Map SVFValues (e.g., ICFGNodes) to all corresponding PAGEdges. More...
 
SymbolTableInfosymInfo
 
- Protected Attributes inherited from SVF::GenericGraph< SVFVar, SVFStmt >
IDToNodeMapTy IDToNodeMap
 node map More...
 

Detailed Description

SVF Intermediate representation, representing variables and statements as a Program Assignment Graph (PAG) Variables as nodes and statements as edges. SymID and NodeID are equal here (same numbering).

Definition at line 43 of file SVFIR.h.

Member Typedef Documentation

◆ CallSiteSet

Definition at line 54 of file SVFIR.h.

◆ CallSiteToFunPtrMap

Definition at line 55 of file SVFIR.h.

◆ CSToArgsListMap

Definition at line 62 of file SVFIR.h.

◆ CSToRetMap

typedef Map<const RetICFGNode*,const SVFVar*> SVF::SVFIR::CSToRetMap

Definition at line 63 of file SVFIR.h.

◆ FunPtrToCallSitesMap

Definition at line 56 of file SVFIR.h.

◆ FunToArgsListMap

Definition at line 61 of file SVFIR.h.

◆ FunToPAGEdgeSetMap

Definition at line 65 of file SVFIR.h.

◆ FunToRetMap

Definition at line 64 of file SVFIR.h.

◆ GepValueVarMap

Definition at line 72 of file SVFIR.h.

◆ ICFGNode2SVFStmtsMap

Definition at line 66 of file SVFIR.h.

◆ MemObjToFieldsMap

Definition at line 57 of file SVFIR.h.

◆ NodeAccessPath

Definition at line 69 of file SVFIR.h.

◆ NodeAccessPathMap

Definition at line 71 of file SVFIR.h.

◆ NodeOffset

typedef std::pair<NodeID, APOffset> SVF::SVFIR::NodeOffset

Definition at line 68 of file SVFIR.h.

◆ NodeOffsetMap

Definition at line 70 of file SVFIR.h.

◆ NodePairSetMap

Definition at line 75 of file SVFIR.h.

◆ NodeToNodeMap

Definition at line 67 of file SVFIR.h.

◆ PHINodeMap

Definition at line 60 of file SVFIR.h.

◆ SVFStmtList

typedef std::vector<const SVFStmt*> SVF::SVFIR::SVFStmtList

Definition at line 58 of file SVFIR.h.

◆ SVFTypeLocSetsPair

typedef std::pair<const SVFType*, std::vector<AccessPath> > SVF::SVFIR::SVFTypeLocSetsPair

Definition at line 73 of file SVFIR.h.

◆ SVFVarList

typedef std::vector<const SVFVar*> SVF::SVFIR::SVFVarList

Definition at line 59 of file SVFIR.h.

◆ TypeLocSetsMap

Definition at line 74 of file SVFIR.h.

Constructor & Destructor Documentation

◆ SVFIR()

SVFIR::SVFIR ( bool  buildFromFile)
private

Constructor.

Definition at line 39 of file SVFIR.cpp.

39  : IRGraph(buildFromFile), svfModule(nullptr), icfg(nullptr), chgraph(nullptr)
40 {
41 }
IRGraph(bool buildFromFile)
Definition: IRGraph.h:104
CommonCHGraph * chgraph
Definition: SVFIR.h:99
SVFModule * svfModule
Definition: SVFIR.h:97
ICFG * icfg
SVF Module.
Definition: SVFIR.h:98

◆ ~SVFIR()

virtual SVF::SVFIR::~SVFIR ( )
inlinevirtual

Destructor.

Definition at line 147 of file SVFIR.h.

148  {
149  destroy();
150  }
void destroy()
Clean up memory.
Definition: SVFIR.cpp:539

Member Function Documentation

◆ addAddrStmt()

AddrStmt * SVFIR::addAddrStmt ( NodeID  src,
NodeID  dst 
)
private

Add an edge into SVFIR.

Add Address edge

Definition at line 46 of file SVFIR.cpp.

47 {
48  SVFVar* srcNode = getGNode(src);
49  SVFVar* dstNode = getGNode(dst);
50  if(hasNonlabeledEdge(srcNode,dstNode, SVFStmt::Addr))
51  return nullptr;
52  else
53  {
54  AddrStmt* addrPE = new AddrStmt(srcNode, dstNode);
55  addToStmt2TypeMap(addrPE);
56  addEdge(srcNode,dstNode, addrPE);
57  return addrPE;
58  }
59 }
NodeType * getGNode(NodeID id) const
Get a node.
Definition: GenericGraph.h:653
bool addEdge(SVFVar *src, SVFVar *dst, SVFStmt *edge)
Add an edge into the graph.
Definition: IRGraph.cpp:45
SVFStmt * hasNonlabeledEdge(SVFVar *src, SVFVar *dst, SVFStmt::PEDGEK kind)
Definition: IRGraph.cpp:60
void addToStmt2TypeMap(SVFStmt *edge)
Map a SVFStatement type to a set of corresponding SVF statements.
Definition: SVFIR.h:495

◆ addBinaryOPStmt()

BinaryOPStmt * SVFIR::addBinaryOPStmt ( NodeID  op1,
NodeID  op2,
NodeID  dst,
u32_t  opcode 
)
private

Add Copy edge.

Add Compare edge

Definition at line 148 of file SVFIR.cpp.

149 {
150  SVFVar* op1Node = getGNode(op1);
151  SVFVar* op2Node = getGNode(op2);
152  SVFVar* dstNode = getGNode(dst);
153  if(hasLabeledEdge(op1Node, dstNode, SVFStmt::BinaryOp, op2Node))
154  return nullptr;
155  else
156  {
157  std::vector<SVFVar*> opnds = {op1Node, op2Node};
158  BinaryOPStmt* binaryOP = new BinaryOPStmt(dstNode, opnds, opcode);
159  addToStmt2TypeMap(binaryOP);
160  addEdge(op1Node,dstNode, binaryOP);
161  return binaryOP;
162  }
163 }
SVFStmt * hasLabeledEdge(SVFVar *src, SVFVar *dst, SVFStmt::PEDGEK kind, const ICFGNode *cs)
Definition: IRGraph.cpp:88

◆ addBlackHoleAddrStmt()

SVFStmt * SVFIR::addBlackHoleAddrStmt ( NodeID  node)
private

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

Add blackhole/constant edge

Definition at line 277 of file SVFIR.cpp.

278 {
280  return pag->addAddrStmt(pag->getBlackHoleNode(), node);
281  else
282  return pag->addCopyStmt(pag->getNullPtr(), node, CopyStmt::COPYVAL);
283 }
static Option< bool > HandBlackHole
Definition: Options.h:102
static std::unique_ptr< SVFIR > pag
call graph
Definition: SVFIR.h:103

◆ addBlackholeObjNode()

NodeID SVF::SVFIR::addBlackholeObjNode ( )
inlineprivate

Definition at line 595 of file SVFIR.h.

596  {
597  return addObjNode(
598  nullptr, new DummyObjVar(getBlackHoleNode(), getBlackHoleObj()),
599  getBlackHoleNode());
600  }
NodeID getBlackHoleNode() const
Definition: IRGraph.h:161
const MemObj * getBlackHoleObj() const
Definition: IRGraph.h:177
NodeID addObjNode(const SVFValue *val, NodeID i)
Add a memory obj node.
Definition: SVFIR.h:553

◆ addBlackholePtrNode()

NodeID SVF::SVFIR::addBlackholePtrNode ( )
inlineprivate

Definition at line 607 of file SVFIR.h.

608  {
609  return addDummyValNode(getBlkPtr());
610  }
NodeID getBlkPtr() const
Definition: IRGraph.h:169
NodeID addDummyValNode()
Definition: SVFIR.h:474

◆ addBranchStmt()

BranchStmt * SVFIR::addBranchStmt ( NodeID  br,
NodeID  cond,
const BranchStmt::SuccAndCondPairVec succs 
)
private

Add BranchStmt.

Definition at line 186 of file SVFIR.cpp.

187 {
188  SVFVar* brNode = getGNode(br);
189  SVFVar* condNode = getGNode(cond);
190  if(hasNonlabeledEdge(condNode,brNode, SVFStmt::Branch))
191  return nullptr;
192  else
193  {
194  BranchStmt* branch = new BranchStmt(brNode, condNode, succs);
195  addToStmt2TypeMap(branch);
196  addEdge(condNode,brNode, branch);
197  return branch;
198  }
199 }

◆ addCallPE()

CallPE * SVFIR::addCallPE ( NodeID  src,
NodeID  dst,
const CallICFGNode cs,
const FunEntryICFGNode entry 
)
private

Add Call edge.

Add Call edge

Definition at line 241 of file SVFIR.cpp.

242 {
243  SVFVar* srcNode = getGNode(src);
244  SVFVar* dstNode = getGNode(dst);
245  if(hasLabeledEdge(srcNode,dstNode, SVFStmt::Call, cs))
246  return nullptr;
247  else
248  {
249  CallPE* callPE = new CallPE(srcNode, dstNode, cs,entry);
250  addToStmt2TypeMap(callPE);
251  addEdge(srcNode,dstNode, callPE);
252  return callPE;
253  }
254 }

◆ addCallSite()

void SVF::SVFIR::addCallSite ( const CallICFGNode call)
inlineprivate

Add callsites.

Definition at line 646 of file SVFIR.h.

647  {
648  callSiteSet.insert(call);
649  }
CallSiteSet callSiteSet
Definition: SVFIR.h:100

◆ addCallSiteArgs()

void SVF::SVFIR::addCallSiteArgs ( CallICFGNode callBlockNode,
const SVFVar arg 
)
inlineprivate

Add callsite arguments.

Definition at line 524 of file SVFIR.h.

525  {
526  callBlockNode->addActualParms(arg);
527  callSiteArgsListMap[callBlockNode].push_back(arg);
528  }
CSToArgsListMap callSiteArgsListMap
Map a callsite to a list of all its actual parameters.
Definition: SVFIR.h:89

◆ addCallSiteRets()

void SVF::SVFIR::addCallSiteRets ( RetICFGNode retBlockNode,
const SVFVar arg 
)
inlineprivate

Add callsite returns.

Definition at line 530 of file SVFIR.h.

531  {
532  retBlockNode->addActualRet(arg);
533  callSiteRetMap[retBlockNode]= arg;
534  }
CSToRetMap callSiteRetMap
Map a callsite to its callsite returns PAGNodes.
Definition: SVFIR.h:90

◆ addCmpStmt()

CmpStmt * SVFIR::addCmpStmt ( NodeID  op1,
NodeID  op2,
NodeID  dst,
u32_t  predicate 
)
private

Add Copy edge.

Add Compare edge

Definition at line 127 of file SVFIR.cpp.

128 {
129  SVFVar* op1Node = getGNode(op1);
130  SVFVar* op2Node = getGNode(op2);
131  SVFVar* dstNode = getGNode(dst);
132  if(hasLabeledEdge(op1Node, dstNode, SVFStmt::Cmp, op2Node))
133  return nullptr;
134  else
135  {
136  std::vector<SVFVar*> opnds = {op1Node, op2Node};
137  CmpStmt* cmp = new CmpStmt(dstNode, opnds, predicate);
138  addToStmt2TypeMap(cmp);
139  addEdge(op1Node, dstNode, cmp);
140  return cmp;
141  }
142 }

◆ addConstantObjNode()

NodeID SVF::SVFIR::addConstantObjNode ( )
inlineprivate

Definition at line 601 of file SVFIR.h.

602  {
603  return addObjNode(nullptr,
604  new DummyObjVar(getConstantNode(), getConstantObj()),
605  getConstantNode());
606  }
NodeID getConstantNode() const
Definition: IRGraph.h:165
const MemObj * getConstantObj() const
Definition: IRGraph.h:181

◆ addCopyStmt()

CopyStmt * SVFIR::addCopyStmt ( NodeID  src,
NodeID  dst,
CopyStmt::CopyKind  type 
)
private

Add Copy edge.

Add Copy edge

Definition at line 64 of file SVFIR.cpp.

65 {
66  SVFVar* srcNode = getGNode(src);
67  SVFVar* dstNode = getGNode(dst);
68  if(hasNonlabeledEdge(srcNode,dstNode, SVFStmt::Copy))
69  return nullptr;
70  else
71  {
72  CopyStmt* copyPE = new CopyStmt(srcNode, dstNode, type);
73  addToStmt2TypeMap(copyPE);
74  addEdge(srcNode,dstNode, copyPE);
75  return copyPE;
76  }
77 }
newitem type
Definition: cJSON.cpp:2739

◆ addDummyMemObj()

const MemObj* SVF::SVFIR::addDummyMemObj ( NodeID  i,
const SVFType type 
)
inlineprivate

Definition at line 591 of file SVFIR.h.

592  {
593  return getSymbolInfo()->createDummyObj(i,type);
594  }
SymbolTableInfo * getSymbolInfo() const
Definition: IRGraph.h:114
const MemObj * createDummyObj(SymID symId, const SVFType *type)
Can only be invoked by SVFIR::addDummyNode() when creating SVFIR from file.

◆ addDummyObjNode() [1/2]

NodeID SVF::SVFIR::addDummyObjNode ( const SVFType type)
inline

Definition at line 478 of file SVFIR.h.

479  {
480  return addDummyObjNode(NodeIDAllocator::get()->allocateObjectId(), type);
481  }
static NodeIDAllocator * get(void)
Return (singleton) allocator.
NodeID addDummyObjNode(const SVFType *type)
Definition: SVFIR.h:478

◆ addDummyObjNode() [2/2]

NodeID SVF::SVFIR::addDummyObjNode ( NodeID  i,
const SVFType type 
)
inlineprivate

Definition at line 586 of file SVFIR.h.

587  {
588  const MemObj* mem = addDummyMemObj(i, type);
589  return addObjNode(nullptr, new DummyObjVar(i,mem), i);
590  }
const MemObj * addDummyMemObj(NodeID i, const SVFType *type)
Definition: SVFIR.h:591

◆ addDummyValNode() [1/2]

NodeID SVF::SVFIR::addDummyValNode ( )
inline

Definition at line 474 of file SVFIR.h.

475  {
476  return addDummyValNode(NodeIDAllocator::get()->allocateValueId());
477  }

◆ addDummyValNode() [2/2]

NodeID SVF::SVFIR::addDummyValNode ( NodeID  i)
inlineprivate

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

Definition at line 582 of file SVFIR.h.

583  {
584  return addValNode(nullptr, new DummyValVar(i), i);
585  }
NodeID addValNode(const SVFValue *val, NodeID i, const SVFBaseNode *gNode)
add node into SVFIR
Definition: SVFIR.h:547

◆ addFIObjNode()

NodeID SVFIR::addFIObjNode ( const MemObj obj)
private

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 465 of file SVFIR.cpp.

466 {
467  //assert(findPAGNode(i) == false && "this node should not be created before");
468  NodeID base = obj->getId();
469  memToFieldsMap[base].set(obj->getId());
470  FIObjVar *node = new FIObjVar(obj->getValue(), obj->getId(), obj);
471  return addObjNode(obj->getValue(), node, obj->getId());
472 }
const SVFValue * getValue() const
Get the reference value to this object.
SymID getId() const
Get the memory object id.
MemObjToFieldsMap memToFieldsMap
Map a mem object id to all its fields.
Definition: SVFIR.h:85
u32_t NodeID
Definition: GeneralType.h:55

◆ addFunArgs()

void SVF::SVFIR::addFunArgs ( const SVFFunction fun,
const SVFVar arg 
)
inlineprivate

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

Add function arguments

Definition at line 510 of file SVFIR.h.

511  {
512  FunEntryICFGNode* funEntryBlockNode = icfg->getFunEntryICFGNode(fun);
513  funEntryBlockNode->addFormalParms(arg);
514  funArgsListMap[fun].push_back(arg);
515  }
void addFormalParms(const SVFVar *fp)
Add formal parameters.
Definition: ICFGNode.h:307
FunEntryICFGNode * getFunEntryICFGNode(const SVFFunction *fun)
Add a function entry node.
Definition: ICFG.cpp:234
FunToArgsListMap funArgsListMap
Map a function to a list of all its formal parameters.
Definition: SVFIR.h:88

◆ addFunRet()

void SVF::SVFIR::addFunRet ( const SVFFunction fun,
const SVFVar ret 
)
inlineprivate

Add function returns.

Definition at line 517 of file SVFIR.h.

518  {
519  FunExitICFGNode* funExitBlockNode = icfg->getFunExitICFGNode(fun);
520  funExitBlockNode->addFormalRet(ret);
521  funRetMap[fun] = ret;
522  }
void addFormalRet(const SVFVar *fr)
Add formal return parameter.
Definition: ICFGNode.h:378
FunExitICFGNode * getFunExitICFGNode(const SVFFunction *fun)
Add a function exit node.
Definition: ICFG.cpp:241
FunToRetMap funRetMap
Map a function to its unique function return PAGNodes.
Definition: SVFIR.h:91

◆ addGepObjNode()

NodeID SVFIR::addGepObjNode ( const MemObj obj,
const APOffset apOffset,
const NodeID  gepId 
)
private

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

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

Definition at line 449 of file SVFIR.cpp.

450 {
451  //assert(findPAGNode(i) == false && "this node should not be created before");
452  NodeID base = obj->getId();
453  assert(0==GepObjVarMap.count(std::make_pair(base, apOffset))
454  && "this node should not be created before");
455 
456  GepObjVarMap[std::make_pair(base, apOffset)] = gepId;
457  GepObjVar *node = new GepObjVar(obj, gepId, apOffset);
458  memToFieldsMap[base].set(gepId);
459  return addObjNode(obj->getValue(), node, gepId);
460 }
NodeOffsetMap GepObjVarMap
Map a pair<base,off> to a gep obj node id.
Definition: SVFIR.h:84

◆ addGepStmt()

GepStmt * SVFIR::addGepStmt ( NodeID  src,
NodeID  dst,
const AccessPath ap,
bool  constGep 
)
private

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 Variant GepStmt edge.

Definition at line 327 of file SVFIR.cpp.

328 {
329 
330  SVFVar* node = getGNode(src);
331  if (!constGep || node->hasIncomingVariantGepEdge())
332  {
335  return addVariantGepStmt(src, dst, ap);
336  }
337  else
338  {
339  return addNormalGepStmt(src, dst, ap);
340  }
341 }
GepStmt * addVariantGepStmt(NodeID src, NodeID dst, const AccessPath &ap)
Add Variant(Gep) edge.
Definition: SVFIR.cpp:365
GepStmt * addNormalGepStmt(NodeID src, NodeID dst, const AccessPath &ap)
Add Offset(Gep) edge.
Definition: SVFIR.cpp:346
bool hasIncomingVariantGepEdge() const
Has incoming VariantGepEdges.
Definition: SVFVariables.h:230

◆ addGepValNode()

NodeID SVFIR::addGepValNode ( const SVFValue curInst,
const SVFValue gepVal,
const AccessPath ap,
NodeID  i,
const SVFType type 
)
private

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

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

Definition at line 386 of file SVFIR.cpp.

387 {
388  NodeID base = getValueNode(gepVal);
389  //assert(findPAGNode(i) == false && "this node should not be created before");
390  assert(0==GepValObjMap[curInst].count(std::make_pair(base, ap))
391  && "this node should not be created before");
392  GepValObjMap[curInst][std::make_pair(base, ap)] = i;
393  GepValVar *node = new GepValVar(gepVal, i, ap, type);
394  return addValNode(gepVal, node, i);
395 }
int count
Definition: cJSON.h:216
NodeID getValueNode(const SVFValue *V)
Definition: IRGraph.h:137
GepValueVarMap GepValObjMap
Map a pair<base,off> to a gep value node id.
Definition: SVFIR.h:82

◆ addGlobalPAGEdge()

void SVF::SVFIR::addGlobalPAGEdge ( const SVFStmt edge)
inlineprivate

Add global PAGEdges (not in a procedure)

Definition at line 641 of file SVFIR.h.

642  {
643  globSVFStmtSet.insert(edge);
644  }
SVFStmtSet globSVFStmtSet
Global PAGEdges without control flow information.
Definition: SVFIR.h:86

◆ addIndirectCallsites()

void SVF::SVFIR::addIndirectCallsites ( const CallICFGNode cs,
NodeID  funPtr 
)
inlineprivate

Add indirect callsites.

Definition at line 536 of file SVFIR.h.

537  {
538  bool added = indCallSiteToFunPtrMap.emplace(cs, funPtr).second;
539  (void) added;
540  funPtrToCallSitesMap[funPtr].insert(cs);
541  assert(added && "adding the same indirect callsite twice?");
542  }
CallSiteToFunPtrMap indCallSiteToFunPtrMap
Map an indirect callsite to its function pointer.
Definition: SVFIR.h:92
FunPtrToCallSitesMap funPtrToCallSitesMap
Definition: SVFIR.h:93

◆ addLoadStmt()

LoadStmt * SVFIR::addLoadStmt ( NodeID  src,
NodeID  dst 
)
private

Add Load edge.

Add Load edge

Definition at line 204 of file SVFIR.cpp.

205 {
206  SVFVar* srcNode = getGNode(src);
207  SVFVar* dstNode = getGNode(dst);
208  if(hasNonlabeledEdge(srcNode,dstNode, SVFStmt::Load))
209  return nullptr;
210  else
211  {
212  LoadStmt* loadPE = new LoadStmt(srcNode, dstNode);
213  addToStmt2TypeMap(loadPE);
214  addEdge(srcNode,dstNode, loadPE);
215  return loadPE;
216  }
217 }

◆ addNormalGepStmt()

GepStmt * SVFIR::addNormalGepStmt ( NodeID  src,
NodeID  dst,
const AccessPath ap 
)
private

Add Offset(Gep) edge.

Add normal (Gep) edge

Definition at line 346 of file SVFIR.cpp.

347 {
348  SVFVar* baseNode = getGNode(src);
349  SVFVar* dstNode = getGNode(dst);
350  if(hasNonlabeledEdge(baseNode, dstNode, SVFStmt::Gep))
351  return nullptr;
352  else
353  {
354  GepStmt* gepPE = new GepStmt(baseNode, dstNode, ap);
355  addToStmt2TypeMap(gepPE);
356  addEdge(baseNode, dstNode, gepPE);
357  return gepPE;
358  }
359 }

◆ addObjNode() [1/2]

NodeID SVF::SVFIR::addObjNode ( const SVFValue ,
SVFVar node,
NodeID  i 
)
inlineprivate

Add a memory obj node.

Definition at line 622 of file SVFIR.h.

623  {
624  assert(hasGNode(i) == false &&
625  "This NodeID clashes here. Please check NodeIDAllocator. Switch "
626  "Strategy::DBUG to SEQ or DENSE");
627  return addNode(node, i);
628  }
bool hasGNode(NodeID id) const
Has a node.
Definition: GenericGraph.h:661
NodeID addNode(SVFVar *node, NodeID i)
Add a node into the graph.
Definition: IRGraph.h:68

◆ addObjNode() [2/2]

NodeID SVF::SVFIR::addObjNode ( const SVFValue val,
NodeID  i 
)
inlineprivate

Add a memory obj node.

Definition at line 553 of file SVFIR.h.

554  {
555  const MemObj* mem = getMemObj(val);
556  assert(mem->getId() == i && "not same object id?");
557  return addFIObjNode(mem);
558  }
const MemObj * getMemObj(const SVFValue *val) const
get MemObj according to LLVM value
Definition: IRGraph.h:98
NodeID addFIObjNode(const MemObj *obj)
Add a field-insensitive node, this method can only invoked by getFIGepObjNode.
Definition: SVFIR.cpp:465

◆ addPhiStmt()

PhiStmt * SVFIR::addPhiStmt ( NodeID  res,
NodeID  opnd,
const ICFGNode pred 
)
private

Add phi node information.

Add Phi statement

return null if we already added this PhiStmt

Definition at line 82 of file SVFIR.cpp.

83 {
84  SVFVar* opNode = getGNode(opnd);
85  SVFVar* resNode = getGNode(res);
86  PHINodeMap::iterator it = phiNodeMap.find(resNode);
87  if(it == phiNodeMap.end())
88  {
89  PhiStmt* phi = new PhiStmt(resNode, {opNode}, {pred});
90  addToStmt2TypeMap(phi);
91  addEdge(opNode, resNode, phi);
92  phiNodeMap[resNode] = phi;
93  return phi;
94  }
95  else
96  {
97  it->second->addOpVar(opNode,pred);
99  return nullptr;
100  }
101 }
void addOpVar(SVFVar *op, const ICFGNode *inode)
PHINodeMap phiNodeMap
A set of phi copy edges.
Definition: SVFIR.h:87

◆ addRetNode() [1/2]

NodeID SVF::SVFIR::addRetNode ( const SVFFunction ,
SVFVar node,
NodeID  i 
)
inlineprivate

Add a unique return node for a procedure.

Definition at line 630 of file SVFIR.h.

631  {
632  return addNode(node,i);
633  }

◆ addRetNode() [2/2]

NodeID SVF::SVFIR::addRetNode ( const SVFFunction val,
NodeID  i 
)
inlineprivate

Add a unique return node for a procedure.

Definition at line 560 of file SVFIR.h.

561  {
562  SVFVar *node = new RetPN(val,i);
563  return addRetNode(val, node, i);
564  }
NodeID addRetNode(const SVFFunction *val, NodeID i)
Add a unique return node for a procedure.
Definition: SVFIR.h:560

◆ addRetPE()

RetPE * SVFIR::addRetPE ( NodeID  src,
NodeID  dst,
const CallICFGNode cs,
const FunExitICFGNode exit 
)
private

Add Return edge.

Add Return edge

Definition at line 259 of file SVFIR.cpp.

260 {
261  SVFVar* srcNode = getGNode(src);
262  SVFVar* dstNode = getGNode(dst);
263  if(hasLabeledEdge(srcNode,dstNode, SVFStmt::Ret, cs))
264  return nullptr;
265  else
266  {
267  RetPE* retPE = new RetPE(srcNode, dstNode, cs, exit);
268  addToStmt2TypeMap(retPE);
269  addEdge(srcNode,dstNode, retPE);
270  return retPE;
271  }
272 }

◆ addSelectStmt()

SelectStmt * SVFIR::addSelectStmt ( NodeID  res,
NodeID  op1,
NodeID  op2,
NodeID  cond 
)
private

Add SelectStmt.

Add Phi statement

Definition at line 106 of file SVFIR.cpp.

107 {
108  SVFVar* op1Node = getGNode(op1);
109  SVFVar* op2Node = getGNode(op2);
110  SVFVar* dstNode = getGNode(res);
111  SVFVar* condNode = getGNode(cond);
112  if(hasLabeledEdge(op1Node, dstNode, SVFStmt::Select, op2Node))
113  return nullptr;
114  else
115  {
116  std::vector<SVFVar*> opnds = {op1Node, op2Node};
117  SelectStmt* select = new SelectStmt(dstNode, opnds, condNode);
118  addToStmt2TypeMap(select);
119  addEdge(op1Node, dstNode, select);
120  return select;
121  }
122 }

◆ addStoreStmt()

StoreStmt * SVFIR::addStoreStmt ( NodeID  src,
NodeID  dst,
const ICFGNode curVal 
)
private

Add Store edge.

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

Definition at line 223 of file SVFIR.cpp.

224 {
225  SVFVar* srcNode = getGNode(src);
226  SVFVar* dstNode = getGNode(dst);
227  if(hasLabeledEdge(srcNode,dstNode, SVFStmt::Store, curVal))
228  return nullptr;
229  else
230  {
231  StoreStmt* storePE = new StoreStmt(srcNode, dstNode, curVal);
232  addToStmt2TypeMap(storePE);
233  addEdge(srcNode,dstNode, storePE);
234  return storePE;
235  }
236 }

◆ addThreadForkPE()

TDForkPE * SVFIR::addThreadForkPE ( NodeID  src,
NodeID  dst,
const CallICFGNode cs,
const FunEntryICFGNode entry 
)
private

Add Thread fork edge for parameter passing.

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

Definition at line 288 of file SVFIR.cpp.

289 {
290  SVFVar* srcNode = getGNode(src);
291  SVFVar* dstNode = getGNode(dst);
292  if(hasLabeledEdge(srcNode,dstNode, SVFStmt::ThreadFork, cs))
293  return nullptr;
294  else
295  {
296  TDForkPE* forkPE = new TDForkPE(srcNode, dstNode, cs, entry);
297  addToStmt2TypeMap(forkPE);
298  addEdge(srcNode,dstNode, forkPE);
299  return forkPE;
300  }
301 }

◆ addThreadJoinPE()

TDJoinPE * SVFIR::addThreadJoinPE ( NodeID  src,
NodeID  dst,
const CallICFGNode cs,
const FunExitICFGNode exit 
)
private

Add Thread join edge for parameter passing.

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

Definition at line 306 of file SVFIR.cpp.

307 {
308  SVFVar* srcNode = getGNode(src);
309  SVFVar* dstNode = getGNode(dst);
310  if(hasLabeledEdge(srcNode,dstNode, SVFStmt::ThreadJoin, cs))
311  return nullptr;
312  else
313  {
314  TDJoinPE* joinPE = new TDJoinPE(srcNode, dstNode, cs, exit);
315  addToStmt2TypeMap(joinPE);
316  addEdge(srcNode,dstNode, joinPE);
317  return joinPE;
318  }
319 }

◆ addToStmt2TypeMap()

void SVF::SVFIR::addToStmt2TypeMap ( SVFStmt edge)
inlineprivate

Map a SVFStatement type to a set of corresponding SVF statements.

this is a pointer-related SVFStmt if (1) both RHS and LHS are pointers or (2) this an int2ptr statment, i.e., LHS = int2ptr RHS

Definition at line 495 of file SVFIR.h.

496  {
497  bool added = KindToSVFStmtSetMap[edge->getEdgeKind()].insert(edge).second;
498  (void)added; // Suppress warning of unused variable under release build
499  assert(added && "duplicated edge, not added!!!");
501  if (edge->isPTAEdge() || (SVFUtil::isa<CopyStmt>(edge) && SVFUtil::cast<CopyStmt>(edge)->isInt2Ptr()))
502  {
503  totalPTAPAGEdge++;
504  KindToPTASVFStmtSetMap[edge->getEdgeKind()].insert(edge);
505  }
506  }
SVFStmt::KindToSVFStmtMapTy KindToSVFStmtSetMap
SVFIR edge map containing all PAGEdges.
Definition: IRGraph.h:59
u32_t totalPTAPAGEdge
Definition: IRGraph.h:63
SVFStmt::KindToSVFStmtMapTy KindToPTASVFStmtSetMap
SVFIR edge map containing only pointer-related edges, i.e., both LHS and RHS are of pointer type.
Definition: IRGraph.h:60

◆ addToSVFStmtList()

void SVF::SVFIR::addToSVFStmtList ( ICFGNode inst,
SVFStmt edge 
)
inline

Add a SVFStmt into instruction map.

Definition at line 231 of file SVFIR.h.

232  {
233  edge->setICFGNode(inst);
234  icfgNode2SVFStmtsMap[inst].push_back(edge);
235  if (edge->isPTAEdge())
236  icfgNode2PTASVFStmtsMap[inst].push_back(edge);
237  }
ICFGNode2SVFStmtsMap icfgNode2SVFStmtsMap
Map an ICFGNode to its SVFStmts.
Definition: SVFIR.h:80
ICFGNode2SVFStmtsMap icfgNode2PTASVFStmtsMap
Map an ICFGNode to its PointerAnalysis related SVFStmts.
Definition: SVFIR.h:81

◆ addToTypeLocSetsMap()

void SVF::SVFIR::addToTypeLocSetsMap ( NodeID  argId,
SVFTypeLocSetsPair locSets 
)
inline

Add a base SVFType* and all its field location sets to an arg NodeId.

Definition at line 239 of file SVFIR.h.

240  {
241  typeLocSetsMap[argId]=locSets;
242  }
TypeLocSetsMap typeLocSetsMap
Map an arg to its base SVFType* and all its field location sets.
Definition: SVFIR.h:83

◆ addUnaryOPStmt()

UnaryOPStmt * SVFIR::addUnaryOPStmt ( NodeID  src,
NodeID  dst,
u32_t  opcode 
)
private

Add Unary edge.

Add Unary edge

Definition at line 168 of file SVFIR.cpp.

169 {
170  SVFVar* srcNode = getGNode(src);
171  SVFVar* dstNode = getGNode(dst);
172  if(hasNonlabeledEdge(srcNode,dstNode, SVFStmt::UnaryOp))
173  return nullptr;
174  else
175  {
176  UnaryOPStmt* unaryOP = new UnaryOPStmt(srcNode, dstNode, opcode);
177  addToStmt2TypeMap(unaryOP);
178  addEdge(srcNode,dstNode, unaryOP);
179  return unaryOP;
180  }
181 }

◆ addValNode() [1/2]

NodeID SVF::SVFIR::addValNode ( const SVFValue ,
SVFVar node,
NodeID  i 
)
inlineprivate

Add a value (pointer) node.

Definition at line 614 of file SVFIR.h.

615  {
616  assert(hasGNode(i) == false &&
617  "This NodeID clashes here. Please check NodeIDAllocator. Switch "
618  "Strategy::DBUG to SEQ or DENSE");
619  return addNode(node, i);
620  }

◆ addValNode() [2/2]

NodeID SVF::SVFIR::addValNode ( const SVFValue val,
NodeID  i,
const SVFBaseNode gNode 
)
inlineprivate

add node into SVFIR

Add a value (pointer) node

Definition at line 547 of file SVFIR.h.

548  {
549  SVFVar *node = new ValVar(val,i, ValVar::ValNode, gNode);
550  return addValNode(val, node, i);
551  }

◆ addVarargNode() [1/2]

NodeID SVF::SVFIR::addVarargNode ( const SVFFunction ,
SVFVar node,
NodeID  i 
)
inlineprivate

Add a unique vararg node for a procedure.

Definition at line 635 of file SVFIR.h.

636  {
637  return addNode(node,i);
638  }

◆ addVarargNode() [2/2]

NodeID SVF::SVFIR::addVarargNode ( const SVFFunction val,
NodeID  i 
)
inlineprivate

Add a unique vararg node for a procedure.

Definition at line 566 of file SVFIR.h.

567  {
568  SVFVar *node = new VarArgPN(val,i);
569  return addNode(node,i);
570  }

◆ addVariantGepStmt()

GepStmt * SVFIR::addVariantGepStmt ( NodeID  src,
NodeID  dst,
const AccessPath ap 
)
private

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 365 of file SVFIR.cpp.

366 {
367  SVFVar* baseNode = getGNode(src);
368  SVFVar* dstNode = getGNode(dst);
369  if(hasNonlabeledEdge(baseNode, dstNode, SVFStmt::Gep))
370  return nullptr;
371  else
372  {
373  GepStmt* gepPE = new GepStmt(baseNode, dstNode, ap, true);
374  addToStmt2TypeMap(gepPE);
375  addEdge(baseNode, dstNode, gepPE);
376  return gepPE;
377  }
378 }

◆ callsiteHasRet()

bool SVF::SVFIR::callsiteHasRet ( const RetICFGNode cs) const
inline

Definition at line 310 of file SVFIR.h.

311  {
312  return callSiteRetMap.find(cs) != callSiteRetMap.end();
313  }

◆ destroy()

void SVFIR::destroy ( )
private

Clean up memory.

Clean up memory

Definition at line 539 of file SVFIR.cpp.

540 {
541  delete icfg;
542  icfg = nullptr;
543  delete chgraph;
544  chgraph = nullptr;
546  svfModule = nullptr;
547  delete callGraph;
548  callGraph = nullptr;
549 }
PTACallGraph * callGraph
all the callsites of a program
Definition: SVFIR.h:101
static void releaseSVFModule()
Definition: SVFModule.cpp:69

◆ funHasRet()

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

Definition at line 326 of file SVFIR.h.

327  {
328  return funRetMap.find(func) != funRetMap.end();
329  }

◆ getAllFieldsObjVars() [1/2]

NodeBS & SVFIR::getAllFieldsObjVars ( const MemObj obj)

Get all fields of an object.

Get all fields object nodes of an object

Definition at line 477 of file SVFIR.cpp.

478 {
479  NodeID base = obj->getId();
480  return memToFieldsMap[base];
481 }

◆ getAllFieldsObjVars() [2/2]

NodeBS & SVFIR::getAllFieldsObjVars ( NodeID  id)

Get all fields object nodes of an object

Definition at line 486 of file SVFIR.cpp.

487 {
488  const SVFVar* node = pag->getGNode(id);
489  assert(SVFUtil::isa<ObjVar>(node) && "need an object node");
490  const ObjVar* obj = SVFUtil::cast<ObjVar>(node);
491  return getAllFieldsObjVars(obj->getMemObj());
492 }
const MemObj * getMemObj() const
Return memory object.
Definition: SVFVariables.h:358
NodeBS & getAllFieldsObjVars(const MemObj *obj)
Get all fields of an object.
Definition: SVFIR.cpp:477

◆ getAllValidPtrs()

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

Return valid pointers.

Definition at line 139 of file SVFIR.h.

140  {
141  return candidatePointers;
142  }
OrderedNodeSet candidatePointers
Definition: SVFIR.h:96

◆ getBaseObj()

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

Definition at line 459 of file SVFIR.h.

460  {
461  const SVFVar* node = pag->getGNode(id);
462  assert(SVFUtil::isa<ObjVar>(node) && "need an object node");
463  const ObjVar* obj = SVFUtil::cast<ObjVar>(node);
464  return obj->getMemObj();
465  }

◆ getBaseObjVar()

NodeID SVF::SVFIR::getBaseObjVar ( NodeID  id) const
inline

Base and Offset methods for Value and Object node.

Get a base pointer node given a field pointer

Definition at line 455 of file SVFIR.h.

456  {
457  return getBaseObj(id)->getId();
458  }
const MemObj * getBaseObj(NodeID id) const
Definition: SVFIR.h:459

◆ getCallGraph()

PTACallGraph* SVF::SVFIR::getCallGraph ( )
inline

Definition at line 192 of file SVFIR.h.

193  {
194  assert(callGraph && "empty PTACallGraph! Build SVF IR first!");
195  return callGraph;
196  }

◆ getCallSiteArgsList()

const SVFVarList& SVF::SVFIR::getCallSiteArgsList ( const CallICFGNode cs) const
inline

Get callsite argument list.

Definition at line 292 of file SVFIR.h.

293  {
294  CSToArgsListMap::const_iterator it = callSiteArgsListMap.find(cs);
295  assert(it != callSiteArgsListMap.end() && "this call site doesn't have arguments");
296  return it->second;
297  }

◆ getCallSiteArgsMap()

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

Get callsite argument list.

Definition at line 287 of file SVFIR.h.

288  {
289  return callSiteArgsListMap;
290  }

◆ getCallSiteRet()

const SVFVar* SVF::SVFIR::getCallSiteRet ( const RetICFGNode cs) const
inline

Get callsite return.

Definition at line 304 of file SVFIR.h.

305  {
306  CSToRetMap::const_iterator it = callSiteRetMap.find(cs);
307  assert(it != callSiteRetMap.end() && "this call site doesn't have return");
308  return it->second;
309  }

◆ getCallSiteRets()

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

Get callsite return.

Definition at line 299 of file SVFIR.h.

300  {
301  return callSiteRetMap;
302  }

◆ getCallSiteSet()

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

Get all callsites.

Definition at line 254 of file SVFIR.h.

255  {
256  return callSiteSet;
257  }

◆ getCHG()

CommonCHGraph* SVF::SVFIR::getCHG ( )
inline

Definition at line 181 of file SVFIR.h.

182  {
183  assert(chgraph && "empty ICFG! Build SVF IR first!");
184  return chgraph;
185  }

◆ getFieldObjNodeNum()

u32_t SVF::SVFIR::getFieldObjNodeNum ( ) const
inline

Definition at line 338 of file SVFIR.h.

339  {
340  return GepObjVarMap.size();
341  }

◆ getFieldsAfterCollapse()

NodeBS SVFIR::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 499 of file SVFIR.cpp.

500 {
501  const SVFVar* node = pag->getGNode(id);
502  assert(SVFUtil::isa<ObjVar>(node) && "need an object node");
503  const MemObj* mem = SVFUtil::cast<ObjVar>(node)->getMemObj();
504  if(mem->isFieldInsensitive())
505  {
506  NodeBS bs;
507  bs.set(getFIObjVar(mem));
508  return bs;
509  }
510  else
511  return getAllFieldsObjVars(mem);
512 }
bool isFieldInsensitive() const
Return true if its field limit is 0.
NodeID getFIObjVar(const MemObj *obj) const
Get a field-insensitive obj SVFIR node according to a mem obj.
Definition: SVFIR.h:415
void set(unsigned Idx)

◆ getFieldValNodeNum()

u32_t SVF::SVFIR::getFieldValNodeNum ( ) const
inline

Node and edge statistics.

Definition at line 334 of file SVFIR.h.

335  {
336  return GepValObjMap.size();
337  }

◆ getFIObjVar() [1/2]

NodeID SVF::SVFIR::getFIObjVar ( const MemObj obj) const
inline

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

Definition at line 415 of file SVFIR.h.

416  {
417  return obj->getId();
418  }

◆ getFIObjVar() [2/2]

NodeID SVF::SVFIR::getFIObjVar ( NodeID  id) const
inline

Definition at line 419 of file SVFIR.h.

420  {
421  return getBaseObjVar(id);
422  }
NodeID getBaseObjVar(NodeID id) const
Base and Offset methods for Value and Object node.
Definition: SVFIR.h:455

◆ getFunArgsList()

const SVFVarList& SVF::SVFIR::getFunArgsList ( const SVFFunction func) const
inline

Get function arguments list.

Definition at line 275 of file SVFIR.h.

276  {
277  FunToArgsListMap::const_iterator it = funArgsListMap.find(func);
278  assert(it != funArgsListMap.end() && "this function doesn't have arguments");
279  return it->second;
280  }

◆ getFunArgsMap()

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

Get function arguments list.

Definition at line 270 of file SVFIR.h.

271  {
272  return funArgsListMap;
273  }

◆ getFunPtr()

NodeID SVF::SVFIR::getFunPtr ( const CallICFGNode cs) const
inline

Definition at line 354 of file SVFIR.h.

355  {
356  CallSiteToFunPtrMap::const_iterator it = indCallSiteToFunPtrMap.find(cs);
357  assert(it!=indCallSiteToFunPtrMap.end() && "indirect callsite not have a function pointer?");
358  return it->second;
359  }

◆ getFunRet()

const SVFVar* SVF::SVFIR::getFunRet ( const SVFFunction func) const
inline

Get function return list.

Definition at line 320 of file SVFIR.h.

321  {
322  FunToRetMap::const_iterator it = funRetMap.find(func);
323  assert(it != funRetMap.end() && "this function doesn't have return");
324  return it->second;
325  }

◆ getFunRets()

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

Get function return list.

Definition at line 315 of file SVFIR.h.

316  {
317  return funRetMap;
318  }

◆ getGepObjNodeMap()

NodeOffsetMap& SVF::SVFIR::getGepObjNodeMap ( )
inline

Return GepObjVarMap.

Definition at line 134 of file SVFIR.h.

135  {
136  return GepObjVarMap;
137  }

◆ getGepObjVar() [1/2]

NodeID SVFIR::getGepObjVar ( const MemObj obj,
const APOffset apOffset 
)

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

Get a field obj SVFIR 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 422 of file SVFIR.cpp.

423 {
424  NodeID base = obj->getId();
425 
427  if (obj->isFieldInsensitive())
428  return getFIObjVar(obj);
429 
430  APOffset newLS = pag->getSymbolInfo()->getModulusOffset(obj, apOffset);
431 
432  // Base and first field are the same memory location.
433  if (Options::FirstFieldEqBase() && newLS == 0) return base;
434 
435  NodeOffsetMap::iterator iter = GepObjVarMap.find(std::make_pair(base, newLS));
436  if (iter == GepObjVarMap.end())
437  {
439  return addGepObjNode(obj, newLS,gepId);
440  }
441  else
442  return iter->second;
443 
444 }
NodeID allocateGepObjectId(NodeID base, u32_t offset, u32_t maxFieldLimit)
static const Option< bool > FirstFieldEqBase
Definition: Options.h:103
static const Option< u32_t > MaxFieldLimit
Maximum number of field derivations for an object.
Definition: Options.h:38
NodeID addGepObjNode(const MemObj *obj, const APOffset &apOffset, const NodeID gepId)
Add a field obj node, this method can only invoked by getGepObjVar.
Definition: SVFIR.cpp:449
s64_t APOffset
Definition: GeneralType.h:60

◆ getGepObjVar() [2/2]

NodeID SVFIR::getGepObjVar ( NodeID  id,
const APOffset apOffset 
)

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

Given an object node, find its field object node

Definition at line 400 of file SVFIR.cpp.

401 {
402  SVFVar* node = pag->getGNode(id);
403  if (GepObjVar* gepNode = SVFUtil::dyn_cast<GepObjVar>(node))
404  return getGepObjVar(gepNode->getMemObj(), gepNode->getConstantFieldIdx() + apOffset);
405  else if (FIObjVar* baseNode = SVFUtil::dyn_cast<FIObjVar>(node))
406  return getGepObjVar(baseNode->getMemObj(), apOffset);
407  else if (DummyObjVar* baseNode = SVFUtil::dyn_cast<DummyObjVar>(node))
408  return getGepObjVar(baseNode->getMemObj(), apOffset);
409  else
410  {
411  assert(false && "new gep obj node kind?");
412  return id;
413  }
414 }
NodeID getGepObjVar(const MemObj *obj, const APOffset &ap)
Get a field SVFIR Object node according to base mem obj and offset.
Definition: SVFIR.cpp:422

◆ getGepValVar()

NodeID SVFIR::getGepValVar ( const SVFValue curInst,
NodeID  base,
const AccessPath ap 
) const

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

It is used to create a dummy GepValVar during global initialization.

Definition at line 517 of file SVFIR.cpp.

518 {
519  GepValueVarMap::const_iterator iter = GepValObjMap.find(curInst);
520  if(iter==GepValObjMap.end())
521  {
522  return UINT_MAX;
523  }
524  else
525  {
526  NodeAccessPathMap::const_iterator lit =
527  iter->second.find(std::make_pair(base, ap));
528  if (lit == iter->second.end())
529  return UINT_MAX;
530  else
531  return lit->second;
532  }
533 }

◆ getGlobalSVFStmtSet()

SVFStmtSet& SVF::SVFIR::getGlobalSVFStmtSet ( )
inline

Get global PAGEdges (not in a procedure)

Definition at line 249 of file SVFIR.h.

250  {
251  return globSVFStmtSet;
252  }

◆ getICFG()

ICFG* SVF::SVFIR::getICFG ( ) const
inline

Definition at line 171 of file SVFIR.h.

172  {
173  assert(icfg->totalICFGNode>0 && "empty ICFG! Build SVF IR first!");
174  return icfg;
175  }
NodeID totalICFGNode
Definition: ICFG.h:66

◆ getIndCallSites()

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

Definition at line 360 of file SVFIR.h.

361  {
362  FunPtrToCallSitesMap::const_iterator it = funPtrToCallSitesMap.find(funPtr);
363  assert(it!=funPtrToCallSitesMap.end() && "function pointer not used at any indirect callsite?");
364  return it->second;
365  }

◆ getIndirectCallsites()

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

Add/get indirect callsites.

Definition at line 350 of file SVFIR.h.

351  {
352  return indCallSiteToFunPtrMap;
353  }

◆ getIntraPAGEdge() [1/2]

SVFStmt* SVF::SVFIR::getIntraPAGEdge ( NodeID  src,
NodeID  dst,
SVFStmt::PEDGEK  kind 
)
inline

Get an edge according to src, dst and kind.

Definition at line 377 of file SVFIR.h.

378  {
379  return getIntraPAGEdge(getGNode(src), getGNode(dst), kind);
380  }
SVFStmt * getIntraPAGEdge(NodeID src, NodeID dst, SVFStmt::PEDGEK kind)
Get an edge according to src, dst and kind.
Definition: SVFIR.h:377

◆ getIntraPAGEdge() [2/2]

SVFStmt* SVF::SVFIR::getIntraPAGEdge ( SVFVar src,
SVFVar dst,
SVFStmt::PEDGEK  kind 
)
inline

Definition at line 381 of file SVFIR.h.

382  {
383  SVFStmt edge(src, dst, kind, false);
384  const SVFStmt::SVFStmtSetTy& edgeSet = getSVFStmtSet(kind);
385  SVFStmt::SVFStmtSetTy::const_iterator it = edgeSet.find(&edge);
386  assert(it != edgeSet.end() && "can not find pag edge");
387  return (*it);
388  }
SVFStmt::SVFStmtSetTy & getSVFStmtSet(SVFStmt::PEDGEK kind)
Get/set methods to get SVFStmts based on their kinds and ICFGNodes.
Definition: SVFIR.h:201
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy

◆ getMemToFieldsMap()

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

Return memToFieldsMap.

Definition at line 129 of file SVFIR.h.

130  {
131  return memToFieldsMap;
132  }

◆ getModule()

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

Definition at line 161 of file SVFIR.h.

162  {
163  assert(svfModule && "empty SVFModule! Build SVF IR first!");
164  return svfModule;
165  }

◆ getObject() [1/2]

const MemObj* SVF::SVFIR::getObject ( const ObjVar node) const
inline

Definition at line 403 of file SVFIR.h.

404  {
405  return node->getMemObj();
406  }

◆ getObject() [2/2]

const MemObj* SVF::SVFIR::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 ObjVar type

Definition at line 395 of file SVFIR.h.

396  {
397  const SVFVar* node = getGNode(id);
398  if (const ObjVar* objPN = SVFUtil::dyn_cast<ObjVar>(node))
399  return getObject(objPN);
400  else
401  return nullptr;
402  }
const MemObj * getObject(NodeID id) const
Definition: SVFIR.h:395

◆ getPAG()

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

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

Definition at line 115 of file SVFIR.h.

116  {
117  if (pag == nullptr)
118  {
119  pag = std::unique_ptr<SVFIR>(new SVFIR(buildFromFile));
120  }
121  return pag.get();
122  }
SVFIR(bool buildFromFile)
Constructor.
Definition: SVFIR.cpp:39

◆ getPTASVFStmtList()

SVFStmtList& SVF::SVFIR::getPTASVFStmtList ( const ICFGNode inst)
inline

Given an instruction, get all its PTA PAGEdges.

Definition at line 226 of file SVFIR.h.

227  {
228  return icfgNode2PTASVFStmtsMap[inst];
229  }

◆ getPTASVFStmtSet()

SVFStmt::SVFStmtSetTy& SVF::SVFIR::getPTASVFStmtSet ( SVFStmt::PEDGEK  kind)
inline

Get PTA edges set according to its kind.

Definition at line 206 of file SVFIR.h.

207  {
208  return KindToPTASVFStmtSetMap[kind];
209  }

◆ getSVFStmtList()

SVFStmtList& SVF::SVFIR::getSVFStmtList ( const ICFGNode inst)
inline

Given an instruction, get all its PAGEdges.

Definition at line 221 of file SVFIR.h.

222  {
223  return icfgNode2SVFStmtsMap[inst];
224  }

◆ getSVFStmtSet()

SVFStmt::SVFStmtSetTy& SVF::SVFIR::getSVFStmtSet ( SVFStmt::PEDGEK  kind)
inline

Get/set methods to get SVFStmts based on their kinds and ICFGNodes.

Get edges set according to its kind

Definition at line 201 of file SVFIR.h.

202  {
203  return KindToSVFStmtSetMap[kind];
204  }

◆ getTypeLocSetsMap()

SVFTypeLocSetsPair& SVF::SVFIR::getTypeLocSetsMap ( NodeID  argId)
inline

Given an arg NodeId, get its base SVFType* and all its field location sets.

Definition at line 244 of file SVFIR.h.

245  {
246  return typeLocSetsMap[argId];
247  }

◆ handleBlackHole()

void SVFIR::handleBlackHole ( bool  b)
static

SVFIR build configurations.

Whether to handle blackhole edge

Definition at line 688 of file SVFIR.cpp.

689 {
691 }
const cJSON *const b
Definition: cJSON.h:255
void setValue(T v)
Definition: CommandLine.h:351

◆ hasCallSiteArgsMap()

bool SVF::SVFIR::hasCallSiteArgsMap ( const CallICFGNode cs) const
inline

Callsite has argument list.

Definition at line 282 of file SVFIR.h.

283  {
284  return (callSiteArgsListMap.find(cs) != callSiteArgsListMap.end());
285  }

◆ hasFunArgsList()

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

Function has arguments list.

Definition at line 265 of file SVFIR.h.

266  {
267  return (funArgsListMap.find(func) != funArgsListMap.end());
268  }

◆ hasPTASVFStmtList()

bool SVF::SVFIR::hasPTASVFStmtList ( const ICFGNode inst) const
inline

Definition at line 215 of file SVFIR.h.

216  {
217  return icfgNode2PTASVFStmtsMap.find(inst) !=
219  }

◆ hasSVFStmtList()

bool SVF::SVFIR::hasSVFStmtList ( const ICFGNode inst) const
inline

Whether this instruction has SVFIR Edge.

Definition at line 211 of file SVFIR.h.

212  {
213  return icfgNode2SVFStmtsMap.find(inst) != icfgNode2SVFStmtsMap.end();
214  }

◆ initialiseCandidatePointers()

void SVFIR::initialiseCandidatePointers ( )

Initialize candidate pointers.

Definition at line 639 of file SVFIR.cpp.

640 {
641  // collect candidate pointers for demand-driven analysis
642  for (iterator nIter = begin(); nIter != end(); ++nIter)
643  {
644  NodeID nodeId = nIter->first;
645  // do not compute points-to for isolated node
646  if (isValidPointer(nodeId) == false)
647  continue;
648  candidatePointers.insert(nodeId);
649  }
650 }
IDToNodeMapTy::iterator iterator
Node Iterators.
Definition: GenericGraph.h:606
bool isValidPointer(NodeID nodeId) const
Whether a node is a valid pointer.
Definition: SVFIR.cpp:655

◆ isBlkObj()

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

Definition at line 439 of file SVFIR.h.

440  {
441  return SymbolTableInfo::isBlkObj(id);
442  }
static bool isBlkObj(NodeID id)

◆ isBlkObjOrConstantObj()

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

Definition at line 435 of file SVFIR.h.

436  {
437  return (isBlkObj(id) || isConstantObj(id));
438  }
bool isBlkObj(NodeID id) const
Definition: SVFIR.h:439
bool isConstantObj(NodeID id) const
Definition: SVFIR.h:443

◆ isBlkPtr()

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

Get black hole and constant id.

Definition at line 427 of file SVFIR.h.

428  {
429  return (SymbolTableInfo::isBlkPtr(id));
430  }
static bool isBlkPtr(NodeID id)
special value

◆ isConstantObj()

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

Definition at line 443 of file SVFIR.h.

444  {
445  const MemObj* obj = getObject(id);
446  assert(obj && "not an object node?");
447  return SymbolTableInfo::isConstantObj(id) ||
448  obj->isConstDataOrConstGlobal();
449  }
static bool isConstantObj(NodeID id)

◆ isFunPtr()

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

Definition at line 370 of file SVFIR.h.

371  {
372  return (funPtrToCallSitesMap.find(id) != funPtrToCallSitesMap.end());
373  }

◆ isIndirectCallSites()

bool SVF::SVFIR::isIndirectCallSites ( const CallICFGNode cs) const
inline

Definition at line 366 of file SVFIR.h.

367  {
368  return (indCallSiteToFunPtrMap.find(cs) != indCallSiteToFunPtrMap.end());
369  }

◆ isNullPtr()

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

Definition at line 431 of file SVFIR.h.

432  {
433  return (SymbolTableInfo::isNullPtr(id));
434  }
static bool isNullPtr(NodeID id)

◆ isPhiNode()

bool SVF::SVFIR::isPhiNode ( const SVFVar node) const
inline

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

Definition at line 259 of file SVFIR.h.

260  {
261  return phiNodeMap.find(node) != phiNodeMap.end();
262  }

◆ isValidPointer()

bool SVFIR::isValidPointer ( NodeID  nodeId) const

Whether a node is a valid pointer.

Definition at line 655 of file SVFIR.cpp.

656 {
657  SVFVar* node = pag->getGNode(nodeId);
658 
659  if (node->hasValue() && node->isPointer())
660  {
661  if(const SVFArgument* arg = SVFUtil::dyn_cast<SVFArgument>(node->getValue()))
662  {
663  if (!(arg->getParent()->isDeclaration()))
664  return true;
665  }
666  }
667 
668  if ((node->getInEdges().empty() && node->getOutEdges().empty()))
669  return false;
670  return node->isPointer();
671 }
const GEdgeSetTy & getOutEdges() const
Definition: GenericGraph.h:430
const GEdgeSetTy & getInEdges() const
Definition: GenericGraph.h:434
bool hasValue() const
Definition: SVFVariables.h:101
virtual bool isPointer() const
Whether it is a pointer.
Definition: SVFVariables.h:106
const SVFValue * getValue() const
Get/has methods of the components.
Definition: SVFVariables.h:83

◆ isValidTopLevelPtr()

bool SVFIR::isValidTopLevelPtr ( const SVFVar node)

Definition at line 673 of file SVFIR.cpp.

674 {
675  if (SVFUtil::isa<ValVar>(node))
676  {
677  if (isValidPointer(node->getId()) && node->hasValue())
678  {
680  }
681  }
682  return false;
683 }
NodeID getId() const
Get ID.
Definition: GenericGraph.h:260
bool isArgOfUncalledFunction(const SVFValue *svfval)
Return true if this argument belongs to an uncalled function.
Definition: SVFUtil.h:346

◆ print()

void SVFIR::print ( void  )

Print SVFIR.

Print this SVFIR graph including its nodes and edges

Definition at line 554 of file SVFIR.cpp.

555 {
556 
557  outs() << "-------------------SVFIR------------------------------------\n";
558  SVFStmt::SVFStmtSetTy& addrs = pag->getSVFStmtSet(SVFStmt::Addr);
559  for (SVFStmt::SVFStmtSetTy::iterator iter = addrs.begin(), eiter =
560  addrs.end(); iter != eiter; ++iter)
561  {
562  outs() << (*iter)->getSrcID() << " -- Addr --> " << (*iter)->getDstID()
563  << "\n";
564  }
565 
566  SVFStmt::SVFStmtSetTy& copys = pag->getSVFStmtSet(SVFStmt::Copy);
567  for (SVFStmt::SVFStmtSetTy::iterator iter = copys.begin(), eiter =
568  copys.end(); iter != eiter; ++iter)
569  {
570  outs() << (*iter)->getSrcID() << " -- Copy --> " << (*iter)->getDstID()
571  << "\n";
572  }
573 
574  SVFStmt::SVFStmtSetTy& calls = pag->getSVFStmtSet(SVFStmt::Call);
575  for (SVFStmt::SVFStmtSetTy::iterator iter = calls.begin(), eiter =
576  calls.end(); iter != eiter; ++iter)
577  {
578  outs() << (*iter)->getSrcID() << " -- Call --> " << (*iter)->getDstID()
579  << "\n";
580  }
581 
582  SVFStmt::SVFStmtSetTy& rets = pag->getSVFStmtSet(SVFStmt::Ret);
583  for (SVFStmt::SVFStmtSetTy::iterator iter = rets.begin(), eiter =
584  rets.end(); iter != eiter; ++iter)
585  {
586  outs() << (*iter)->getSrcID() << " -- Ret --> " << (*iter)->getDstID()
587  << "\n";
588  }
589 
590  SVFStmt::SVFStmtSetTy& tdfks = pag->getSVFStmtSet(SVFStmt::ThreadFork);
591  for (SVFStmt::SVFStmtSetTy::iterator iter = tdfks.begin(), eiter =
592  tdfks.end(); iter != eiter; ++iter)
593  {
594  outs() << (*iter)->getSrcID() << " -- ThreadFork --> "
595  << (*iter)->getDstID() << "\n";
596  }
597 
598  SVFStmt::SVFStmtSetTy& tdjns = pag->getSVFStmtSet(SVFStmt::ThreadJoin);
599  for (SVFStmt::SVFStmtSetTy::iterator iter = tdjns.begin(), eiter =
600  tdjns.end(); iter != eiter; ++iter)
601  {
602  outs() << (*iter)->getSrcID() << " -- ThreadJoin --> "
603  << (*iter)->getDstID() << "\n";
604  }
605 
606  SVFStmt::SVFStmtSetTy& ngeps = pag->getSVFStmtSet(SVFStmt::Gep);
607  for (SVFStmt::SVFStmtSetTy::iterator iter = ngeps.begin(), eiter =
608  ngeps.end(); iter != eiter; ++iter)
609  {
610  GepStmt* gep = SVFUtil::cast<GepStmt>(*iter);
611  if(gep->isVariantFieldGep())
612  outs() << (*iter)->getSrcID() << " -- VariantGep --> "
613  << (*iter)->getDstID() << "\n";
614  else
615  outs() << gep->getRHSVarID() << " -- Gep (" << gep->getConstantStructFldIdx()
616  << ") --> " << gep->getLHSVarID() << "\n";
617  }
618 
619  SVFStmt::SVFStmtSetTy& loads = pag->getSVFStmtSet(SVFStmt::Load);
620  for (SVFStmt::SVFStmtSetTy::iterator iter = loads.begin(), eiter =
621  loads.end(); iter != eiter; ++iter)
622  {
623  outs() << (*iter)->getSrcID() << " -- Load --> " << (*iter)->getDstID()
624  << "\n";
625  }
626 
627  SVFStmt::SVFStmtSetTy& stores = pag->getSVFStmtSet(SVFStmt::Store);
628  for (SVFStmt::SVFStmtSetTy::iterator iter = stores.begin(), eiter =
629  stores.end(); iter != eiter; ++iter)
630  {
631  outs() << (*iter)->getSrcID() << " -- Store --> " << (*iter)->getDstID()
632  << "\n";
633  }
634  outs() << "----------------------------------------------------------\n";
635 
636 }
NodeID getRHSVarID() const
NodeID getLHSVarID() const
bool isVariantFieldGep() const
Gep statement with a variant field index (pointer arithmetic) for struct field access.
APOffset getConstantStructFldIdx() const
Field index of the gep statement if it access the field of a struct.
std::ostream & outs()
Overwrite llvm::outs()
Definition: SVFUtil.h:50

◆ releaseSVFIR()

static void SVF::SVFIR::releaseSVFIR ( )
inlinestatic

Definition at line 123 of file SVFIR.h.

124  {
125  pag = nullptr;
126  }

◆ setCallGraph()

void SVF::SVFIR::setCallGraph ( PTACallGraph c)
inline

Set/Get CG.

Definition at line 188 of file SVFIR.h.

189  {
190  callGraph = c;
191  }

◆ setCHG()

void SVF::SVFIR::setCHG ( CommonCHGraph c)
inline

Set/Get CHG.

Definition at line 177 of file SVFIR.h.

178  {
179  chgraph = c;
180  }

◆ setICFG()

void SVF::SVFIR::setICFG ( ICFG i)
inline

Set/Get ICFG.

Definition at line 167 of file SVFIR.h.

168  {
169  icfg = i;
170  }

◆ setModule()

void SVF::SVFIR::setModule ( SVFModule mod)
inline

Set/Get LLVM Module.

Definition at line 157 of file SVFIR.h.

158  {
159  svfModule = mod;
160  }

Friends And Related Function Documentation

◆ BVDataPTAImpl

friend class BVDataPTAImpl
friend

Definition at line 51 of file SVFIR.h.

◆ ExternalPAG

friend class ExternalPAG
friend

Definition at line 46 of file SVFIR.h.

◆ PAGBuilderFromFile

friend class PAGBuilderFromFile
friend

Definition at line 47 of file SVFIR.h.

◆ SVFIRBuilder

friend class SVFIRBuilder
friend

Definition at line 45 of file SVFIR.h.

◆ SVFIRReader

friend class SVFIRReader
friend

Definition at line 50 of file SVFIR.h.

◆ SVFIRWriter

friend class SVFIRWriter
friend

Definition at line 49 of file SVFIR.h.

◆ TypeBasedHeapCloning

friend class TypeBasedHeapCloning
friend

Definition at line 48 of file SVFIR.h.

Member Data Documentation

◆ callGraph

PTACallGraph* SVF::SVFIR::callGraph
private

all the callsites of a program

Definition at line 101 of file SVFIR.h.

◆ callSiteArgsListMap

CSToArgsListMap SVF::SVFIR::callSiteArgsListMap
private

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

Definition at line 89 of file SVFIR.h.

◆ callSiteRetMap

CSToRetMap SVF::SVFIR::callSiteRetMap
private

Map a callsite to its callsite returns PAGNodes.

Definition at line 90 of file SVFIR.h.

◆ callSiteSet

CallSiteSet SVF::SVFIR::callSiteSet
private

Definition at line 100 of file SVFIR.h.

◆ candidatePointers

OrderedNodeSet SVF::SVFIR::candidatePointers
private

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

Definition at line 96 of file SVFIR.h.

◆ chgraph

CommonCHGraph* SVF::SVFIR::chgraph
private

Definition at line 99 of file SVFIR.h.

◆ funArgsListMap

FunToArgsListMap SVF::SVFIR::funArgsListMap
private

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

Definition at line 88 of file SVFIR.h.

◆ funPtrToCallSitesMap

FunPtrToCallSitesMap SVF::SVFIR::funPtrToCallSitesMap
private

Map a function pointer to the callsites where it is used

Definition at line 93 of file SVFIR.h.

◆ funRetMap

FunToRetMap SVF::SVFIR::funRetMap
private

Map a function to its unique function return PAGNodes.

Definition at line 91 of file SVFIR.h.

◆ GepObjVarMap

NodeOffsetMap SVF::SVFIR::GepObjVarMap
private

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

Definition at line 84 of file SVFIR.h.

◆ GepValObjMap

GepValueVarMap SVF::SVFIR::GepValObjMap
private

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

Definition at line 82 of file SVFIR.h.

◆ globSVFStmtSet

SVFStmtSet SVF::SVFIR::globSVFStmtSet
private

Global PAGEdges without control flow information.

Definition at line 86 of file SVFIR.h.

◆ icfg

ICFG* SVF::SVFIR::icfg
private

SVF Module.

Definition at line 98 of file SVFIR.h.

◆ icfgNode2PTASVFStmtsMap

ICFGNode2SVFStmtsMap SVF::SVFIR::icfgNode2PTASVFStmtsMap
private

Map an ICFGNode to its PointerAnalysis related SVFStmts.

Definition at line 81 of file SVFIR.h.

◆ icfgNode2SVFStmtsMap

ICFGNode2SVFStmtsMap SVF::SVFIR::icfgNode2SVFStmtsMap
private

Map an ICFGNode to its SVFStmts.

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

Definition at line 80 of file SVFIR.h.

◆ indCallSiteToFunPtrMap

CallSiteToFunPtrMap SVF::SVFIR::indCallSiteToFunPtrMap
private

Map an indirect callsite to its function pointer.

Definition at line 92 of file SVFIR.h.

◆ memToFieldsMap

MemObjToFieldsMap SVF::SVFIR::memToFieldsMap
private

Map a mem object id to all its fields.

Definition at line 85 of file SVFIR.h.

◆ pag

std::unique_ptr< SVFIR > SVFIR::pag
staticprivate

call graph

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

Definition at line 103 of file SVFIR.h.

◆ phiNodeMap

PHINodeMap SVF::SVFIR::phiNodeMap
private

A set of phi copy edges.

Definition at line 87 of file SVFIR.h.

◆ svfModule

SVFModule* SVF::SVFIR::svfModule
private

Definition at line 97 of file SVFIR.h.

◆ typeLocSetsMap

TypeLocSetsMap SVF::SVFIR::typeLocSetsMap
private

Map an arg to its base SVFType* and all its field location sets.

Definition at line 83 of file SVFIR.h.


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