60 else assert(
false &&
"BVDataPTAImpl::BVDataPTAImpl: unexpected points-to backing type!");
67 else assert(
false &&
"BVDataPTAImpl::BVDataPTAImpl: unexpected points-to backing type!");
75 else assert(
false &&
"BVDataPTAImpl::BVDataPTAImpl: unexpected points-to backing type!");
81 else assert(
false &&
"BVDataPTAImpl::BVDataPTAImpl: unexpected points-to backing type!");
88 else assert(
false &&
"BVDataPTAImpl::BVDataPTAImpl: unexpected points-to backing type!");
90 else assert(
false &&
"no points-to data available");
102 std::string moduleName(
pag->getModuleIdentifier());
104 if (names.size() > 1)
105 moduleName = names[names.size() - 1];
107 std::string subtitle;
110 subtitle =
"Andersen's analysis bitvector";
112 subtitle =
"flow-sensitive analysis bitvector";
114 subtitle =
"CFL analysis bitvector";
116 subtitle =
"Type analysis bitvector";
118 subtitle =
"DDA bitvector";
120 subtitle =
"bitvector";
122 SVFUtil::outs() <<
"\n****Persistent Points-To Cache Statistics: " << subtitle <<
"****\n";
123 SVFUtil::outs() <<
"################ (program : " << moduleName <<
")###############\n";
125 ptCache.printStats(
"bitvector");
126 SVFUtil::outs() <<
"#######################################################" << std::endl;
142 expandedPts |=
pag->getAllFieldsObjVars(*pit);
150 for (
const NodeID o : pts)
154 expandedPts |=
pag->getAllFieldsObjVars(o);
166 outs() <<
"Storing ObjVar to '" << filename <<
"'...";
168 std::fstream f(filename.c_str(), std::ios_base::out);
171 outs() <<
" error opening file for writing!\n";
177 for (
auto it =
pag->begin(), ie =
pag->end(); it != ie; ++it)
182 if (NodeIDs.
test(
n))
continue;
203 for (
auto it =
pag->begin(), ie =
pag->end(); it != ie; ++it)
209 f << var <<
" -> { ";
230 for(SVFIR::OffsetToGepVarMap::const_iterator it = gepObjVarMap.begin(), eit = gepObjVarMap.end(); it != eit; it++)
234 f << offsetPair.first <<
" ";
236 f << offsetPair.second <<
" ";
238 f << it->second <<
"\n";
251 outs() <<
"Storing pointer analysis results to '" << filename <<
"'...";
254 std::fstream f(filename.c_str(), std::ios_base::app);
257 outs() <<
" error opening file for writing!\n";
271 for (
auto it =
pag->begin(), ie =
pag->end(); it != ie; ++it)
276 if (NodeIDs.
test(
n))
continue;
298 string delimiter1 =
" -> { ";
299 string delimiter2 =
" }";
300 map<NodeID, string> nodePtsMap;
301 map<string, PointsTo> strPtsMap;
307 if (line.at(0) ==
'[' || line ==
"---VERSIONED---")
continue;
308 if (line ==
"------")
break;
309 size_t pos = line.find(delimiter1);
310 if (pos == string::npos)
break;
311 if (line.back() !=
'}')
break;
314 NodeID var = atoi(line.substr(0, pos).c_str());
317 pos = pos + delimiter1.length();
318 size_t len = line.length() - pos - delimiter2.length();
319 string objs = line.substr(pos, len);
325 nodePtsMap[var] = objs;
326 if (strPtsMap.count(objs))
continue;
328 istringstream ss(objs);
336 strPtsMap[objs] = dstPts;
341 for (
auto t: nodePtsMap)
342 ptD->unionPts(t.first, strPtsMap[t.second]);
353 if (line ==
"------")
break;
355 istringstream ss(line);
359 ss >> base >>
offset >>id;
360 SVFIR::OffsetToGepVarMap::const_iterator iter = gepObjVarMap.find(std::make_pair(base,
offset));
361 if (iter == gepObjVarMap.end())
363 const SVFVar* node =
pag->getSVFVar(base);
367 obj = gepObjVar->getBaseObj();
378 assert(
false &&
"new gep obj node kind?");
394 if (line.empty() || line == delimiterStr)
397 istringstream ss(line);
400 ss >> base >> insensitive;
416 outs() <<
"Loading pointer analysis results from '" << filename <<
"'...";
418 ifstream F(filename.c_str());
421 outs() <<
" error opening file for reading!\n";
452 if (
getPAG()->isValidTopLevelPtr(node))
455 outs() <<
"\nNodeID " << node->
getId() <<
" ";
459 outs() <<
"\t\tPointsTo: {empty}\n\n";
463 outs() <<
"\t\tPointsTo: { ";
466 outs() << *it <<
" ";
484 pagNodes.insert(it->first);
489 outs() <<
"----------------------------------------------\n";
493 outs() <<
"----------------------------------------------\n";
504 for(CallSiteToFunPtrMap::const_iterator iter = callsites.begin(), eiter = callsites.end(); iter!=eiter; ++iter)
511 assert(vtbl !=
nullptr);
531 for(ThreadCallGraph::CallSiteSet::const_iterator it = tdCallGraph->forksitesBegin(),
532 eit = tdCallGraph->forksitesEnd(); it != eit; ++it)
534 const ValVar* pVar = tdCallGraph->getThreadAPI()->getForkedFun(*it);
541 if(
const ObjVar *objPN =
pag->getObjVar(*ii))
547 if(tdCallGraph->addIndirectForkEdge(*it, svfForkedFun))
548 newForkEdges[*it].insert(svfForkedFun);
567 for (
auto t: memToFieldsMap)
571 assert(obj &&
"Invalid baseObj in memToFieldsMap");
575 for (
NodeID id : t.second)
582 assert(
id == base &&
"Not a GepObj Node or a baseObj Node?");
595 if (!dropNodes.
test(obj))
597 NodeID baseObj =
pag->getBaseObjVarID(obj);
610 GepObjVarMap.erase(std::make_pair(base, apOffset));
611 memToFieldsMap[base].reset(
n);
613 pag->removeGNode(gepNode);
virtual void normalizePointsTo()
virtual void writeToFile(const std::string &filename)
Interface for analysis result storage on filesystem.
virtual bool readFromFile(const std::string &filename)
virtual void writeObjVarToFile(const std::string &filename)
virtual void clearPts(NodeID id, NodeID element)
Remove element from the points-to set of id.
virtual void readAndSetObjFieldSensitivity(std::ifstream &f, const std::string &delimiterStr)
AliasResult alias(const SVFVar *V1, const SVFVar *V2) override
Interface expose to users of our pointer analysis, given Value infos.
virtual void writeGepObjVarMapToFile(std::fstream &f)
void finalize() override
Finalization of pointer analysis, and normalize points-to information to Bit Vector representation.
virtual void writePtsResultToFile(std::fstream &f)
virtual void expandFIObjs(const PointsTo &pts, PointsTo &expandedPts)
Expand FI objects.
void dumpAllPts() override
void remapPointsToSets(void)
Remap all points-to sets to use the current mapping.
BVDataPTAImpl(SVFIR *pag, PTATY type, bool alias_check=true)
Constructor.
virtual void onTheFlyThreadCallGraphSolve(const CallSiteToFunPtrMap &callsites, CallEdgeMap &newForkEdges)
On the fly thread call graph construction respecting forksite.
PersistentPointsToCache< PointsTo > ptCache
virtual void onTheFlyCallGraphSolve(const CallSiteToFunPtrMap &callsites, CallEdgeMap &newEdges)
On the fly call graph construction.
virtual bool updateCallGraph(const CallSiteToFunPtrMap &)
Update callgraph. This should be implemented by its subclass.
std::unique_ptr< PTDataTy > ptD
Points-to data.
PersistentPointsToCache< PointsTo > & getPtCache()
PTData< NodeID, NodeSet, NodeID, PointsTo > PTDataTy
void dumpTopLevelPtsTo() override
const PointsTo & getPts(NodeID id) override
virtual void readPtsResultFromFile(std::ifstream &f)
PTDataTy * getPTDataTy() const
Get points-to data structure.
virtual bool addPts(NodeID id, NodeID ptd)
virtual void readGepObjVarMapFromFile(std::ifstream &f)
bool isFunction() const
object attributes methods
bool isFieldInsensitive() const
Return true if its field limit is 0.
const SVFVar * getVtablePtr() const
bool isVirtualCall() const
virtual const FunObjVar * getFunction() const
Get containing function, or null for globals/constants.
IDToNodeMapTy::iterator iterator
APOffset getConstantFieldIdx() const
offset of the mem object
static NodeIDAllocator * get(void)
Return (singleton) allocator.
void increaseNumOfObjAndNodes()
static const Option< bool > INCDFPTData
static const OptionMap< PTBackingType > ptDataBacking
PTData type.
static const Option< u32_t > MaxFieldLimit
Maximum number of field derivations for an object.
virtual void remapAllPts(void)=0
Remaps all points-to sets to use the current mapping.
bool isFieldInsensitive(NodeID id) const
virtual void finalize()
Finalization of a pointer analysis, including checking alias correctness.
virtual void dumpPts(NodeID ptr, const PointsTo &pts)
bool print_stat
User input flags.
OrderedMap< const CallICFGNode *, FunctionSet > CallEdgeMap
bool containBlackHoleNode(const PointsTo &pts)
Determine whether a points-to contains a black hole or constant node.
PTAImplTy ptaImplTy
PTA implementation type.
OrderedNodeSet & getAllValidPtrs()
Get all Valid Pointers for resolution.
virtual void resolveIndCalls(const CallICFGNode *cs, const PointsTo &target, CallEdgeMap &newEdges)
Resolve indirect call edges.
CallGraph * callgraph
Call graph used for pointer analysis.
PointerAnalysis(SVFIR *pag, PTATY ty=PTATY::Default_PTA, bool alias_check=true)
Constructor.
virtual void resolveCPPIndCalls(const CallICFGNode *cs, const PointsTo &target, CallEdgeMap &newEdges)
Resolve cpp indirect call edges.
void setObjFieldInsensitive(NodeID id)
SVFIR::CallSiteToFunPtrMap CallSiteToFunPtrMap
PTATY ptaTy
Pointer analysis Type.
bool empty() const
Returns true if set is empty.
const_iterator end() const
void set(u32_t n)
Inserts n in the set.
NodeBS toNodeBS() const
Returns this points-to set as a NodeBS.
const_iterator begin() const
bool intersects(const PointsTo &rhs) const
Returns true if this set and rhs share any elements.
std::pair< NodeID, APOffset > GepOffset
const SVFVar * getSVFVar(NodeID id) const
ObjVar/GepObjVar/BaseObjVar.
Map< NodeID, NodeBS > MemObjToFieldsMap
Map< GepOffset, NodeID > OffsetToGepVarMap
NodeID getId() const
Get ID.
SparseBitVectorIterator iterator
bool test(unsigned Idx) const
std::enable_if_t<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type > cast(const Y &Val)
LLVM_NODISCARD bool isa(const Y &Val)
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)
std::vector< std::string > split(const std::string &s, char separator)
Split into two substrings around the first occurrence of a separator string.
@ BVDataImpl
Represents BVDataPTAImpl.
PTATY
Pointer analysis type list.
@ Cxt_DDA
context sensitive DDA
@ VFS_WPA
Versioned sparse flow-sensitive WPA.
@ Andersen_WPA
Andersen PTA.
@ FSSPARSE_WPA
Sparse flow sensitive WPA.
@ AndersenSFR_WPA
Stride-based field representation.
@ FieldS_DDA
Field sensitive DDA.
@ FlowS_DDA
Flow sensitive DDA.
@ AndersenWaveDiff_WPA
Diff wave propagation andersen-style WPA.
@ CFLFICI_WPA
Flow-, context-, insensitive CFL-reachability-based analysis.
@ TypeCPP_WPA
Type-based analysis for C++.
@ FSDATAFLOW_WPA
Traditional Dataflow-based flow sensitive WPA.
@ Steensgaard_WPA
Steensgaard PTA.
@ FSCS_WPA
Flow-, context- sensitive WPA.
@ CFLFSCS_WPA
Flow-, context-, CFL-reachability-based analysis.
@ Andersen_BASE
Base Andersen PTA.
@ AndersenSCD_WPA
Selective cycle detection andersen-style WPA.
OrderedSet< NodeID > OrderedNodeSet