30#ifndef INCLUDE_MEMORYMODEL_POINTERANALYSISIMPL_H_
31#define INCLUDE_MEMORYMODEL_POINTERANALYSISIMPL_H_
88 return ptD->getPts(
id);
92 return ptD->getRevPts(nodeId);
99 ptD->clearPts(
id, element);
105 ptD->clearFullPts(
id);
113 return ptD->unionPts(
id, target);
117 return ptD->unionPts(
id,ptd);
121 return ptD->addPts(
id,ptd);
141 virtual void writeToFile(
const std::string& filename);
165 assert(
false &&
"Virtual function not implemented!");
172 assert(diff &&
"BVDataPTAImpl::getDiffPTDataTy: not a DiffPTDataTy!");
179 assert(df &&
"BVDataPTAImpl::getDFPTDataTy: not a DFPTDataTy!");
186 assert(mdf &&
"BVDataPTAImpl::getMutDFPTDataTy: not a MutDFPTDataTy!");
193 assert(v &&
"BVDataPTAImpl::getVersionedPTDataTy: not a VersionedPTDataTy!");
210 std::unique_ptr<PTDataTy>
ptD;
217 const SVFVar* V2)
override
273 assert(
false &&
"no points-to data available");
305 assert(mut &&
"BVDataPTAImpl::getMutPTDataTy: not a MutPTDataTy!");
317 assert(
false &&
"CondPTAImpl::getPtsMap: not a PTData with a PtsMap!");
325 return ptD->getPts(
id);
329 return ptD->getRevPts(nodeId);
356 expandedCpts = cpts;;
359 if(
pag->getBaseObjVarID(cit->get_id())==cit->get_id())
361 NodeBS& fields =
pag->getAllFieldsObjVars(cit->get_id());
364 CVar cvar(cit->get_cond(),*it);
365 expandedCpts.
set(cvar);
384 return ptD->unionPts(
id, target);
389 return ptD->unionPts(
id,ptd);
394 return ptD->addPts(
id,ptd);
456 for(
typename MutPTDataTy::PtsMap::const_iterator it = ptsMap.begin(), eit=ptsMap.end(); it!=eit; ++it)
468 assert(
false &&
"CondPTAImpl::NormalizePointsTo: could not normalize points-to sets");
492 pts.
set(cit->get_id());
498 assert(
normalized &&
"Pts of all context-var have to be merged/normalized. Want to use getPts(CVar cvar)??");
504 assert(
normalized &&
"Pts of all context-vars have to be merged/normalized. Want to use getPts(CVar cvar)??");
510 assert(
normalized &&
"Pts of all context-var have to be merged/normalized. Want to use getPts(CVar cvar)??");
552 if(cit->get_id() ==
pag->getBlackHoleNode())
562 if(cit->get_id() ==
pag->getConstantNode())
568 virtual bool isCondCompatible(
const Cond& cxt1,
const Cond& cxt2,
bool singleton)
const = 0;
576 if (this->
getPAG()->isValidTopLevelPtr(node))
VersionedPTDataTy * getVersionedPTDataTy() const
PersistentDiffPTData< NodeID, NodeSet, NodeID, PointsTo > PersDiffPTDataTy
virtual void normalizePointsTo()
virtual void writeToFile(const std::string &filename)
Interface for analysis result storage on filesystem.
virtual bool readFromFile(const std::string &filename)
PersistentIncDFPTData< NodeID, NodeSet, NodeID, PointsTo > PersIncDFPTDataTy
virtual void writeObjVarToFile(const std::string &filename)
const NodeSet & getRevPts(NodeID nodeId) override
virtual void clearAllPts()
Clear all data.
virtual void clearPts(NodeID id, NodeID element)
Remove element from the points-to set of id.
~BVDataPTAImpl() override=default
Destructor.
virtual void readAndSetObjFieldSensitivity(std::ifstream &f, const std::string &delimiterStr)
DiffPTDataTy * getDiffPTDataTy() const
AliasResult alias(const SVFVar *V1, const SVFVar *V2) override
Interface expose to users of our pointer analysis, given Value infos.
MutablePTData< NodeID, NodeSet, NodeID, PointsTo > MutPTDataTy
DFPTData< NodeID, NodeSet, NodeID, PointsTo > DFPTDataTy
virtual void writeGepObjVarMapToFile(std::fstream &f)
void finalize() override
Finalization of pointer analysis, and normalize points-to information to Bit Vector representation.
MutableIncDFPTData< NodeID, NodeSet, NodeID, PointsTo > MutIncDFPTDataTy
bool mayAlias(const PointsTo &pts1, const PointsTo &pts2)
Convenience bool wrappers: return true if the two operands may/must/partial alias.
static bool classof(const PointerAnalysis *pta)
virtual void writePtsResultToFile(std::fstream &f)
PersistentDFPTData< NodeID, NodeSet, NodeID, PointsTo > PersDFPTDataTy
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.
MutableVersionedPTData< NodeID, NodeSet, NodeID, PointsTo, VersionedVar, Set< VersionedVar > > MutVersionedPTDataTy
BVDataPTAImpl(SVFIR *pag, PTATY type, bool alias_check=true)
Constructor.
MutDFPTDataTy * getMutDFPTDataTy() const
VersionedPTData< NodeID, NodeSet, NodeID, PointsTo, VersionedVar, Set< VersionedVar > > VersionedPTDataTy
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.
DFPTDataTy * getDFPTDataTy() const
DiffPTData< NodeID, NodeSet, NodeID, PointsTo > DiffPTDataTy
MutableDFPTData< NodeID, NodeSet, NodeID, PointsTo > MutDFPTDataTy
PersistentPointsToCache< PointsTo > & getPtCache()
MutableDiffPTData< NodeID, NodeSet, NodeID, PointsTo > MutDiffPTDataTy
void dumpCPts() override
dump and debug, print out conditional pts
PTData< NodeID, NodeSet, NodeID, PointsTo > PTDataTy
void dumpTopLevelPtsTo() override
virtual bool unionPts(NodeID id, NodeID ptd)
const PointsTo & getPts(NodeID id) override
PersistentVersionedPTData< NodeID, NodeSet, NodeID, PointsTo, VersionedVar, Set< VersionedVar > > PersVersionedPTDataTy
PersistentPTData< NodeID, NodeSet, NodeID, PointsTo > PersPTDataTy
virtual bool unionPts(NodeID id, const PointsTo &target)
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)
virtual void clearFullPts(NodeID id)
Clear points-to set of id.
virtual ~CondPTAImpl()
Destructor.
virtual bool addPts(CVar id, CVar ptd)
MutPTDataTy * getMutPTDataTy() const
virtual bool unionPts(CVar id, const CPtSet &target)
PtrToNSMap objToNSRevPtsMap
Normal points-to representation (without conditions).
PTDataTy * getPTDataTy() const
Get points-to data.
PtrToBVPtsMap ptrToBVPtsMap
Normal points-to representation (without conditions).
bool containConstantNode(const CPtSet &cpts)
Test constant node for cpts.
bool mustAlias(const CVar &var1, const CVar &var2)
Internal interface to be used for conditional points-to set queries.
CondStdSet< CVar > CPtSet
virtual const CPtSet & getCondPointsTo(NodeID ptr)
Given a pointer return its conditional points-to.
virtual bool unionPts(CVar id, CVar ptd)
Map< NodeID, CPtSet > PtrToCPtsMap
virtual const Set< CVar > & getRevPts(CVar nodeId)
CondPTAImpl(SVFIR *pag, PTATY type)
map a pointer to its conditional points-to set
bool hasPtsMap(void) const
bool contains(const CPtSet &cpts1, const CPtSet &cpts2)
void destroy()
Release memory.
PtrToCPtsMap ptrToCPtsMap
Conditional points-to representation (with conditions).
virtual bool isCondCompatible(const Cond &cxt1, const Cond &cxt2, bool singleton) const =0
Whether two conditions are compatible (to be implemented by child class).
PTData< CVar, Set< CVar >, CVar, CPtSet > PTDataTy
bool isSameVar(const CVar &var1, const CVar &var2) const
Whether two pointers/objects are the same one by considering their conditions.
void dumpTopLevelPtsTo()
Dump points-to information of top-level pointers.
Map< NodeID, NodeSet > PtrToNSMap
map a pointer to its BitVector points-to representation
void expandFIObjs(const CPtSet &cpts, CPtSet &expandedCpts)
Expand all fields of an aggregate in all points-to sets.
bool containBlackHoleNode(const CPtSet &cpts)
Test blk node for cpts.
virtual AliasResult alias(const CPtSet &pts1, const CPtSet &pts2)
Interface expose to users of our pointer analysis, given two conditional points-to sets.
virtual PointsTo getBVPointsTo(const CPtSet &cpts) const
Given a conditional pts return its bit vector points-to.
virtual NodeSet & getRevPts(NodeID obj)
Given an object return all pointers points to this object.
virtual void finalize()
Finalization of pointer analysis, and normalize points-to information to Bit Vector representation.
virtual void dumpCPts()
Print out conditional pts.
virtual void normalizePointsTo()
Normalize points-to information to BitVector/conditional representation.
bool normalized
Normalized flag.
Map< NodeID, PointsTo > PtrToBVPtsMap
virtual AliasResult alias(NodeID node1, NodeID node2)
Interface expose to users of our pointer analysis, given two pointers.
virtual AliasResult alias(const SVFVar *V1, const SVFVar *V2)
Interface expose to users of our pointer analysis, given Value infos.
virtual AliasResult alias(const CVar &var1, const CVar &var2)
Interface expose to users of our pointer analysis, given conditional variables.
bool overlap(const CPtSet &cpts1, const CPtSet &cpts2) const
Whether cpts1 and cpts2 have overlap points-to targets.
virtual void clearPts()
Clear all data.
virtual PointsTo & getPts(NodeID ptr)
Given a pointer return its bit vector points-to.
static bool classof(const PointerAnalysis *pta)
virtual const CPtSet & getPts(CVar id)
const MutPTDataTy::PtsMap & getPtsMap() const
MutablePTData< CVar, Set< CVar >, CVar, CPtSet > MutPTDataTy
PTDataTy * ptD
Points-to data.
bool empty() const
Set size.
OrderedSet< CVar >::const_iterator const_iterator
iterator begin()
Iterators.
void set(const Element &var)
Add the element into set.
const Cond & get_cond() const
DiffPTData implemented with points-to sets which are updated continuously.
Incremental version of the mutable data-flow points-to data structure.
PTData implemented using points-to sets which are created once and updated continuously.
Map< CVar, CPtSet > PtsMap
DFPTData backed by a PersistentPointsToCache.
DiffPTData implemented with a persistent points-to backing.
Incremental version of the persistent data-flow points-to data structure.
PTData backed by a PersistentPointsToCache.
bool isLocalVarInRecursiveFun(NodeID id) const
Whether a local variable is in function recursions.
virtual void finalize()
Finalization of a pointer analysis, including checking alias correctness.
OrderedMap< const CallICFGNode *, FunctionSet > CallEdgeMap
PTAImplTy ptaImplTy
PTA implementation type.
bool mayAlias(const SVFVar *V1, const SVFVar *V2)
Convenience bool wrappers: return true if the two operands may/must/partial alias.
OrderedNodeSet & getAllValidPtrs()
Get all Valid Pointers for resolution.
PointerAnalysis(SVFIR *pag, PTATY ty=PTATY::Default_PTA, bool alias_check=true)
Constructor.
PTAImplTy getImplTy() const
Return implementation type of the pointer analysis.
PTATY getAnalysisTy() const
Type of pointer analysis.
SVFIR::CallSiteToFunPtrMap CallSiteToFunPtrMap
bool isHeapMemObj(NodeID id) const
Whether this object is heap or array.
bool empty() const
Returns true if set is empty.
const_iterator end() const
void set(u32_t n)
Inserts n in the set.
const_iterator begin() const
const SVFVar * getSVFVar(NodeID id) const
ObjVar/GepObjVar/BaseObjVar.
NodeID getId() const
Get ID.
virtual const std::string toString() const
Get string representation.
SparseBitVectorIterator iterator
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)
@ BVDataImpl
Represents BVDataPTAImpl.
@ CondImpl
Represents CondPTAImpl.
PTATY
Pointer analysis type list.
@ Cxt_DDA
context sensitive DDA
@ PathS_DDA
Guarded value-flow DDA.
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map