30#ifndef INCLUDE_SVFIR_H_
31#define INCLUDE_SVFIR_H_
104 static std::unique_ptr<SVFIR>
pag;
234 edge->setICFGNode(inst);
236 if (
edge->isPTAEdge())
323 FunToRetMap::const_iterator
it =
funRetMap.find(func);
386 SVFStmt::SVFStmtSetTy::const_iterator
it =
edgeSet.find(&
edge);
399 if (
const ObjVar*
objPN = SVFUtil::dyn_cast<ObjVar>(node))
409 return SVFUtil::dyn_cast<BaseObjVar>(
412 return SVFUtil::dyn_cast<BaseObjVar>(node);
419 return SVFUtil::dyn_cast<ValVar>(
422 return SVFUtil::dyn_cast<ValVar>(node);
470 obj->isConstDataOrConstGlobal();
484 assert(SVFUtil::isa<ObjVar>(node) &&
"need an object node");
485 const ObjVar*
obj = SVFUtil::cast<ObjVar>(node);
486 return obj->getMemObj();
523 if (
edge->isPTAEdge() || (SVFUtil::isa<CopyStmt>(
edge) && SVFUtil::cast<CopyStmt>(
edge)->isInt2Ptr()))
563 assert(
added &&
"adding the same indirect callsite twice?");
756 "This NodeID clashes here. Please check NodeIDAllocator. Switch "
757 "Strategy::DBUG to SEQ or DENSE");
764 "This NodeID clashes here. Please check NodeIDAllocator. Switch "
765 "Strategy::DBUG to SEQ or DENSE");
std::vector< std::pair< const ICFGNode *, s32_t > > SuccAndCondPairVec
void addActualParms(const ValVar *ap)
Add actual parameters.
Common base for class hierarchy graph. Only implements what PointerAnalysis needs.
void addFormalParms(const SVFVar *fp)
Add formal parameters.
void addFormalRet(const SVFVar *fr)
Add formal return parameter.
bool hasGNode(NodeID id) const
Has a node.
NodeType * getGNode(NodeID id) const
Get a node.
Class representing a heap object variable in the SVFIR.
FunEntryICFGNode * getFunEntryICFGNode(const SVFFunction *fun)
Add a function entry node.
FunExitICFGNode * getFunExitICFGNode(const SVFFunction *fun)
Add a function exit node.
const MemObj * getConstantObj() const
Set< const SVFStmt * > SVFStmtSet
NodeID getBlackHoleNode() const
SVFStmt::KindToSVFStmtMapTy KindToSVFStmtSetMap
SVFIR edge map containing all PAGEdges.
const MemObj * getBlackHoleObj() const
NodeID addNode(SVFVar *node, NodeID i)
Add a node into the graph.
SymbolTableInfo * getSymbolInfo() const
const MemObj * getMemObj(const SVFValue *val) const
get MemObj according to LLVM value
NodeID getConstantNode() const
SVFStmt::KindToSVFStmtMapTy KindToPTASVFStmtSetMap
SVFIR edge map containing only pointer-related edges, i.e., both LHS and RHS are of pointer type.
SymID getId() const
Get the memory object id.
const SVFValue * getValue() const
Get the reference value to this object.
static NodeIDAllocator * get(void)
Return (singleton) allocator.
const MemObj * getMemObj() const
Return memory object.
static void releaseSVFIR()
const CallSiteSet & getCallSiteSet() const
Get all callsites.
CSToArgsListMap & getCallSiteArgsMap()
Get callsite argument list.
SVFStmt::SVFStmtSetTy & getPTASVFStmtSet(SVFStmt::PEDGEK kind)
Get PTA edges set according to its kind.
bool hasPTASVFStmtList(const ICFGNode *inst) const
NodeID addFIObjNode(const MemObj *obj)
Add a field-insensitive node, this method can only invoked by getFIGepObjNode.
NodeID addVarargNode(const SVFFunction *, SVFVar *node, NodeID i)
Add a unique vararg node for a procedure.
GepStmt * addVariantGepStmt(NodeID src, NodeID dst, const AccessPath &ap)
Add Variant(Gep) edge.
SVFStmt::SVFStmtSetTy & getSVFStmtSet(SVFStmt::PEDGEK kind)
Get/set methods to get SVFStmts based on their kinds and ICFGNodes.
Map< const SVFVar *, PhiStmt * > PHINodeMap
NodeOffsetMap GepObjVarMap
Map a pair<base,off> to a gep obj node id.
CallSiteToFunPtrMap indCallSiteToFunPtrMap
Map an indirect callsite to its function pointer.
CopyStmt * addCopyStmt(NodeID src, NodeID dst, CopyStmt::CopyKind type)
Add Copy edge.
CSToRetMap callSiteRetMap
Map a callsite to its callsite returns PAGNodes.
NodeID addStackObjNode(const SVFValue *val, const SVFFunction *f, NodeID i)
CallGraph * getCallGraph()
bool isBlkObj(NodeID id) const
RetPE * addRetPE(NodeID src, NodeID dst, const CallICFGNode *cs, const FunExitICFGNode *exit)
Add Return edge.
NodeID getFunPtr(const CallICFGNode *cs) const
bool isNullPtr(NodeID id) const
GepStmt * addGepStmt(NodeID src, NodeID dst, const AccessPath &ap, bool constGep)
Add Gep edge.
NodeID addObjNode(const SVFValue *val, NodeID i)
Add a memory obj node.
NodeID addGlobalValueObjNode(const SVFValue *curInst, const NodeID i)
static void handleBlackHole(bool b)
SVFIR build configurations.
const MemObj * addDummyMemObj(NodeID i, const SVFType *type)
NodeID getFIObjVar(const MemObj *obj) const
Get a field-insensitive obj SVFIR node according to a mem obj.
void addToStmt2TypeMap(SVFStmt *edge)
Map a SVFStatement type to a set of corresponding SVF statements.
NodeID addBlackholePtrNode()
Set< const CallICFGNode * > CallSiteSet
NodeID addBlackholeObjNode()
const MemObj * getObject(const ObjVar *node) const
Map< const CallICFGNode *, SVFVarList > CSToArgsListMap
SVFStmt * addBlackHoleAddrStmt(NodeID node)
Set a pointer points-to black hole (e.g. int2ptr)
NodeID addDummyObjNode(NodeID i, const SVFType *type)
LoadStmt * addLoadStmt(NodeID src, NodeID dst)
Add Load edge.
GepStmt * addNormalGepStmt(NodeID src, NodeID dst, const AccessPath &ap)
Add Offset(Gep) edge.
u32_t getFieldObjNodeNum() const
MemObjToFieldsMap memToFieldsMap
Map a mem object id to all its fields.
Map< const RetICFGNode *, const SVFVar * > CSToRetMap
virtual ~SVFIR()
Destructor.
NodeID addGlobalValueValNode(const SVFValue *curInst, const NodeID i, const ICFGNode *icfgNode)
bool isIndirectCallSites(const CallICFGNode *cs) const
SVFStmt * getIntraPAGEdge(SVFVar *src, SVFVar *dst, SVFStmt::PEDGEK kind)
PHINodeMap phiNodeMap
A set of phi copy edges.
NodeBS getFieldsAfterCollapse(NodeID id)
std::pair< NodeID, APOffset > NodeOffset
Map< const SVFFunction *, SVFVarList > FunToArgsListMap
Map< const ICFGNode *, SVFStmtList > ICFGNode2SVFStmtsMap
FunToRetMap funRetMap
Map a function to its unique function return PAGNodes.
OrderedMap< const CallICFGNode *, NodeID > CallSiteToFunPtrMap
void setModule(SVFModule *mod)
Set/Get LLVM Module.
void addFunRet(const SVFFunction *fun, const SVFVar *ret)
Add function returns.
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 addConstantIntValNode(const SVFValue *curInst, s64_t sval, u64_t zval, const NodeID i, const ICFGNode *icfgNode)
CallPE * addCallPE(NodeID src, NodeID dst, const CallICFGNode *cs, const FunEntryICFGNode *entry)
Add Call edge.
SVFStmtList & getSVFStmtList(const ICFGNode *inst)
Given an instruction, get all its PAGEdges.
bool isValidTopLevelPtr(const SVFVar *node)
bool isConstantObj(NodeID id) const
NodeID addConstantFPObjNode(const SVFValue *curInst, double dval, const NodeID i)
bool isPhiNode(const SVFVar *node) const
Whether this SVFVar is a result operand a of phi node.
OrderedNodeSet & getAllValidPtrs()
Return valid pointers.
NodeID addConstantNullPtrObjNode(const SVFValue *curInst, const NodeID i)
NodeID addValNode(const SVFValue *val, NodeID i, const ICFGNode *icfgNode)
add node into SVFIR
bool hasSVFStmtList(const ICFGNode *inst) const
Whether this instruction has SVFIR Edge.
TypeLocSetsMap typeLocSetsMap
Map an arg to its base SVFType* and all its field location sets.
std::vector< const SVFVar * > SVFVarList
TDJoinPE * addThreadJoinPE(NodeID src, NodeID dst, const CallICFGNode *cs, const FunExitICFGNode *exit)
Add Thread join edge for parameter passing.
CallGraph * callGraph
all the callsites of a program
Map< NodeID, NodeID > NodeToNodeMap
const SVFVarList & getFunArgsList(const SVFFunction *func) const
Get function arguments list.
CSToRetMap & getCallSiteRets()
Get callsite return.
void destroy()
Clean up memory.
NodeID addGepObjNode(const MemObj *obj, const APOffset &apOffset, const NodeID gepId)
Add a field obj node, this method can only invoked by getGepObjVar.
NodeID addConstantFPValNode(const SVFValue *curInst, double dval, const NodeID i, const ICFGNode *icfgNode)
bool isBlkPtr(NodeID id) const
Get black hole and constant id.
void addToSVFStmtList(ICFGNode *inst, SVFStmt *edge)
Add a SVFStmt into instruction map.
NodeID addDummyValNode(NodeID i)
Add a dummy value/object node according to node ID (llvm value is null)
std::vector< const SVFStmt * > SVFStmtList
const BaseObjVar * getBaseObject(NodeID id) const
NodeID addFunValNode(const CallGraphNode *callGraphNode, NodeID i, const ICFGNode *icfgNode)
SVFStmtSet globSVFStmtSet
Global PAGEdges without control flow information.
NodeBS & getAllFieldsObjVars(const MemObj *obj)
Get all fields of an object.
void addCallSiteRets(RetICFGNode *retBlockNode, const SVFVar *arg)
Add callsite returns.
std::pair< NodeID, AccessPath > NodeAccessPath
void setICFG(ICFG *i)
Set/Get ICFG.
NodeID getBaseObjVar(NodeID id) const
Base and Offset methods for Value and Object node.
Map< NodeAccessPath, NodeID > NodeAccessPathMap
CmpStmt * addCmpStmt(NodeID op1, NodeID op2, NodeID dst, u32_t predict)
Add Copy edge.
NodeID addConstantIntObjNode(const SVFValue *curInst, s64_t sval, u64_t zval, const NodeID i)
FunToRetMap & getFunRets()
Get function return list.
const MemObj * getBaseObj(NodeID id) const
SVFStmtSet & getGlobalSVFStmtSet()
Get global PAGEdges (not in a procedure)
NodeID addRetNode(const CallGraphNode *, SVFVar *node, NodeID i)
Add a unique return node for a procedure.
void addCallSiteArgs(CallICFGNode *callBlockNode, const ValVar *arg)
Add callsite arguments.
AddrStmt * addAddrStmt(NodeID src, NodeID dst)
Add an edge into SVFIR.
FunToArgsListMap funArgsListMap
Map a function to a list of all its formal parameters.
ICFGNode2SVFStmtsMap icfgNode2SVFStmtsMap
Map an ICFGNode to its SVFStmts.
u32_t getFieldValNodeNum() const
Node and edge statistics.
UnaryOPStmt * addUnaryOPStmt(NodeID src, NodeID dst, u32_t opcode)
Add Unary edge.
NodeID addConstantNullPtrValNode(const SVFValue *curInst, const NodeID i, const ICFGNode *icfgNode)
std::pair< const SVFType *, std::vector< AccessPath > > SVFTypeLocSetsPair
TDForkPE * addThreadForkPE(NodeID src, NodeID dst, const CallICFGNode *cs, const FunEntryICFGNode *entry)
Add Thread fork edge for parameter passing.
bool isFunPtr(NodeID id) const
SVFStmt * getIntraPAGEdge(NodeID src, NodeID dst, SVFStmt::PEDGEK kind)
Get an edge according to src, dst and kind.
const SVFVar * getFunRet(const SVFFunction *func) const
Get function return list.
BinaryOPStmt * addBinaryOPStmt(NodeID op1, NodeID op2, NodeID dst, u32_t opcode)
Add Copy edge.
bool hasCallSiteArgsMap(const CallICFGNode *cs) const
Callsite has argument list.
void addCallSite(const CallICFGNode *call)
Add callsites.
static std::unique_ptr< SVFIR > pag
call graph
StoreStmt * addStoreStmt(NodeID src, NodeID dst, const ICFGNode *val)
Add Store edge.
void addToTypeLocSetsMap(NodeID argId, SVFTypeLocSetsPair &locSets)
Add a base SVFType* and all its field location sets to an arg NodeId.
CSToArgsListMap callSiteArgsListMap
Map a callsite to a list of all its actual parameters.
NodeID addRetNode(const CallGraphNode *callGraphNode, NodeID i)
Add a unique return node for a procedure.
void setCHG(CommonCHGraph *c)
Set/Get CHG.
NodeOffsetMap & getGepObjNodeMap()
Return GepObjVarMap.
const CallSiteToFunPtrMap & getIndirectCallsites() const
Add/get indirect callsites.
bool callsiteHasRet(const RetICFGNode *cs) const
NodeID addVarargNode(const CallGraphNode *val, NodeID i)
Add a unique vararg node for a procedure.
SVFStmtList & getPTASVFStmtList(const ICFGNode *inst)
Given an instruction, get all its PTA PAGEdges.
ICFGNode2SVFStmtsMap icfgNode2PTASVFStmtsMap
Map an ICFGNode to its PointerAnalysis related SVFStmts.
Map< NodeID, NodeBS > MemObjToFieldsMap
Map< NodePair, NodeID > NodePairSetMap
NodeID addHeapObjNode(const SVFValue *val, const SVFFunction *f, NodeID i)
const MemObj * getObject(NodeID id) const
PhiStmt * addPhiStmt(NodeID res, NodeID opnd, const ICFGNode *pred)
Add phi node information.
OrderedNodeSet candidatePointers
void addFunArgs(const SVFFunction *fun, const SVFVar *arg)
Get/set method for function/callsite arguments and returns.
bool hasFunArgsList(const SVFFunction *func) const
Function has arguments list.
friend class TypeBasedHeapCloning
const SVFVarList & getCallSiteArgsList(const CallICFGNode *cs) const
Get callsite argument list.
Map< const SVFFunction *, SVFStmtSet > FunToPAGEdgeSetMap
NodeID addConstantDataValNode(const SVFValue *curInst, const NodeID i, const ICFGNode *icfgNode)
NodeID getFIObjVar(NodeID id) const
SelectStmt * addSelectStmt(NodeID res, NodeID op1, NodeID op2, NodeID cond)
Add SelectStmt.
void setCallGraph(CallGraph *c)
Set/Get CG.
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
NodeID addConstantDataObjNode(const SVFValue *curInst, const NodeID i)
NodeID getGepValVar(const SVFValue *curInst, NodeID base, const AccessPath &ap) const
Due to constraint expression, curInst is used to distinguish different instructions (e....
Map< NodeID, SVFTypeLocSetsPair > TypeLocSetsMap
GepValueVarMap GepValObjMap
Map a pair<base,off> to a gep value node id.
const ValVar * getBaseValVar(NodeID id) const
NodeID addFunObjNode(const CallGraphNode *callGraphNode, NodeID id)
bool isBlkObjOrConstantObj(NodeID id) const
const CallSiteSet & getIndCallSites(NodeID funPtr) const
bool isValidPointer(NodeID nodeId) const
Whether a node is a valid pointer.
Map< NodeID, CallSiteSet > FunPtrToCallSitesMap
const SVFVar * getCallSiteRet(const RetICFGNode *cs) const
Get callsite return.
NodeID getGepObjVar(const MemObj *obj, const APOffset &ap)
Get a field SVFIR Object node according to base mem obj and offset.
Map< const SVFFunction *, const SVFVar * > FunToRetMap
void addGlobalPAGEdge(const SVFStmt *edge)
Add global PAGEdges (not in a procedure)
BranchStmt * addBranchStmt(NodeID br, NodeID cond, const BranchStmt::SuccAndCondPairVec &succs)
Add BranchStmt.
Map< NodeOffset, NodeID > NodeOffsetMap
NodeID addValNode(const SVFValue *, SVFVar *node, NodeID i)
Add a value (pointer) node.
void addIndirectCallsites(const CallICFGNode *cs, NodeID funPtr)
Add indirect callsites.
FunToArgsListMap & getFunArgsMap()
Get function arguments list.
void initialiseCandidatePointers()
Initialize candidate pointers.
Map< const SVFValue *, NodeAccessPathMap > GepValueVarMap
NodeID addObjNode(const SVFValue *, SVFVar *node, NodeID i)
Add a memory obj node.
FunPtrToCallSitesMap funPtrToCallSitesMap
SVFTypeLocSetsPair & getTypeLocSetsMap(NodeID argId)
Given an arg NodeId, get its base SVFType* and all its field location sets.
NodeID addDummyObjNode(const SVFType *type)
MemObjToFieldsMap & getMemToFieldsMap()
Return memToFieldsMap.
bool funHasRet(const SVFFunction *func) const
NodeID addConstantObjNode()
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy
Represents a stack-allocated object variable in the SVFIR (SVF Intermediate Representation) @inherits...
static bool isConstantObj(NodeID id)
static bool isBlkPtr(NodeID id)
special value
static bool isNullPtr(NodeID id)
static bool isBlkObj(NodeID id)
const MemObj * createDummyObj(SymID symId, const SVFType *type)
Can only be invoked by SVFIR::addDummyNode() when creating SVFIR from file.
OrderedSet< NodeID > OrderedNodeSet
llvm::IRBuilder IRBuilder