Static Value-Flow Analysis
Loading...
Searching...
No Matches
VersionedFlowSensitiveStat.cpp
Go to the documentation of this file.
1//===- VersionedFlowSensitiveStat.cpp -- Statistics for VFSPTA -//
2
3/*
4 * VersionedFlowSensitiveStat.cpp
5 *
6 * Created on: 25/07/2020
7 * Author: mbarbar
8 */
9
10#include "Util/SVFUtil.h"
11#include "WPA/WPAStat.h"
14
15using namespace SVF;
16using namespace SVFUtil;
17
34
36{
37 // Largely based on that in FlowSensitiveStat. Would be better to split the FSStat version
38 // and reuse code rather than copy.
39 assert(SVFUtil::isa<VersionedFlowSensitive>(vfspta) && "VFSStat::performStat: not given VFSPTA.");
40 endClk();
41
42 clearStat();
43
44 SVFIR *pag = vfspta->getPAG();
45
48
51 Set<SymID> nodeSet;
52 for (SVFIR::const_iterator it = pag->begin(); it != pag->end(); ++it)
53 {
54 NodeID nodeId = it->first;
55 PAGNode* pagNode = it->second;
56 if (SVFUtil::isa<ObjVar>(pagNode))
57 {
58 const MemObj *memObj = pag->getBaseObj(nodeId);
60 if (nodeSet.insert(baseId).second)
61 {
62 if (memObj->isFieldInsensitive()) fiObjNumber++;
63 else fsObjNumber++;
64 }
65 }
66 }
67
68 PTNumStatMap["FIObjNum"] = fiObjNumber;
69 PTNumStatMap["FSObjNum"] = fsObjNumber;
70
71 unsigned numOfCopy = 0;
72 unsigned numOfStore = 0;
73 for (SVFG::iterator it = vfspta->svfg->begin(); it != vfspta->svfg->end(); ++it)
74 {
75 SVFGNode* svfgNode = it->second;
76 if (SVFUtil::isa<CopySVFGNode>(svfgNode)) numOfCopy++;
77 else if (SVFUtil::isa<StoreSVFGNode>(svfgNode)) numOfStore++;
78 }
79
81
82 timeStatMap["TotalTime"] = (endTime - startTime)/TIMEINTERVAL;
83 timeStatMap["SolveTime"] = vfspta->solveTime;
84 timeStatMap["SCCTime"] = vfspta->sccTime;
85 timeStatMap["ProcessTime"] = vfspta->processTime;
86 timeStatMap["PropagationTime"] = vfspta->propagationTime;
87 timeStatMap["DirectPropaTime"] = vfspta->directPropaTime;
88 timeStatMap["IndirectPropaTime"] = vfspta->indirectPropaTime;
89 timeStatMap["Strong/WeakUpdTime"] = vfspta->updateTime;
90 timeStatMap["AddrTime"] = vfspta->addrTime;
91 timeStatMap["CopyTime"] = vfspta->copyTime;
92 timeStatMap["GepTime"] = vfspta->gepTime;
93 timeStatMap["LoadTime"] = vfspta->loadTime;
94 timeStatMap["StoreTime"] = vfspta->storeTime;
95 timeStatMap["UpdateCGTime"] = vfspta->updateCallGraphTime;
96 timeStatMap["PhiTime"] = vfspta->phiTime;
97 timeStatMap["meldLabelingTime"] = vfspta->meldLabelingTime;
98 timeStatMap["PrelabelingTime"] = vfspta->prelabelingTime;
99 timeStatMap["VersionPropTime"] = vfspta->versionPropTime;
100
101 PTNumStatMap["TotalPointers"] = pag->getValueNodeNum() + pag->getFieldValNodeNum();
102 PTNumStatMap["TotalObjects"] = pag->getObjectNodeNum() + pag->getFieldObjNodeNum();
103
104 PTNumStatMap["Pointers"] = pag->getValueNodeNum();
105 PTNumStatMap["MemObjects"] = pag->getObjectNodeNum();
106 PTNumStatMap["DummyFieldPtrs"] = pag->getFieldValNodeNum();
107 PTNumStatMap["FieldObjs"] = pag->getFieldObjNodeNum();
108
109 PTNumStatMap["TotalVersions"] = _NumVersions;
110 PTNumStatMap["MaxVersionsForObj"] = _MaxVersions;
111 PTNumStatMap["TotalNonEmptyVPts"] = _NumNonEmptyVersions;
112 PTNumStatMap["TotalEmptyVPts"] = _NumEmptyVersions;
113 PTNumStatMap["TotalExistingVPts"] = _NumUsedVersions;
114 PTNumStatMap["TotalSingleVObjs"] = _NumSingleVersion;
115
116 PTNumStatMap["CopysNum"] = numOfCopy;
117 PTNumStatMap["StoresNum"] = numOfStore;
118
119 PTNumStatMap["SolveIterations"] = vfspta->numOfIteration;
120
121 PTNumStatMap["IndEdgeSolved"] = vfspta->getNumOfResolvedIndCallEdge();
122
123 PTNumStatMap["StrongUpdates"] = vfspta->svfgHasSU.count();
124
125 PTNumStatMap["MaxPtsSize"] = _MaxPtsSize;
126 PTNumStatMap["MaxTopLvlPtsSize"] = _MaxTopLvlPtsSize;
127 PTNumStatMap["MaxVersionPtsSize"] = _MaxVersionPtsSize;
128
129 timeStatMap["AvgPtsSize"] = _AvgPtsSize;
130 timeStatMap["AvgTopLvlPtsSize"] = _AvgTopLvlPtsSize;
131 timeStatMap["AvgVersionPtsSize"] = _AvgVersionPtsSize;
132
133 PTNumStatMap["ProcessedAddr"] = vfspta->numOfProcessedAddr;
134 PTNumStatMap["ProcessedCopy"] = vfspta->numOfProcessedCopy;
135 PTNumStatMap["ProcessedGep"] = vfspta->numOfProcessedGep;
136 PTNumStatMap["ProcessedLoad"] = vfspta->numOfProcessedLoad;
137 PTNumStatMap["ProcessedStore"] = vfspta->numOfProcessedStore;
138 PTNumStatMap["ProcessedPhi"] = vfspta->numOfProcessedPhi;
139 PTNumStatMap["ProcessedAParam"] = vfspta->numOfProcessedActualParam;
140 PTNumStatMap["ProcessedFRet"] = vfspta->numOfProcessedFormalRet;
141 PTNumStatMap["ProcessedMSSANode"] = vfspta->numOfProcessedMSSANode;
142
143 PTNumStatMap["NumOfNodesInSCC"] = vfspta->numOfNodesInSCC;
144 PTNumStatMap["MaxSCCSize"] = vfspta->maxSCCSize;
145 PTNumStatMap["NumOfSCC"] = vfspta->numOfSCC;
146 timeStatMap["AverageSCCSize"] = (vfspta->numOfSCC == 0) ? 0 :
148
149 PTAStat::printStat("Versioned Flow-Sensitive Pointer Analysis Statistics");
150}
151
153{
154 // TODO! Need to merge yield/consume.
156 _MaxVersions = 0;
157
160 {
162 })
163 {
165 {
166 for (const VersionedFlowSensitive::ObjToVersionMap::value_type &ov : lov)
167 {
168 const NodeID o = ov.first;
169 const Version v = ov.second;
170
171 ++_NumVersions;
172
173 // If the version was just over-approximate and never accessed, ignore.
174 // TODO: with vPtD changed there is no interface to check if the PTS
175 // exists; an emptiness check is *not* an existence check.
176 if (vfspta->vPtD->getPts(vfspta->atKey(o, v)).empty()) continue;
177
178 const PointsTo &ovPts = vfspta->vPtD->getPts(vfspta->atKey(o, v));
179 if (!ovPts.empty()) ++_NumNonEmptyVersions;
180 else ++_NumEmptyVersions;
181
182 _TotalPtsSize += ovPts.count();
183 totalVersionPtsSize += ovPts.count();
184 if (ovPts.count() > _MaxVersionPtsSize) _MaxVersionPtsSize = ovPts.count();
185 }
186 }
187 }
188
190
192
194}
195
#define TIMEINTERVAL
Definition SVFType.h:512
cJSON * p
Definition cJSON.cpp:2559
const PointsTo & getPts(NodeID id) override
u32_t numOfProcessedLoad
Number of processed Phi node.
u32_t numOfProcessedCopy
Number of processed Addr node.
double gepTime
time of handling gep edges
double indirectPropaTime
time of points-to propagation of top-level pointers
double addrTime
time of handling address edges
double solveTime
time of solve.
u32_t numOfProcessedStore
Number of processed Load node.
double storeTime
time of store edges
double copyTime
time of handling copy edges
u32_t numOfProcessedGep
Number of processed Copy node.
u32_t maxSCCSize
Number of processed mssa node.
double loadTime
time of load edges
u32_t numOfProcessedActualParam
Number of processed Store node.
u32_t numOfProcessedPhi
Number of processed Gep node.
double propagationTime
time of points-to propagation.
u32_t numOfProcessedFormalRet
Number of processed actual param node.
double directPropaTime
time of points-to propagation of address-taken objects
double processTime
time of processNode.
u32_t numOfProcessedAddr
Statistics.
double phiTime
time of phi nodes.
double sccTime
time of SCC detection.
double updateTime
time of strong/weak updates.
u32_t numOfProcessedMSSANode
Number of processed formal ret node.
double updateCallGraphTime
time of updating call graph
iterator begin()
Iterators.
IDToNodeMapTy::const_iterator const_iterator
IDToNodeMapTy::iterator iterator
Node Iterators.
u32_t getValueNodeNum() const
Definition IRGraph.h:186
u32_t getObjectNodeNum() const
Definition IRGraph.h:190
SymID getId() const
Get the memory object id.
void performStat() override
Definition PTAStat.cpp:52
SVFIR * getPAG() const
u32_t getNumOfResolvedIndCallEdge() const
Return number of resolved indirect call edges.
u32_t count() const
Returns number of elements.
Definition PointsTo.cpp:111
u32_t getFieldObjNodeNum() const
Definition SVFIR.h:339
bool isValidTopLevelPtr(const SVFVar *node)
Definition SVFIR.cpp:685
const MemObj * getBaseObj(NodeID id) const
Definition SVFIR.h:481
u32_t getFieldValNodeNum() const
Node and edge statistics.
Definition SVFIR.h:335
NUMStatMap PTNumStatMap
Definition SVFStat.h:77
virtual void printStat(std::string str="")
Definition SVFStat.cpp:67
virtual void endClk()
Definition SVFStat.h:63
TIMEStatMap timeStatMap
Definition SVFStat.h:78
double endTime
Definition SVFStat.h:81
double startTime
Definition SVFStat.h:80
unsigned count() const
VersionedFlowSensitive * vfspta
Definition WPAStat.h:168
double _AvgVersionPtsSize
Average points-to set size for address-taken objects.
Definition WPAStat.h:218
u32_t _NumSingleVersion
Number of objects which have a single version.
Definition WPAStat.h:201
u32_t _NumEmptyVersions
Number of versions with empty points-to sets (actually empty, not never-accessed).
Definition WPAStat.h:199
u32_t _NumNonEmptyVersions
Number of versions with non-empty points-to sets (since versioning is over-approximate).
Definition WPAStat.h:197
u32_t _TotalPtsSize
Total of points-to set sizes for calculating averages.
Definition WPAStat.h:211
double _AvgPtsSize
Average size across all points-to sets.
Definition WPAStat.h:214
u32_t _NumVersions
Total number of versions across all objects.
Definition WPAStat.h:191
double _AvgTopLvlPtsSize
Average points-to set size for top-level pointers.
Definition WPAStat.h:216
u32_t _MaxVersionPtsSize
Max address-taken points-to set size.
Definition WPAStat.h:208
u32_t _MaxPtsSize
Largest PTS size.
Definition WPAStat.h:204
u32_t _MaxVersions
Most versions for a single object.
Definition WPAStat.h:193
u32_t _MaxTopLvlPtsSize
Max points-to set size in top-level pointers.
Definition WPAStat.h:206
u32_t _NumUsedVersions
Number of version PTSs actually used (sum of next two fields).
Definition WPAStat.h:195
void ptsSizeStat(void)
For all PTS size related statistics not handled by versionStat.
void versionStat(void)
For all version-related statistics.
BVDataPTAImpl::VersionedPTDataTy * vPtD
Points-to DS for working with versions.
LocVersionMap yield
Actual yield map. Yield analogue to consume.
double meldLabelingTime
Time to meld label SVFG.
static VersionedVar atKey(NodeID, Version)
Return key into vPtD for address-taken var of a specific version.
double prelabelingTime
Time to prelabel SVFG.
std::vector< ObjToVersionMap > LocVersionMap
double versionPropTime
Time to propagate versions to versions which rely on them.
Map< NodeID, Version > ObjToVersionMap
u32_t numOfIteration
num of iterations during constraint solving
Definition WPASolver.h:200
for isBitcode
Definition BasicTypes.h:68
u32_t NodeID
Definition GeneralType.h:55
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74
unsigned Version
unsigned SymID
Definition GeneralType.h:57
unsigned u32_t
Definition GeneralType.h:46