14#ifndef PERSISTENT_POINTSTO_H_
15#define PERSISTENT_POINTSTO_H_
25template <
typename Key,
typename KeySet,
typename Data,
typename DataSet>
26class PersistentDFPTData;
27template <
typename Key,
typename KeySet,
typename Data,
typename DataSet>
28class PersistentIncDFPTData;
29template <
typename Key,
typename KeySet,
typename Data,
typename DataSet,
typename VersionedKey,
typename VersionedKeySet>
30class PersistentVersionedPTData;
33template <
typename Key,
typename KeySet,
typename Data,
typename DataSet>
36 template <
typename K,
typename KS,
typename D,
typename DS,
typename VK,
typename VKS>
67 assert(this->
rev &&
"PersistentPTData::getRevPts: constructed without reverse PT support!");
125 for (
const typename KeyToIDMap::value_type &
ki :
ptsMap)
147 return ptd->getPTDTY() == PTDataTy::PersBase;
199template <
typename Key,
typename KeySet,
typename Data,
typename DataSet>
231 assert(this->
rev &&
"PersistentDiffPTData::getRevPts: constructed without reverse PT support!");
318 return ptd->getPTDTY() == PTDataTy::PersDiff;
333template <
typename Key,
typename KeySet,
typename Data,
typename DataSet>
365 assert(
false &&
"PersistentDFPTData::getRevPts: not supported yet!");
473 for (
const typename KeyToIDMap::value_type &
ki :
inKeyToId)
504 for (
const typename DFKeyToIDMap::value_type &
lki :
dfInPtsMap)
506 for (
const typename KeyToIDMap::value_type &
ki :
lki.second)
514 for (
const typename KeyToIDMap::value_type &
ki :
lki.second)
543 return ptd->getPTDTY() == PTDataTy::PersDataFlow
544 ||
ptd->getPTDTY() == PTDataTy::PersIncDataFlow;
579template <
typename Key,
typename KeySet,
typename Data,
typename DataSet>
804template <
typename Key,
typename KeySet,
typename Data,
typename DataSet,
typename VersionedKey,
typename VersionedKeySet>
837 assert(this->
rev &&
"PersistentVersionedPTData::getRevPts: constructed without reverse PT support!");
842 assert(this->
rev &&
"PersistentVersionedPTData::getVersionedKeyRevPts: constructed without reverse PT support!");
920 SVFUtil::mergePtsOccMaps<DataSet>(
allPts,
tlPTData.ptCache.getAllPts());
930 SVFUtil::outs() <<
"== Address-taken points-to information\n";
943 return ptd->getPTDTY() == PTDataTy::PersVersioned;
bool rev
Whether we maintain reverse points-to sets or not.
PTDataTy
Types of a points-to data structures.
DFPTData backed by a PersistentPointsToCache.
void clearFullPts(const Key &var) override
Fully clears the points-to set of var.
Map< LocID, KeyToIDMap > DFKeyToIDMap
bool updateATVPts(const Key &srcVar, LocID dstLoc, const Key &dstVar) override
Update address-taken variables OUT[dstLoc:dstVar] with points-to of top-level pointers.
bool hasDFInSet(LocID loc) const override
bool updateDFInFromIn(LocID srcLoc, const Key &srcVar, LocID dstLoc, const Key &dstVar) override
bool updateDFInFromOut(LocID srcLoc, const Key &srcVar, LocID dstLoc, const Key &dstVar) override
Union (IN[dstLoc:dstVar], OUT[srcLoc:srcVar]).
bool updateAllDFInFromIn(LocID srcLoc, const Key &srcVar, LocID dstLoc, const Key &dstVar) override
Union (IN[dstLoc::dstVar], IN[srcLoc:srcVar]. There is no flag check, unlike the above.
bool unionPts(const Key &dstKey, const DataSet &srcDataSet) override
Performs pts(dstVar) = pts(dstVar) U srcDataSet.
bool unionPtsThroughIds(PointsToID &dst, PointsToID &src)
bool unionPts(const Key &dstKey, const Key &srcKey) override
Performs pts(dstVar) = pts(dstVar) U pts(srcVar).
PersistentPTData< Key, KeySet, Data, DataSet > persPTData
PTData for top-level pointers. We will also use its cache for address-taken pointers.
bool hasDFOutSet(LocID loc, const Key &var) const override
PTData< Key, KeySet, Data, DataSet > BasePTData
static bool classof(const PTData< Key, KeySet, Data, DataSet > *ptd)
bool updateAllDFInFromOut(LocID srcLoc, const Key &srcVar, LocID dstLoc, const Key &dstVar) override
Union (IN[dstLoc::dstVar], OUT[srcLoc:srcVar]. There is no flag check, unlike the above.
Map< DataSet, unsigned > getAllPts(bool liveOnly) const override
void clearPts(const Key &var, const Data &element) override
Clears element from the points-to set of var.
~PersistentDFPTData() override=default
void clearAllDFOutUpdatedVar(LocID) override
DFKeyToIDMap dfInPtsMap
Address-taken points-to sets in IN-sets.
BaseDFPTData::LocID LocID
PersistentDFPTData(PersistentPointsToCache< DataSet > &cache, bool reversePT=true, PTDataTy ty=PTDataTy::PersDataFlow)
bool addPts(const Key &dstKey, const Data &element) override
Adds element to the points-to set associated with var.
bool updateAllDFOutFromIn(LocID loc, const Key &singleton, bool strongUpdates) override
For each variable var in IN at loc, do updateDFOutFromIn(loc, var, loc, var).
bool updateDFOutFromIn(LocID srcLoc, const Key &srcVar, LocID dstLoc, const Key &dstVar) override
Union (OUT[dstLoc:dstVar], IN[srcLoc:srcVar]).
void clear() override
Clears all points-to sets as if nothing is stored.
void dumpPTData() override
Dump stored keys and points-to sets.
BasePTData::PTDataTy PTDataTy
const DataSet & getDFInPtsSet(LocID loc, const Key &var) override
const KeySet & getRevPts(const Data &) override
Get reverse points-to set of a datum.
static bool classof(const PersistentDFPTData< Key, KeySet, Data, DataSet > *)
bool hasDFInSet(LocID loc, const Key &var) const override
DFKeyToIDMap dfOutPtsMap
Address-taken points-to sets in OUT-sets.
PointsToID & getDFInPtIdRef(LocID loc, const Key &var)
bool updateTLVPts(LocID srcLoc, const Key &srcVar, const Key &dstVar) override
Update points-to set of top-level pointers with IN[srcLoc:srcVar].
PointsToID & getDFOutPtIdRef(LocID loc, const Key &var)
const DataSet & getDFOutPtsSet(LocID loc, const Key &var) override
BasePersPTData::KeyToIDMap KeyToIDMap
void remapAllPts() override
Remaps all points-to sets to use the current mapping.
PersistentPointsToCache< DataSet > & ptCache
bool hasDFOutSet(LocID loc) const override
DFPTData< Key, KeySet, Data, DataSet > BaseDFPTData
const DataSet & getPts(const Key &var) override
Get points-to set of var.
PersistentPTData< Key, KeySet, Data, DataSet > BasePersPTData
DiffPTData implemented with a persistent points-to backing.
bool computeDiffPts(Key &var, const DataSet &all) override
PersistentPTData< Key, KeySet, Data, DataSet > persPTData
Backing to implement basic PTData methods. Allows us to avoid multiple inheritance.
PersistentDiffPTData(PersistentPointsToCache< DataSet > &cache, bool reversePT=true, PTDataTy ty=PTDataTy::PersDiff)
Constructor.
Map< DataSet, unsigned > getAllPts(bool liveOnly) const override
~PersistentDiffPTData() override=default
void dumpPTData() override
Dump stored keys and points-to sets.
DiffPTData< Key, KeySet, Data, DataSet > BaseDiffPTData
PersistentPointsToCache< DataSet > & ptCache
void clearPts(const Key &var, const Data &element) override
Clears element from the points-to set of var.
const DataSet & getPts(const Key &var) override
Get points-to set of var.
BasePersPTData::KeyToIDMap KeyToIDMap
static bool classof(const PTData< Key, KeySet, Data, DataSet > *ptd)
void clearPropaPts(Key &var) override
Clear propagated points-to set of var.
const DataSet & getDiffPts(Key &var) override
Get diff points to.
bool addPts(const Key &dstKey, const Data &element) override
Adds element to the points-to set associated with var.
BasePTData::PTDataTy PTDataTy
PTData< Key, KeySet, Data, DataSet > BasePTData
PersistentPTData< Key, KeySet, Data, DataSet > BasePersPTData
void updatePropaPtsMap(Key &src, Key &dst) override
KeyToIDMap propaPtsMap
Points-to already propagated.
BasePersPTData::RevPtsMap RevPtsMap
void remapAllPts() override
Remaps all points-to sets to use the current mapping.
KeyToIDMap diffPtsMap
Diff points-to to be propagated.
const KeySet & getRevPts(const Data &data) override
Get reverse points-to set of a datum.
bool unionPts(const Key &dstKey, const Key &srcKey) override
Performs pts(dstVar) = pts(dstVar) U pts(srcVar).
void clear() override
Clears all points-to sets as if nothing is stored.
void clearFullPts(const Key &var) override
Fully clears the points-to set of var.
bool unionPts(const Key &dstKey, const DataSet &srcDataSet) override
Performs pts(dstVar) = pts(dstVar) U srcDataSet.
static bool classof(const PersistentDiffPTData< Key, KeySet, Data, DataSet > *)
Incremental version of the persistent data-flow points-to data structure.
UpdatedVarMap outUpdatedVarMap
UpdatedVarMap inUpdatedVarMap
const KeySet & getDFOutUpdatedVar(LocID loc)
Get all variables which have new pts info in loc's OUT set.
bool updateATVPts(const Key &srcVar, LocID dstLoc, const Key &dstVar) override
Update address-taken variables OUT[dstLoc:dstVar] with points-to of top-level pointers.
void setVarDFInSetUpdated(LocID loc, const Key &var)
Handle address-taken variables whose IN pts changed.
bool updateTLVPts(LocID srcLoc, const Key &srcVar, const Key &dstVar) override
Update points-to set of top-level pointers with IN[srcLoc:srcVar].
BasePTData::PTDataTy PTDataTy
bool updateAllDFOutFromIn(LocID loc, const Key &singleton, bool strongUpdates) override
For each variable var in IN at loc, do updateDFOutFromIn(loc, var, loc, var).
static bool classof(const PTData< Key, KeySet, Data, DataSet > *ptd)
PersistentIncDFPTData(PersistentPointsToCache< DataSet > &cache, bool reversePT=true, PTDataTy ty=BasePTData::PersIncDataFlow)
Constructor.
bool updateAllDFInFromOut(LocID srcLoc, const Key &srcVar, LocID dstLoc, const Key &dstVar) override
Union (IN[dstLoc::dstVar], OUT[srcLoc:srcVar]. There is no flag check, unlike the above.
bool varHasNewDFInPts(LocID loc, const Key &var)
Return TRUE if var has a new pts in loc's IN set.
bool updateDFInFromIn(LocID srcLoc, const Key &srcVar, LocID dstLoc, const Key &dstVar) override
static bool classof(const PersistentIncDFPTData< Key, KeySet, Data, DataSet > *)
PTData< Key, KeySet, Data, DataSet > BasePTData
BaseDFPTData::LocID LocID
const KeySet & getDFInUpdatedVar(LocID loc)
Get all variables which have new pts information in loc's IN set.
bool updateAllDFInFromIn(LocID srcLoc, const Key &srcVar, LocID dstLoc, const Key &dstVar) override
Union (IN[dstLoc::dstVar], IN[srcLoc:srcVar]. There is no flag check, unlike the above.
void setVarDFOutSetUpdated(LocID loc, const Key &var)
bool updateDFOutFromIn(LocID srcLoc, const Key &srcVar, LocID dstLoc, const Key &dstVar) override
Union (OUT[dstLoc:dstVar], IN[srcLoc:srcVar]).
void clearAllDFOutUpdatedVar(LocID loc) override
Map< LocID, KeySet > UpdatedVarMap
PersistentDFPTData< Key, KeySet, Data, DataSet > BasePersDFPTData
PersistentPTData< Key, KeySet, Data, DataSet > BasePersPTData
void removeVarFromDFOutUpdatedSet(LocID loc, const Key &var)
Remove var from loc's OUT updated set.
void removeVarFromDFInUpdatedSet(LocID loc, const Key &var)
Remove var from loc's IN updated set.
void clear() override
Clears all points-to sets as if nothing is stored.
~PersistentIncDFPTData() override=default
bool varHasNewDFOutPts(LocID loc, const Key &var)
Return TRUE if var has a new pts in loc's OUT set.
DFPTData< Key, KeySet, Data, DataSet > BaseDFPTData
bool updateDFInFromOut(LocID srcLoc, const Key &srcVar, LocID dstLoc, const Key &dstVar) override
Union (IN[dstLoc:dstVar], OUT[srcLoc:srcVar]).
PTData backed by a PersistentPointsToCache.
const DataSet & getPts(const Key &var) override
Get points-to set of var.
bool unionPtsFromId(const Key &dstKey, PointsToID srcId)
PersistentPointsToCache< DataSet > & ptCache
static bool classof(const PersistentPTData< Key, KeySet, Data, DataSet > *)
void clearRevPts(const DataSet &pts, const Key &k)
void clearSingleRevPts(KeySet &revSet, const Key &k)
bool addPts(const Key &dstKey, const Data &element) override
Adds element to the points-to set associated with var.
void clear() override
Clears all points-to sets as if nothing is stored.
static bool classof(const PTData< Key, KeySet, Data, DataSet > *ptd)
bool unionPts(const Key &dstKey, const Key &srcKey) override
Performs pts(dstVar) = pts(dstVar) U pts(srcVar).
Map< DataSet, unsigned > getAllPts(bool liveOnly) const override
PersistentPTData(PersistentPointsToCache< DataSet > &cache, bool reversePT=true, PTDataTy ty=PTDataTy::PersBase)
Constructor.
~PersistentPTData() override=default
BasePTData::PTDataTy PTDataTy
void remapAllPts() override
Remaps all points-to sets to use the current mapping.
PTData< Key, KeySet, Data, DataSet > BasePTData
void clearPts(const Key &var, const Data &element) override
Clears element from the points-to set of var.
void dumpPTData() override
Dump stored keys and points-to sets.
bool unionPts(const Key &dstKey, const DataSet &srcData) override
Performs pts(dstVar) = pts(dstVar) U srcDataSet.
const KeySet & getRevPts(const Data &data) override
Get reverse points-to set of a datum.
Map< Key, PointsToID > KeyToIDMap
Map< Data, KeySet > RevPtsMap
void clearFullPts(const Key &var) override
Fully clears the points-to set of var.
PointsToID unionPts(PointsToID lhs, PointsToID rhs)
Unions lhs and rhs and returns their union's ID.
PointsToID intersectPts(PointsToID lhs, PointsToID rhs)
Intersects lhs and rhs (lhs AND rhs) and returns the intersection's ID.
Map< Data, unsigned > getAllPts(void)
const Data & getActualPts(PointsToID id) const
Returns the points-to set which id represents. id must be stored in the cache.
PointsToID complementPts(PointsToID lhs, PointsToID rhs)
Relatively complements lhs and rhs (lhs \ rhs) and returns it's ID.
void remapAllPts(void)
Remaps all points-to sets stored in the cache to the current mapping.
static PointsToID emptyPointsToId(void)
PointsToID emplacePts(const Data &pts)
void clearFullPts(const Key &k) override
Fully clears the points-to set of var.
bool unionPts(const Key &dstVar, const Key &srcVar) override
Performs pts(dstVar) = pts(dstVar) U pts(srcVar).
static bool classof(const PTData< Key, KeySet, Data, DataSet > *ptd)
PersistentPTData< VersionedKey, VersionedKeySet, Data, DataSet >::KeyToIDMap VersionedKeyToIDMap
static bool classof(const PersistentVersionedPTData< Key, KeySet, Data, DataSet, VersionedKey, VersionedKeySet > *)
PersistentPTData< Key, KeySet, Data, DataSet > tlPTData
PTData for Keys (top-level pointers, generally).
const DataSet & getPts(const VersionedKey &vk) override
PersistentPTData< Key, KeySet, Data, DataSet >::KeyToIDMap KeyToIDMap
bool addPts(const VersionedKey &vk, const Data &element) override
void clearPts(const Key &k, const Data &element) override
Clears element from the points-to set of var.
const KeySet & getRevPts(const Data &data) override
Get reverse points-to set of a datum.
void remapAllPts() override
Remaps all points-to sets to use the current mapping.
PersistentVersionedPTData(PersistentPointsToCache< DataSet > &cache, bool reversePT=true, PTDataTy ty=PTDataTy::PersVersioned)
bool unionPts(const VersionedKey &dstVar, const Key &srcVar) override
BasePTData::PTDataTy PTDataTy
PersistentPTData< VersionedKey, VersionedKeySet, Data, DataSet > atPTData
PTData for VersionedKeys (address-taken objects, generally).
void clearPts(const VersionedKey &vk, const Data &element) override
~PersistentVersionedPTData() override=default
void clearFullPts(const VersionedKey &vk) override
const DataSet & getPts(const Key &vk) override
Get points-to set of var.
bool unionPts(const Key &dstVar, const DataSet &srcDataSet) override
Performs pts(dstVar) = pts(dstVar) U srcDataSet.
void dumpPTData() override
Dump stored keys and points-to sets.
bool unionPts(const VersionedKey &dstVar, const DataSet &srcDataSet) override
VersionedPTData< Key, KeySet, Data, DataSet, VersionedKey, VersionedKeySet > BaseVersionedPTData
bool addPts(const Key &k, const Data &element) override
Adds element to the points-to set associated with var.
PTData< Key, KeySet, Data, DataSet > BasePTData
bool unionPts(const Key &dstVar, const VersionedKey &srcVar) override
bool unionPts(const VersionedKey &dstVar, const VersionedKey &srcVar) override
const VersionedKeySet & getVersionedKeyRevPts(const Data &data) override
void clear() override
Clears all points-to sets as if nothing is stored.
Map< DataSet, unsigned > getAllPts(bool liveOnly) const override
std::ostream & outs()
Overwrite llvm::outs()
void removeKey(const Key &key, KeySet &keySet)
Removes an element from a Set/CondSet (or anything implementing ::erase).
void insertKey(const Key &key, KeySet &keySet)
Inserts an element into a Set/CondSet (with ::insert).
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
llvm::IRBuilder IRBuilder