Static Value-Flow Analysis
Loading...
Searching...
No Matches
SVF::VersionedFlowSensitiveStat Class Reference

#include <WPAStat.h>

Inheritance diagram for SVF::VersionedFlowSensitiveStat:
SVF::PTAStat SVF::SVFStat

Public Member Functions

 VersionedFlowSensitiveStat (VersionedFlowSensitive *pta)
virtual ~VersionedFlowSensitiveStat ()
virtual void performStat ()
Public Member Functions inherited from SVF::PTAStat
 PTAStat (PointerAnalysis *p)
virtual ~PTAStat ()
void setMemUsageBefore (u32_t vmrss, u32_t vmsize)
void setMemUsageAfter (u32_t vmrss, u32_t vmsize)
void callgraphStat () override
Public Member Functions inherited from SVF::SVFStat
 SVFStat ()
virtual ~SVFStat ()
virtual void startClk ()
virtual void endClk ()
virtual void printStat (std::string str="")
virtual void performStatPerQuery (NodeID)
virtual void printStatPerQuery (NodeID, const PointsTo &)

Public Attributes

VersionedFlowSensitive * vfspta
Public Attributes inherited from SVF::PTAStat
NodeBS localVarInRecursion
Public Attributes inherited from SVF::SVFStat
NUMStatMap generalNumMap
NUMStatMap PTNumStatMap
TIMEStatMap timeStatMap
double startTime
double endTime

Private Member Functions

void clearStat ()
void versionStat (void)
 For all version-related statistics.
void ptsSizeStat (void)
 For all PTS size related statistics not handled by versionStat.

Private Attributes

u32_t _NumVersions
 Total number of versions across all objects.
u32_t _MaxVersions
 Most versions for a single object.
u32_t _NumUsedVersions
 Number of version PTSs actually used (sum of next two fields).
u32_t _NumNonEmptyVersions
 Number of versions with non-empty points-to sets (since versioning is over-approximate).
u32_t _NumEmptyVersions
 Number of versions with empty points-to sets (actually empty, not never-accessed).
u32_t _NumSingleVersion
 Number of objects which have a single version.
u32_t _MaxPtsSize
 Largest PTS size.
u32_t _MaxTopLvlPtsSize
 Max points-to set size in top-level pointers.
u32_t _MaxVersionPtsSize
 Max address-taken points-to set size.
u32_t _TotalPtsSize
 Total of points-to set sizes for calculating averages.
double _AvgPtsSize
 Average size across all points-to sets.
double _AvgTopLvlPtsSize
 Average points-to set size for top-level pointers.
double _AvgVersionPtsSize
 Average points-to set size for address-taken objects.

Additional Inherited Members

Public Types inherited from SVF::SVFStat
enum class  ClockType { Wall , CPU }
typedef OrderedMap< std::string, u32_t > NUMStatMap
typedef OrderedMap< std::string, double > TIMEStatMap
Static Public Member Functions inherited from SVF::SVFStat
static double getClk (bool mark=false)
Static Public Attributes inherited from SVF::SVFStat
static bool printGeneralStats = true
 SVF's general statistics are only printed once even if you run multiple anayses.
static double timeOfBuildingLLVMModule = 0
static double timeOfBuildingSymbolTable = 0
static double timeOfBuildingSVFIR = 0
Protected Attributes inherited from SVF::PTAStat
PointerAnalysis * pta
u32_t _vmrssUsageBefore
u32_t _vmrssUsageAfter
u32_t _vmsizeUsageBefore
u32_t _vmsizeUsageAfter

Detailed Description

Definition at line 166 of file WPAStat.h.

Constructor & Destructor Documentation

◆ VersionedFlowSensitiveStat()

SVF::VersionedFlowSensitiveStat::VersionedFlowSensitiveStat ( VersionedFlowSensitive * pta)
inline

Definition at line 171 of file WPAStat.h.

171 : PTAStat(pta)
172 {
173 vfspta = pta;
174 clearStat();
175 startClk();
176 }
PointerAnalysis * pta
Definition PTAStat.h:73
PTAStat(PointerAnalysis *p)
Definition PTAStat.cpp:40
virtual void startClk()
Definition SVFStat.h:61
VersionedFlowSensitive * vfspta
Definition WPAStat.h:169

◆ ~VersionedFlowSensitiveStat()

virtual SVF::VersionedFlowSensitiveStat::~VersionedFlowSensitiveStat ( )
inlinevirtual

Definition at line 178 of file WPAStat.h.

178{ }

Member Function Documentation

◆ clearStat()

void VersionedFlowSensitiveStat::clearStat ( )
private

Definition at line 18 of file VersionedFlowSensitiveStat.cpp.

19{
20 _NumVersions = 0;
21 _MaxVersions = 0;
26 _MaxPtsSize = 0;
29 _TotalPtsSize = 0;
30 _AvgPtsSize = 0.0;
33}
double _AvgVersionPtsSize
Average points-to set size for address-taken objects.
Definition WPAStat.h:219
u32_t _NumSingleVersion
Number of objects which have a single version.
Definition WPAStat.h:202
u32_t _NumEmptyVersions
Number of versions with empty points-to sets (actually empty, not never-accessed).
Definition WPAStat.h:200
u32_t _NumNonEmptyVersions
Number of versions with non-empty points-to sets (since versioning is over-approximate).
Definition WPAStat.h:198
u32_t _TotalPtsSize
Total of points-to set sizes for calculating averages.
Definition WPAStat.h:212
double _AvgPtsSize
Average size across all points-to sets.
Definition WPAStat.h:215
u32_t _NumVersions
Total number of versions across all objects.
Definition WPAStat.h:192
double _AvgTopLvlPtsSize
Average points-to set size for top-level pointers.
Definition WPAStat.h:217
u32_t _MaxVersionPtsSize
Max address-taken points-to set size.
Definition WPAStat.h:209
u32_t _MaxPtsSize
Largest PTS size.
Definition WPAStat.h:205
u32_t _MaxVersions
Most versions for a single object.
Definition WPAStat.h:194
u32_t _MaxTopLvlPtsSize
Max points-to set size in top-level pointers.
Definition WPAStat.h:207
u32_t _NumUsedVersions
Number of version PTSs actually used (sum of next two fields).
Definition WPAStat.h:196

◆ performStat()

void VersionedFlowSensitiveStat::performStat ( )
virtual

Reimplemented from SVF::PTAStat.

Definition at line 35 of file VersionedFlowSensitiveStat.cpp.

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
49 u32_t fiObjNumber = 0;
50 u32_t fsObjNumber = 0;
51 Set<NodeID> 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 BaseObjVar* baseObj = pag->getBaseObject(nodeId);
59 NodeID baseId = baseObj->getId();
60 if (nodeSet.insert(baseId).second)
61 {
62 if (baseObj->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();
102 PTNumStatMap["TotalObjects"] = pag->getObjectNodeNum();
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 :
147 ((double)vfspta->numOfNodesInSCC / vfspta->numOfSCC);
148
149 PTAStat::printStat("Versioned Flow-Sensitive Pointer Analysis Statistics");
150}
#define TIMEINTERVAL
Definition SVFType.h:604
NodeID getId() const
Get the memory object id.
bool isFieldInsensitive() const
Return true if its field limit is 0.
iterator begin()
Iterators.
IDToNodeMapTy::const_iterator const_iterator
u32_t getObjectNodeNum()
Definition IRGraph.cpp:360
u32_t getValueNodeNum()
Definition IRGraph.cpp:347
void performStat() override
Definition PTAStat.cpp:53
u32_t getFieldObjNodeNum() const
Definition SVFIR.h:442
const BaseObjVar * getBaseObject(NodeID id) const
Definition SVFIR.h:499
u32_t getFieldValNodeNum() const
Node and edge statistics.
Definition SVFIR.h:438
NUMStatMap PTNumStatMap
Definition SVFStat.h:80
virtual void printStat(std::string str="")
Definition SVFStat.cpp:71
virtual void endClk()
Definition SVFStat.h:66
TIMEStatMap timeStatMap
Definition SVFStat.h:81
double endTime
Definition SVFStat.h:84
double startTime
Definition SVFStat.h:83
VFGNodeIDToNodeMapTy::iterator iterator
Definition VFG.h:80
void ptsSizeStat(void)
For all PTS size related statistics not handled by versionStat.
void versionStat(void)
For all version-related statistics.
LLVM_NODISCARD bool isa(const Y &Val)
Definition Casting.h:241
u32_t NodeID
Definition GeneralType.h:76
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
Definition GeneralType.h:51
VFGNode SVFGNode
Definition SVFG.h:43
SVFVar PAGNode
Definition IRGraph.h:40
unsigned u32_t
Definition GeneralType.h:67

◆ ptsSizeStat()

void VersionedFlowSensitiveStat::ptsSizeStat ( void )
private

For all PTS size related statistics not handled by versionStat.

Definition at line 196 of file VersionedFlowSensitiveStat.cpp.

197{
198 u32_t totalValidTopLvlPointers = 0;
199 u32_t totalTopLvlPtsSize = 0;
200 for (SVFIR::iterator it = vfspta->getPAG()->begin(); it != vfspta->getPAG()->end(); ++it)
201 {
202 if (!vfspta->getPAG()->isValidTopLevelPtr(it->second)) continue;
203
204 NodeID p = it->first;
205
206 totalValidTopLvlPointers++;
207
208 u32_t size = vfspta->getPts(p).count();
209 totalTopLvlPtsSize += size;
210 if (size > _MaxTopLvlPtsSize) _MaxTopLvlPtsSize = size;
211 }
212
213 if (totalValidTopLvlPointers != 0) _AvgTopLvlPtsSize = (double)totalTopLvlPtsSize / (double)totalValidTopLvlPointers;
214
215 _TotalPtsSize += totalTopLvlPtsSize;
216
217 if (_NumNonEmptyVersions + totalValidTopLvlPointers != 0)
218 {
219 _AvgPtsSize = (double)_TotalPtsSize / (double)(_NumNonEmptyVersions + totalValidTopLvlPointers);
220 }
221
223}
cJSON * p
Definition cJSON.cpp:2559
IDToNodeMapTy::iterator iterator

◆ versionStat()

void VersionedFlowSensitiveStat::versionStat ( void )
private

For all version-related statistics.

Definition at line 152 of file VersionedFlowSensitiveStat.cpp.

153{
154 // TODO! Need to merge yield/consume.
156 _MaxVersions = 0;
157
158 u32_t totalVersionPtsSize = 0;
160 {
161 &vfspta->consume, &vfspta->yield
162 })
163 {
164 for (const VersionedFlowSensitive::ObjToVersionMap &lov : *lvm)
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
191 if (_NumNonEmptyVersions != 0) _AvgVersionPtsSize = (double)totalVersionPtsSize / (double)_NumUsedVersions;
192
193 _TotalPtsSize += totalVersionPtsSize;
194}
bool empty() const
Returns true if set is empty.
Definition PointsTo.cpp:110
u32_t count() const
Returns number of elements.
Definition PointsTo.cpp:123
std::vector< ObjToVersionMap > LocVersionMap
Map< NodeID, Version > ObjToVersionMap
unsigned Version
Definition GeneralType.h:97

Member Data Documentation

◆ _AvgPtsSize

double SVF::VersionedFlowSensitiveStat::_AvgPtsSize
private

Average size across all points-to sets.

Definition at line 215 of file WPAStat.h.

◆ _AvgTopLvlPtsSize

double SVF::VersionedFlowSensitiveStat::_AvgTopLvlPtsSize
private

Average points-to set size for top-level pointers.

Definition at line 217 of file WPAStat.h.

◆ _AvgVersionPtsSize

double SVF::VersionedFlowSensitiveStat::_AvgVersionPtsSize
private

Average points-to set size for address-taken objects.

Definition at line 219 of file WPAStat.h.

◆ _MaxPtsSize

u32_t SVF::VersionedFlowSensitiveStat::_MaxPtsSize
private

Largest PTS size.

Definition at line 205 of file WPAStat.h.

◆ _MaxTopLvlPtsSize

u32_t SVF::VersionedFlowSensitiveStat::_MaxTopLvlPtsSize
private

Max points-to set size in top-level pointers.

Definition at line 207 of file WPAStat.h.

◆ _MaxVersionPtsSize

u32_t SVF::VersionedFlowSensitiveStat::_MaxVersionPtsSize
private

Max address-taken points-to set size.

Definition at line 209 of file WPAStat.h.

◆ _MaxVersions

u32_t SVF::VersionedFlowSensitiveStat::_MaxVersions
private

Most versions for a single object.

Definition at line 194 of file WPAStat.h.

◆ _NumEmptyVersions

u32_t SVF::VersionedFlowSensitiveStat::_NumEmptyVersions
private

Number of versions with empty points-to sets (actually empty, not never-accessed).

Definition at line 200 of file WPAStat.h.

◆ _NumNonEmptyVersions

u32_t SVF::VersionedFlowSensitiveStat::_NumNonEmptyVersions
private

Number of versions with non-empty points-to sets (since versioning is over-approximate).

Definition at line 198 of file WPAStat.h.

◆ _NumSingleVersion

u32_t SVF::VersionedFlowSensitiveStat::_NumSingleVersion
private

Number of objects which have a single version.

Definition at line 202 of file WPAStat.h.

◆ _NumUsedVersions

u32_t SVF::VersionedFlowSensitiveStat::_NumUsedVersions
private

Number of version PTSs actually used (sum of next two fields).

Definition at line 196 of file WPAStat.h.

◆ _NumVersions

u32_t SVF::VersionedFlowSensitiveStat::_NumVersions
private

Total number of versions across all objects.

Definition at line 192 of file WPAStat.h.

◆ _TotalPtsSize

u32_t SVF::VersionedFlowSensitiveStat::_TotalPtsSize
private

Total of points-to set sizes for calculating averages.

Definition at line 212 of file WPAStat.h.

◆ vfspta

VersionedFlowSensitive* SVF::VersionedFlowSensitiveStat::vfspta

Definition at line 169 of file WPAStat.h.


The documentation for this class was generated from the following files: