43 using namespace SVFUtil;
55 collectCandidateQueries(pta->
getPAG());
58 for (OrderedNodeSet::iterator nIter = candidateQueries.begin();
59 nIter != candidateQueries.end(); ++nIter,++
count)
65 " [" <<
count + 1<<
"/" << candidateQueries.size() <<
"]" <<
" \n");
67 " [" <<
count + 1<<
"/" << candidateQueries.size() <<
"]" <<
" \n");
68 setCurrentQueryPtr(node->
getId());
81 for(SVFIR::CallSiteToFunPtrMap::const_iterator it = pag->getIndirectCallsites().begin(),
82 eit = pag->getIndirectCallsites().end(); it!=eit; ++it)
84 if (it->first->isVirtualCall())
86 const SVFVar* vtblPtr = it->first->getVtablePtr();
87 assert(vtblPtr !=
nullptr &&
"not a vtable pointer?");
90 vtableToCallSiteMap[vtblId] = it->first;
94 addCandidate(it->second);
97 return candidateQueries;
104 u32_t totalCallsites = 0;
105 u32_t morePreciseCallsites = 0;
106 u32_t zeroTargetCallsites = 0;
107 u32_t oneTargetCallsites = 0;
108 u32_t twoTargetCallsites = 0;
109 u32_t moreThanTwoCallsites = 0;
111 for (VTablePtrToCallSiteMap::iterator nIter = vtableToCallSiteMap.begin();
112 nIter != vtableToCallSiteMap.end(); ++nIter)
114 NodeID vtptr = nIter->first;
129 if(callees.size() == 0)
130 zeroTargetCallsites++;
131 else if(callees.size() == 1)
132 oneTargetCallsites++;
133 else if(callees.size() == 2)
134 twoTargetCallsites++;
136 moreThanTwoCallsites++;
146 ++morePreciseCallsites;
147 outs() <<
"============more precise callsite =================\n";
148 outs() << (nIter->second)->toString() <<
"\n";
151 outs() <<
"------ander pts or vtable num---(" << anderPts.
count() <<
")--\n";
152 outs() <<
"------DDA vfn num---(" << ander_vfns.size() <<
")--\n";
154 outs() <<
"------DDA pts or vtable num---(" << ddaPts.
count() <<
")--\n";
155 outs() <<
"------DDA vfn num---(" << dda_vfns.size() <<
")--\n";
157 outs() <<
"-------------------------\n";
159 outs() <<
"=================================================\n";
162 outs() <<
"=================================================\n";
163 outs() <<
"Total virtual callsites: " << vtableToCallSiteMap.size() <<
"\n";
164 outs() <<
"Total analyzed virtual callsites: " << totalCallsites <<
"\n";
166 outs() <<
"Precise callsites: " << morePreciseCallsites <<
"\n";
167 outs() <<
"Zero target callsites: " << zeroTargetCallsites <<
"\n";
168 outs() <<
"One target callsites: " << oneTargetCallsites <<
"\n";
169 outs() <<
"Two target callsites: " << twoTargetCallsites <<
"\n";
170 outs() <<
"More than two target callsites: " << moreThanTwoCallsites <<
"\n";
171 outs() <<
"=================================================\n";
180 for (SVFStmt::SVFStmtSetTy::iterator iter = loads.begin(), eiter =
181 loads.end(); iter != eiter; ++iter)
183 PAGNode* loadsrc = (*iter)->getSrcNode();
184 loadSrcNodes.insert(loadsrc);
185 addCandidate(loadsrc->
getId());
189 for (SVFStmt::SVFStmtSetTy::iterator iter = stores.begin(), eiter =
190 stores.end(); iter != eiter; ++iter)
192 PAGNode* storedst = (*iter)->getDstNode();
193 storeDstNodes.insert(storedst);
194 addCandidate(storedst->
getId());
197 for (SVFStmt::SVFStmtSetTy::iterator iter = geps.begin(), eiter =
198 geps.end(); iter != eiter; ++iter)
200 PAGNode* gepsrc = (*iter)->getSrcNode();
201 gepSrcNodes.insert(gepsrc);
202 addCandidate(gepsrc->
getId());
204 return candidateQueries;
210 for(PAGNodeSet::const_iterator lit = loadSrcNodes.begin(); lit!=loadSrcNodes.end(); lit++)
212 for(PAGNodeSet::const_iterator sit = storeDstNodes.begin(); sit!=storeDstNodes.end(); sit++)
220 outs() <<
"\n=================================================\n";
223 outs() <<
"[NodeID:" << node1->
getId() <<
", NodeID:" << node2->
getId() <<
" " << result <<
"]\n";
224 outs() <<
"=================================================\n";
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
virtual OrderedNodeSet & collectCandidateQueries(SVFIR *pag)
Only collect function pointers as query candidates.
virtual void performStat(PointerAnalysis *pta)
static AndersenWaveDiff * createAndersenWaveDiff(SVFIR *_pag)
Create an singleton instance directly instead of invoking llvm pass manager.
virtual const PointsTo & getPts(NodeID id)
Operation of points-to set.
virtual void answerQueries(PointerAnalysis *pta)
virtual OrderedNodeSet & collectCandidateQueries(SVFIR *p)
Only collect function pointers as query candidates.
virtual void performStat(PointerAnalysis *pta)
NodeType * getGNode(NodeID id) const
Get a node.
Set< const SVFFunction * > FunctionSet
bool hasIndCSCallees(const CallICFGNode *cs) const
const FunctionSet & getIndCSCallees(const CallICFGNode *cs) const
CallEdgeMap & getIndCallMap()
Get callees from an indirect callsite.
void setMemUsageBefore(u32_t vmrss, u32_t vmsize)
void setMemUsageAfter(u32_t vmrss, u32_t vmsize)
void getVFnsFromPts(const CallICFGNode *cs, const PointsTo &target, VFunSet &vfns)
virtual void computeDDAPts(NodeID)
Compute points-to results on-demand, overridden by derived classes.
PTAStat * getStat() const
Get PTA stat.
virtual const PointsTo & getPts(NodeID ptr)=0
Get points-to targets of a pointer. It needs to be implemented in child class.
PTACallGraph * getCallGraph() const
Return call graph.
virtual AliasResult alias(const SVFValue *V1, const SVFValue *V2)=0
Interface exposed to users of our pointer analysis, given Value infos.
bool empty() const
Returns true if set is empty.
u32_t count() const
Returns number of elements.
NodeID getId() const
Get ID.
bool isValidTopLevelPtr(const SVFVar *node)
SVFStmt::SVFStmtSetTy & getSVFStmtSet(SVFStmt::PEDGEK kind)
Get/set methods to get SVFStmts based on their kinds and ICFGNodes.
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy
std::string toString() const
Needs to be implemented by a SVF front end.
const SVFValue * getValue() const
Get/has methods of the components.
const std::string getSourceLoc(const Value *val)
bool getMemoryUsageKB(u32_t *vmrss_kb, u32_t *vmsize_kb)
Get memory usage from system file. Return TRUE if succeed.
std::ostream & outs()
Overwrite llvm::outs()
OrderedSet< NodeID > OrderedNodeSet
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set