74 MRSet::const_iterator mit =
memRegSet.find(&mr);
79 if(mrs.find(mr)==mrs.end())
96 MRSet::iterator mit =
memRegSet.find(&mr);
97 assert(mit!=
memRegSet.end() &&
"memory region not found!!");
178 for (
const auto&
item: *svfirCallGraph)
187 iter != eiter; ++iter)
193 for (SVFStmtList::iterator bit = pagEdgeList.begin(), ebit =
194 pagEdgeList.end(); bit != ebit; ++bit)
200 NodeBS cpts(
pta->getPts(st->getLHSVarID()).toNodeBS());
204 assert(!cpts.
empty() &&
"null pointer!!");
210 NodeBS cpts(
pta->getPts(ld->getRHSVarID()).toNodeBS());
214 assert(!cpts.
empty() &&
"null pointer!!");
233 for(SVFIR::CallSiteSet::const_iterator it =
pta->getPAG()->getCallSiteSet().begin(),
234 eit =
pta->getPAG()->getCallSiteSet().end(); it!=eit; ++it)
243 while(!worklist.
empty())
259 for (
const CallICFGNode* callBlockNode :
pta->getPAG()->getCallSiteSet())
293 NodeBS& existCPts = it->second;
296 subSetList.insert(it->first);
304 for(PointsToList::iterator it = subSetList.begin(), eit = subSetList.end(); it!=eit; ++it)
325 for(PointsToList::iterator cit = it->second.begin(), ecit = it->second.end(); cit!=ecit; ++cit)
335 for(PointsToList::iterator cit = it->second.begin(), ecit = it->second.end(); cit!=ecit; ++cit)
354 const NodeBS& storeCPts = it->second;
356 for(MRSet::iterator ait = aliasMRs.begin(), eait = aliasMRs.end(); ait!=eait; ++ait)
366 const NodeBS& loadCPts = it->second;
368 for(MRSet::iterator ait = aliasMRs.begin(), eait = aliasMRs.end(); ait!=eait; ++ait)
378 const FunObjVar* fun = it->first->getCaller();
380 const NodeBS& callsiteModCPts = it->second;
382 for(MRSet::iterator ait = aliasMRs.begin(), eait = aliasMRs.end(); ait!=eait; ++ait)
390 const FunObjVar* fun = it->first->getCaller();
392 const NodeBS& callsiteRefCPts = it->second;
394 for(MRSet::iterator ait = aliasMRs.begin(), eait = aliasMRs.end(); ait!=eait; ++ait)
488 for(SVFIR::ValVarList::const_iterator itA = args.begin(), ieA = args.end(); itA!=ieA; ++itA)
496 while(!worklist.
empty())
499 const NodeBS& tmp =
pta->getPts(nodeId).toNodeBS();
507 if (
pta->getPAG()->callsiteHasRet(retBlockNode))
509 const PAGNode* node =
pta->getPAG()->getCallSiteRet(retBlockNode);
526 NodeID baseId =
pta->getPAG()->getBaseObjVarID(
id);
533 pts |=
pta->getPAG()->getFieldsAfterCollapse(baseId);
539 while(!worklist.
empty())
542 const NodeBS& tmp =
pta->getPts(nodeId).toNodeBS();
565 assert(pVar &&
"object not found!!");
579 assert(obj &&
"object not found!!");
582 assert(pVar &&
"object not found!");
610 for (SVFStmtList::const_iterator bit = pagEdgeList.begin(),
611 ebit = pagEdgeList.end(); bit != ebit; ++bit)
615 mod.
set(addr->getRHSVarID());
630 return refchanged || modchanged;
647 for(CallGraphEdge::CallInstSet::iterator cit = edge->
getDirectCalls().begin(),
657 for(CallGraphEdge::CallInstSet::iterator cit = edge->
getIndirectCalls().begin(),
680 for (SVFStmtList::const_iterator bit = pagEdgeList.begin(), ebit =
681 pagEdgeList.end(); bit != ebit; ++bit)
685 mods |=
pta->getPts(st->getLHSVarID()).toNodeBS();
704 for (SVFStmtList::const_iterator bit = pagEdgeList.begin(), ebit =
705 pagEdgeList.end(); bit != ebit; ++bit)
709 refs |=
pta->getPts(ld->getRHSVarID()).toNodeBS();
750 NodeBS ptsExpanded, csRefExpanded, csModExpanded;
751 pta->expandFIObjs(pts, ptsExpanded);
752 pta->expandFIObjs(csRef, csRefExpanded);
753 pta->expandFIObjs(csMod, csModExpanded);
786 NodeBS cs1RefExpanded, cs1ModExpanded, cs2RefExpanded, cs2ModExpanded;
787 pta->expandFIObjs(cs1Ref, cs1RefExpanded);
788 pta->expandFIObjs(cs1Mod, cs1ModExpanded);
789 pta->expandFIObjs(cs2Ref, cs2RefExpanded);
790 pta->expandFIObjs(cs2Mod, cs2ModExpanded);
793 if (cs1RefExpanded.
intersects(cs2ModExpanded))
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
virtual const FunObjVar * getFunction() const
Get containing function, or null for globals/constants.
CallInstSet & getIndirectCalls()
CallInstSet & getDirectCalls()
const FunObjVar * getFunction() const
Get function of this call node.
const RetICFGNode * getRetICFGNode() const
Return callsite.
const FunObjVar * getCaller() const
Return callsite.
bool push(const Data &data)
BasicBlockGraph::IDToNodeMapTy::const_iterator const_bb_iterator
const_bb_iterator begin() const
bool isUncalledFunction() const
const_bb_iterator end() const
NodeID getSrcID() const
get methods of the components
iterator begin()
Iterators.
IDToNodeMapTy::iterator iterator
GEdgeSetTy::iterator iterator
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;.
const NodeBS & getModSideEffectOfFunction(const FunObjVar *fun)
Get indirect mods of a function.
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.
const NodeBS & getRefSideEffectOfFunction(const FunObjVar *fun)
Get indirect refs of a function.
FunToPointsToMap funToModsMap
Map a function to its indirect defs of memory objects.
virtual void refineCallsiteModRef(NodeBS &, NodeBS &, const CallICFGNode *, const FunObjVar *)
CallSiteToPointsToMap callsiteToRefPointsToMap
Map a callsite to it refs cpts set.
void addRefSideEffectOfFunction(const FunObjVar *fun, const NodeBS &refs)
Add/Get methods for side-effect of functions and callsites.
FunToMRsMap funToMRsMap
Map a function to all its memory regions.
bool addUnfilteredModSideEffectOfCallSite(const CallICFGNode *cs, const NodeBS &mods)
Add indirect def to a callsite without applying call-argument filtering.
virtual bool handleCallsiteModRef(NodeBS &mod, NodeBS &ref, const CallICFGNode *cs, const FunObjVar *fun)
Get Mod-Ref of a callee function.
virtual void generateMRs()
Start generating memory regions.
virtual void collectModRefForCall()
Generate regions for calls/rets.
void createMR(const FunObjVar *fun, const NodeBS &cpts)
Generate a memory region and put in into functions which use it.
virtual void propagateAdditionalModRef(CallGraphNode *, WorkList &)
const MemRegion * getMR(const NodeBS &cpts) const
Get a memory region according to cpts.
void addCPtsToLoad(NodeBS &cpts, const LoadStmt *ld, const FunObjVar *fun)
FunToPointsTosMap & getFunToPointsToList()
void addModSideEffectOfFunction(const FunObjVar *fun, const NodeBS &mods)
Add indirect def an memory object in the function.
CallSiteToPointsToMap csToModsMap
Map a callsite to its indirect defs of memory objects.
virtual void sortPointsTo(const NodeBS &cpts)
Given a condition pts, insert into cptsToRepCPtsMap for region generation.
void addCPtsToStore(NodeBS &cpts, const StoreStmt *st, const FunObjVar *fun)
Add cpts to store/load.
FIFOWorkList< NodeID > WorkList
CallSiteToMRsMap callsiteToRefMRsMap
Map a callsite to its refs regions.
virtual void getAliasMemRegions(MRSet &aliasMRs, const NodeBS &cpts, const FunObjVar *fun)
Get all aliased mem regions from function fun according to cpts.
StoresToPointsToMap storesToPointsToMap
Map a store SVFIR Edge to its CPts set map.
const FunObjVar * getFunction(const PAGEdge *pagEdge) const
Get the function which SVFIR Edge located.
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.
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.
virtual void updateAliasMRs()
Update aliased regions for loads/stores/callsites.
void collectCallSitePts(const CallICFGNode *cs)
const NodeBS & getRepPointsTo(const NodeBS &cpts) const
Get superset cpts set.
virtual void getMRsForCallSiteRef(MRSet &aliasMRs, const NodeBS &cpts, const FunObjVar *)
Get memory regions for call site ref according to cpts.
bool hasSVFStmtList(const ICFGNode *icfgNode)
Whether this instruction has SVFIR Edge.
PAGEdgeToFunMap pagEdgeToFunMap
Map a PAGEdge to its fun.
PtsToRepPtsSetMap cptsToRepCPtsMap
Map a condition pts to its rep conditional pts (super set points-to).
void addCPtsToCallSiteMods(NodeBS &cpts, const CallICFGNode *cs)
virtual void getMRsForLoad(MRSet &aliasMRs, const NodeBS &cpts, const FunObjVar *)
Get memory regions for a load statement according to cpts.
CallSiteToPointsToMap callsiteToModPointsToMap
Map a callsite to it mods cpts set.
SVFStmtList & getSVFStmtsFromInst(const ICFGNode *node)
Given an instruction, get all its the PAGEdge (statement) in sequence.
virtual void partitionMRs()
Partition regions.
ModRefInfo getModRefInfo(const CallICFGNode *cs)
void destroy()
Clean up memory.
const NodeBS & getRefSideEffectOfCallSite(const CallICFGNode *cs)
Get indirect refs of a callsite.
CallSiteToPointsToMap csToRefsMap
Map a callsite to its indirect uses of memory objects.
MRGenerator(BVDataPTAImpl *p, bool ptrOnly)
NodeBS & getCallSiteArgsPts(const CallICFGNode *cs)
Return the pts chain of all callsite arguments.
bool isNonLocalObject(NodeID id, const FunObjVar *curFun) const
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
const NodeBS & getModSideEffectOfCallSite(const CallICFGNode *cs)
Get indirect mods of a callsite.
SCCDetection< CallGraph * > SCC
Call Graph SCC.
virtual void modRefAnalysis(CallGraphNode *callGraphNode, WorkList &worklist)
Mod-Ref analysis for callsite invoking this callGraphNode.
NodeBS & getCallSiteRetPts(const CallICFGNode *cs)
Return the pts chain of the return parameter of the callsite.
NodeBS allGlobals
All global variable SVFIR node ids.
LoadsToPointsToMap loadsToPointsToMap
Map a load SVFIR Edge to its CPts set map.
FunToPointsToMap funToRefsMap
Map a function to its indirect uses of memory objects.
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.
const MemRegion * getMR() const
Return the memory region.
MRVERID getID() const
Get MRVERID.
MSSADef * getDef() const
Get MSSADef.
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
const std::vector< const ICFGNode * > & getICFGNodeList() const
bool hasPTASVFStmtList(const ICFGNode *inst) const
std::vector< const ValVar * > ValVarList
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 SVFStmt * > SVFStmtList
const BaseObjVar * getBaseObject(NodeID id) const
const CallGraph * getCallGraph()
Get CG.
bool hasCallSiteArgsMap(const CallICFGNode *cs) const
Callsite has argument list.
SVFStmtList & getPTASVFStmtList(const ICFGNode *inst)
Given an instruction, get all its PTA PAGEdges.
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
NodeID getId() const
Get ID.
virtual bool isPointer() const
Check if this variable represents a pointer.
SparseBitVectorIterator iterator
bool intersects(const SparseBitVector< ElementSize > *RHS) const
bool contains(const SparseBitVector< ElementSize > &RHS) const
std::string pasMsg(const std::string &msg)
Print each pass/phase message by converting a string into blue string output.
LLVM_NODISCARD bool isa(const Y &Val)
bool isHeapAllocExtCall(const ICFGNode *cs)
bool isExtCall(const FunObjVar *fun)
std::ostream & outs()
Overwrite llvm::outs().
LLVM_NODISCARD std::enable_if_t<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type > dyn_cast(const Y &Val)
IntervalValue operator<<(const IntervalValue &lhs, const IntervalValue &rhs)
Left binary shift of IntervalValues.