26 assert(version !=
invalidVersion &&
"VersionedFlowSensitive::atKey: trying to use an invalid version!");
27 return std::make_pair(
var, version);
101 const MRSVFGNode *mr = SVFUtil::dyn_cast<MRSVFGNode>(
ln);
132 std::vector<std::pair<const SVFGNode *, const PointsTo *>>
prelabeledNodes;
144 const NodeID p = store->getPAGDstNodeID();
205 else if (
const MRSVFGNode *mr = SVFUtil::dyn_cast<MRSVFGNode>(
sn))
211 assert(
false &&
"VFS::meldLabel: unexpected prelabeled node!");
216 std::vector<const IndirectSVFGEdge *>
footprint;
312 const NodeID m =
ie->getDstNode()->getId();
314 if (!
ie->getPointsTo().test(
o))
continue;
396 if (
scc == -1)
continue;
416 std::vector<std::thread>
workers;
434 assert(
l <
deltaMap.size() &&
"VFS::delta: deltaMap is missing SVFG nodes!");
450 if (SVFUtil::isa<StoreSVFGNode>(
it->second))
isStoreMap[
it->first] =
true;
451 else if (SVFUtil::isa<LoadSVFGNode>(
it->second))
isLoadMap[
it->first] =
true;
457 assert(
l <
isStoreMap.size() &&
"VFS::isStore: isStoreMap is missing SVFG nodes!");
463 assert(
l <
isLoadMap.size() &&
"VFS::isLoad: isLoadMap is missing SVFG nodes!");
513 if (
const CallICFGNode *
cbn = SVFUtil::dyn_cast<CallICFGNode>(
s->getICFGNode()))
534 if (SVFUtil::isa<IndirectSVFGEdge>(e))
toDeleteFromIn.push_back(e);
579 assert(
dvp !=
nullptr &&
"VFS::propagateVersion: propagation dummy node not found?");
613 if (SVFUtil::isa<PHISVFGNode>(
dstNode)
614 || SVFUtil::isa<FormalParmSVFGNode>(
dstNode)
615 || SVFUtil::isa<ActualRetSVFGNode>(
dstNode))
622 assert(
ie !=
nullptr &&
"VFS::updateConnectedNodes: given direct edge?");
624 assert(
delta(dst) &&
"VFS::updateConnectedNodes: new edges should be to delta nodes!");
625 assert(
deltaSource(src) &&
"VFS::updateConnectedNodes: new indirect edges should be from delta source nodes!");
698 if (
ppt.empty())
return false;
742 for (
const ObjToVersionMap::value_type &
oc :
consume[
l])
782 std::vector<std::pair<unsigned, unsigned>>
keys;
786 unsigned v =
pit->first;
789 keys.push_back(std::make_pair(
v,
occ));
887 SVFUtil::outs() <<
" Version " <<
v <<
" is a reliance for statements: ";
919 if (
lvm->at(
loc).empty())
continue;
929 for (
const ObjToVersionMap::value_type &
ov :
lvm->at(
loc))
1016 std::error_code
err;
1017 std::fstream
f(
filename.c_str(), std::ios_base::app);
1031 for (
const VersionedFlowSensitive::ObjToVersionMap::value_type &
ov :
lov)
1037 f <<
"[ " <<
o <<
" " <<
v<<
" ]"<<
" -> { ";
1055 f <<
"---VERSIONED---\n";
1074 if (
line ==
"---VERSIONED---")
break;
1078 std::istringstream
ss(
pair);
1086 if (
pos == std::string::npos)
break;
1087 if (
line.back() !=
'}')
break;
1094 std::istringstream pt(
objs);
1112 std::vector<int> &
partOf,
1113 std::vector<const IndirectSVFGEdge *> &
footprint)
1120 std::stack<const SVFGNode *>
stack;
1141 std::vector<int> &
partOf,
1142 std::vector<const IndirectSVFGEdge *> &
footprint,
1144 std::stack<const SVFGNode *> &
stack,
1158 for (
const SVFGEdge *e :
v->getOutEdges())
1167 if (!
ie->getPointsTo().test(
object))
continue;
set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) add_llvm_executable(wpa wpa.cpp) target_link_libraries(wpa PUBLIC $
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)
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 NodeBS & getPointsTo() const
Return points-to of the MR.
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="")
static std::vector< NodeID > getReverseNodeMapping(const std::vector< NodeID > &nodeMapping)
static Option< bool > OPTSVFG
static const Option< bool > PredictPtOcc
static const Option< u32_t > VersioningThreads
Number of threads for the versioning phase.
Set< const CallICFGNode * > CallInstSet
void getIndCallSitesInvokingCallee(const SVFFunction *callee, PTACallGraphEdge::CallInstSet &csSet)
PTATY
Pointer analysis type list.
bool isFieldInsensitive(NodeID id) const
PTAStat * stat
Statistics.
PTACallGraph * 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.
NodeID getId() const
Get ID.
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 SVFFunction * isFunEntrySVFGNode(const SVFGNode *node) const
Whether a node is function entry SVFGNode.
bool isConstantObj(NodeID id) const
const CallSiteToFunPtrMap & getIndirectCallsites() const
Add/get indirect callsites.
const MemObj * getObject(NodeID id) const
static double getClk(bool mark=false)
virtual bool isPointer() const
Whether it is a pointer.
NodeID getPAGDstNodeID() const
PAGNode * getPAGSrcNode() const
PAGNode * getPAGDstNode() const
NodeID getPAGSrcNodeID() 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.
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)
VersionedFlowSensitive(SVFIR *_pag, PTATY type=VFS_WPA)
Constructor.
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
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
llvm::IRBuilder IRBuilder