36 using namespace SVFUtil;
42 pta(
p), ptrOnlyMSSA(ptrOnly)
73 MRSet::const_iterator mit =
memRegSet.find(&mr);
78 if(mrs.find(mr)==mrs.end())
95 MRSet::iterator mit =
memRegSet.find(&mr);
96 assert(mit!=
memRegSet.end() &&
"memory region not found!!");
109 if(
ObjVar* obj = SVFUtil::dyn_cast<ObjVar>(nIter->second))
111 if (obj->getMemObj()->isGlobalObj())
177 for (
const auto&
item: *svfirCallGraph)
186 iter != eiter; ++iter)
192 for (SVFStmtList::iterator bit = pagEdgeList.begin(), ebit =
193 pagEdgeList.end(); bit != ebit; ++bit)
197 if (
const StoreStmt *st = SVFUtil::dyn_cast<StoreStmt>(inst))
203 assert(!cpts.
empty() &&
"null pointer!!");
207 else if (
const LoadStmt *ld = SVFUtil::dyn_cast<LoadStmt>(inst))
213 assert(!cpts.
empty() &&
"null pointer!!");
243 while(!worklist.
empty())
292 NodeBS& existCPts = it->second;
295 subSetList.insert(it->first);
303 for(PointsToList::iterator it = subSetList.begin(), eit = subSetList.end(); it!=eit; ++it)
324 for(PointsToList::iterator cit = it->second.begin(), ecit = it->second.end(); cit!=ecit; ++cit)
334 for(PointsToList::iterator cit = it->second.begin(), ecit = it->second.end(); cit!=ecit; ++cit)
353 const NodeBS& storeCPts = it->second;
355 for(MRSet::iterator ait = aliasMRs.begin(), eait = aliasMRs.end(); ait!=eait; ++ait)
365 const NodeBS& loadCPts = it->second;
367 for(MRSet::iterator ait = aliasMRs.begin(), eait = aliasMRs.end(); ait!=eait; ++ait)
379 const NodeBS& callsiteModCPts = it->second;
381 for(MRSet::iterator ait = aliasMRs.begin(), eait = aliasMRs.end(); ait!=eait; ++ait)
391 const NodeBS& callsiteRefCPts = it->second;
393 for(MRSet::iterator ait = aliasMRs.begin(), eait = aliasMRs.end(); ait!=eait; ++ait)
465 while(!topoOrder.empty())
467 NodeID callgraphNodeID = topoOrder.top();
469 worklist.
push(callgraphNodeID);
488 for(SVFIR::SVFVarList::const_iterator itA = args.begin(), ieA = args.end(); itA!=ieA; ++itA)
496 while(!worklist.
empty())
539 while(!worklist.
empty())
564 assert(obj &&
"object not found!!");
577 assert(obj &&
"object not found!!");
606 for (SVFStmtList::const_iterator bit = pagEdgeList.begin(),
607 ebit = pagEdgeList.end(); bit != ebit; ++bit)
610 if (
const AddrStmt* addr = SVFUtil::dyn_cast<AddrStmt>(edge))
611 mod.
set(addr->getRHSVarID());
625 return refchanged || modchanged;
642 for(PTACallGraphEdge::CallInstSet::iterator cit = edge->
getDirectCalls().begin(),
652 for(PTACallGraphEdge::CallInstSet::iterator cit = edge->
getIndirectCalls().begin(),
673 for (SVFStmtList::const_iterator bit = pagEdgeList.begin(), ebit =
674 pagEdgeList.end(); bit != ebit; ++bit)
677 if (
const StoreStmt* st = SVFUtil::dyn_cast<StoreStmt>(edge))
697 for (SVFStmtList::const_iterator bit = pagEdgeList.begin(), ebit =
698 pagEdgeList.end(); bit != ebit; ++bit)
701 if (
const LoadStmt* ld = SVFUtil::dyn_cast<LoadStmt>(edge))
745 NodeBS ptsExpanded, csRefExpanded, csModExpanded;
782 NodeBS cs1RefExpanded, cs1ModExpanded, cs2RefExpanded, cs2ModExpanded;
789 if (cs1RefExpanded.
intersects(cs2ModExpanded))
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
virtual void expandFIObjs(const PointsTo &pts, PointsTo &expandedPts)
Expand FI objects.
const PointsTo & getPts(NodeID id) override
const SVFFunction * getCaller() const
Return callsite.
const RetICFGNode * getRetICFGNode() const
Return callsite.
bool push(const Data &data)
NodeID getSrcID() const
get methods of the components
iterator begin()
Iterators.
NodeType * getGNode(NodeID id) const
Get a node.
IDToNodeMapTy::iterator iterator
Node Iterators.
bool hasValueNode(const SVFValue *V)
NodeID getValueNode(const SVFValue *V)
virtual void getMRsForCallSiteRef(MRSet &aliasMRs, const NodeBS &cpts, const SVFFunction *)
Get memory regions for call site ref according to cpts.
LoadsToMRsMap loadsToMRsMap
Map a load SVFIR Edge to its memory regions sets in order for inserting mus in Memory SSA.
NodeToPTSSMap cachedPtsChainMap
Map a pointer to its cached points-to chain;.
FunToPointsTosMap & getFunToPointsToList()
const NodeBS & getModSideEffectOfCallSite(const CallICFGNode *cs)
Get indirect mods of a callsite.
bool hasModSideEffectOfCallSite(const CallICFGNode *cs)
Has indirect mods of a callsite.
virtual void collectModRefForLoadStore()
Generate regions for loads/stores.
CallSiteToPointsToMap csToCallSiteRetPtsMap
Map a callsite to all its object might return from its callees.
StoresToMRsMap storesToMRsMap
Map a store SVFIR Edge to its memory regions sets in order for inserting chis in Memory SSA.
SVFStmtList & getPAGEdgesFromInst(const ICFGNode *node)
Given an instruction, get all its the PAGEdge (statement) in sequence.
FunToPointsToMap funToModsMap
Map a function to its indirect defs of memory objects.
bool isNonLocalObject(NodeID id, const SVFFunction *curFun) const
const SVFFunction * getFunction(const PAGEdge *pagEdge) const
Get the function which SVFIR Edge located.
CallSiteToPointsToMap callsiteToRefPointsToMap
Map a callsite to it refs cpts set.
void addModSideEffectOfFunction(const SVFFunction *fun, const NodeBS &mods)
Add indirect def an memory object in the function.
FunToMRsMap funToMRsMap
Map a function to all its memory regions.
virtual void generateMRs()
Start generating memory regions.
virtual void collectModRefForCall()
Generate regions for calls/rets.
const MemRegion * getMR(const NodeBS &cpts) const
Get a memory region according to cpts.
CallSiteToPointsToMap csToModsMap
Map a callsite to its indirect defs of memory objects.
const NodeBS & getRefSideEffectOfCallSite(const CallICFGNode *cs)
Get indirect refs of a callsite.
virtual void sortPointsTo(const NodeBS &cpts)
Given a condition pts, insert into cptsToRepCPtsMap for region generation.
void addCPtsToLoad(NodeBS &cpts, const LoadStmt *ld, const SVFFunction *fun)
CallSiteToMRsMap callsiteToRefMRsMap
Map a callsite to its refs regions.
const NodeBS & getModSideEffectOfFunction(const SVFFunction *fun)
Get indirect mods of a function.
StoresToPointsToMap storesToPointsToMap
Map a store SVFIR Edge to its CPts set map.
NodeBS & CollectPtsChain(NodeID id)
bool addRefSideEffectOfCallSite(const CallICFGNode *cs, const NodeBS &refs)
Add indirect uses an memory object in the function.
SVFIR::SVFStmtList SVFStmtList
SVFIR edge list.
void addRefSideEffectOfFunction(const SVFFunction *fun, const NodeBS &refs)
Add/Get methods for side-effect of functions and callsites.
OrderedSet< NodeBS, SVFUtil::equalNodeBS > PointsToList
bool addModSideEffectOfCallSite(const CallICFGNode *cs, const NodeBS &mods)
Add indirect def an memory object in the function.
void addCPtsToCallSiteRefs(NodeBS &cpts, const CallICFGNode *cs)
NodeBS getRefInfoForCall(const CallICFGNode *cs)
bool hasRefSideEffectOfCallSite(const CallICFGNode *cs)
Has indirect refs of a callsite.
OrderedSet< const MemRegion *, MemRegion::equalMemRegion > MRSet
Get typedef from Pointer Analysis.
const NodeBS & getRepPointsTo(const NodeBS &cpts) const
Get superset cpts set.
virtual void updateAliasMRs()
Update aliased regions for loads/stores/callsites.
void collectCallSitePts(const CallICFGNode *cs)
bool hasSVFStmtList(const ICFGNode *icfgNode)
Whether this instruction has SVFIR Edge.
NodeBS & getCallSiteRetPts(const CallICFGNode *cs)
Return the pts chain of the return parameter of the callsite.
PAGEdgeToFunMap pagEdgeToFunMap
Map a PAGEdge to its fun.
void getCallGraphSCCRevTopoOrder(WorkList &worklist)
Get reverse topo call graph scc.
PtsToRepPtsSetMap cptsToRepCPtsMap
Map a condition pts to its rep conditional pts (super set points-to)
void addCPtsToCallSiteMods(NodeBS &cpts, const CallICFGNode *cs)
CallSiteToPointsToMap callsiteToModPointsToMap
Map a callsite to it mods cpts set.
virtual void getMRsForLoad(MRSet &aliasMRs, const NodeBS &cpts, const SVFFunction *)
Get memory regions for a load statement according to cpts.
const NodeBS & getRefSideEffectOfFunction(const SVFFunction *fun)
Get indirect refs of a function.
virtual void partitionMRs()
Partition regions.
ModRefInfo getModRefInfo(const CallICFGNode *cs)
void createMR(const SVFFunction *fun, const NodeBS &cpts)
Generate a memory region and put in into functions which use it.
void destroy()
Clean up memory.
CallSiteToPointsToMap csToRefsMap
Map a callsite to its indirect uses of memory objects.
MRGenerator(BVDataPTAImpl *p, bool ptrOnly)
virtual bool handleCallsiteModRef(NodeBS &mod, NodeBS &ref, const CallICFGNode *cs, const SVFFunction *fun)
Get Mod-Ref of a callee function.
NodeBS & getCallSiteArgsPts(const CallICFGNode *cs)
Return the pts chain of all callsite arguments.
virtual void getAliasMemRegions(MRSet &aliasMRs, const NodeBS &cpts, const SVFFunction *fun)
Get all aliased mem regions from function fun according to cpts.
virtual void modRefAnalysis(PTACallGraphNode *callGraphNode, WorkList &worklist)
Mod-Ref analysis for callsite invoking this callGraphNode.
void getEscapObjviaGlobals(NodeBS &globs, const NodeBS &pts)
Get all the objects in callee's modref escaped via global objects (the chain pts of globals)
CallSiteToMRsMap callsiteToModMRsMap
Map a callsite to its mods regions.
NodeBS getModInfoForCall(const CallICFGNode *cs)
getModRefInfo APIs
NodeBS allGlobals
All global variable SVFIR node ids.
LoadsToPointsToMap loadsToPointsToMap
Map a load SVFIR Edge to its CPts set map.
void addCPtsToStore(NodeBS &cpts, const StoreStmt *st, const SVFFunction *fun)
Add cpts to store/load.
FunToPointsToMap funToRefsMap
Map a function to its indirect uses of memory objects.
SCCDetection< PTACallGraph * > SCC
Call Graph SCC.
MRSet memRegSet
A set of All memory regions.
void collectGlobals()
Collect all global variables for later escape analysis.
CallSiteToPointsToMap csToCallSiteArgsPtsMap
Map a callsite to all its object might pass into its callees.
MRVERSION getSSAVersion() const
Return SSA version.
MRVERID getID() const
Get MRVERID.
MSSADef * getDef() const
Get MSSADef.
const MemRegion * getMR() const
Return the memory region.
static u32_t totalVERNum
ver ID 0 is reserved
DEFTYPE getType() const
Return type of this CHI.
const MemRegion * getMR() const
Return memory region.
static u32_t totalMRNum
region ID 0 is reserved
std::string dumpStr() const
Dump string.
static const Option< bool > IgnoreDeadFun
CallInstSet & getIndirectCalls()
CallInstSet & getDirectCalls()
PTACallGraphEdge::CallGraphEdgeSet::iterator iterator
const SVFFunction * getFunction() const
Get function of this call node.
PTACallGraphNode * getCallGraphNode(NodeID id) const
Get call graph node.
PTACallGraph * getCallGraph() const
Return call graph.
NodeBS toNodeBS() const
Returns this points-to set as a NodeBS.
bool isInCycle(NodeID n) const
whether the node is in a cycle
GNodeStack & topoNodeStack()
const NodeBS & subNodes(NodeID n) const
get all subnodes in one scc, if size is empty insert itself into the set
NodeID getId() const
Get ID.
const std::vector< const ICFGNode * > & getICFGNodeList() const
const_iterator end() const
const_iterator begin() const
bool isUncalledFunction() const
std::vector< const SVFBasicBlock * >::const_iterator const_iterator
bool hasPTASVFStmtList(const ICFGNode *inst) const
PTACallGraph * getCallGraph()
const SVFVarList & getCallSiteArgsList(const CallICFGNode *cs) const
Get callsite argument list.
const MemObj * getObject(NodeID id) const
const SVFVar * getCallSiteRet(const RetICFGNode *cs) const
Get callsite return.
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
NodeBS getFieldsAfterCollapse(NodeID id)
SVFStmtList & getSVFStmtList(const ICFGNode *inst)
Given an instruction, get all its PAGEdges.
bool hasSVFStmtList(const ICFGNode *inst) const
Whether this instruction has SVFIR Edge.
std::vector< const SVFVar * > SVFVarList
std::vector< const SVFStmt * > SVFStmtList
NodeID getBaseObjVar(NodeID id) const
Base and Offset methods for Value and Object node.
bool hasCallSiteArgsMap(const CallICFGNode *cs) const
Callsite has argument list.
const CallSiteSet & getCallSiteSet() const
Get all callsites.
bool callsiteHasRet(const RetICFGNode *cs) const
SVFStmtList & getPTASVFStmtList(const ICFGNode *inst)
Given an instruction, get all its PTA PAGEdges.
virtual bool isPointer() const
Whether it is a pointer.
virtual const SVFFunction * getFunction() const
Return the function that this SVFVar resides in. Return nullptr if it is a global or constantexpr nod...
bool test(unsigned Idx) const
bool intersects(const SparseBitVector< ElementSize > *RHS) const
bool contains(const SparseBitVector< ElementSize > &RHS) const
bool isHeapAllocExtCall(const Instruction *inst)
bool isExtCall(const SVFFunction *fun)
std::string pasMsg(const std::string &msg)
Print each pass/phase message by converting a string into blue string output.
std::ostream & outs()
Overwrite llvm::outs()
std::stack< NodeID > NodeStack
IntervalValue operator<<(const IntervalValue &lhs, const IntervalValue &rhs)
Left binary shift of IntervalValues.