29 assert(version !=
invalidVersion &&
"VersionedFlowSensitive::atKey: trying to use an invalid version!");
30 return std::make_pair(
var, version);
104 const MRSVFGNode *mr = SVFUtil::dyn_cast<MRSVFGNode>(
ln);
135 std::vector<std::pair<const SVFGNode *, const PointsTo *>>
prelabeledNodes;
147 const NodeID p = store->getDstNodeID();
208 else if (
const MRSVFGNode *mr = SVFUtil::dyn_cast<MRSVFGNode>(
sn))
214 assert(
false &&
"VFS::meldLabel: unexpected prelabeled node!");
219 std::vector<const IndirectSVFGEdge *>
footprint;
315 const NodeID m =
ie->getDstNode()->getId();
317 if (!
ie->getPointsTo().test(
o))
continue;
399 if (
scc == -1)
continue;
419 std::vector<std::thread>
workers;
437 assert(
l <
deltaMap.size() &&
"VFS::delta: deltaMap is missing SVFG nodes!");
453 if (SVFUtil::isa<StoreSVFGNode>(
it->second))
isStoreMap[
it->first] =
true;
454 else if (SVFUtil::isa<LoadSVFGNode>(
it->second))
isLoadMap[
it->first] =
true;
460 assert(
l <
isStoreMap.size() &&
"VFS::isStore: isStoreMap is missing SVFG nodes!");
466 assert(
l <
isLoadMap.size() &&
"VFS::isLoad: isLoadMap is missing SVFG nodes!");
516 if (
const CallICFGNode *
cbn = SVFUtil::dyn_cast<CallICFGNode>(
s->getICFGNode()))
537 if (SVFUtil::isa<IndirectSVFGEdge>(e))
toDeleteFromIn.push_back(e);
582 assert(
dvp !=
nullptr &&
"VFS::propagateVersion: propagation dummy node not found?");
616 if (SVFUtil::isa<PHISVFGNode>(
dstNode)
617 || SVFUtil::isa<FormalParmSVFGNode>(
dstNode)
618 || SVFUtil::isa<ActualRetSVFGNode>(
dstNode))
625 assert(
ie !=
nullptr &&
"VFS::updateConnectedNodes: given direct edge?");
627 assert(
delta(dst) &&
"VFS::updateConnectedNodes: new edges should be to delta nodes!");
628 assert(
deltaSource(src) &&
"VFS::updateConnectedNodes: new indirect edges should be from delta source nodes!");
701 if (
ppt.empty())
return false;
745 for (
const ObjToVersionMap::value_type &
oc :
consume[
l])
785 std::vector<std::pair<unsigned, unsigned>>
keys;
790 unsigned v =
pit->first;
793 keys.push_back(std::make_pair(
v,
occ));
797 std::make_shared<std::vector<NodeID>>(
893 SVFUtil::outs() <<
" Version " <<
v <<
" is a reliance for statements: ";
925 if (
lvm->at(
loc).empty())
continue;
935 for (
const ObjToVersionMap::value_type &
ov :
lvm->at(
loc))
1022 std::error_code
err;
1023 std::fstream
f(
filename.c_str(), std::ios_base::app);
1037 for (
const VersionedFlowSensitive::ObjToVersionMap::value_type &
ov :
lov)
1043 f <<
"[ " <<
o <<
" " <<
v<<
" ]"<<
" -> { ";
1061 f <<
"---VERSIONED---\n";
1080 if (
line ==
"---VERSIONED---")
break;
1084 std::istringstream
ss(
pair);
1092 if (
pos == std::string::npos)
break;
1093 if (
line.back() !=
'}')
break;
1100 std::istringstream pt(
objs);
1118 std::vector<int> &
partOf,
1119 std::vector<const IndirectSVFGEdge *> &
footprint)
1126 std::stack<const SVFGNode *>
stack;
1147 std::vector<int> &
partOf,
1148 std::vector<const IndirectSVFGEdge *> &
footprint,
1150 std::stack<const SVFGNode *> &
stack,
1164 for (
const SVFGEdge *e :
v->getOutEdges())
1173 if (!
ie->getPointsTo().test(
object))
continue;
virtual const PointsTo & getPts(NodeID id)
Operation of points-to set.
VersionedPTDataTy * getVersionedPTDataTy() const
virtual void writeToFile(const std::string &filename)
Interface for analysis result storage on filesystem.
virtual void writeObjVarToFile(const std::string &filename)
virtual void readAndSetObjFieldSensitivity(std::ifstream &f, const std::string &delimiterStr)
const PointsTo & getPts(NodeID id) override
virtual void readPtsResultFromFile(std::ifstream &f)
virtual void readGepObjVarMapFromFile(std::ifstream &f)
Set< const CallICFGNode * > CallInstSet
void getIndCallSitesInvokingCallee(const FunObjVar *callee, CallGraphEdge::CallInstSet &csSet)
const_iterator end(void) const
bool push(const Data &data)
virtual void solveConstraints()
bool isStrongUpdate(const SVFGNode *node, NodeID &singleton)
Return TRUE if this is a strong update STORE statement.
SVFG::SVFGEdgeSetTy SVFGEdgeSetTy
double storeTime
time of store edges
void finalize() override
Finalize analysis.
bool processSVFGNode(SVFGNode *node)
double loadTime
time of load edges
bool updateCallGraph(const CallSiteToFunPtrMap &callsites) override
Update call graph.
void initialize() override
Initialize analysis.
std::vector< std::pair< hclust_fast_methods, std::vector< NodeID > > > candidateMappings
Save candidate mappings for evaluation's sake.
double updateTime
time of strong/weak updates.
iterator begin()
Iterators.
IDToNodeMapTy::const_iterator const_iterator
u32_t getTotalNodeNum() const
Get total number of node/edge.
IDToNodeMapTy::iterator iterator
Node Iterators.
const GEdgeSetTy & getInEdges() const
const ValVar * getDstNode() const
const NodeBS & getPointsTo() const
Return points-to of the MR.
static std::vector< NodeID > getReverseNodeMapping(const std::vector< NodeID > &nodeMapping)
static std::vector< NodeID > cluster(BVDataPTAImpl *pta, const std::vector< std::pair< NodeID, unsigned > > keys, std::vector< std::pair< hclust_fast_methods, std::vector< NodeID > > > &candidates, std::string evalSubtitle="", bool printStat=true)
static Option< bool > OPTSVFG
static const Option< bool > PredictPtOcc
static const Option< u32_t > VersioningThreads
Number of threads for the versioning phase.
bool isFieldInsensitive(NodeID id) const
bool print_stat
User input flags.
PTAStat * stat
Statistics.
CallGraph * getCallGraph() const
Return call graph.
virtual const NodeBS & getAllFieldsObjVars(NodeID id)
std::shared_ptr< std::vector< NodeID > > MappingPtr
static void setCurrentBestNodeMapping(MappingPtr newCurrentBestNodeMapping, MappingPtr newCurrentBestReverseNodeMapping)
u32_t count() const
Returns number of elements.
SVFGNode * getSVFGNode(NodeID id) const
Get a SVFG node.
const DummyVersionPropSVFGNode * addDummyVersionPropSVFGNode(const NodeID object, const NodeID version)
void removeSVFGEdge(SVFGEdge *edge)
Remove a SVFG edge.
const CallICFGNode * isCallSiteRetSVFGNode(const SVFGNode *node) const
Whether a node is callsite return SVFGNode.
const FunObjVar * isFunEntrySVFGNode(const SVFGNode *node) const
Whether a node is function entry SVFGNode.
bool isConstantObj(NodeID id) const
const BaseObjVar * getBaseObject(NodeID id) const
const CallSiteToFunPtrMap & getIndirectCallsites() const
Add/get indirect callsites.
static double getClk(bool mark=false)
NodeID getId() const
Get ID.
virtual bool isPointer() const
Check if this variable represents a pointer.
NodeID getSrcNodeID() const
NodeID getDstNodeID() const
const ValVar * getSrcNode() const
static void visit(VersionedFlowSensitive *vfs, const NodeID object, std::vector< int > &partOf, std::vector< const IndirectSVFGEdge * > &footprint, std::vector< NodeData > &nodeData, std::stack< const SVFGNode * > &stack, int &index, int ¤tSCC, const SVFGNode *v)
Called by detectSCCs then called recursively.
Version getYield(const NodeID l, const NodeID o) const
Returns the yielded version of o at l. If no such version exists, returns invalidVersion.
void dumpLocVersionMaps(void) const
Dumps maps consume and yield.
BVDataPTAImpl::VersionedPTDataTy * vPtD
Points-to DS for working with versions.
std::vector< bool > deltaMap
LocVersionMap yield
Actual yield map. Yield analogue to consume.
std::vector< bool > isStoreMap
isStoreMap[l] means SVFG node l is a store node.
virtual void updateConnectedNodes(const SVFGEdgeSetTy &newEdges) override
Update nodes connected during updating call graph.
virtual bool processLoad(const LoadSVFGNode *load) override
static bool meld(MeldVersion &mv1, const MeldVersion &mv2)
Melds v2 into v1 (in place), returns whether a change occurred.
VersionRelianceMap versionReliance
o -> (version -> versions which rely on it).
u32_t numPrelabelVersions
Number of versions created during prelabeling.
void removeAllIndirectSVFGEdges(void)
Removes all indirect edges in the SVFG.
Map< NodeID, NodeID > equivalentObject
void readVersionedAnalysisResultFromFile(std::ifstream &F)
virtual void buildDeltaMaps(void)
Fills in deltaMap and deltaSourceMap for the SVFG.
NodeBS & getStmtReliance(const NodeID o, const Version v)
Returns the statements which rely on o:v.
static const Version invalidVersion
If this version appears, there has been an error.
virtual bool deltaSource(const NodeID l) const
double meldLabelingTime
Time to meld label SVFG.
static VersionedFlowSensitive * vfspta
static VersionedVar atKey(NodeID, Version)
Return key into vPtD for address-taken var of a specific version.
Version getVersion(const NodeID l, const NodeID o, const LocVersionMap &lvm) const
Shared code for getConsume and getYield. They wrap this function.
std::vector< bool > isLoadMap
isLoadMap[l] means SVFG node l is a load node.
static void dumpMeldVersion(MeldVersion &v)
Dumps a MeldVersion to stdout.
double prelabelingTime
Time to prelabel SVFG.
void propagateVersion(NodeID o, Version v)
void prelabel(void)
Prelabel the SVFG: set y(o) for stores and c(o) for delta nodes to a new version.
virtual void initialize() override
Initialize analysis.
virtual void processNode(NodeID n) override
Handle various constraints.
virtual void buildIsStoreLoadMaps(void)
Fills in isStoreMap and isLoadMap.
virtual bool isLoad(const NodeID l) const
Returns true if l is a load node.
void dumpReliances(void) const
Dumps versionReliance and stmtReliance.
VersionedFlowSensitive(SVFIR *_pag, PTATY type=PTATY::VFS_WPA)
Constructor.
virtual bool delta(const NodeID l) const
std::vector< ObjToVersionMap > LocVersionMap
virtual bool processStore(const StoreSVFGNode *store) override
Set< NodeID > prelabeledObjects
void setConsume(const NodeID l, const NodeID o, const Version v)
Sets the consumed version of o at l to v.
virtual bool isStore(const NodeID l) const
Returns true if l is a store node.
friend class VersionedFlowSensitiveStat
void meldLabel(void)
Meld label the prelabeled SVFG.
void writeVersionedAnalysisResultToFile(const std::string &filename)
void setYield(const NodeID l, const NodeID o, const Version v)
Sets the yielded version of o at l to v.
void solveAndwritePtsToFile(const std::string &filename) override
virtual void finalize() override
Finalize analysis.
void setVersion(const NodeID l, const NodeID o, const Version v, LocVersionMap &lvm)
Shared code for setConsume and setYield. They wrap this function.
FIFOWorkList< NodeID > vWorklist
std::vector< Version > & getReliantVersions(const NodeID o, const Version v)
Returns the versions of o which rely on o:v.
void readPtsFromFile(const std::string &filename) override
virtual void cluster(void) override
Override since we want to assign different weights based on versioning.
std::vector< bool > deltaSourceMap
Map< NodeID, Map< Version, NodeBS > > stmtReliance
o x version -> statement nodes which rely on that o/version.
VarToPropNodeMap versionedVarToPropNode
double versionPropTime
Time to propagate versions to versions which rely on them.
Version getConsume(const NodeID l, const NodeID o) const
Returns the consumed version of o at l. If no such version exists, returns invalidVersion.
Map< NodeID, Version > ObjToVersionMap
u32_t numPrelabeledNodes
Additional statistics.
std::unique_ptr< SCC > scc
SCC.
virtual void pushIntoWorklist(NodeID id)
virtual void propagate(GNODE *v)
void setGraph(GraphType g)
std::ostream & outs()
Overwrite llvm::outs()
std::pair< NodeID, Version > VersionedVar
PTATY
Pointer analysis type list.
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
llvm::IRBuilder IRBuilder