Static Value-Flow Analysis
Loading...
Searching...
No Matches
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 FunObjVar *, SVFVarListFunToArgsListMap
 
typedef Map< const CallICFGNode *, SVFVarListCSToArgsListMap
 
typedef Map< const RetICFGNode *, const SVFVar * > CSToRetMap
 
typedef Map< const FunObjVar *, const SVFVar * > FunToRetMap
 
typedef Map< const FunObjVar *, 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< NodeID, NodeAccessPathMapGepValueVarMap
 
typedef std::pair< const SVFType *, std::vector< AccessPath > > SVFTypeLocSetsPair
 
typedef Map< NodeID, SVFTypeLocSetsPairTypeLocSetsMap
 
typedef Map< NodePair, NodeIDNodePairSetMap
 
- Public Types inherited from SVF::IRGraph
enum  SYMTYPE {
  NullPtr , BlkPtr , BlackHole , ConstantObj ,
  ValSymbol , ObjSymbol , RetSymbol , VarargSymbol
}
 Symbol types. More...
 
typedef OrderedMap< NodeID, ObjTypeInfo * > IDToTypeInfoMapTy
 various maps defined
 
typedef OrderedMap< const FunObjVar *, NodeIDFunObjVarToIDMapTy
 function to sym id map
 
typedef Set< const SVFType * > SVFTypeSet
 struct type to struct info map
 
typedef Set< const SVFStmt * > SVFStmtSet
 
- Public Types inherited from SVF::GenericGraph< SVFVar, SVFStmt >
typedef SVFVar NodeType
 
typedef SVFStmt EdgeType
 
typedef OrderedMap< NodeID, NodeType * > IDToNodeMapTy
 NodeID to GenericNode map.
 
typedef IDToNodeMapTy::iterator iterator
 Node Iterators.
 
typedef IDToNodeMapTy::const_iterator const_iterator
 

Public Member Functions

MemObjToFieldsMapgetMemToFieldsMap ()
 Return memToFieldsMap.
 
NodeOffsetMapgetGepObjNodeMap ()
 Return GepObjVarMap.
 
OrderedNodeSetgetAllValidPtrs ()
 Return valid pointers.
 
void initialiseCandidatePointers ()
 Initialize candidate pointers.
 
virtual ~SVFIR ()
 Destructor.
 
void setICFG (ICFG *i)
 Set/Get ICFG.
 
ICFGgetICFG () const
 
void setCHG (CommonCHGraph *c)
 Set/Get CHG.
 
CommonCHGraphgetCHG ()
 
const CallGraphgetCallGraph ()
 Get CG.
 
const FunObjVargetFunObjVar (const std::string &name)
 
const std::string & getModuleIdentifier () const
 
void setModuleIdentifier (const std::string &moduleIdentifier)
 
SVFStmt::SVFStmtSetTygetSVFStmtSet (SVFStmt::PEDGEK kind)
 Get/set methods to get SVFStmts based on their kinds and ICFGNodes.
 
SVFStmt::SVFStmtSetTygetPTASVFStmtSet (SVFStmt::PEDGEK kind)
 Get PTA edges set according to its kind.
 
bool hasSVFStmtList (const ICFGNode *inst) const
 Whether this instruction has SVFIR Edge.
 
bool hasPTASVFStmtList (const ICFGNode *inst) const
 
SVFStmtListgetSVFStmtList (const ICFGNode *inst)
 Given an instruction, get all its PAGEdges.
 
SVFStmtListgetPTASVFStmtList (const ICFGNode *inst)
 Given an instruction, get all its PTA PAGEdges.
 
void addToSVFStmtList (ICFGNode *inst, SVFStmt *edge)
 Add a SVFStmt into instruction map.
 
void addToTypeLocSetsMap (NodeID argId, SVFTypeLocSetsPair &locSets)
 Add a base SVFType* and all its field location sets to an arg NodeId.
 
SVFTypeLocSetsPairgetTypeLocSetsMap (NodeID argId)
 Given an arg NodeId, get its base SVFType* and all its field location sets.
 
SVFStmtSetgetGlobalSVFStmtSet ()
 Get global PAGEdges (not in a procedure)
 
const CallSiteSetgetCallSiteSet () const
 Get all callsites.
 
bool isPhiNode (const SVFVar *node) const
 Whether this SVFVar is a result operand a of phi node.
 
bool hasFunArgsList (const FunObjVar *func) const
 Function has arguments list.
 
FunToArgsListMapgetFunArgsMap ()
 Get function arguments list.
 
const SVFVarListgetFunArgsList (const FunObjVar *func) const
 Get function arguments list.
 
bool hasCallSiteArgsMap (const CallICFGNode *cs) const
 Callsite has argument list.
 
CSToArgsListMapgetCallSiteArgsMap ()
 Get callsite argument list.
 
const SVFVarListgetCallSiteArgsList (const CallICFGNode *cs) const
 Get callsite argument list.
 
CSToRetMapgetCallSiteRets ()
 Get callsite return.
 
const SVFVargetCallSiteRet (const RetICFGNode *cs) const
 Get callsite return.
 
bool callsiteHasRet (const RetICFGNode *cs) const
 
FunToRetMapgetFunRets ()
 Get function return list.
 
const SVFVargetFunRet (const FunObjVar *func) const
 Get function return list.
 
bool funHasRet (const FunObjVar *func) const
 
u32_t getFieldValNodeNum () const
 Node and edge statistics.
 
u32_t getFieldObjNodeNum () const
 
NodeID getGepValVar (NodeID curInst, NodeID base, const AccessPath &ap) const
 Due to constraint expression, curInst is used to distinguish different instructions (e.g., memorycpy) when creating GepValVar.
 
const CallSiteToFunPtrMapgetIndirectCallsites () const
 Add/get indirect callsites.
 
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.
 
SVFStmtgetIntraPAGEdge (SVFVar *src, SVFVar *dst, SVFStmt::PEDGEK kind)
 
const BaseObjVargetBaseObject (NodeID id) const
 
const ValVargetBaseValVar (NodeID id) const
 
NodeID getGepObjVar (const BaseObjVar *baseObj, const APOffset &ap)
 Get a field SVFIR Object node according to base mem obj and offset.
 
NodeID getGepObjVar (NodeID id, const APOffset &ap)
 Get a field obj SVFIR node according to a mem obj and a given offset.
 
NodeID getFIObjVar (const BaseObjVar *obj) const
 Get a field-insensitive obj SVFIR node according to a mem obj.
 
NodeID getFIObjVar (NodeID id) const
 
bool isBlkObjOrConstantObj (NodeID id) const
 Get black hole and constant id.
 
bool isConstantObj (NodeID id) const
 
NodeID getBaseObjVar (NodeID id) const
 Base and Offset methods for Value and Object node.
 
NodeBSgetAllFieldsObjVars (const BaseObjVar *obj)
 Get all fields of an object.
 
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.
 
bool isValidTopLevelPtr (const SVFVar *node)
 
void print ()
 Print SVFIR.
 
- Public Member Functions inherited from SVF::IRGraph
 IRGraph (bool buildFromFile)
 
virtual ~IRGraph ()
 
bool isBuiltFromFile ()
 Whether this SVFIR built from a txt file.
 
NodeID blkPtrSymID () const
 
NodeID nullPtrSymID () const
 
NodeID constantSymID () const
 
NodeID blackholeSymID () const
 
u32_t getTotalSymNum () const
 Statistics.
 
u32_t getMaxStructSize () const
 
IDToTypeInfoMapTyidToObjTypeInfoMap ()
 Get different kinds of syms maps.
 
const IDToTypeInfoMapTyidToObjTypeInfoMap () const
 
FunObjVarToIDMapTyretFunObjSyms ()
 
FunObjVarToIDMapTyvarargFunObjSyms ()
 
ObjTypeInfogetObjTypeInfo (NodeID id) const
 
NodeID getReturnNode (const FunObjVar *func) const
 GetReturnNode - Return the unique node representing the return value of a function.
 
NodeID getVarargNode (const FunObjVar *func) const
 getVarargNode - Return the unique node representing the variadic argument of a variadic function.
 
NodeID getBlackHoleNode () const
 
NodeID getConstantNode () const
 
NodeID getBlkPtr () const
 
NodeID getNullPtr () const
 
u32_t getValueNodeNum ()
 
u32_t getObjectNodeNum ()
 
const SVFTypeSetgetSVFTypes () const
 Constant reader that won't change the state of the symbol table.
 
const Set< const StInfo * > & getStInfos () const
 
virtual APOffset getModulusOffset (const BaseObjVar *baseObj, const APOffset &apOffset)
 Given an offset from a Gep Instruction, return it modulus offset by considering memory layout.
 
const StInfogetTypeInfo (const SVFType *T) const
 Get struct info.
 
bool hasSVFTypeInfo (const SVFType *T)
 
ObjTypeInfocreateObjTypeInfo (const SVFType *type)
 Create an objectInfo based on LLVM type (value is null, and type could be null, representing a dummy object)
 
const ObjTypeInfocreateDummyObjTypeInfo (NodeID symId, const SVFType *type)
 
u32_t getNumOfFlattenElements (const SVFType *T)
 
u32_t getFlattenedElemIdx (const SVFType *T, u32_t origId)
 Flattened element idx of an array or struct by considering stride.
 
const SVFTypegetFlatternedElemType (const SVFType *baseType, u32_t flatten_idx)
 Return the type of a flattened element given a flattened index.
 
const SVFTypegetOriginalElemType (const SVFType *baseType, u32_t origId) const
 
void printFlattenFields (const SVFType *type)
 Debug method.
 
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.
 
void dumpSymTable ()
 
void dump (std::string name)
 Dump SVFIR.
 
void view ()
 View graph from the debugger.
 
void addTypeInfo (const SVFType *ty)
 
void addStInfo (StInfo *stInfo)
 
- Public Member Functions inherited from SVF::GenericGraph< SVFVar, SVFStmt >
 GenericGraph ()
 Constructor.
 
virtual ~GenericGraph ()
 Destructor.
 
void destroy ()
 Release memory.
 
iterator begin ()
 Iterators.
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
void addGNode (NodeID id, NodeType *node)
 Add a Node.
 
NodeTypegetGNode (NodeID id) const
 Get a node.
 
bool hasGNode (NodeID id) const
 Has a node.
 
void removeGNode (NodeType *node)
 Delete a node.
 
u32_t getTotalNodeNum () const
 Get total number of node/edge.
 
u32_t getTotalEdgeNum () const
 
void incNodeNum ()
 Increase number of node/edge.
 
void incEdgeNum ()
 

Static Public Member Functions

static SVFIRgetPAG (bool buildFromFile=false)
 Singleton design here to make sure we only have one instance during any analysis.
 
static void releaseSVFIR ()
 
static void handleBlackHole (bool b)
 SVFIR build configurations.
 
static std::string pagFileName ()
 
static bool pagReadFromTXT ()
 
static void setPagFromTXT (const std::string &txt)
 
- Static Public Member Functions inherited from SVF::IRGraph
static bool isBlkPtr (NodeID id)
 special value
 
static bool isNullPtr (NodeID id)
 
static bool isBlkObj (NodeID id)
 
static bool isConstantSym (NodeID id)
 
static bool isBlkObjOrConstantObj (NodeID id)
 

Private Member Functions

 SVFIR (bool buildFromFile)
 Constructor.
 
void destroy ()
 Clean up memory.
 
void addToStmt2TypeMap (SVFStmt *edge)
 Map a SVFStatement type to a set of corresponding SVF statements.
 
void addFunArgs (const FunObjVar *fun, const SVFVar *arg)
 Get/set method for function/callsite arguments and returns.
 
void addFunRet (const FunObjVar *fun, const SVFVar *ret)
 Add function returns.
 
void addCallSiteArgs (CallICFGNode *callBlockNode, const ValVar *arg)
 Add callsite arguments.
 
void addCallSiteRets (RetICFGNode *retBlockNode, const SVFVar *arg)
 Add callsite returns.
 
void addIndirectCallsites (const CallICFGNode *cs, NodeID funPtr)
 Add indirect callsites.
 
NodeID addValNode (NodeID i, const SVFType *type, const ICFGNode *icfgNode)
 add node into SVFIR
 
NodeID addFunValNode (NodeID i, const ICFGNode *icfgNode, const FunObjVar *funObjVar, const SVFType *type)
 
NodeID addArgValNode (NodeID i, u32_t argNo, const ICFGNode *icfgNode, const FunObjVar *callGraphNode, const SVFType *type)
 
NodeID addConstantFPValNode (const NodeID i, double dval, const ICFGNode *icfgNode, const SVFType *type)
 
NodeID addConstantIntValNode (NodeID i, const std::pair< s64_t, u64_t > &intValue, const ICFGNode *icfgNode, const SVFType *type)
 
NodeID addConstantNullPtrValNode (const NodeID i, const ICFGNode *icfgNode, const SVFType *type)
 
NodeID addGlobalValNode (const NodeID i, const ICFGNode *icfgNode, const SVFType *svfType)
 
NodeID addConstantAggValNode (const NodeID i, const ICFGNode *icfgNode, const SVFType *svfType)
 
NodeID addConstantDataValNode (const NodeID i, const ICFGNode *icfgNode, const SVFType *type)
 
NodeID addObjNode (NodeID i, ObjTypeInfo *ti, const SVFType *type, const ICFGNode *node)
 Add a memory obj node.
 
NodeID addHeapObjNode (NodeID i, ObjTypeInfo *ti, const SVFType *type, const ICFGNode *node)
 
NodeID addStackObjNode (NodeID i, ObjTypeInfo *ti, const SVFType *type, const ICFGNode *node)
 
NodeID addFunObjNode (NodeID id, ObjTypeInfo *ti, const SVFType *type, const ICFGNode *node)
 
NodeID addConstantFPObjNode (NodeID i, ObjTypeInfo *ti, double dval, const SVFType *type, const ICFGNode *node)
 
NodeID addConstantIntObjNode (NodeID i, ObjTypeInfo *ti, const std::pair< s64_t, u64_t > &intValue, const SVFType *type, const ICFGNode *node)
 
NodeID addConstantNullPtrObjNode (const NodeID i, ObjTypeInfo *ti, const SVFType *type, const ICFGNode *node)
 
NodeID addGlobalObjNode (const NodeID i, ObjTypeInfo *ti, const SVFType *type, const ICFGNode *node)
 
NodeID addConstantAggObjNode (const NodeID i, ObjTypeInfo *ti, const SVFType *type, const ICFGNode *node)
 
NodeID addConstantDataObjNode (const NodeID i, ObjTypeInfo *ti, const SVFType *type, const ICFGNode *node)
 
NodeID addRetNode (NodeID i, const FunObjVar *callGraphNode, const SVFType *type, const ICFGNode *icn)
 Add a unique return node for a procedure.
 
NodeID addVarargNode (NodeID i, const FunObjVar *val, const SVFType *type, const ICFGNode *n)
 Add a unique vararg node for a procedure.
 
NodeID addGepValNode (NodeID curInst, const ValVar *base, const AccessPath &ap, NodeID i, const SVFType *type, const ICFGNode *node)
 Add a temp field value node, this method can only invoked by getGepValVar.
 
NodeID addGepObjNode (const BaseObjVar *baseObj, const APOffset &apOffset, const NodeID gepId)
 Add a field obj node, this method can only invoked by getGepObjVar.
 
NodeID addFIObjNode (NodeID i, ObjTypeInfo *ti, const SVFType *type, const ICFGNode *node)
 Add a field-insensitive node, this method can only invoked by getFIGepObjNode.
 
NodeID addDummyValNode (NodeID i, const ICFGNode *node)
 Add a dummy value/object node according to node ID (llvm value is null)
 
NodeID addDummyObjNode (NodeID i, const SVFType *type)
 
NodeID addBlackholeObjNode ()
 
NodeID addConstantObjNode ()
 
NodeID addBlackholePtrNode ()
 
NodeID addValNode (SVFVar *node)
 Add a value (pointer) node.
 
NodeID addObjNode (SVFVar *node)
 Add a memory obj node.
 
NodeID addRetNode (const FunObjVar *, SVFVar *node)
 Add a unique return node for a procedure.
 
NodeID addVarargNode (const FunObjVar *, SVFVar *node)
 Add a unique vararg node for a procedure.
 
void addGlobalPAGEdge (const SVFStmt *edge)
 Add global PAGEdges (not in a procedure)
 
void addCallSite (const CallICFGNode *call)
 Add callsites.
 
AddrStmtaddAddrStmt (NodeID src, NodeID dst)
 Add an edge into SVFIR.
 
CopyStmtaddCopyStmt (NodeID src, NodeID dst, CopyStmt::CopyKind type)
 Add Copy edge.
 
PhiStmtaddPhiStmt (NodeID res, NodeID opnd, const ICFGNode *pred)
 Add phi node information.
 
SelectStmtaddSelectStmt (NodeID res, NodeID op1, NodeID op2, NodeID cond)
 Add SelectStmt.
 
CmpStmtaddCmpStmt (NodeID op1, NodeID op2, NodeID dst, u32_t predict)
 Add Copy edge.
 
BinaryOPStmtaddBinaryOPStmt (NodeID op1, NodeID op2, NodeID dst, u32_t opcode)
 Add Copy edge.
 
UnaryOPStmtaddUnaryOPStmt (NodeID src, NodeID dst, u32_t opcode)
 Add Unary edge.
 
BranchStmtaddBranchStmt (NodeID br, NodeID cond, const BranchStmt::SuccAndCondPairVec &succs)
 Add BranchStmt.
 
LoadStmtaddLoadStmt (NodeID src, NodeID dst)
 Add Load edge.
 
StoreStmtaddStoreStmt (NodeID src, NodeID dst, const ICFGNode *val)
 Add Store edge.
 
CallPEaddCallPE (NodeID src, NodeID dst, const CallICFGNode *cs, const FunEntryICFGNode *entry)
 Add Call edge.
 
RetPEaddRetPE (NodeID src, NodeID dst, const CallICFGNode *cs, const FunExitICFGNode *exit)
 Add Return edge.
 
GepStmtaddGepStmt (NodeID src, NodeID dst, const AccessPath &ap, bool constGep)
 Add Gep edge.
 
GepStmtaddNormalGepStmt (NodeID src, NodeID dst, const AccessPath &ap)
 Add Offset(Gep) edge.
 
GepStmtaddVariantGepStmt (NodeID src, NodeID dst, const AccessPath &ap)
 Add Variant(Gep) edge.
 
TDForkPEaddThreadForkPE (NodeID src, NodeID dst, const CallICFGNode *cs, const FunEntryICFGNode *entry)
 Add Thread fork edge for parameter passing.
 
TDJoinPEaddThreadJoinPE (NodeID src, NodeID dst, const CallICFGNode *cs, const FunExitICFGNode *exit)
 Add Thread join edge for parameter passing.
 
SVFStmtaddBlackHoleAddrStmt (NodeID node)
 Set a pointer points-to black hole (e.g. int2ptr)
 

Private Attributes

ICFGNode2SVFStmtsMap icfgNode2SVFStmtsMap
 Map an ICFGNode to its SVFStmts.
 
ICFGNode2SVFStmtsMap icfgNode2PTASVFStmtsMap
 Map an ICFGNode to its PointerAnalysis related SVFStmts.
 
GepValueVarMap GepValObjMap
 Map a pair<base,off> to a gep value node id.
 
TypeLocSetsMap typeLocSetsMap
 Map an arg to its base SVFType* and all its field location sets.
 
NodeOffsetMap GepObjVarMap
 Map a pair<base,off> to a gep obj node id.
 
MemObjToFieldsMap memToFieldsMap
 Map a mem object id to all its fields.
 
SVFStmtSet globSVFStmtSet
 Global PAGEdges without control flow information.
 
PHINodeMap phiNodeMap
 A set of phi copy edges.
 
FunToArgsListMap funArgsListMap
 Map a function to a list of all its formal parameters.
 
CSToArgsListMap callSiteArgsListMap
 Map a callsite to a list of all its actual parameters.
 
CSToRetMap callSiteRetMap
 Map a callsite to its callsite returns PAGNodes.
 
FunToRetMap funRetMap
 Map a function to its unique function return PAGNodes.
 
CallSiteToFunPtrMap indCallSiteToFunPtrMap
 Map an indirect callsite to its function pointer.
 
FunPtrToCallSitesMap funPtrToCallSitesMap
 
OrderedNodeSet candidatePointers
 
ICFGicfg
 
CommonCHGraphchgraph
 
CallSiteSet callSiteSet
 
CallGraphcallGraph
 all the callsites of a program
 
std::string moduleIdentifier
 

Static Private Attributes

static std::unique_ptr< SVFIRpag
 Callgraph with direct calls only; no change allowed after init and use callgraph in PointerAnalysis for indirect calls)
 
static std::string pagReadFromTxt = ""
 

Friends

class SVFIRBuilder
 
class ExternalPAG
 
class PAGBuilderFromFile
 
class TypeBasedHeapCloning
 
class BVDataPTAImpl
 

Additional Inherited Members

- Public Attributes inherited from SVF::IRGraph
const SVFTypemaxStruct
 The struct type with the most fields.
 
u32_t maxStSize
 The number of fields in max_struct.
 
- Public Attributes inherited from SVF::GenericGraph< SVFVar, SVFStmt >
u32_t edgeNum
 total num of node
 
u32_t nodeNum
 total num of edge
 
- Protected Member Functions inherited from SVF::IRGraph
NodeID addNode (SVFVar *node)
 Add a node into the graph.
 
bool addEdge (SVFVar *src, SVFVar *dst, SVFStmt *edge)
 Add an edge into the graph.
 
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)
 
const std::vector< const SVFType * > & getFlattenFieldTypes (const SVFStructType *T)
 Return the flattened field type for struct type only.
 
- Protected Attributes inherited from SVF::IRGraph
SVFStmt::KindToSVFStmtMapTy KindToSVFStmtSetMap
 SVFIR edge map containing all PAGEdges.
 
SVFStmt::KindToSVFStmtMapTy KindToPTASVFStmtSetMap
 SVFIR edge map containing only pointer-related edges, i.e., both LHS and RHS are of pointer type.
 
bool fromFile
 Whether the SVFIR is built according to user specified data from a txt file.
 
NodeID nodeNumAfterPAGBuild
 initial node number after building SVFIR, excluding later added nodes, e.g., gepobj nodes
 
u32_t totalPTAPAGEdge
 
u32_t valVarNum
 
u32_t objVarNum
 
- Protected Attributes inherited from SVF::GenericGraph< SVFVar, SVFStmt >
IDToNodeMapTy IDToNodeMap
 node map
 

Detailed Description

SVF Intermediate representation, representing variables and statements as a Program Assignment Graph (PAG) Variables as nodes and statements as edges.

Definition at line 42 of file SVFIR.h.

Member Typedef Documentation

◆ CallSiteSet

Definition at line 51 of file SVFIR.h.

◆ CallSiteToFunPtrMap

Definition at line 52 of file SVFIR.h.

◆ CSToArgsListMap

Definition at line 59 of file SVFIR.h.

◆ CSToRetMap

Definition at line 60 of file SVFIR.h.

◆ FunPtrToCallSitesMap

Definition at line 53 of file SVFIR.h.

◆ FunToArgsListMap

Definition at line 58 of file SVFIR.h.

◆ FunToPAGEdgeSetMap

Definition at line 62 of file SVFIR.h.

◆ FunToRetMap

Definition at line 61 of file SVFIR.h.

◆ GepValueVarMap

Definition at line 69 of file SVFIR.h.

◆ ICFGNode2SVFStmtsMap

Definition at line 63 of file SVFIR.h.

◆ MemObjToFieldsMap

Definition at line 54 of file SVFIR.h.

◆ NodeAccessPath

Definition at line 66 of file SVFIR.h.

◆ NodeAccessPathMap

Definition at line 68 of file SVFIR.h.

◆ NodeOffset

Definition at line 65 of file SVFIR.h.

◆ NodeOffsetMap

Definition at line 67 of file SVFIR.h.

◆ NodePairSetMap

Definition at line 72 of file SVFIR.h.

◆ NodeToNodeMap

Definition at line 64 of file SVFIR.h.

◆ PHINodeMap

Definition at line 57 of file SVFIR.h.

◆ SVFStmtList

Definition at line 55 of file SVFIR.h.

◆ SVFTypeLocSetsPair

Definition at line 70 of file SVFIR.h.

◆ SVFVarList

Definition at line 56 of file SVFIR.h.

◆ TypeLocSetsMap

Definition at line 71 of file SVFIR.h.

Constructor & Destructor Documentation

◆ SVFIR()

SVFIR::SVFIR ( bool  buildFromFile)
private

Constructor.

Definition at line 42 of file SVFIR.cpp.

42 : IRGraph(buildFromFile), icfg(nullptr), chgraph(nullptr)
43{
44}
CommonCHGraph * chgraph
Definition SVFIR.h:95
ICFG * icfg
Definition SVFIR.h:94
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ ~SVFIR()

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

Destructor.

Definition at line 146 of file SVFIR.h.

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

Member Function Documentation

◆ addAddrStmt()

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

Add an edge into SVFIR.

Add Address edge

Definition at line 63 of file SVFIR.cpp.

64{
65 SVFVar* srcNode = getGNode(src);
66 SVFVar* dstNode = getGNode(dst);
68 return nullptr;
69 else
70 {
74 return addrPE;
75 }
76}
NodeType * getGNode(NodeID id) const
Get a node.
bool addEdge(SVFVar *src, SVFVar *dst, SVFStmt *edge)
Add an edge into the graph.
Definition IRGraph.cpp:253
SVFStmt * hasNonlabeledEdge(SVFVar *src, SVFVar *dst, SVFStmt::PEDGEK kind)
Definition IRGraph.cpp:268
void addToStmt2TypeMap(SVFStmt *edge)
Map a SVFStatement type to a set of corresponding SVF statements.
Definition SVFIR.h:506

◆ addArgValNode()

NodeID SVF::SVFIR::addArgValNode ( NodeID  i,
u32_t  argNo,
const ICFGNode icfgNode,
const FunObjVar callGraphNode,
const SVFType type 
)
inlineprivate

Definition at line 570 of file SVFIR.h.

571 {
572 ArgValVar* node =
573 new ArgValVar(i, argNo, icfgNode, callGraphNode, type);
574 return addValNode(node);
575 }
newitem type
Definition cJSON.cpp:2739
NodeID addValNode(NodeID i, const SVFType *type, const ICFGNode *icfgNode)
add node into SVFIR
Definition SVFIR.h:558

◆ addBinaryOPStmt()

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

Add Copy edge.

Add Compare edge

Definition at line 165 of file SVFIR.cpp.

166{
169 SVFVar* dstNode = getGNode(dst);
171 return nullptr;
172 else
173 {
174 std::vector<SVFVar*> opnds = {op1Node, op2Node};
178 return binaryOP;
179 }
180}
SVFStmt * hasLabeledEdge(SVFVar *src, SVFVar *dst, SVFStmt::PEDGEK kind, const ICFGNode *cs)
Definition IRGraph.cpp:296

◆ addBlackHoleAddrStmt()

SVFStmt * SVFIR::addBlackHoleAddrStmt ( NodeID  node)
private

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

Add blackhole/constant edge

Definition at line 294 of file SVFIR.cpp.

295{
297 return pag->addAddrStmt(pag->getBlackHoleNode(), node);
298 else
299 return pag->addCopyStmt(pag->getNullPtr(), node, CopyStmt::COPYVAL);
300}
static Option< bool > HandBlackHole
Definition Options.h:99
static std::unique_ptr< SVFIR > pag
Callgraph with direct calls only; no change allowed after init and use callgraph in PointerAnalysis f...
Definition SVFIR.h:99

◆ addBlackholeObjNode()

NodeID SVF::SVFIR::addBlackholeObjNode ( )
inlineprivate

Definition at line 741 of file SVFIR.h.

742 {
743 return addObjNode(new DummyObjVar(getBlackHoleNode(), getObjTypeInfo(getBlackHoleNode()), nullptr));
744 }
NodeID getBlackHoleNode() const
Definition IRGraph.h:245
ObjTypeInfo * getObjTypeInfo(NodeID id) const
Definition IRGraph.h:232
NodeID addObjNode(NodeID i, ObjTypeInfo *ti, const SVFType *type, const ICFGNode *node)
Add a memory obj node.
Definition SVFIR.h:617

◆ addBlackholePtrNode()

NodeID SVF::SVFIR::addBlackholePtrNode ( )
inlineprivate

Definition at line 749 of file SVFIR.h.

750 {
751 return addDummyValNode(getBlkPtr(), nullptr);
752 }
NodeID getBlkPtr() const
Definition IRGraph.h:253
NodeID addDummyValNode()
Definition SVFIR.h:485

◆ addBranchStmt()

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

Add BranchStmt.

Definition at line 203 of file SVFIR.cpp.

204{
206 SVFVar* condNode = getGNode(cond);
208 return nullptr;
209 else
210 {
214 return branch;
215 }
216}

◆ addCallPE()

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

Add Call edge.

Add Call edge

Definition at line 258 of file SVFIR.cpp.

259{
260 SVFVar* srcNode = getGNode(src);
261 SVFVar* dstNode = getGNode(dst);
263 return nullptr;
264 else
265 {
266 CallPE* callPE = new CallPE(srcNode, dstNode, cs,entry);
269 return callPE;
270 }
271}

◆ addCallSite()

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

Add callsites.

Definition at line 790 of file SVFIR.h.

791 {
792 callSiteSet.insert(call);
793 }
CallSiteSet callSiteSet
Definition SVFIR.h:96

◆ addCallSiteArgs()

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

Add callsite arguments.

Definition at line 535 of file SVFIR.h.

536 {
537 callBlockNode->addActualParms(arg);
538 callSiteArgsListMap[callBlockNode].push_back(arg);
539 }
CSToArgsListMap callSiteArgsListMap
Map a callsite to a list of all its actual parameters.
Definition SVFIR.h:86

◆ addCallSiteRets()

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

Add callsite returns.

Definition at line 541 of file SVFIR.h.

542 {
543 retBlockNode->addActualRet(arg);
545 }
CSToRetMap callSiteRetMap
Map a callsite to its callsite returns PAGNodes.
Definition SVFIR.h:87

◆ addCmpStmt()

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

Add Copy edge.

Add Compare edge

Definition at line 144 of file SVFIR.cpp.

145{
148 SVFVar* dstNode = getGNode(dst);
150 return nullptr;
151 else
152 {
153 std::vector<SVFVar*> opnds = {op1Node, op2Node};
154 CmpStmt* cmp = new CmpStmt(dstNode, opnds, predicate);
157 return cmp;
158 }
159}

◆ addConstantAggObjNode()

NodeID SVF::SVFIR::addConstantAggObjNode ( const NodeID  i,
ObjTypeInfo ti,
const SVFType type,
const ICFGNode node 
)
inlineprivate

Definition at line 680 of file SVFIR.h.

681 {
682 memToFieldsMap[i].set(i);
683 ConstAggObjVar* conObj = new ConstAggObjVar(i, ti, type, node);
684 return addObjNode(conObj);
685 }
MemObjToFieldsMap memToFieldsMap
Map a mem object id to all its fields.
Definition SVFIR.h:82

◆ addConstantAggValNode()

NodeID SVF::SVFIR::addConstantAggValNode ( const NodeID  i,
const ICFGNode icfgNode,
const SVFType svfType 
)
inlineprivate

Definition at line 603 of file SVFIR.h.

604 {
605 SVFVar* node = new ConstAggValVar(i, icfgNode, svfType);
606 return addNode(node);
607 }
NodeID addNode(SVFVar *node)
Add a node into the graph.
Definition IRGraph.h:116

◆ addConstantDataObjNode()

NodeID SVF::SVFIR::addConstantDataObjNode ( const NodeID  i,
ObjTypeInfo ti,
const SVFType type,
const ICFGNode node 
)
inlineprivate

Definition at line 686 of file SVFIR.h.

687 {
688 memToFieldsMap[i].set(i);
689 ConstDataObjVar* conObj = new ConstDataObjVar(i, ti, type, node);
690 return addObjNode(conObj);
691 }

◆ addConstantDataValNode()

NodeID SVF::SVFIR::addConstantDataValNode ( const NodeID  i,
const ICFGNode icfgNode,
const SVFType type 
)
inlineprivate

Definition at line 609 of file SVFIR.h.

610 {
611 SVFVar* node = new ConstDataValVar(i, icfgNode, type);
612 return addNode(node);
613 }

◆ addConstantFPObjNode()

NodeID SVF::SVFIR::addConstantFPObjNode ( NodeID  i,
ObjTypeInfo ti,
double  dval,
const SVFType type,
const ICFGNode node 
)
inlineprivate

Definition at line 650 of file SVFIR.h.

651 {
652 memToFieldsMap[i].set(i);
653 ConstFPObjVar* conObj = new ConstFPObjVar(i, dval, ti, type, node);
654 return addObjNode(conObj);
655 }

◆ addConstantFPValNode()

NodeID SVF::SVFIR::addConstantFPValNode ( const NodeID  i,
double  dval,
const ICFGNode icfgNode,
const SVFType type 
)
inlineprivate

Definition at line 577 of file SVFIR.h.

579 {
580 SVFVar* node = new ConstFPValVar(i, dval, icfgNode, type);
581 return addNode(node);
582 }

◆ addConstantIntObjNode()

NodeID SVF::SVFIR::addConstantIntObjNode ( NodeID  i,
ObjTypeInfo ti,
const std::pair< s64_t, u64_t > &  intValue,
const SVFType type,
const ICFGNode node 
)
inlineprivate

Definition at line 658 of file SVFIR.h.

659 {
660 memToFieldsMap[i].set(i);
661 ConstIntObjVar* conObj =
662 new ConstIntObjVar(i, intValue.first, intValue.second, ti, type, node);
663 return addObjNode(conObj);
664 }

◆ addConstantIntValNode()

NodeID SVF::SVFIR::addConstantIntValNode ( NodeID  i,
const std::pair< s64_t, u64_t > &  intValue,
const ICFGNode icfgNode,
const SVFType type 
)
inlineprivate

Definition at line 584 of file SVFIR.h.

586 {
587 SVFVar* node = new ConstIntValVar(i, intValue.first, intValue.second, icfgNode, type);
588 return addNode(node);
589 }

◆ addConstantNullPtrObjNode()

NodeID SVF::SVFIR::addConstantNullPtrObjNode ( const NodeID  i,
ObjTypeInfo ti,
const SVFType type,
const ICFGNode node 
)
inlineprivate

Definition at line 667 of file SVFIR.h.

668 {
669 memToFieldsMap[i].set(i);
670 ConstNullPtrObjVar* conObj = new ConstNullPtrObjVar(i, ti, type, node);
671 return addObjNode(conObj);
672 }

◆ addConstantNullPtrValNode()

NodeID SVF::SVFIR::addConstantNullPtrValNode ( const NodeID  i,
const ICFGNode icfgNode,
const SVFType type 
)
inlineprivate

Definition at line 591 of file SVFIR.h.

592 {
593 SVFVar* node = new ConstNullPtrValVar(i, icfgNode, type);
594 return addNode(node);
595 }

◆ addConstantObjNode()

NodeID SVF::SVFIR::addConstantObjNode ( )
inlineprivate

Definition at line 745 of file SVFIR.h.

746 {
747 return addObjNode(new DummyObjVar(getConstantNode(), getObjTypeInfo(getConstantNode()), nullptr));
748 }
NodeID getConstantNode() const
Definition IRGraph.h:249

◆ addCopyStmt()

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

Add Copy edge.

Add Copy edge

Definition at line 81 of file SVFIR.cpp.

82{
83 SVFVar* srcNode = getGNode(src);
84 SVFVar* dstNode = getGNode(dst);
86 return nullptr;
87 else
88 {
92 return copyPE;
93 }
94}

◆ addDummyObjNode() [1/2]

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

Definition at line 489 of file SVFIR.h.

490 {
491 return addDummyObjNode(NodeIDAllocator::get()->allocateObjectId(), type);
492 }
static NodeIDAllocator * get(void)
Return (singleton) allocator.
NodeID addDummyObjNode(const SVFType *type)
Definition SVFIR.h:489

◆ addDummyObjNode() [2/2]

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

Definition at line 727 of file SVFIR.h.

728 {
729 if (idToObjTypeInfoMap().find(i) == idToObjTypeInfoMap().end())
730 {
731 ObjTypeInfo* ti = createObjTypeInfo(type);
733 return addObjNode(new DummyObjVar(i, ti, nullptr, type));
734 }
735 else
736 {
737 return addObjNode(new DummyObjVar(i, getObjTypeInfo(i), nullptr, type));
738 }
739 }
ObjTypeInfo * createObjTypeInfo(const SVFType *type)
Create an objectInfo based on LLVM type (value is null, and type could be null, representing a dummy ...
Definition IRGraph.cpp:231
IDToTypeInfoMapTy & idToObjTypeInfoMap()
Get different kinds of syms maps.
Definition IRGraph.h:210

◆ addDummyValNode() [1/2]

NodeID SVF::SVFIR::addDummyValNode ( )
inline

Definition at line 485 of file SVFIR.h.

486 {
487 return addDummyValNode(NodeIDAllocator::get()->allocateValueId(), nullptr);
488 }

◆ addDummyValNode() [2/2]

NodeID SVF::SVFIR::addDummyValNode ( NodeID  i,
const ICFGNode node 
)
inlineprivate

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

Definition at line 723 of file SVFIR.h.

724 {
725 return addValNode(new DummyValVar(i, node));
726 }

◆ addFIObjNode()

NodeID SVF::SVFIR::addFIObjNode ( NodeID  i,
ObjTypeInfo ti,
const SVFType type,
const ICFGNode node 
)
inlineprivate

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

Definition at line 711 of file SVFIR.h.

712 {
713 memToFieldsMap[i].set(i);
714 BaseObjVar* baseObj = new BaseObjVar(i, ti, type, node);
715 return addObjNode(baseObj);
716 }

◆ addFunArgs()

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

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

Add function arguments

Definition at line 521 of file SVFIR.h.

522 {
523 FunEntryICFGNode* funEntryBlockNode = icfg->getFunEntryICFGNode(fun);
525 funArgsListMap[fun].push_back(arg);
526 }
void addFormalParms(const SVFVar *fp)
Add formal parameters.
Definition ICFGNode.h:295
FunEntryICFGNode * getFunEntryICFGNode(const FunObjVar *fun)
Add a function entry node.
Definition ICFG.cpp:242
FunToArgsListMap funArgsListMap
Map a function to a list of all its formal parameters.
Definition SVFIR.h:85

◆ addFunObjNode()

NodeID SVF::SVFIR::addFunObjNode ( NodeID  id,
ObjTypeInfo ti,
const SVFType type,
const ICFGNode node 
)
inlineprivate

Definition at line 642 of file SVFIR.h.

643 {
644 memToFieldsMap[id].set(id);
645 FunObjVar* funObj = new FunObjVar(id, ti, type, node);
646 return addObjNode(funObj);
647 }

◆ addFunRet()

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

Add function returns.

Definition at line 528 of file SVFIR.h.

529 {
530 FunExitICFGNode* funExitBlockNode = icfg->getFunExitICFGNode(fun);
532 funRetMap[fun] = ret;
533 }
void addFormalRet(const SVFVar *fr)
Add formal return parameter.
Definition ICFGNode.h:358
FunExitICFGNode * getFunExitICFGNode(const FunObjVar *fun)
Add a function exit node.
Definition ICFG.cpp:249
FunToRetMap funRetMap
Map a function to its unique function return PAGNodes.
Definition SVFIR.h:88

◆ addFunValNode()

NodeID SVF::SVFIR::addFunValNode ( NodeID  i,
const ICFGNode icfgNode,
const FunObjVar funObjVar,
const SVFType type 
)
inlineprivate

Definition at line 564 of file SVFIR.h.

565 {
566 FunValVar* node = new FunValVar(i, icfgNode, funObjVar, type);
567 return addValNode(node);
568 }

◆ addGepObjNode()

NodeID SVFIR::addGepObjNode ( const BaseObjVar baseObj,
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 466 of file SVFIR.cpp.

467{
468 //assert(findPAGNode(i) == false && "this node should not be created before");
469 NodeID base = baseObj->getId();
470 assert(0==GepObjVarMap.count(std::make_pair(base, apOffset))
471 && "this node should not be created before");
472
473 GepObjVarMap[std::make_pair(base, apOffset)] = gepId;
474 //ABTest
475 GepObjVar *node = new GepObjVar(baseObj, gepId, apOffset);
476 memToFieldsMap[base].set(gepId);
477 return addObjNode(node);
478}
NodeOffsetMap GepObjVarMap
Map a pair<base,off> to a gep obj node id.
Definition SVFIR.h:81
u32_t NodeID
Definition GeneralType.h:56

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

345{
346
347 SVFVar* node = getGNode(src);
348 if (!constGep || node->hasIncomingVariantGepEdge())
349 {
352 return addVariantGepStmt(src, dst, ap);
353 }
354 else
355 {
356 return addNormalGepStmt(src, dst, ap);
357 }
358}
GepStmt * addVariantGepStmt(NodeID src, NodeID dst, const AccessPath &ap)
Add Variant(Gep) edge.
Definition SVFIR.cpp:382
GepStmt * addNormalGepStmt(NodeID src, NodeID dst, const AccessPath &ap)
Add Offset(Gep) edge.
Definition SVFIR.cpp:363
bool hasIncomingVariantGepEdge() const
Check for incoming variable field GEP edges.

◆ addGepValNode()

NodeID SVFIR::addGepValNode ( NodeID  curInst,
const ValVar baseVar,
const AccessPath ap,
NodeID  i,
const SVFType type,
const ICFGNode icn 
)
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 403 of file SVFIR.cpp.

404{
405 NodeID base = baseVar->getId();
406 //assert(findPAGNode(i) == false && "this node should not be created before");
407 assert(0==GepValObjMap[curInst].count(std::make_pair(base, ap))
408 && "this node should not be created before");
409 GepValObjMap[curInst][std::make_pair(base, ap)] = i;
410 GepValVar *node = new GepValVar(baseVar, i, ap, type, icn);
411 return addValNode(node);
412}
int count
Definition cJSON.h:216
GepValueVarMap GepValObjMap
Map a pair<base,off> to a gep value node id.
Definition SVFIR.h:79

◆ addGlobalObjNode()

NodeID SVF::SVFIR::addGlobalObjNode ( const NodeID  i,
ObjTypeInfo ti,
const SVFType type,
const ICFGNode node 
)
inlineprivate

Definition at line 674 of file SVFIR.h.

675 {
676 memToFieldsMap[i].set(i);
677 GlobalObjVar* gObj = new GlobalObjVar(i, ti, type, node);
678 return addObjNode(gObj);
679 }

◆ addGlobalPAGEdge()

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

Add global PAGEdges (not in a procedure)

Definition at line 785 of file SVFIR.h.

786 {
787 globSVFStmtSet.insert(edge);
788 }
SVFStmtSet globSVFStmtSet
Global PAGEdges without control flow information.
Definition SVFIR.h:83

◆ addGlobalValNode()

NodeID SVF::SVFIR::addGlobalValNode ( const NodeID  i,
const ICFGNode icfgNode,
const SVFType svfType 
)
inlineprivate

Definition at line 597 of file SVFIR.h.

598 {
599 SVFVar* node = new GlobalValVar(i, icfgNode, svfType);
600 return addNode(node);
601 }

◆ addHeapObjNode()

NodeID SVF::SVFIR::addHeapObjNode ( NodeID  i,
ObjTypeInfo ti,
const SVFType type,
const ICFGNode node 
)
inlineprivate

Creates and adds a heap object node to the SVFIR

Definition at line 625 of file SVFIR.h.

626 {
627 memToFieldsMap[i].set(i);
628 HeapObjVar *heapObj = new HeapObjVar(i, ti, type, node);
629 return addObjNode(heapObj);
630 }

◆ addIndirectCallsites()

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

Add indirect callsites.

Definition at line 547 of file SVFIR.h.

548 {
549 bool added = indCallSiteToFunPtrMap.emplace(cs, funPtr).second;
550 (void) added;
551 funPtrToCallSitesMap[funPtr].insert(cs);
552 assert(added && "adding the same indirect callsite twice?");
553 }
CallSiteToFunPtrMap indCallSiteToFunPtrMap
Map an indirect callsite to its function pointer.
Definition SVFIR.h:89
FunPtrToCallSitesMap funPtrToCallSitesMap
Definition SVFIR.h:90

◆ addLoadStmt()

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

Add Load edge.

Add Load edge

Definition at line 221 of file SVFIR.cpp.

222{
223 SVFVar* srcNode = getGNode(src);
224 SVFVar* dstNode = getGNode(dst);
226 return nullptr;
227 else
228 {
232 return loadPE;
233 }
234}

◆ addNormalGepStmt()

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

Add Offset(Gep) edge.

Add normal (Gep) edge

Definition at line 363 of file SVFIR.cpp.

364{
365 SVFVar* baseNode = getGNode(src);
366 SVFVar* dstNode = getGNode(dst);
368 return nullptr;
369 else
370 {
371 GepStmt* gepPE = new GepStmt(baseNode, dstNode, ap);
374 return gepPE;
375 }
376}

◆ addObjNode() [1/2]

NodeID SVF::SVFIR::addObjNode ( NodeID  i,
ObjTypeInfo ti,
const SVFType type,
const ICFGNode node 
)
inlineprivate

Add a memory obj node.

Definition at line 617 of file SVFIR.h.

618 {
619 return addFIObjNode( i, ti, type, node);
620 }
NodeID addFIObjNode(NodeID i, ObjTypeInfo *ti, const SVFType *type, const ICFGNode *node)
Add a field-insensitive node, this method can only invoked by getFIGepObjNode.
Definition SVFIR.h:711

◆ addObjNode() [2/2]

NodeID SVF::SVFIR::addObjNode ( SVFVar node)
inlineprivate

Add a memory obj node.

Definition at line 765 of file SVFIR.h.

766 {
767 assert(node && "node cannot be nullptr.");
768 assert(hasGNode(node->getId()) == false &&
769 "This NodeID clashes here. Please check NodeIDAllocator. Switch "
770 "Strategy::DBUG to SEQ or DENSE");
771 return addNode(node);
772 }
bool hasGNode(NodeID id) const
Has a node.

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

100{
102 SVFVar* resNode = getGNode(res);
103 PHINodeMap::iterator it = phiNodeMap.find(resNode);
104 if(it == phiNodeMap.end())
105 {
106 PhiStmt* phi = new PhiStmt(resNode, {opNode}, {pred});
110 return phi;
111 }
112 else
113 {
114 it->second->addOpVar(opNode,pred);
116 return nullptr;
117 }
118}
PHINodeMap phiNodeMap
A set of phi copy edges.
Definition SVFIR.h:84

◆ addRetNode() [1/2]

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

Add a unique return node for a procedure.

Definition at line 774 of file SVFIR.h.

775 {
776 return addNode(node);
777 }

◆ addRetNode() [2/2]

NodeID SVF::SVFIR::addRetNode ( NodeID  i,
const FunObjVar callGraphNode,
const SVFType type,
const ICFGNode icn 
)
inlineprivate

Add a unique return node for a procedure.

Definition at line 694 of file SVFIR.h.

695 {
696 SVFVar *node = new RetValPN(i, callGraphNode, type, icn);
697 return addRetNode(callGraphNode, node);
698 }
NodeID addRetNode(NodeID i, const FunObjVar *callGraphNode, const SVFType *type, const ICFGNode *icn)
Add a unique return node for a procedure.
Definition SVFIR.h:694

◆ addRetPE()

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

Add Return edge.

Add Return edge

Definition at line 276 of file SVFIR.cpp.

277{
278 SVFVar* srcNode = getGNode(src);
279 SVFVar* dstNode = getGNode(dst);
281 return nullptr;
282 else
283 {
284 RetPE* retPE = new RetPE(srcNode, dstNode, cs, exit);
285 addToStmt2TypeMap(retPE);
286 addEdge(srcNode,dstNode, retPE);
287 return retPE;
288 }
289}

◆ addSelectStmt()

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

Add SelectStmt.

Add Phi statement

Definition at line 123 of file SVFIR.cpp.

124{
127 SVFVar* dstNode = getGNode(res);
128 SVFVar* condNode = getGNode(cond);
130 return nullptr;
131 else
132 {
133 std::vector<SVFVar*> opnds = {op1Node, op2Node};
137 return select;
138 }
139}

◆ addStackObjNode()

NodeID SVF::SVFIR::addStackObjNode ( NodeID  i,
ObjTypeInfo ti,
const SVFType type,
const ICFGNode node 
)
inlineprivate

Creates and adds a stack object node to the SVFIR

Definition at line 635 of file SVFIR.h.

636 {
637 memToFieldsMap[i].set(i);
638 StackObjVar *stackObj = new StackObjVar(i, ti, type, node);
639 return addObjNode(stackObj);
640 }

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

241{
242 SVFVar* srcNode = getGNode(src);
243 SVFVar* dstNode = getGNode(dst);
245 return nullptr;
246 else
247 {
248 StoreStmt* storePE = new StoreStmt(srcNode, dstNode, curVal);
251 return storePE;
252 }
253}

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

306{
307 SVFVar* srcNode = getGNode(src);
308 SVFVar* dstNode = getGNode(dst);
310 return nullptr;
311 else
312 {
313 TDForkPE* forkPE = new TDForkPE(srcNode, dstNode, cs, entry);
316 return forkPE;
317 }
318}

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

324{
325 SVFVar* srcNode = getGNode(src);
326 SVFVar* dstNode = getGNode(dst);
328 return nullptr;
329 else
330 {
331 TDJoinPE* joinPE = new TDJoinPE(srcNode, dstNode, cs, exit);
334 return joinPE;
335 }
336}

◆ 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 506 of file SVFIR.h.

507 {
508 bool added = KindToSVFStmtSetMap[edge->getEdgeKind()].insert(edge).second;
509 (void)added; // Suppress warning of unused variable under release build
510 assert(added && "duplicated edge, not added!!!");
512 if (edge->isPTAEdge() || (SVFUtil::isa<CopyStmt>(edge) && SVFUtil::cast<CopyStmt>(edge)->isInt2Ptr()))
513 {
515 KindToPTASVFStmtSetMap[edge->getEdgeKind()].insert(edge);
516 }
517 }
SVFStmt::KindToSVFStmtMapTy KindToSVFStmtSetMap
SVFIR edge map containing all PAGEdges.
Definition IRGraph.h:107
u32_t totalPTAPAGEdge
Definition IRGraph.h:111
SVFStmt::KindToSVFStmtMapTy KindToPTASVFStmtSetMap
SVFIR edge map containing only pointer-related edges, i.e., both LHS and RHS are of pointer type.
Definition IRGraph.h:108

◆ addToSVFStmtList()

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

Add a SVFStmt into instruction map.

Definition at line 253 of file SVFIR.h.

254 {
255 edge->setICFGNode(inst);
256 icfgNode2SVFStmtsMap[inst].push_back(edge);
257 if (edge->isPTAEdge())
258 icfgNode2PTASVFStmtsMap[inst].push_back(edge);
259 }
ICFGNode2SVFStmtsMap icfgNode2SVFStmtsMap
Map an ICFGNode to its SVFStmts.
Definition SVFIR.h:77
ICFGNode2SVFStmtsMap icfgNode2PTASVFStmtsMap
Map an ICFGNode to its PointerAnalysis related SVFStmts.
Definition SVFIR.h:78

◆ 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 261 of file SVFIR.h.

262 {
264 }
TypeLocSetsMap typeLocSetsMap
Map an arg to its base SVFType* and all its field location sets.
Definition SVFIR.h:80

◆ addUnaryOPStmt()

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

Add Unary edge.

Add Unary edge

Definition at line 185 of file SVFIR.cpp.

186{
187 SVFVar* srcNode = getGNode(src);
188 SVFVar* dstNode = getGNode(dst);
190 return nullptr;
191 else
192 {
196 return unaryOP;
197 }
198}

◆ addValNode() [1/2]

NodeID SVF::SVFIR::addValNode ( NodeID  i,
const SVFType type,
const ICFGNode icfgNode 
)
inlineprivate

add node into SVFIR

Add a value (pointer) node

Definition at line 558 of file SVFIR.h.

559 {
560 SVFVar *node = new ValVar(i, type, icfgNode, ValVar::ValNode);
561 return addValNode(node);
562 }

◆ addValNode() [2/2]

NodeID SVF::SVFIR::addValNode ( SVFVar node)
inlineprivate

Add a value (pointer) node.

Definition at line 756 of file SVFIR.h.

757 {
758 assert(node && "node cannot be nullptr.");
759 assert(hasGNode(node->getId()) == false &&
760 "This NodeID clashes here. Please check NodeIDAllocator. Switch "
761 "Strategy::DBUG to SEQ or DENSE");
762 return addNode(node);
763 }

◆ addVarargNode() [1/2]

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

Add a unique vararg node for a procedure.

Definition at line 779 of file SVFIR.h.

780 {
781 return addNode(node);
782 }

◆ addVarargNode() [2/2]

NodeID SVF::SVFIR::addVarargNode ( NodeID  i,
const FunObjVar val,
const SVFType type,
const ICFGNode n 
)
inlineprivate

Add a unique vararg node for a procedure.

Definition at line 700 of file SVFIR.h.

701 {
702 SVFVar *node = new VarArgValPN(i, val, type, n);
703 return addNode(node);
704 }
cJSON * n
Definition cJSON.cpp:2558

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

383{
384 SVFVar* baseNode = getGNode(src);
385 SVFVar* dstNode = getGNode(dst);
387 return nullptr;
388 else
389 {
390 GepStmt* gepPE = new GepStmt(baseNode, dstNode, ap, true);
393 return gepPE;
394 }
395}

◆ callsiteHasRet()

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

Definition at line 332 of file SVFIR.h.

333 {
334 return callSiteRetMap.find(cs) != callSiteRetMap.end();
335 }

◆ destroy()

void SVFIR::destroy ( )
private

Clean up memory.

Clean up memory

Definition at line 544 of file SVFIR.cpp.

545{
546 delete icfg;
547 icfg = nullptr;
548 delete chgraph;
549 chgraph = nullptr;
550 delete callGraph;
551 callGraph = nullptr;
552}
CallGraph * callGraph
all the callsites of a program
Definition SVFIR.h:97

◆ funHasRet()

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

Definition at line 348 of file SVFIR.h.

349 {
350 return funRetMap.find(func) != funRetMap.end();
351 }

◆ getAllFieldsObjVars() [1/2]

NodeBS & SVFIR::getAllFieldsObjVars ( const BaseObjVar obj)

Get all fields of an object.

Get all fields object nodes of an object

Definition at line 483 of file SVFIR.cpp.

484{
485 NodeID base = obj->getId();
486 return memToFieldsMap[base];
487}

◆ getAllFieldsObjVars() [2/2]

NodeBS & SVFIR::getAllFieldsObjVars ( NodeID  id)

Get all fields object nodes of an object

Definition at line 492 of file SVFIR.cpp.

493{
494 const SVFVar* node = pag->getGNode(id);
495 assert(SVFUtil::isa<ObjVar>(node) && "need an object node");
497}
const BaseObjVar * getBaseObject(NodeID id) const
Definition SVFIR.h:417
NodeBS & getAllFieldsObjVars(const BaseObjVar *obj)
Get all fields of an object.
Definition SVFIR.cpp:483

◆ getAllValidPtrs()

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

Return valid pointers.

Definition at line 138 of file SVFIR.h.

139 {
140 return candidatePointers;
141 }
OrderedNodeSet candidatePointers
Definition SVFIR.h:93

◆ getBaseObject()

const BaseObjVar * SVF::SVFIR::getBaseObject ( 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 417 of file SVFIR.h.

418 {
419 const SVFVar* node = getGNode(id);
420 if(const GepObjVar* gepObjVar = SVFUtil::dyn_cast<GepObjVar>(node))
421 return SVFUtil::dyn_cast<BaseObjVar>(
422 getGNode(gepObjVar->getBaseNode()));
423 else
424 return SVFUtil::dyn_cast<BaseObjVar>(node);
425 }

◆ 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 473 of file SVFIR.h.

474 {
475 return getBaseObject(id)->getId();
476 }
NodeID getId() const
Get the memory object id.

◆ getBaseValVar()

const ValVar * SVF::SVFIR::getBaseValVar ( NodeID  id) const
inline

Definition at line 427 of file SVFIR.h.

428 {
429 const SVFVar* node = getGNode(id);
430 if(const GepValVar* gepVar = SVFUtil::dyn_cast<GepValVar>(node))
431 return gepVar->getBaseNode();
432 else
433 return SVFUtil::dyn_cast<ValVar>(node);
434 }

◆ getCallGraph()

const CallGraph * SVF::SVFIR::getCallGraph ( )
inline

Get CG.

Definition at line 178 of file SVFIR.h.

179 {
180 assert(callGraph && "empty CallGraph! Build SVF IR first!");
181 return callGraph;
182 }

◆ getCallSiteArgsList()

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

Get callsite argument list.

Definition at line 314 of file SVFIR.h.

315 {
316 CSToArgsListMap::const_iterator it = callSiteArgsListMap.find(cs);
317 assert(it != callSiteArgsListMap.end() && "this call site doesn't have arguments");
318 return it->second;
319 }

◆ getCallSiteArgsMap()

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

Get callsite argument list.

Definition at line 309 of file SVFIR.h.

310 {
311 return callSiteArgsListMap;
312 }

◆ getCallSiteRet()

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

Get callsite return.

Definition at line 326 of file SVFIR.h.

327 {
328 CSToRetMap::const_iterator it = callSiteRetMap.find(cs);
329 assert(it != callSiteRetMap.end() && "this call site doesn't have return");
330 return it->second;
331 }

◆ getCallSiteRets()

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

Get callsite return.

Definition at line 321 of file SVFIR.h.

322 {
323 return callSiteRetMap;
324 }

◆ getCallSiteSet()

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

Get all callsites.

Definition at line 276 of file SVFIR.h.

277 {
278 return callSiteSet;
279 }

◆ getCHG()

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

Definition at line 171 of file SVFIR.h.

172 {
173 assert(chgraph && "empty ICFG! Build SVF IR first!");
174 return chgraph;
175 }

◆ getFieldObjNodeNum()

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

Definition at line 360 of file SVFIR.h.

361 {
362 return GepObjVarMap.size();
363 }

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

505{
506 const SVFVar* node = pag->getGNode(id);
507 assert(SVFUtil::isa<ObjVar>(node) && "need an object node");
508 const BaseObjVar* obj = getBaseObject(id);
509 if(obj->isFieldInsensitive())
510 {
511 NodeBS bs;
513 return bs;
514 }
515 else
516 return getAllFieldsObjVars(obj);
517}
NodeID getFIObjVar(const BaseObjVar *obj) const
Get a field-insensitive obj SVFIR node according to a mem obj.
Definition SVFIR.h:443
void set(unsigned Idx)

◆ getFieldValNodeNum()

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

Node and edge statistics.

Definition at line 356 of file SVFIR.h.

357 {
358 return GepValObjMap.size();
359 }

◆ getFIObjVar() [1/2]

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

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

Definition at line 443 of file SVFIR.h.

444 {
445 return obj->getId();
446 }

◆ getFIObjVar() [2/2]

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

Definition at line 447 of file SVFIR.h.

448 {
449 return getBaseObjVar(id);
450 }
NodeID getBaseObjVar(NodeID id) const
Base and Offset methods for Value and Object node.
Definition SVFIR.h:473

◆ getFunArgsList()

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

Get function arguments list.

Definition at line 297 of file SVFIR.h.

298 {
299 FunToArgsListMap::const_iterator it = funArgsListMap.find(func);
300 assert(it != funArgsListMap.end() && "this function doesn't have arguments");
301 return it->second;
302 }

◆ getFunArgsMap()

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

Get function arguments list.

Definition at line 292 of file SVFIR.h.

293 {
294 return funArgsListMap;
295 }

◆ getFunObjVar()

const FunObjVar * SVFIR::getFunObjVar ( const std::string &  name)

Definition at line 47 of file SVFIR.cpp.

48{
49 for (const auto &item: *callGraph)
50 {
51 if (item.second->getName() == name)
52 {
53 return item.second->getFunction();
54 }
55 }
56 return nullptr;
57}
const char *const name
Definition cJSON.h:264
cJSON * item
Definition cJSON.h:222

◆ getFunPtr()

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

Definition at line 376 of file SVFIR.h.

377 {
378 CallSiteToFunPtrMap::const_iterator it = indCallSiteToFunPtrMap.find(cs);
379 assert(it!=indCallSiteToFunPtrMap.end() && "indirect callsite not have a function pointer?");
380 return it->second;
381 }

◆ getFunRet()

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

Get function return list.

Definition at line 342 of file SVFIR.h.

343 {
344 FunToRetMap::const_iterator it = funRetMap.find(func);
345 assert(it != funRetMap.end() && "this function doesn't have return");
346 return it->second;
347 }

◆ getFunRets()

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

Get function return list.

Definition at line 337 of file SVFIR.h.

338 {
339 return funRetMap;
340 }

◆ getGepObjNodeMap()

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

Return GepObjVarMap.

Definition at line 133 of file SVFIR.h.

134 {
135 return GepObjVarMap;
136 }

◆ getGepObjVar() [1/2]

NodeID SVFIR::getGepObjVar ( const BaseObjVar baseObj,
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 439 of file SVFIR.cpp.

440{
441 NodeID base = baseObj->getId();
442
444 if (baseObj->isFieldInsensitive())
445 return getFIObjVar(baseObj);
446
447 APOffset newLS = pag->getModulusOffset(baseObj, apOffset);
448
449 // Base and first field are the same memory location.
450 if (Options::FirstFieldEqBase() && newLS == 0) return base;
451
452 NodeOffsetMap::iterator iter = GepObjVarMap.find(std::make_pair(base, newLS));
453 if (iter == GepObjVarMap.end())
454 {
457 }
458 else
459 return iter->second;
460
461}
NodeID allocateGepObjectId(NodeID base, u32_t offset, u32_t maxFieldLimit)
static const Option< bool > FirstFieldEqBase
Definition Options.h:100
static const Option< u32_t > MaxFieldLimit
Maximum number of field derivations for an object.
Definition Options.h:35
NodeID addGepObjNode(const BaseObjVar *baseObj, const APOffset &apOffset, const NodeID gepId)
Add a field obj node, this method can only invoked by getGepObjVar.
Definition SVFIR.cpp:466
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 417 of file SVFIR.cpp.

418{
419 SVFVar* node = pag->getGNode(id);
420 if (GepObjVar* gepNode = SVFUtil::dyn_cast<GepObjVar>(node))
421 return getGepObjVar(gepNode->getBaseObj(), gepNode->getConstantFieldIdx() + apOffset);
422 else if (BaseObjVar* baseNode = SVFUtil::dyn_cast<BaseObjVar>(node))
423 return getGepObjVar(baseNode, apOffset);
424 else if (DummyObjVar* baseNode = SVFUtil::dyn_cast<DummyObjVar>(node))
425 return getGepObjVar(baseNode, apOffset);
426 else
427 {
428 assert(false && "new gep obj node kind?");
429 return id;
430 }
431}
NodeID getGepObjVar(const BaseObjVar *baseObj, const APOffset &ap)
Get a field SVFIR Object node according to base mem obj and offset.
Definition SVFIR.cpp:439

◆ getGepValVar()

NodeID SVFIR::getGepValVar ( NodeID  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 522 of file SVFIR.cpp.

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

◆ getGlobalSVFStmtSet()

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

Get global PAGEdges (not in a procedure)

Definition at line 271 of file SVFIR.h.

272 {
273 return globSVFStmtSet;
274 }

◆ getICFG()

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

Definition at line 161 of file SVFIR.h.

162 {
163 assert(icfg->totalICFGNode>0 && "empty ICFG! Build SVF IR first!");
164 return icfg;
165 }
NodeID totalICFGNode
Definition ICFG.h:64

◆ getIndCallSites()

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

Definition at line 382 of file SVFIR.h.

383 {
384 FunPtrToCallSitesMap::const_iterator it = funPtrToCallSitesMap.find(funPtr);
385 assert(it!=funPtrToCallSitesMap.end() && "function pointer not used at any indirect callsite?");
386 return it->second;
387 }

◆ getIndirectCallsites()

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

Add/get indirect callsites.

Definition at line 372 of file SVFIR.h.

373 {
375 }

◆ 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 399 of file SVFIR.h.

400 {
401 return getIntraPAGEdge(getGNode(src), getGNode(dst), kind);
402 }
SVFStmt * getIntraPAGEdge(NodeID src, NodeID dst, SVFStmt::PEDGEK kind)
Get an edge according to src, dst and kind.
Definition SVFIR.h:399

◆ getIntraPAGEdge() [2/2]

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

Definition at line 403 of file SVFIR.h.

404 {
405 SVFStmt edge(src, dst, kind, false);
407 SVFStmt::SVFStmtSetTy::const_iterator it = edgeSet.find(&edge);
408 assert(it != edgeSet.end() && "can not find pag edge");
409 return (*it);
410 }
SVFStmt::SVFStmtSetTy & getSVFStmtSet(SVFStmt::PEDGEK kind)
Get/set methods to get SVFStmts based on their kinds and ICFGNodes.
Definition SVFIR.h:223
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy

◆ getMemToFieldsMap()

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

Return memToFieldsMap.

Definition at line 128 of file SVFIR.h.

129 {
130 return memToFieldsMap;
131 }

◆ getModuleIdentifier()

const std::string & SVF::SVFIR::getModuleIdentifier ( ) const
inline

Definition at line 186 of file SVFIR.h.

187 {
188 if (pagReadFromTxt.empty())
189 {
190 assert(!moduleIdentifier.empty() &&
191 "No module found! Reading from a file other than LLVM-IR?");
192 return moduleIdentifier;
193 }
194 else
195 {
196 return pagReadFromTxt;
197 }
198 }
static std::string pagReadFromTxt
Definition SVFIR.h:100
std::string moduleIdentifier
Definition SVFIR.h:102

◆ 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 114 of file SVFIR.h.

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

◆ getPTASVFStmtList()

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

Given an instruction, get all its PTA PAGEdges.

Definition at line 248 of file SVFIR.h.

249 {
250 return icfgNode2PTASVFStmtsMap[inst];
251 }

◆ getPTASVFStmtSet()

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

Get PTA edges set according to its kind.

Definition at line 228 of file SVFIR.h.

229 {
230 return KindToPTASVFStmtSetMap[kind];
231 }

◆ getSVFStmtList()

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

Given an instruction, get all its PAGEdges.

Definition at line 243 of file SVFIR.h.

244 {
245 return icfgNode2SVFStmtsMap[inst];
246 }

◆ 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 223 of file SVFIR.h.

224 {
225 return KindToSVFStmtSetMap[kind];
226 }

◆ 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 266 of file SVFIR.h.

267 {
268 return typeLocSetsMap[argId];
269 }

◆ handleBlackHole()

void SVFIR::handleBlackHole ( bool  b)
static

SVFIR build configurations.

Whether to handle blackhole edge

Definition at line 690 of file SVFIR.cpp.

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

◆ hasCallSiteArgsMap()

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

Callsite has argument list.

Definition at line 304 of file SVFIR.h.

305 {
306 return (callSiteArgsListMap.find(cs) != callSiteArgsListMap.end());
307 }

◆ hasFunArgsList()

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

Function has arguments list.

Definition at line 287 of file SVFIR.h.

288 {
289 return (funArgsListMap.find(func) != funArgsListMap.end());
290 }

◆ hasPTASVFStmtList()

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

Definition at line 237 of file SVFIR.h.

238 {
239 return icfgNode2PTASVFStmtsMap.find(inst) !=
241 }

◆ hasSVFStmtList()

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

Whether this instruction has SVFIR Edge.

Definition at line 233 of file SVFIR.h.

234 {
235 return icfgNode2SVFStmtsMap.find(inst) != icfgNode2SVFStmtsMap.end();
236 }

◆ initialiseCandidatePointers()

void SVFIR::initialiseCandidatePointers ( )

Initialize candidate pointers.

Definition at line 642 of file SVFIR.cpp.

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

◆ isBlkObjOrConstantObj()

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

Get black hole and constant id.

Definition at line 456 of file SVFIR.h.

457 {
458 return (isBlkObj(id) || isConstantObj(id));
459 }
static bool isBlkObj(NodeID id)
Definition IRGraph.h:163
bool isConstantObj(NodeID id) const
Definition SVFIR.h:461

◆ isConstantObj()

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

Definition at line 461 of file SVFIR.h.

462 {
463 const BaseObjVar* obj = getBaseObject(id);
464 assert(obj && "not an object node?");
465 return isConstantSym(id) ||
466 obj->isConstDataOrConstGlobal();
467 }
static bool isConstantSym(NodeID id)
Definition IRGraph.h:167

◆ isFunPtr()

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

Definition at line 392 of file SVFIR.h.

393 {
394 return (funPtrToCallSitesMap.find(id) != funPtrToCallSitesMap.end());
395 }

◆ isIndirectCallSites()

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

Definition at line 388 of file SVFIR.h.

389 {
390 return (indCallSiteToFunPtrMap.find(cs) != indCallSiteToFunPtrMap.end());
391 }

◆ isPhiNode()

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

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

Definition at line 281 of file SVFIR.h.

282 {
283 return phiNodeMap.find(node) != phiNodeMap.end();
284 }

◆ isValidPointer()

bool SVFIR::isValidPointer ( NodeID  nodeId) const

Whether a node is a valid pointer.

Definition at line 658 of file SVFIR.cpp.

659{
660 SVFVar* node = pag->getGNode(nodeId);
661
662 if(node->isPointer())
663 if (const ValVar* pVar = pag->getBaseValVar(nodeId))
664 if (const ArgValVar* arg = SVFUtil::dyn_cast<ArgValVar>(pVar))
665 if (!(arg->getParent()->isDeclaration()))
666 return true;
667
668 if ((node->getInEdges().empty() && node->getOutEdges().empty()))
669 return false;
670 return node->isPointer();
671}
Class representing a function argument variable in the SVFIR.
const GEdgeSetTy & getOutEdges() const
const GEdgeSetTy & getInEdges() const
virtual bool isPointer() const
Check if this variable represents a pointer.

◆ 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()))
678 {
679 const ValVar* baseVar = pag->getBaseValVar(node->getId());
680 if(!SVFUtil::isa<DummyValVar, BlackHoleValVar>(baseVar))
682 }
683 }
684 return false;
685}
NodeID getId() const
Get ID.
Definition SVFValue.h:160
bool isArgOfUncalledFunction(const SVFVar *svfvar)
Definition SVFUtil.cpp:422

◆ pagFileName()

static std::string SVF::SVFIR::pagFileName ( )
inlinestatic

Definition at line 200 of file SVFIR.h.

201 {
202 return pagReadFromTxt;
203 }

◆ pagReadFromTXT()

static bool SVF::SVFIR::pagReadFromTXT ( )
inlinestatic

Definition at line 205 of file SVFIR.h.

206 {
207 return !pagReadFromTxt.empty();
208 }

◆ print()

void SVFIR::print ( )

Print SVFIR.

Print this SVFIR graph including its nodes and edges

Definition at line 557 of file SVFIR.cpp.

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

◆ releaseSVFIR()

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

Definition at line 122 of file SVFIR.h.

123 {
124 pag = nullptr;
125 }

◆ setCHG()

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

Set/Get CHG.

Definition at line 167 of file SVFIR.h.

168 {
169 chgraph = c;
170 }

◆ setICFG()

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

Set/Get ICFG.

Definition at line 157 of file SVFIR.h.

158 {
159 icfg = i;
160 }

◆ setModuleIdentifier()

void SVF::SVFIR::setModuleIdentifier ( const std::string &  moduleIdentifier)
inline

Definition at line 215 of file SVFIR.h.

216 {
218 }

◆ setPagFromTXT()

static void SVF::SVFIR::setPagFromTXT ( const std::string &  txt)
inlinestatic

Definition at line 210 of file SVFIR.h.

211 {
213 }

Friends And Related Symbol Documentation

◆ BVDataPTAImpl

Definition at line 48 of file SVFIR.h.

◆ ExternalPAG

friend class ExternalPAG
friend

Definition at line 45 of file SVFIR.h.

◆ PAGBuilderFromFile

Definition at line 46 of file SVFIR.h.

◆ SVFIRBuilder

Definition at line 44 of file SVFIR.h.

◆ TypeBasedHeapCloning

friend class TypeBasedHeapCloning
friend

Definition at line 47 of file SVFIR.h.

Member Data Documentation

◆ callGraph

CallGraph* SVF::SVFIR::callGraph
private

all the callsites of a program

Definition at line 97 of file SVFIR.h.

◆ callSiteArgsListMap

CSToArgsListMap SVF::SVFIR::callSiteArgsListMap
private

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

Definition at line 86 of file SVFIR.h.

◆ callSiteRetMap

CSToRetMap SVF::SVFIR::callSiteRetMap
private

Map a callsite to its callsite returns PAGNodes.

Definition at line 87 of file SVFIR.h.

◆ callSiteSet

CallSiteSet SVF::SVFIR::callSiteSet
private

Definition at line 96 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 93 of file SVFIR.h.

◆ chgraph

CommonCHGraph* SVF::SVFIR::chgraph
private

Definition at line 95 of file SVFIR.h.

◆ funArgsListMap

FunToArgsListMap SVF::SVFIR::funArgsListMap
private

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

Definition at line 85 of file SVFIR.h.

◆ funPtrToCallSitesMap

FunPtrToCallSitesMap SVF::SVFIR::funPtrToCallSitesMap
private

Map a function pointer to the callsites where it is used

Definition at line 90 of file SVFIR.h.

◆ funRetMap

FunToRetMap SVF::SVFIR::funRetMap
private

Map a function to its unique function return PAGNodes.

Definition at line 88 of file SVFIR.h.

◆ GepObjVarMap

NodeOffsetMap SVF::SVFIR::GepObjVarMap
private

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

Definition at line 81 of file SVFIR.h.

◆ GepValObjMap

GepValueVarMap SVF::SVFIR::GepValObjMap
private

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

Definition at line 79 of file SVFIR.h.

◆ globSVFStmtSet

SVFStmtSet SVF::SVFIR::globSVFStmtSet
private

Global PAGEdges without control flow information.

Definition at line 83 of file SVFIR.h.

◆ icfg

ICFG* SVF::SVFIR::icfg
private

Definition at line 94 of file SVFIR.h.

◆ icfgNode2PTASVFStmtsMap

ICFGNode2SVFStmtsMap SVF::SVFIR::icfgNode2PTASVFStmtsMap
private

Map an ICFGNode to its PointerAnalysis related SVFStmts.

Definition at line 78 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 77 of file SVFIR.h.

◆ indCallSiteToFunPtrMap

CallSiteToFunPtrMap SVF::SVFIR::indCallSiteToFunPtrMap
private

Map an indirect callsite to its function pointer.

Definition at line 89 of file SVFIR.h.

◆ memToFieldsMap

MemObjToFieldsMap SVF::SVFIR::memToFieldsMap
private

Map a mem object id to all its fields.

Definition at line 82 of file SVFIR.h.

◆ moduleIdentifier

std::string SVF::SVFIR::moduleIdentifier
private

Definition at line 102 of file SVFIR.h.

◆ pag

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

Callgraph with direct calls only; no change allowed after init and use callgraph in PointerAnalysis for indirect calls)

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

Definition at line 99 of file SVFIR.h.

◆ pagReadFromTxt

std::string SVFIR::pagReadFromTxt = ""
staticprivate

Definition at line 100 of file SVFIR.h.

◆ phiNodeMap

PHINodeMap SVF::SVFIR::phiNodeMap
private

A set of phi copy edges.

Definition at line 84 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 80 of file SVFIR.h.


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