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 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.
 
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 setModule (SVFModule *mod)
 Set/Get LLVM Module.
 
SVFModulegetModule ()
 
void setICFG (ICFG *i)
 Set/Get ICFG.
 
ICFGgetICFG () const
 
void setCHG (CommonCHGraph *c)
 Set/Get CHG.
 
CommonCHGraphgetCHG ()
 
void setCallGraph (CallGraph *c)
 Set/Get CG.
 
CallGraphgetCallGraph ()
 
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 SVFFunction *func) const
 Function has arguments list.
 
FunToArgsListMapgetFunArgsMap ()
 Get function arguments list.
 
const SVFVarListgetFunArgsList (const SVFFunction *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 SVFFunction *func) const
 Get function return list.
 
bool funHasRet (const SVFFunction *func) const
 
u32_t getFieldValNodeNum () const
 Node and edge statistics.
 
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.
 
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 MemObjgetObject (NodeID id) const
 
const BaseObjVargetBaseObject (NodeID id) const
 
const ValVargetBaseValVar (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.
 
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 MemObj *obj) const
 Get a field-insensitive obj SVFIR node according to a mem obj.
 
NodeID getFIObjVar (NodeID id) const
 
bool isBlkPtr (NodeID id) const
 Get black hole and constant id.
 
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.
 
const MemObjgetBaseObj (NodeID id) const
 
NodeBSgetAllFieldsObjVars (const MemObj *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 ()
 
SymbolTableInfogetSymbolInfo () const
 
bool isBuiltFromFile ()
 Whether this SVFIR built from a txt file.
 
const SVFStmtSetgetValueEdges (const SVFValue *V)
 Get all SVFIR Edges that corresponds to an LLVM value.
 
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.
 
NodeID getVarargNode (const SVFFunction *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
 
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.
 
void dump (std::string name)
 Dump SVFIR.
 
void view ()
 View graph from the debugger.
 
- 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.
 

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 SVFFunction *fun, const SVFVar *arg)
 Get/set method for function/callsite arguments and returns.
 
void addFunRet (const SVFFunction *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 (const SVFValue *val, NodeID i, const ICFGNode *icfgNode)
 add node into SVFIR
 
NodeID addFunValNode (const CallGraphNode *callGraphNode, NodeID i, const ICFGNode *icfgNode)
 
NodeID addConstantFPValNode (const SVFValue *curInst, double dval, const NodeID i, const ICFGNode *icfgNode)
 
NodeID addConstantIntValNode (const SVFValue *curInst, s64_t sval, u64_t zval, const NodeID i, const ICFGNode *icfgNode)
 
NodeID addConstantNullPtrValNode (const SVFValue *curInst, const NodeID i, const ICFGNode *icfgNode)
 
NodeID addGlobalValueValNode (const SVFValue *curInst, const NodeID i, const ICFGNode *icfgNode)
 
NodeID addConstantDataValNode (const SVFValue *curInst, const NodeID i, const ICFGNode *icfgNode)
 
NodeID addObjNode (const SVFValue *val, NodeID i)
 Add a memory obj node.
 
NodeID addHeapObjNode (const SVFValue *val, const SVFFunction *f, NodeID i)
 
NodeID addStackObjNode (const SVFValue *val, const SVFFunction *f, NodeID i)
 
NodeID addFunObjNode (const CallGraphNode *callGraphNode, NodeID id)
 
NodeID addConstantFPObjNode (const SVFValue *curInst, double dval, const NodeID i)
 
NodeID addConstantIntObjNode (const SVFValue *curInst, s64_t sval, u64_t zval, const NodeID i)
 
NodeID addConstantNullPtrObjNode (const SVFValue *curInst, const NodeID i)
 
NodeID addGlobalValueObjNode (const SVFValue *curInst, const NodeID i)
 
NodeID addConstantDataObjNode (const SVFValue *curInst, const NodeID i)
 
NodeID addRetNode (const CallGraphNode *callGraphNode, NodeID i)
 Add a unique return node for a procedure.
 
NodeID addVarargNode (const CallGraphNode *val, NodeID i)
 Add a unique vararg node for a procedure.
 
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.
 
NodeID addGepObjNode (const MemObj *obj, const APOffset &apOffset, const NodeID gepId)
 Add a field obj node, this method can only invoked by getGepObjVar.
 
NodeID addFIObjNode (const MemObj *obj)
 Add a field-insensitive node, this method can only invoked by getFIGepObjNode.
 
NodeID addDummyValNode (NodeID i)
 Add a dummy value/object node according to node ID (llvm value is null)
 
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.
 
NodeID addObjNode (const SVFValue *, SVFVar *node, NodeID i)
 Add a memory obj node.
 
NodeID addRetNode (const CallGraphNode *, SVFVar *node, NodeID i)
 Add a unique return node for a procedure.
 
NodeID addVarargNode (const SVFFunction *, SVFVar *node, NodeID i)
 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
 
SVFModulesvfModule
 
ICFGicfg
 SVF Module.
 
CommonCHGraphchgraph
 
CallSiteSet callSiteSet
 
CallGraphcallGraph
 all the callsites of a program
 

Static Private Attributes

static std::unique_ptr< SVFIRpag
 call graph
 

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
 
u32_t nodeNum
 total num of edge
 
- Protected Member Functions inherited from SVF::IRGraph
NodeID addNode (SVFVar *node, NodeID i)
 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)
 
void mapValueToEdge (const SVFValue *V, SVFStmt *edge)
 Map a value to a set of edges.
 
const MemObjgetMemObj (const SVFValue *val) const
 get MemObj according to LLVM value
 
- 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
 
ValueToEdgeMap valueToEdgeMap
 Map SVFValues (e.g., ICFGNodes) to all corresponding PAGEdges.
 
SymbolTableInfosymInfo
 
- 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. SymID and NodeID are equal here (same numbering).

Definition at line 44 of file SVFIR.h.

Member Typedef Documentation

◆ CallSiteSet

Definition at line 55 of file SVFIR.h.

◆ CallSiteToFunPtrMap

Definition at line 56 of file SVFIR.h.

◆ CSToArgsListMap

Definition at line 63 of file SVFIR.h.

◆ CSToRetMap

Definition at line 64 of file SVFIR.h.

◆ FunPtrToCallSitesMap

Definition at line 57 of file SVFIR.h.

◆ FunToArgsListMap

Definition at line 62 of file SVFIR.h.

◆ FunToPAGEdgeSetMap

Definition at line 66 of file SVFIR.h.

◆ FunToRetMap

Definition at line 65 of file SVFIR.h.

◆ GepValueVarMap

Definition at line 73 of file SVFIR.h.

◆ ICFGNode2SVFStmtsMap

Definition at line 67 of file SVFIR.h.

◆ MemObjToFieldsMap

Definition at line 58 of file SVFIR.h.

◆ NodeAccessPath

Definition at line 70 of file SVFIR.h.

◆ NodeAccessPathMap

Definition at line 72 of file SVFIR.h.

◆ NodeOffset

Definition at line 69 of file SVFIR.h.

◆ NodeOffsetMap

Definition at line 71 of file SVFIR.h.

◆ NodePairSetMap

Definition at line 76 of file SVFIR.h.

◆ NodeToNodeMap

Definition at line 68 of file SVFIR.h.

◆ PHINodeMap

Definition at line 61 of file SVFIR.h.

◆ SVFStmtList

Definition at line 59 of file SVFIR.h.

◆ SVFTypeLocSetsPair

Definition at line 74 of file SVFIR.h.

◆ SVFVarList

Definition at line 60 of file SVFIR.h.

◆ TypeLocSetsMap

Definition at line 75 of file SVFIR.h.

Constructor & Destructor Documentation

◆ SVFIR()

SVFIR::SVFIR ( bool  buildFromFile)
private

Constructor.

Definition at line 40 of file SVFIR.cpp.

40 : IRGraph(buildFromFile), svfModule(nullptr), icfg(nullptr), chgraph(nullptr)
41{
42}
CommonCHGraph * chgraph
Definition SVFIR.h:100
SVFModule * svfModule
Definition SVFIR.h:98
ICFG * icfg
SVF Module.
Definition SVFIR.h:99
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ ~SVFIR()

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

Destructor.

Definition at line 148 of file SVFIR.h.

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

Member Function Documentation

◆ addAddrStmt()

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

Add an edge into SVFIR.

Add Address edge

Definition at line 47 of file SVFIR.cpp.

48{
49 SVFVar* srcNode = getGNode(src);
50 SVFVar* dstNode = getGNode(dst);
52 return nullptr;
53 else
54 {
58 return addrPE;
59 }
60}
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: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:517

◆ addBinaryOPStmt()

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

Add Copy edge.

Add Compare edge

Definition at line 149 of file SVFIR.cpp.

150{
153 SVFVar* dstNode = getGNode(dst);
155 return nullptr;
156 else
157 {
158 std::vector<SVFVar*> opnds = {op1Node, op2Node};
162 return binaryOP;
163 }
164}
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 278 of file SVFIR.cpp.

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

◆ addBlackholeObjNode()

NodeID SVF::SVFIR::addBlackholeObjNode ( )
inlineprivate

Definition at line 734 of file SVFIR.h.

735 {
736 return addObjNode(
737 nullptr, new DummyObjVar(getBlackHoleNode(), getBlackHoleObj()),
739 }
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:615

◆ addBlackholePtrNode()

NodeID SVF::SVFIR::addBlackholePtrNode ( )
inlineprivate

Definition at line 746 of file SVFIR.h.

747 {
748 return addDummyValNode(getBlkPtr());
749 }
NodeID getBlkPtr() const
Definition IRGraph.h:169
NodeID addDummyValNode()
Definition SVFIR.h:496

◆ addBranchStmt()

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

Add BranchStmt.

Definition at line 187 of file SVFIR.cpp.

188{
190 SVFVar* condNode = getGNode(cond);
192 return nullptr;
193 else
194 {
198 return branch;
199 }
200}

◆ addCallPE()

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

Add Call edge.

Add Call edge

Definition at line 242 of file SVFIR.cpp.

243{
244 SVFVar* srcNode = getGNode(src);
245 SVFVar* dstNode = getGNode(dst);
247 return nullptr;
248 else
249 {
250 CallPE* callPE = new CallPE(srcNode, dstNode, cs,entry);
253 return callPE;
254 }
255}

◆ addCallSite()

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

Add callsites.

Definition at line 785 of file SVFIR.h.

786 {
787 callSiteSet.insert(call);
788 }
CallSiteSet callSiteSet
Definition SVFIR.h:101

◆ addCallSiteArgs()

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

Add callsite arguments.

Definition at line 546 of file SVFIR.h.

547 {
548 callBlockNode->addActualParms(arg);
549 callSiteArgsListMap[callBlockNode].push_back(arg);
550 }
CSToArgsListMap callSiteArgsListMap
Map a callsite to a list of all its actual parameters.
Definition SVFIR.h:90

◆ addCallSiteRets()

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

Add callsite returns.

Definition at line 552 of file SVFIR.h.

553 {
554 retBlockNode->addActualRet(arg);
556 }
CSToRetMap callSiteRetMap
Map a callsite to its callsite returns PAGNodes.
Definition SVFIR.h:91

◆ addCmpStmt()

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

Add Copy edge.

Add Compare edge

Definition at line 128 of file SVFIR.cpp.

129{
132 SVFVar* dstNode = getGNode(dst);
134 return nullptr;
135 else
136 {
137 std::vector<SVFVar*> opnds = {op1Node, op2Node};
138 CmpStmt* cmp = new CmpStmt(dstNode, opnds, predicate);
141 return cmp;
142 }
143}

◆ addConstantDataObjNode()

NodeID SVF::SVFIR::addConstantDataObjNode ( const SVFValue curInst,
const NodeID  i 
)
inlineprivate

Definition at line 688 of file SVFIR.h.

689 {
690 const MemObj* mem = getMemObj(curInst);
691 NodeID base = mem->getId();
692 memToFieldsMap[base].set(mem->getId());
693 ConstantDataObjVar* node = new ConstantDataObjVar(curInst, mem->getId(), mem);
694 return addObjNode(mem->getValue(), node, mem->getId());
695 }
const MemObj * getMemObj(const SVFValue *val) const
get MemObj according to LLVM value
Definition IRGraph.h:98
MemObjToFieldsMap memToFieldsMap
Map a mem object id to all its fields.
Definition SVFIR.h:86
u32_t NodeID
Definition GeneralType.h:55

◆ addConstantDataValNode()

NodeID SVF::SVFIR::addConstantDataValNode ( const SVFValue curInst,
const NodeID  i,
const ICFGNode icfgNode 
)
inlineprivate

Definition at line 607 of file SVFIR.h.

608 {
609 SVFVar* node = new ConstantDataValVar(curInst, i, icfgNode);
610 return addNode(node, i);
611 }
NodeID addNode(SVFVar *node, NodeID i)
Add a node into the graph.
Definition IRGraph.h:68

◆ addConstantFPObjNode()

NodeID SVF::SVFIR::addConstantFPObjNode ( const SVFValue curInst,
double  dval,
const NodeID  i 
)
inlineprivate

Definition at line 649 of file SVFIR.h.

650 {
651 const MemObj* mem = getMemObj(curInst);
652 NodeID base = mem->getId();
653 memToFieldsMap[base].set(mem->getId());
654 ConstantFPObjVar* node = new ConstantFPObjVar(curInst, dval, mem->getId(), mem);
655 return addObjNode(curInst, node, mem->getId());
656 }

◆ addConstantFPValNode()

NodeID SVF::SVFIR::addConstantFPValNode ( const SVFValue curInst,
double  dval,
const NodeID  i,
const ICFGNode icfgNode 
)
inlineprivate

Definition at line 581 of file SVFIR.h.

583 {
584 SVFVar* node = new ConstantFPValVar(curInst, dval, i, icfgNode);
585 return addNode(node, i);
586 }

◆ addConstantIntObjNode()

NodeID SVF::SVFIR::addConstantIntObjNode ( const SVFValue curInst,
s64_t  sval,
u64_t  zval,
const NodeID  i 
)
inlineprivate

Definition at line 659 of file SVFIR.h.

660 {
661 const MemObj* mem = getMemObj(curInst);
662 NodeID base = mem->getId();
663 memToFieldsMap[base].set(mem->getId());
664 ConstantIntObjVar* node =
665 new ConstantIntObjVar(curInst, sval, zval, mem->getId(), mem);
666 return addObjNode(curInst, node, mem->getId());
667 }

◆ addConstantIntValNode()

NodeID SVF::SVFIR::addConstantIntValNode ( const SVFValue curInst,
s64_t  sval,
u64_t  zval,
const NodeID  i,
const ICFGNode icfgNode 
)
inlineprivate

Definition at line 588 of file SVFIR.h.

590 {
591 SVFVar* node = new ConstantIntValVar(curInst, sval, zval, i, icfgNode);
592 return addNode(node, i);
593 }

◆ addConstantNullPtrObjNode()

NodeID SVF::SVFIR::addConstantNullPtrObjNode ( const SVFValue curInst,
const NodeID  i 
)
inlineprivate

Definition at line 670 of file SVFIR.h.

671 {
672 const MemObj* mem = getMemObj(curInst);
673 NodeID base = mem->getId();
674 memToFieldsMap[base].set(mem->getId());
675 ConstantNullPtrObjVar* node = new ConstantNullPtrObjVar(curInst, mem->getId(), mem);
676 return addObjNode(mem->getValue(), node, mem->getId());
677 }

◆ addConstantNullPtrValNode()

NodeID SVF::SVFIR::addConstantNullPtrValNode ( const SVFValue curInst,
const NodeID  i,
const ICFGNode icfgNode 
)
inlineprivate

Definition at line 595 of file SVFIR.h.

596 {
597 SVFVar* node = new ConstantNullPtrValVar(curInst, i, icfgNode);
598 return addNode(node, i);
599 }

◆ addConstantObjNode()

NodeID SVF::SVFIR::addConstantObjNode ( )
inlineprivate

Definition at line 740 of file SVFIR.h.

741 {
742 return addObjNode(nullptr,
743 new DummyObjVar(getConstantNode(), getConstantObj()),
745 }
const MemObj * getConstantObj() const
Definition IRGraph.h:181
NodeID getConstantNode() const
Definition IRGraph.h:165

◆ addCopyStmt()

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

Add Copy edge.

Add Copy edge

Definition at line 65 of file SVFIR.cpp.

66{
67 SVFVar* srcNode = getGNode(src);
68 SVFVar* dstNode = getGNode(dst);
70 return nullptr;
71 else
72 {
76 return copyPE;
77 }
78}
newitem type
Definition cJSON.cpp:2739

◆ addDummyMemObj()

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

Definition at line 730 of file SVFIR.h.

731 {
733 }
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 500 of file SVFIR.h.

501 {
502 return addDummyObjNode(NodeIDAllocator::get()->allocateObjectId(), type);
503 }
static NodeIDAllocator * get(void)
Return (singleton) allocator.
NodeID addDummyObjNode(const SVFType *type)
Definition SVFIR.h:500

◆ addDummyObjNode() [2/2]

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

Definition at line 725 of file SVFIR.h.

726 {
727 const MemObj* mem = addDummyMemObj(i, type);
728 return addObjNode(nullptr, new DummyObjVar(i,mem), i);
729 }
const MemObj * addDummyMemObj(NodeID i, const SVFType *type)
Definition SVFIR.h:730

◆ addDummyValNode() [1/2]

NodeID SVF::SVFIR::addDummyValNode ( )
inline

Definition at line 496 of file SVFIR.h.

497 {
498 return addDummyValNode(NodeIDAllocator::get()->allocateValueId());
499 }

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

722 {
723 return addValNode(nullptr, new DummyValVar(i), i);
724 }
NodeID addValNode(const SVFValue *val, NodeID i, const ICFGNode *icfgNode)
add node into SVFIR
Definition SVFIR.h:569

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

467{
468 //assert(findPAGNode(i) == false && "this node should not be created before");
469 NodeID base = obj->getId();
470 memToFieldsMap[base].set(obj->getId());
471 BaseObjVar*node = new BaseObjVar(obj->getValue(), obj->getId(), obj);
472 return addObjNode(obj->getValue(), node, obj->getId());
473}

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

533 {
534 FunEntryICFGNode* funEntryBlockNode = icfg->getFunEntryICFGNode(fun);
536 funArgsListMap[fun].push_back(arg);
537 }
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:89

◆ addFunObjNode()

NodeID SVFIR::addFunObjNode ( const CallGraphNode callGraphNode,
NodeID  id 
)
private

Definition at line 475 of file SVFIR.cpp.

476{
477 const MemObj* mem = getMemObj(callGraphNode->getFunction());
478 assert(mem->getId() == id && "not same object id?");
479 //assert(findPAGNode(i) == false && "this node should not be created before");
480 NodeID base = mem->getId();
481 memToFieldsMap[base].set(mem->getId());
482 FunObjVar*node = new FunObjVar(callGraphNode, mem->getId(), mem);
483 return addObjNode(mem->getValue(), node, mem->getId());
484}
const SVFFunction * getFunction() const
Get function of this call node.
Definition CallGraph.h:131
SymID getId() const
Get the memory object id.
const SVFValue * getValue() const
Get the reference value to this object.

◆ addFunRet()

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

Add function returns.

Definition at line 539 of file SVFIR.h.

540 {
541 FunExitICFGNode* funExitBlockNode = icfg->getFunExitICFGNode(fun);
543 funRetMap[fun] = ret;
544 }
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:92

◆ addFunValNode()

NodeID SVF::SVFIR::addFunValNode ( const CallGraphNode callGraphNode,
NodeID  i,
const ICFGNode icfgNode 
)
inlineprivate

Definition at line 575 of file SVFIR.h.

576 {
577 FunValVar* node = new FunValVar(callGraphNode, i, icfgNode);
578 return addValNode(nullptr, node, i);
579 }

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

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

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

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

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

388{
389 NodeID base = getValueNode(gepVal);
390 //assert(findPAGNode(i) == false && "this node should not be created before");
391 assert(0==GepValObjMap[curInst].count(std::make_pair(base, ap))
392 && "this node should not be created before");
393 GepValObjMap[curInst][std::make_pair(base, ap)] = i;
394 GepValVar *node = new GepValVar(base, gepVal, i, ap, type);
395 return addValNode(gepVal, node, i);
396}
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:83

◆ addGlobalPAGEdge()

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

Add global PAGEdges (not in a procedure)

Definition at line 780 of file SVFIR.h.

781 {
782 globSVFStmtSet.insert(edge);
783 }
SVFStmtSet globSVFStmtSet
Global PAGEdges without control flow information.
Definition SVFIR.h:87

◆ addGlobalValueObjNode()

NodeID SVF::SVFIR::addGlobalValueObjNode ( const SVFValue curInst,
const NodeID  i 
)
inlineprivate

Definition at line 679 of file SVFIR.h.

680 {
681 const MemObj* mem = getMemObj(curInst);
682 NodeID base = mem->getId();
683 memToFieldsMap[base].set(mem->getId());
684 GlobalObjVar* node = new GlobalObjVar(curInst, mem->getId(), mem);
685 return addObjNode(mem->getValue(), node, mem->getId());
686 }

◆ addGlobalValueValNode()

NodeID SVF::SVFIR::addGlobalValueValNode ( const SVFValue curInst,
const NodeID  i,
const ICFGNode icfgNode 
)
inlineprivate

Definition at line 601 of file SVFIR.h.

602 {
603 SVFVar* node = new GlobalValVar(curInst, i, icfgNode);
604 return addNode(node, i);
605 }

◆ addHeapObjNode()

NodeID SVF::SVFIR::addHeapObjNode ( const SVFValue val,
const SVFFunction f,
NodeID  i 
)
inlineprivate

Creates and adds a heap object node to the SVFIR

Definition at line 625 of file SVFIR.h.

626 {
627 const MemObj* mem = getMemObj(val);
628 assert(mem->getId() == i && "not same object id?");
629 memToFieldsMap[i].set(i);
630 HeapObjVar *node = new HeapObjVar(f, val->getType(), i, mem);
631 return addObjNode(val, node, i);
632 }

◆ addIndirectCallsites()

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

Add indirect callsites.

Definition at line 558 of file SVFIR.h.

559 {
560 bool added = indCallSiteToFunPtrMap.emplace(cs, funPtr).second;
561 (void) added;
562 funPtrToCallSitesMap[funPtr].insert(cs);
563 assert(added && "adding the same indirect callsite twice?");
564 }
CallSiteToFunPtrMap indCallSiteToFunPtrMap
Map an indirect callsite to its function pointer.
Definition SVFIR.h:93
FunPtrToCallSitesMap funPtrToCallSitesMap
Definition SVFIR.h:94

◆ addLoadStmt()

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

Add Load edge.

Add Load edge

Definition at line 205 of file SVFIR.cpp.

206{
207 SVFVar* srcNode = getGNode(src);
208 SVFVar* dstNode = getGNode(dst);
210 return nullptr;
211 else
212 {
216 return loadPE;
217 }
218}

◆ addNormalGepStmt()

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

Add Offset(Gep) edge.

Add normal (Gep) edge

Definition at line 347 of file SVFIR.cpp.

348{
349 SVFVar* baseNode = getGNode(src);
350 SVFVar* dstNode = getGNode(dst);
352 return nullptr;
353 else
354 {
355 GepStmt* gepPE = new GepStmt(baseNode, dstNode, ap);
358 return gepPE;
359 }
360}

◆ addObjNode() [1/2]

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

Add a memory obj node.

Definition at line 761 of file SVFIR.h.

762 {
763 assert(hasGNode(i) == false &&
764 "This NodeID clashes here. Please check NodeIDAllocator. Switch "
765 "Strategy::DBUG to SEQ or DENSE");
766 return addNode(node, i);
767 }
bool hasGNode(NodeID id) const
Has a node.

◆ addObjNode() [2/2]

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

Add a memory obj node.

Definition at line 615 of file SVFIR.h.

616 {
617 const MemObj* mem = getMemObj(val);
618 assert(mem->getId() == i && "not same object id?");
619 return addFIObjNode(mem);
620 }
NodeID addFIObjNode(const MemObj *obj)
Add a field-insensitive node, this method can only invoked by getFIGepObjNode.
Definition SVFIR.cpp:466

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

84{
86 SVFVar* resNode = getGNode(res);
87 PHINodeMap::iterator it = phiNodeMap.find(resNode);
88 if(it == phiNodeMap.end())
89 {
90 PhiStmt* phi = new PhiStmt(resNode, {opNode}, {pred});
94 return phi;
95 }
96 else
97 {
98 it->second->addOpVar(opNode,pred);
100 return nullptr;
101 }
102}
PHINodeMap phiNodeMap
A set of phi copy edges.
Definition SVFIR.h:88

◆ addRetNode() [1/2]

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

Add a unique return node for a procedure.

Definition at line 769 of file SVFIR.h.

770 {
771 return addNode(node,i);
772 }

◆ addRetNode() [2/2]

NodeID SVF::SVFIR::addRetNode ( const CallGraphNode callGraphNode,
NodeID  i 
)
inlineprivate

Add a unique return node for a procedure.

Definition at line 698 of file SVFIR.h.

699 {
700 SVFVar *node = new RetPN(callGraphNode,i);
701 return addRetNode(callGraphNode, node, i);
702 }
NodeID addRetNode(const CallGraphNode *callGraphNode, NodeID i)
Add a unique return node for a procedure.
Definition SVFIR.h:698

◆ addRetPE()

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

Add Return edge.

Add Return edge

Definition at line 260 of file SVFIR.cpp.

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

◆ addSelectStmt()

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

Add SelectStmt.

Add Phi statement

Definition at line 107 of file SVFIR.cpp.

108{
111 SVFVar* dstNode = getGNode(res);
112 SVFVar* condNode = getGNode(cond);
114 return nullptr;
115 else
116 {
117 std::vector<SVFVar*> opnds = {op1Node, op2Node};
121 return select;
122 }
123}

◆ addStackObjNode()

NodeID SVF::SVFIR::addStackObjNode ( const SVFValue val,
const SVFFunction f,
NodeID  i 
)
inlineprivate

Creates and adds a stack object node to the SVFIR

Definition at line 637 of file SVFIR.h.

638 {
639 const MemObj* mem = getMemObj(val);
640 assert(mem->getId() == i && "not same object id?");
641 memToFieldsMap[i].set(i);
642 StackObjVar *node = new StackObjVar(f, val->getType(), i, mem);
643 return addObjNode(val, node, i);
644 }

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

225{
226 SVFVar* srcNode = getGNode(src);
227 SVFVar* dstNode = getGNode(dst);
229 return nullptr;
230 else
231 {
232 StoreStmt* storePE = new StoreStmt(srcNode, dstNode, curVal);
235 return storePE;
236 }
237}

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

290{
291 SVFVar* srcNode = getGNode(src);
292 SVFVar* dstNode = getGNode(dst);
294 return nullptr;
295 else
296 {
297 TDForkPE* forkPE = new TDForkPE(srcNode, dstNode, cs, entry);
300 return forkPE;
301 }
302}

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

308{
309 SVFVar* srcNode = getGNode(src);
310 SVFVar* dstNode = getGNode(dst);
312 return nullptr;
313 else
314 {
315 TDJoinPE* joinPE = new TDJoinPE(srcNode, dstNode, cs, exit);
318 return joinPE;
319 }
320}

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

518 {
519 bool added = KindToSVFStmtSetMap[edge->getEdgeKind()].insert(edge).second;
520 (void)added; // Suppress warning of unused variable under release build
521 assert(added && "duplicated edge, not added!!!");
523 if (edge->isPTAEdge() || (SVFUtil::isa<CopyStmt>(edge) && SVFUtil::cast<CopyStmt>(edge)->isInt2Ptr()))
524 {
526 KindToPTASVFStmtSetMap[edge->getEdgeKind()].insert(edge);
527 }
528 }
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 232 of file SVFIR.h.

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

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

241 {
243 }
TypeLocSetsMap typeLocSetsMap
Map an arg to its base SVFType* and all its field location sets.
Definition SVFIR.h:84

◆ addUnaryOPStmt()

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

Add Unary edge.

Add Unary edge

Definition at line 169 of file SVFIR.cpp.

170{
171 SVFVar* srcNode = getGNode(src);
172 SVFVar* dstNode = getGNode(dst);
174 return nullptr;
175 else
176 {
180 return unaryOP;
181 }
182}

◆ addValNode() [1/2]

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

Add a value (pointer) node.

Definition at line 753 of file SVFIR.h.

754 {
755 assert(hasGNode(i) == false &&
756 "This NodeID clashes here. Please check NodeIDAllocator. Switch "
757 "Strategy::DBUG to SEQ or DENSE");
758 return addNode(node, i);
759 }

◆ addValNode() [2/2]

NodeID SVF::SVFIR::addValNode ( const SVFValue val,
NodeID  i,
const ICFGNode icfgNode 
)
inlineprivate

add node into SVFIR

Add a value (pointer) node

Definition at line 569 of file SVFIR.h.

570 {
571 SVFVar *node = new ValVar(val,i, ValVar::ValNode, icfgNode);
572 return addValNode(val, node, i);
573 }

◆ addVarargNode() [1/2]

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

Add a unique vararg node for a procedure.

Definition at line 704 of file SVFIR.h.

705 {
706 SVFVar *node = new VarArgPN(val,i);
707 return addNode(node,i);
708 }

◆ addVarargNode() [2/2]

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

Add a unique vararg node for a procedure.

Definition at line 774 of file SVFIR.h.

775 {
776 return addNode(node,i);
777 }

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

367{
368 SVFVar* baseNode = getGNode(src);
369 SVFVar* dstNode = getGNode(dst);
371 return nullptr;
372 else
373 {
374 GepStmt* gepPE = new GepStmt(baseNode, dstNode, ap, true);
377 return gepPE;
378 }
379}

◆ callsiteHasRet()

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

Definition at line 311 of file SVFIR.h.

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

◆ destroy()

void SVFIR::destroy ( )
private

Clean up memory.

Clean up memory

Definition at line 551 of file SVFIR.cpp.

552{
553 delete icfg;
554 icfg = nullptr;
555 delete chgraph;
556 chgraph = nullptr;
558 svfModule = nullptr;
559 delete callGraph;
560 callGraph = nullptr;
561}
CallGraph * callGraph
all the callsites of a program
Definition SVFIR.h:102
static void releaseSVFModule()
Definition SVFModule.cpp:69

◆ funHasRet()

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

Definition at line 327 of file SVFIR.h.

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

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

490{
491 NodeID base = obj->getId();
492 return memToFieldsMap[base];
493}

◆ getAllFieldsObjVars() [2/2]

NodeBS & SVFIR::getAllFieldsObjVars ( NodeID  id)

Get all fields object nodes of an object

Definition at line 498 of file SVFIR.cpp.

499{
500 const SVFVar* node = pag->getGNode(id);
501 assert(SVFUtil::isa<ObjVar>(node) && "need an object node");
502 const ObjVar* obj = SVFUtil::cast<ObjVar>(node);
503 return getAllFieldsObjVars(obj->getMemObj());
504}
NodeBS & getAllFieldsObjVars(const MemObj *obj)
Get all fields of an object.
Definition SVFIR.cpp:489

◆ getAllValidPtrs()

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

Return valid pointers.

Definition at line 140 of file SVFIR.h.

141 {
142 return candidatePointers;
143 }
OrderedNodeSet candidatePointers
Definition SVFIR.h:97

◆ getBaseObj()

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

Definition at line 481 of file SVFIR.h.

482 {
483 const SVFVar* node = pag->getGNode(id);
484 assert(SVFUtil::isa<ObjVar>(node) && "need an object node");
485 const ObjVar* obj = SVFUtil::cast<ObjVar>(node);
486 return obj->getMemObj();
487 }

◆ getBaseObject()

const BaseObjVar * SVF::SVFIR::getBaseObject ( NodeID  id) const
inline

Definition at line 405 of file SVFIR.h.

406 {
407 const SVFVar* node = getGNode(id);
408 if(const GepObjVar* gepObjVar = SVFUtil::dyn_cast<GepObjVar>(node))
409 return SVFUtil::dyn_cast<BaseObjVar>(
410 getGNode(gepObjVar->getBaseNode()));
411 else
412 return SVFUtil::dyn_cast<BaseObjVar>(node);
413 }

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

478 {
479 return getBaseObj(id)->getId();
480 }
const MemObj * getBaseObj(NodeID id) const
Definition SVFIR.h:481

◆ getBaseValVar()

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

Definition at line 415 of file SVFIR.h.

416 {
417 const SVFVar* node = getGNode(id);
418 if(const GepValVar* gepVar = SVFUtil::dyn_cast<GepValVar>(node))
419 return SVFUtil::dyn_cast<ValVar>(
420 getGNode(gepVar->getBaseNode()));
421 else
422 return SVFUtil::dyn_cast<ValVar>(node);
423 }

◆ getCallGraph()

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

Definition at line 193 of file SVFIR.h.

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

◆ getCallSiteArgsList()

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

Get callsite argument list.

Definition at line 293 of file SVFIR.h.

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

◆ getCallSiteArgsMap()

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

Get callsite argument list.

Definition at line 288 of file SVFIR.h.

289 {
290 return callSiteArgsListMap;
291 }

◆ getCallSiteRet()

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

Get callsite return.

Definition at line 305 of file SVFIR.h.

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

◆ getCallSiteRets()

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

Get callsite return.

Definition at line 300 of file SVFIR.h.

301 {
302 return callSiteRetMap;
303 }

◆ getCallSiteSet()

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

Get all callsites.

Definition at line 255 of file SVFIR.h.

256 {
257 return callSiteSet;
258 }

◆ getCHG()

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

Definition at line 182 of file SVFIR.h.

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

◆ getFieldObjNodeNum()

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

Definition at line 339 of file SVFIR.h.

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

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

512{
513 const SVFVar* node = pag->getGNode(id);
514 assert(SVFUtil::isa<ObjVar>(node) && "need an object node");
515 const MemObj* mem = SVFUtil::cast<ObjVar>(node)->getMemObj();
516 if(mem->isFieldInsensitive())
517 {
518 NodeBS bs;
519 bs.set(getFIObjVar(mem));
520 return bs;
521 }
522 else
523 return getAllFieldsObjVars(mem);
524}
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:437
void set(unsigned Idx)

◆ getFieldValNodeNum()

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

Node and edge statistics.

Definition at line 335 of file SVFIR.h.

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

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

438 {
439 return obj->getId();
440 }

◆ getFIObjVar() [2/2]

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

Definition at line 441 of file SVFIR.h.

442 {
443 return getBaseObjVar(id);
444 }
NodeID getBaseObjVar(NodeID id) const
Base and Offset methods for Value and Object node.
Definition SVFIR.h:477

◆ getFunArgsList()

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

Get function arguments list.

Definition at line 276 of file SVFIR.h.

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

◆ getFunArgsMap()

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

Get function arguments list.

Definition at line 271 of file SVFIR.h.

272 {
273 return funArgsListMap;
274 }

◆ getFunPtr()

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

Definition at line 355 of file SVFIR.h.

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

◆ getFunRet()

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

Get function return list.

Definition at line 321 of file SVFIR.h.

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

◆ getFunRets()

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

Get function return list.

Definition at line 316 of file SVFIR.h.

317 {
318 return funRetMap;
319 }

◆ getGepObjNodeMap()

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

Return GepObjVarMap.

Definition at line 135 of file SVFIR.h.

136 {
137 return GepObjVarMap;
138 }

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

424{
425 NodeID base = obj->getId();
426
428 if (obj->isFieldInsensitive())
429 return getFIObjVar(obj);
430
431 APOffset newLS = pag->getSymbolInfo()->getModulusOffset(obj, apOffset);
432
433 // Base and first field are the same memory location.
434 if (Options::FirstFieldEqBase() && newLS == 0) return base;
435
436 NodeOffsetMap::iterator iter = GepObjVarMap.find(std::make_pair(base, newLS));
437 if (iter == GepObjVarMap.end())
438 {
440 return addGepObjNode(obj, newLS,gepId);
441 }
442 else
443 return iter->second;
444
445}
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:450
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 401 of file SVFIR.cpp.

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

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

530{
531 GepValueVarMap::const_iterator iter = GepValObjMap.find(curInst);
532 if(iter==GepValObjMap.end())
533 {
534 return UINT_MAX;
535 }
536 else
537 {
538 NodeAccessPathMap::const_iterator lit =
539 iter->second.find(std::make_pair(base, ap));
540 if (lit == iter->second.end())
541 return UINT_MAX;
542 else
543 return lit->second;
544 }
545}

◆ getGlobalSVFStmtSet()

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

Get global PAGEdges (not in a procedure)

Definition at line 250 of file SVFIR.h.

251 {
252 return globSVFStmtSet;
253 }

◆ getICFG()

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

Definition at line 172 of file SVFIR.h.

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

◆ getIndCallSites()

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

Definition at line 361 of file SVFIR.h.

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

◆ getIndirectCallsites()

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

Add/get indirect callsites.

Definition at line 351 of file SVFIR.h.

352 {
354 }

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

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

◆ getIntraPAGEdge() [2/2]

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

Definition at line 382 of file SVFIR.h.

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

◆ getMemToFieldsMap()

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

Return memToFieldsMap.

Definition at line 130 of file SVFIR.h.

131 {
132 return memToFieldsMap;
133 }

◆ getModule()

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

Definition at line 162 of file SVFIR.h.

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

◆ getObject() [1/2]

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

Definition at line 425 of file SVFIR.h.

426 {
427 return node->getMemObj();
428 }

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

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

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

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

◆ getPTASVFStmtList()

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

Given an instruction, get all its PTA PAGEdges.

Definition at line 227 of file SVFIR.h.

228 {
229 return icfgNode2PTASVFStmtsMap[inst];
230 }

◆ getPTASVFStmtSet()

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

Get PTA edges set according to its kind.

Definition at line 207 of file SVFIR.h.

208 {
209 return KindToPTASVFStmtSetMap[kind];
210 }

◆ getSVFStmtList()

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

Given an instruction, get all its PAGEdges.

Definition at line 222 of file SVFIR.h.

223 {
224 return icfgNode2SVFStmtsMap[inst];
225 }

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

203 {
204 return KindToSVFStmtSetMap[kind];
205 }

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

246 {
247 return typeLocSetsMap[argId];
248 }

◆ handleBlackHole()

void SVFIR::handleBlackHole ( bool  b)
static

SVFIR build configurations.

Whether to handle blackhole edge

Definition at line 706 of file SVFIR.cpp.

707{
709}
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 283 of file SVFIR.h.

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

◆ hasFunArgsList()

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

Function has arguments list.

Definition at line 266 of file SVFIR.h.

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

◆ hasPTASVFStmtList()

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

Definition at line 216 of file SVFIR.h.

217 {
218 return icfgNode2PTASVFStmtsMap.find(inst) !=
220 }

◆ hasSVFStmtList()

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

Whether this instruction has SVFIR Edge.

Definition at line 212 of file SVFIR.h.

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

◆ initialiseCandidatePointers()

void SVFIR::initialiseCandidatePointers ( )

Initialize candidate pointers.

Definition at line 651 of file SVFIR.cpp.

652{
653 // collect candidate pointers for demand-driven analysis
654 for (iterator nIter = begin(); nIter != end(); ++nIter)
655 {
656 NodeID nodeId = nIter->first;
657 // do not compute points-to for isolated node
658 if (isValidPointer(nodeId) == false)
659 continue;
661 }
662}
IDToNodeMapTy::iterator iterator
Node Iterators.
bool isValidPointer(NodeID nodeId) const
Whether a node is a valid pointer.
Definition SVFIR.cpp:667

◆ isBlkObj()

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

Definition at line 461 of file SVFIR.h.

462 {
463 return SymbolTableInfo::isBlkObj(id);
464 }
static bool isBlkObj(NodeID id)

◆ isBlkObjOrConstantObj()

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

Definition at line 457 of file SVFIR.h.

458 {
459 return (isBlkObj(id) || isConstantObj(id));
460 }
bool isBlkObj(NodeID id) const
Definition SVFIR.h:461
bool isConstantObj(NodeID id) const
Definition SVFIR.h:465

◆ isBlkPtr()

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

Get black hole and constant id.

Definition at line 449 of file SVFIR.h.

450 {
451 return (SymbolTableInfo::isBlkPtr(id));
452 }
static bool isBlkPtr(NodeID id)
special value

◆ isConstantObj()

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

Definition at line 465 of file SVFIR.h.

466 {
467 const MemObj* obj = getObject(id);
468 assert(obj && "not an object node?");
470 obj->isConstDataOrConstGlobal();
471 }
static bool isConstantObj(NodeID id)

◆ isFunPtr()

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

Definition at line 371 of file SVFIR.h.

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

◆ isIndirectCallSites()

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

Definition at line 367 of file SVFIR.h.

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

◆ isNullPtr()

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

Definition at line 453 of file SVFIR.h.

454 {
455 return (SymbolTableInfo::isNullPtr(id));
456 }
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 260 of file SVFIR.h.

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

◆ isValidPointer()

bool SVFIR::isValidPointer ( NodeID  nodeId) const

Whether a node is a valid pointer.

Definition at line 667 of file SVFIR.cpp.

668{
669 SVFVar* node = pag->getGNode(nodeId);
670
671 if (node->hasValue() && node->isPointer())
672 {
673 if(const SVFArgument* arg = SVFUtil::dyn_cast<SVFArgument>(node->getValue()))
674 {
675 if (!(arg->getParent()->isDeclaration()))
676 return true;
677 }
678 }
679
680 if ((node->getInEdges().empty() && node->getOutEdges().empty()))
681 return false;
682 return node->isPointer();
683}
const GEdgeSetTy & getOutEdges() const
const GEdgeSetTy & getInEdges() const
const SVFValue * getValue() const
Get/has methods of the components.
bool hasValue() const
virtual bool isPointer() const
Whether it is a pointer.

◆ isValidTopLevelPtr()

bool SVFIR::isValidTopLevelPtr ( const SVFVar node)

Definition at line 685 of file SVFIR.cpp.

686{
687 if (SVFUtil::isa<ValVar>(node))
688 {
689 if (isValidPointer(node->getId()))
690 {
691 // TODO: after svf value is removed, we use type to determine top level ptr
692 if (SVFUtil::isa<RetPN, VarArgPN, FunValVar, HeapObjVar, StackObjVar>(node))
693 {
694 return true;
695 }
696 else if(node->hasValue())
698 }
699 }
700 return false;
701}
NodeID getId() const
Get ID.
bool isArgOfUncalledFunction(const SVFValue *svfval)
Return true if this argument belongs to an uncalled function.
Definition SVFUtil.h:346

◆ print()

void SVFIR::print ( )

Print SVFIR.

Print this SVFIR graph including its nodes and edges

Definition at line 566 of file SVFIR.cpp.

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

◆ releaseSVFIR()

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

Definition at line 124 of file SVFIR.h.

125 {
126 pag = nullptr;
127 }

◆ setCallGraph()

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

Set/Get CG.

Definition at line 189 of file SVFIR.h.

190 {
191 callGraph = c;
192 }

◆ setCHG()

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

Set/Get CHG.

Definition at line 178 of file SVFIR.h.

179 {
180 chgraph = c;
181 }

◆ setICFG()

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

Set/Get ICFG.

Definition at line 168 of file SVFIR.h.

169 {
170 icfg = i;
171 }

◆ setModule()

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

Set/Get LLVM Module.

Definition at line 158 of file SVFIR.h.

159 {
160 svfModule = mod;
161 }

Friends And Related Symbol Documentation

◆ BVDataPTAImpl

Definition at line 52 of file SVFIR.h.

◆ ExternalPAG

friend class ExternalPAG
friend

Definition at line 47 of file SVFIR.h.

◆ PAGBuilderFromFile

Definition at line 48 of file SVFIR.h.

◆ SVFIRBuilder

Definition at line 46 of file SVFIR.h.

◆ SVFIRReader

Definition at line 51 of file SVFIR.h.

◆ SVFIRWriter

Definition at line 50 of file SVFIR.h.

◆ TypeBasedHeapCloning

friend class TypeBasedHeapCloning
friend

Definition at line 49 of file SVFIR.h.

Member Data Documentation

◆ callGraph

CallGraph* SVF::SVFIR::callGraph
private

all the callsites of a program

Definition at line 102 of file SVFIR.h.

◆ callSiteArgsListMap

CSToArgsListMap SVF::SVFIR::callSiteArgsListMap
private

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

Definition at line 90 of file SVFIR.h.

◆ callSiteRetMap

CSToRetMap SVF::SVFIR::callSiteRetMap
private

Map a callsite to its callsite returns PAGNodes.

Definition at line 91 of file SVFIR.h.

◆ callSiteSet

CallSiteSet SVF::SVFIR::callSiteSet
private

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

◆ chgraph

CommonCHGraph* SVF::SVFIR::chgraph
private

Definition at line 100 of file SVFIR.h.

◆ funArgsListMap

FunToArgsListMap SVF::SVFIR::funArgsListMap
private

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

Definition at line 89 of file SVFIR.h.

◆ funPtrToCallSitesMap

FunPtrToCallSitesMap SVF::SVFIR::funPtrToCallSitesMap
private

Map a function pointer to the callsites where it is used

Definition at line 94 of file SVFIR.h.

◆ funRetMap

FunToRetMap SVF::SVFIR::funRetMap
private

Map a function to its unique function return PAGNodes.

Definition at line 92 of file SVFIR.h.

◆ GepObjVarMap

NodeOffsetMap SVF::SVFIR::GepObjVarMap
private

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

Definition at line 85 of file SVFIR.h.

◆ GepValObjMap

GepValueVarMap SVF::SVFIR::GepValObjMap
private

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

Definition at line 83 of file SVFIR.h.

◆ globSVFStmtSet

SVFStmtSet SVF::SVFIR::globSVFStmtSet
private

Global PAGEdges without control flow information.

Definition at line 87 of file SVFIR.h.

◆ icfg

ICFG* SVF::SVFIR::icfg
private

SVF Module.

Definition at line 99 of file SVFIR.h.

◆ icfgNode2PTASVFStmtsMap

ICFGNode2SVFStmtsMap SVF::SVFIR::icfgNode2PTASVFStmtsMap
private

Map an ICFGNode to its PointerAnalysis related SVFStmts.

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

◆ indCallSiteToFunPtrMap

CallSiteToFunPtrMap SVF::SVFIR::indCallSiteToFunPtrMap
private

Map an indirect callsite to its function pointer.

Definition at line 93 of file SVFIR.h.

◆ memToFieldsMap

MemObjToFieldsMap SVF::SVFIR::memToFieldsMap
private

Map a mem object id to all its fields.

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

◆ phiNodeMap

PHINodeMap SVF::SVFIR::phiNodeMap
private

A set of phi copy edges.

Definition at line 88 of file SVFIR.h.

◆ svfModule

SVFModule* SVF::SVFIR::svfModule
private

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


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