37using namespace SVFUtil;
79 if(
mrs.find(mr)==
mrs.end())
112 if (
obj->getMemObj()->isGlobalObj())
198 if (
const StoreStmt *
st = SVFUtil::dyn_cast<StoreStmt>(inst))
208 else if (
const LoadStmt *
ld = SVFUtil::dyn_cast<LoadStmt>(inst))
244 while(!worklist.
empty())
489 for(SVFIR::SVFVarList::const_iterator
itA = args.begin(),
ieA = args.end();
itA!=
ieA; ++
itA)
497 while(!worklist.
empty())
540 while(!worklist.
empty())
582 if(
obj->isGlobalObj() || SVFUtil::isa<HeapObjVar, DummyObjVar>(
pVar))
586 else if(SVFUtil::isa<StackObjVar>(
pVar))
609 for (SVFStmtList::const_iterator bit =
pagEdgeList.begin(),
645 for(PTACallGraphEdge::CallInstSet::iterator
cit =
edge->getDirectCalls().begin(),
655 for(PTACallGraphEdge::CallInstSet::iterator
cit =
edge->getIndirectCalls().begin(),
813 o <<
"MRVERID: " <<
mrver.getID() <<
" MemRegion: " <<
mrver.getMR()->dumpStr() <<
" MRVERSION: " <<
mrver.getSSAVersion() <<
" MSSADef: " <<
mrver.getDef()->getType() <<
", "
814 <<
mrver.getDef()->getMR()->dumpStr() ;
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) add_llvm_executable(wpa wpa.cpp) target_link_libraries(wpa PUBLIC $
virtual void expandFIObjs(const PointsTo &pts, PointsTo &expandedPts)
Expand FI objects.
const PointsTo & getPts(NodeID id) override
const RetICFGNode * getRetICFGNode() const
Return callsite.
const SVFFunction * getCaller() const
Return callsite.
bool push(const Data &data)
iterator begin()
Iterators.
IDToNodeMapTy::iterator iterator
Node Iterators.
GEdgeSetTy::iterator iterator
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;.
bool hasModSideEffectOfCallSite(const CallICFGNode *cs)
Has indirect mods of a callsite.
const SVFFunction * getFunction(const PAGEdge *pagEdge) const
Get the function which SVFIR Edge located.
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
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.
FunToPointsTosMap & getFunToPointsToList()
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 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.
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.
bool hasSVFStmtList(const ICFGNode *icfgNode)
Whether this instruction has SVFIR Edge.
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.
const NodeBS & getRefSideEffectOfFunction(const SVFFunction *fun)
Get indirect refs of a function.
virtual void getMRsForLoad(MRSet &aliasMRs, const NodeBS &cpts, const SVFFunction *)
Get memory regions for a load statement according to cpts.
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.
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)
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
const NodeBS & getModSideEffectOfCallSite(const CallICFGNode *cs)
Get indirect mods of a callsite.
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.
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.
static u32_t totalVERNum
ver ID 0 is reserved
static u32_t totalMRNum
region ID 0 is reserved
static const Option< bool > IgnoreDeadFun
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.
NodeID getId() const
Get ID.
const std::vector< const ICFGNode * > & getICFGNodeList() const
const_iterator end() const
const_iterator begin() const
std::vector< constSVFBasicBlock * >::const_iterator const_iterator
bool isUncalledFunction() const
const CallSiteSet & getCallSiteSet() const
Get all callsites.
bool hasPTASVFStmtList(const ICFGNode *inst) const
CallGraph * getCallGraph()
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
const BaseObjVar * getBaseObject(NodeID id) const
NodeID getBaseObjVar(NodeID id) const
Base and Offset methods for Value and Object node.
bool hasCallSiteArgsMap(const CallICFGNode *cs) const
Callsite has argument list.
bool callsiteHasRet(const RetICFGNode *cs) const
SVFStmtList & getPTASVFStmtList(const ICFGNode *inst)
Given an instruction, get all its PTA PAGEdges.
const MemObj * getObject(NodeID id) const
const SVFVarList & getCallSiteArgsList(const CallICFGNode *cs) const
Get callsite argument list.
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
const SVFVar * getCallSiteRet(const RetICFGNode *cs) const
Get callsite return.
virtual bool isPointer() const
Whether it is a pointer.
bool test(unsigned Idx) const
bool contains(const SparseBitVector< ElementSize > &RHS) const
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.
bool isHeapAllocExtCall(const ICFGNode *cs)
std::ostream & outs()
Overwrite llvm::outs()
std::stack< NodeID > NodeStack
llvm::IRBuilder IRBuilder
IntervalValue operator<<(const IntervalValue &lhs, const IntervalValue &rhs)
Left binary shift of IntervalValues.