Static Value-Flow Analysis
Public Types | Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
SVF::FlowSensitiveStat Class Reference

#include <WPAStat.h>

Inheritance diagram for SVF::FlowSensitiveStat:
SVF::PTAStat SVF::SVFStat

Public Types

typedef FlowSensitive::DFInOutMap DFInOutMap
 
typedef FlowSensitive::PtsMap PtsMap
 
- Public Types inherited from SVF::SVFStat
enum  ClockType { Wall , CPU }
 
typedef OrderedMap< std::string, u32_tNUMStatMap
 
typedef OrderedMap< std::string, double > TIMEStatMap
 

Public Member Functions

 FlowSensitiveStat (FlowSensitive *pta)
 
virtual ~FlowSensitiveStat ()
 
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

FlowSensitivefspta
 
- 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 Types

enum  ENUM_INOUT { IN , OUT }
 

Private Member Functions

void clearStat ()
 
void statNullPtr ()
 
void statPtsSize ()
 
void statAddrVarPtsSize ()
 
void calculateAddrVarPts (NodeID pointer, const SVFGNode *node)
 
void statInOutPtsSize (const DFInOutMap &data, ENUM_INOUT inOrOut)
 

Private Attributes

u32_t _NumOfNullPtr
 
u32_t _NumOfConstantPtr
 
u32_t _NumOfBlackholePtr
 
u32_t _NumOfSVFGNodesHaveInOut [2]
 number of SVFG nodes which have IN/OUT set. More...
 
u32_t _NumOfFormalInSVFGNodesHaveInOut [2]
 
u32_t _NumOfFormalOutSVFGNodesHaveInOut [2]
 
u32_t _NumOfActualInSVFGNodesHaveInOut [2]
 
u32_t _NumOfActualOutSVFGNodesHaveInOut [2]
 
u32_t _NumOfLoadSVFGNodesHaveInOut [2]
 
u32_t _NumOfStoreSVFGNodesHaveInOut [2]
 
u32_t _NumOfMSSAPhiSVFGNodesHaveInOut [2]
 
u32_t _NumOfVarHaveINOUTPts [2]
 number of pag nodes which have points-to set in IN/OUT set. More...
 
u32_t _NumOfVarHaveEmptyINOUTPts [2]
 
u32_t _NumOfVarHaveINOUTPtsInFormalIn [2]
 
u32_t _NumOfVarHaveINOUTPtsInFormalOut [2]
 
u32_t _NumOfVarHaveINOUTPtsInActualIn [2]
 
u32_t _NumOfVarHaveINOUTPtsInActualOut [2]
 
u32_t _NumOfVarHaveINOUTPtsInLoad [2]
 
u32_t _NumOfVarHaveINOUTPtsInStore [2]
 
u32_t _NumOfVarHaveINOUTPtsInMSSAPhi [2]
 
u32_t _PotentialNumOfVarHaveINOUTPts [2]
 
u32_t _MaxPtsSize
 sizes of points-to set More...
 
u32_t _MaxTopLvlPtsSize
 max points-to set size in top-level pointers. More...
 
u32_t _MaxInOutPtsSize [2]
 max points-to set size in IN/OUT set. More...
 
u32_t _TotalPtsSize
 total points-to set size. More...
 
double _AvgPtsSize
 average points-to set size. More...
 
double _AvgTopLvlPtsSize
 average points-to set size in top-level pointers. More...
 
double _AvgInOutPtsSize [2]
 average points-to set size in IN set. More...
 
double _AvgAddrTakenVarPtsSize
 average points-to set size of addr-taken variables. More...
 
u32_t _MaxAddrTakenVarPts
 max points-to set size of addr-taken variables. More...
 
u32_t _NumOfAddrTakeVar
 number of occurrences of addr-taken variables in load/store. More...
 

Additional Inherited Members

- 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. More...
 
static double timeOfBuildingLLVMModule = 0
 
static double timeOfBuildingSymbolTable = 0
 
static double timeOfBuildingSVFIR = 0
 
- Protected Attributes inherited from SVF::PTAStat
PointerAnalysispta
 
u32_t _vmrssUsageBefore
 
u32_t _vmrssUsageAfter
 
u32_t _vmsizeUsageBefore
 
u32_t _vmsizeUsageAfter
 

Detailed Description

Statistics of flow-sensitive analysis

Definition at line 85 of file WPAStat.h.

Member Typedef Documentation

◆ DFInOutMap

Definition at line 88 of file WPAStat.h.

◆ PtsMap

Definition at line 89 of file WPAStat.h.

Member Enumeration Documentation

◆ ENUM_INOUT

Enumerator
IN 
OUT 

Definition at line 105 of file WPAStat.h.

106  {
107  IN,
108  OUT
109  };

Constructor & Destructor Documentation

◆ FlowSensitiveStat()

SVF::FlowSensitiveStat::FlowSensitiveStat ( FlowSensitive pta)
inline

Definition at line 93 of file WPAStat.h.

93  : PTAStat(pta)
94  {
95  fspta = pta;
96  clearStat();
97  startClk();
98  }
FlowSensitive * fspta
Definition: WPAStat.h:91
PointerAnalysis * pta
Definition: PTAStat.h:74
PTAStat(PointerAnalysis *p)
Definition: PTAStat.cpp:39
virtual void startClk()
Definition: SVFStat.h:58

◆ ~FlowSensitiveStat()

virtual SVF::FlowSensitiveStat::~FlowSensitiveStat ( )
inlinevirtual

Definition at line 100 of file WPAStat.h.

100 {}

Member Function Documentation

◆ calculateAddrVarPts()

void FlowSensitiveStat::calculateAddrVarPts ( NodeID  pointer,
const SVFGNode svfg_node 
)
private

Points-to size

Definition at line 492 of file FlowSensitiveStat.cpp.

493 {
494  const PointsTo& pts = fspta->getPts(pointer);
495  _NumOfAddrTakeVar += pts.count();
496  PointsTo::iterator ptsIt = pts.begin();
497  PointsTo::iterator ptsEit = pts.end();
498  for (; ptsIt != ptsEit; ++ptsIt)
499  {
500  const NodeID ptd = *ptsIt;
501 
502  const PointsTo& cpts = fspta->getDFOutPtsSet(svfg_node, ptd);
503  _AvgAddrTakenVarPtsSize += cpts.count();
504  if (cpts.count() > _MaxAddrTakenVarPts)
505  _MaxAddrTakenVarPts = cpts.count();
506  }
507 }
const PointsTo & getPts(NodeID id) override
double _AvgAddrTakenVarPtsSize
average points-to set size of addr-taken variables.
Definition: WPAStat.h:159
u32_t _MaxAddrTakenVarPts
max points-to set size of addr-taken variables.
Definition: WPAStat.h:161
u32_t _NumOfAddrTakeVar
number of occurrences of addr-taken variables in load/store.
Definition: WPAStat.h:162
const PointsTo & getDFOutPtsSet(const SVFGNode *stmt, const NodeID node)
const_iterator end() const
Definition: PointsTo.h:132
u32_t count() const
Returns number of elements.
Definition: PointsTo.cpp:111
const_iterator begin() const
Definition: PointsTo.h:128
u32_t NodeID
Definition: GeneralType.h:55

◆ clearStat()

void FlowSensitiveStat::clearStat ( )
private

Clear statistics

SVFG nodes

SVFIR nodes.

Definition at line 41 of file FlowSensitiveStat.cpp.

42 {
43  _NumOfNullPtr = 0;
50  _TotalPtsSize = 0;
51 
52  for (int i=IN; i<=OUT; i++)
53  {
63 
65  _NumOfVarHaveINOUTPts[i] = 0;
75 
76  _MaxInOutPtsSize[i] = 0;
77  _AvgInOutPtsSize[i] = 0;
78  }
79 }
u32_t _NumOfActualInSVFGNodesHaveInOut[2]
Definition: WPAStat.h:131
double _AvgPtsSize
average points-to set size.
Definition: WPAStat.h:156
u32_t _PotentialNumOfVarHaveINOUTPts[2]
Definition: WPAStat.h:147
u32_t _NumOfVarHaveINOUTPtsInFormalOut[2]
Definition: WPAStat.h:141
u32_t _NumOfFormalOutSVFGNodesHaveInOut[2]
Definition: WPAStat.h:130
u32_t _NumOfVarHaveEmptyINOUTPts[2]
Definition: WPAStat.h:139
u32_t _NumOfVarHaveINOUTPtsInStore[2]
Definition: WPAStat.h:145
u32_t _NumOfFormalInSVFGNodesHaveInOut[2]
Definition: WPAStat.h:129
double _AvgTopLvlPtsSize
average points-to set size in top-level pointers.
Definition: WPAStat.h:157
u32_t _NumOfActualOutSVFGNodesHaveInOut[2]
Definition: WPAStat.h:132
u32_t _NumOfVarHaveINOUTPtsInActualIn[2]
Definition: WPAStat.h:142
u32_t _NumOfMSSAPhiSVFGNodesHaveInOut[2]
Definition: WPAStat.h:135
u32_t _MaxPtsSize
sizes of points-to set
Definition: WPAStat.h:150
u32_t _TotalPtsSize
total points-to set size.
Definition: WPAStat.h:154
u32_t _NumOfVarHaveINOUTPtsInMSSAPhi[2]
Definition: WPAStat.h:146
u32_t _NumOfSVFGNodesHaveInOut[2]
number of SVFG nodes which have IN/OUT set.
Definition: WPAStat.h:128
u32_t _NumOfVarHaveINOUTPtsInLoad[2]
Definition: WPAStat.h:144
u32_t _MaxInOutPtsSize[2]
max points-to set size in IN/OUT set.
Definition: WPAStat.h:152
u32_t _NumOfVarHaveINOUTPts[2]
number of pag nodes which have points-to set in IN/OUT set.
Definition: WPAStat.h:138
u32_t _NumOfLoadSVFGNodesHaveInOut[2]
Definition: WPAStat.h:133
u32_t _NumOfVarHaveINOUTPtsInActualOut[2]
Definition: WPAStat.h:143
u32_t _NumOfVarHaveINOUTPtsInFormalIn[2]
Definition: WPAStat.h:140
u32_t _NumOfStoreSVFGNodesHaveInOut[2]
Definition: WPAStat.h:134
u32_t _MaxTopLvlPtsSize
max points-to set size in top-level pointers.
Definition: WPAStat.h:151
double _AvgInOutPtsSize[2]
average points-to set size in IN set.
Definition: WPAStat.h:158

◆ performStat()

void FlowSensitiveStat::performStat ( )
virtual

Start statistics

SVFG nodes.

Reimplemented from SVF::PTAStat.

Definition at line 84 of file FlowSensitiveStat.cpp.

85 {
86  assert(SVFUtil::isa<FlowSensitive>(fspta) && "not an flow-sensitive pta pass!! what else??");
87  endClk();
88 
89  clearStat();
90 
91  SVFIR* pag = fspta->getPAG();
92 
93  // stat null ptr number
94  statNullPtr();
95 
96  // stat points-to set information
97  statPtsSize();
98 
99  // stat address-taken variables' points-to
101 
102  u32_t fiObjNumber = 0;
103  u32_t fsObjNumber = 0;
104  Set<SymID> nodeSet;
105  for (SVFIR::const_iterator nodeIt = pag->begin(), nodeEit = pag->end(); nodeIt != nodeEit; nodeIt++)
106  {
107  NodeID nodeId = nodeIt->first;
108  PAGNode* pagNode = nodeIt->second;
109  if(SVFUtil::isa<ObjVar>(pagNode))
110  {
111  const MemObj * memObj = pag->getBaseObj(nodeId);
112  SymID baseId = memObj->getId();
113  if (nodeSet.insert(baseId).second)
114  {
115  if (memObj->isFieldInsensitive())
116  fiObjNumber++;
117  else
118  fsObjNumber++;
119  }
120  }
121  }
122 
123  PTNumStatMap["FIObjNum"] = fiObjNumber;
124  PTNumStatMap["FSObjNum"] = fsObjNumber;
125 
126  unsigned numOfCopy = 0;
127  unsigned numOfStore = 0;
128  SVFG::iterator svfgNodeIt = fspta->svfg->begin();
129  SVFG::iterator svfgNodeEit = fspta->svfg->end();
130  for (; svfgNodeIt != svfgNodeEit; ++svfgNodeIt)
131  {
132  SVFGNode* svfgNode = svfgNodeIt->second;
133  if (SVFUtil::isa<CopySVFGNode>(svfgNode))
134  numOfCopy++;
135  else if (SVFUtil::isa<StoreSVFGNode>(svfgNode))
136  numOfStore++;
137  }
138 
140 
141  timeStatMap["TotalTime"] = (endTime - startTime)/TIMEINTERVAL;
142  timeStatMap["SolveTime"] = fspta->solveTime;
143  timeStatMap["SCCTime"] = fspta->sccTime;
144  timeStatMap["ProcessTime"] = fspta->processTime;
145  timeStatMap["PropagationTime"] = fspta->propagationTime;
146  timeStatMap["DirectPropaTime"] = fspta->directPropaTime;
147  timeStatMap["IndirectPropaTime"] = fspta->indirectPropaTime;
148  timeStatMap["Strong/WeakUpdTime"] = fspta->updateTime;
149  timeStatMap["AddrTime"] = fspta->addrTime;
150  timeStatMap["CopyTime"] = fspta->copyTime;
151  timeStatMap["GepTime"] = fspta->gepTime;
152  timeStatMap["LoadTime"] = fspta->loadTime;
153  timeStatMap["StoreTime"] = fspta->storeTime;
154  timeStatMap["UpdateCGTime"] = fspta->updateCallGraphTime;
155  timeStatMap["PhiTime"] = fspta->phiTime;
156 
157  PTNumStatMap["TotalPointers"] = pag->getValueNodeNum() + pag->getFieldValNodeNum();
158  PTNumStatMap["TotalObjects"] = pag->getObjectNodeNum() + pag->getFieldObjNodeNum();
159 
160  PTNumStatMap["Pointers"] = pag->getValueNodeNum();
161  PTNumStatMap["MemObjects"] = pag->getObjectNodeNum();
162  PTNumStatMap["DummyFieldPtrs"] = pag->getFieldValNodeNum();
163  PTNumStatMap["FieldObjs"] = pag->getFieldObjNodeNum();
164 
165  PTNumStatMap["CopysNum"] = numOfCopy;
166  PTNumStatMap["StoresNum"] = numOfStore;
167 
168  PTNumStatMap["SolveIterations"] = fspta->numOfIteration;
169 
170  PTNumStatMap["IndEdgeSolved"] = fspta->getNumOfResolvedIndCallEdge();
171 
172  PTNumStatMap["NullPointer"] = _NumOfNullPtr;
173  PTNumStatMap["PointsToConstPtr"] = _NumOfConstantPtr;
174  PTNumStatMap["PointsToBlkPtr"] = _NumOfBlackholePtr;
175 
176  PTNumStatMap["StrongUpdates"] = fspta->svfgHasSU.count();
177 
179  PTNumStatMap["SNodesHaveIN"] = _NumOfSVFGNodesHaveInOut[IN];
180  PTNumStatMap["SNodesHaveOUT"] = _NumOfSVFGNodesHaveInOut[OUT];
181 
182  PTNumStatMap["FI_SNodesHaveIN"] = _NumOfFormalInSVFGNodesHaveInOut[IN];
183  PTNumStatMap["FI_SNodesHaveOUT"] = _NumOfFormalInSVFGNodesHaveInOut[OUT];
184 
185  PTNumStatMap["FO_SNodesHaveIN"] = _NumOfFormalOutSVFGNodesHaveInOut[IN];
186  PTNumStatMap["FO_SNodesHaveOUT"] = _NumOfFormalOutSVFGNodesHaveInOut[OUT];
187 
188  PTNumStatMap["AI_SNodesHaveIN"] = _NumOfActualInSVFGNodesHaveInOut[IN];
189  PTNumStatMap["AI_SNodesHaveOUT"] = _NumOfActualInSVFGNodesHaveInOut[OUT];
190 
191  PTNumStatMap["AO_SNodesHaveIN"] = _NumOfActualOutSVFGNodesHaveInOut[IN];
192  PTNumStatMap["AO_SNodesHaveOUT"] = _NumOfActualOutSVFGNodesHaveInOut[OUT];
193 
194  PTNumStatMap["LD_SNodesHaveIN"] = _NumOfLoadSVFGNodesHaveInOut[IN];
195  PTNumStatMap["LD_SNodesHaveOUT"] = _NumOfLoadSVFGNodesHaveInOut[OUT];
196 
197  PTNumStatMap["ST_SNodesHaveIN"] = _NumOfStoreSVFGNodesHaveInOut[IN];
198  PTNumStatMap["ST_SNodesHaveOUT"] = _NumOfStoreSVFGNodesHaveInOut[OUT];
199 
200  PTNumStatMap["PHI_SNodesHaveIN"] = _NumOfMSSAPhiSVFGNodesHaveInOut[IN];
201  PTNumStatMap["PHI_SNodesHaveOUT"] = _NumOfMSSAPhiSVFGNodesHaveInOut[OUT];
202 
203  /*-----------------------------------------------------*/
204  // SVFIR nodes.
205  PTNumStatMap["VarHaveIN"] = _NumOfVarHaveINOUTPts[IN];
206  PTNumStatMap["VarHaveOUT"] = _NumOfVarHaveINOUTPts[OUT];
207 
208  PTNumStatMap["PotentialVarHaveIN"] = _PotentialNumOfVarHaveINOUTPts[IN];
209  PTNumStatMap["PotentialVarHaveOUT"] = _PotentialNumOfVarHaveINOUTPts[OUT];
210 
211  PTNumStatMap["VarHaveEmptyIN"] = _NumOfVarHaveEmptyINOUTPts[IN];
212  PTNumStatMap["VarHaveEmptyOUT"] = _NumOfVarHaveEmptyINOUTPts[OUT];
213 
216 
219 
222 
225 
226  PTNumStatMap["VarHaveIN_LD"] = _NumOfVarHaveINOUTPtsInLoad[IN];
227  PTNumStatMap["VarHaveOUT_LD"] = _NumOfVarHaveINOUTPtsInLoad[OUT];
228 
229  PTNumStatMap["VarHaveIN_ST"] = _NumOfVarHaveINOUTPtsInStore[IN];
230  PTNumStatMap["VarHaveOUT_ST"] = _NumOfVarHaveINOUTPtsInStore[OUT];
231 
232  PTNumStatMap["VarHaveIN_PHI"] = _NumOfVarHaveINOUTPtsInMSSAPhi[IN];
233  PTNumStatMap["VarHaveOUT_PHI"] = _NumOfVarHaveINOUTPtsInMSSAPhi[OUT];
234 
235  PTNumStatMap["MaxPtsSize"] = _MaxPtsSize;
236  PTNumStatMap["MaxTopLvlPtsSize"] = _MaxTopLvlPtsSize;
237  PTNumStatMap["MaxINPtsSize"] = _MaxInOutPtsSize[IN];
238  PTNumStatMap["MaxOUTPtsSize"] = _MaxInOutPtsSize[OUT];
239 
240  timeStatMap["AvgPtsSize"] = _AvgPtsSize;
241  timeStatMap["AvgTopLvlPtsSize"] = _AvgTopLvlPtsSize;
242 
243  PTNumStatMap["NumOfAddrTakenVar"] = _NumOfAddrTakeVar;
244  timeStatMap["AvgAddrTakenVarPts"] = (_NumOfAddrTakeVar == 0) ?
246  PTNumStatMap["MaxAddrTakenVarPts"] = _MaxAddrTakenVarPts;
247 
248  timeStatMap["AvgINPtsSize"] = _AvgInOutPtsSize[IN];
249  timeStatMap["AvgOUTPtsSize"] = _AvgInOutPtsSize[OUT];
250 
251  PTNumStatMap["ProcessedAddr"] = fspta->numOfProcessedAddr;
252  PTNumStatMap["ProcessedCopy"] = fspta->numOfProcessedCopy;
253  PTNumStatMap["ProcessedGep"] = fspta->numOfProcessedGep;
254  PTNumStatMap["ProcessedLoad"] = fspta->numOfProcessedLoad;
255  PTNumStatMap["ProcessedStore"] = fspta->numOfProcessedStore;
256  PTNumStatMap["ProcessedPhi"] = fspta->numOfProcessedPhi;
257  PTNumStatMap["ProcessedAParam"] = fspta->numOfProcessedActualParam;
258  PTNumStatMap["ProcessedFRet"] = fspta->numOfProcessedFormalRet;
259  PTNumStatMap["ProcessedMSSANode"] = fspta->numOfProcessedMSSANode;
260 
261  PTNumStatMap["NumOfNodesInSCC"] = fspta->numOfNodesInSCC;
262  PTNumStatMap["MaxSCCSize"] = fspta->maxSCCSize;
263  PTNumStatMap["NumOfSCC"] = fspta->numOfSCC;
264  timeStatMap["AverageSCCSize"] = (fspta->numOfSCC == 0) ? 0 :
265  ((double)fspta->numOfNodesInSCC / fspta->numOfSCC);
266 
267  PTAStat::printStat("Flow-Sensitive Pointer Analysis Statistics");
268 }
unsigned u32_t
Definition: CommandLine.h:18
#define TIMEINTERVAL
Definition: SVFType.h:512
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.
Definition: GenericGraph.h:627
IDToNodeMapTy::const_iterator const_iterator
Definition: GenericGraph.h:607
u32_t getValueNodeNum() const
Definition: IRGraph.h:186
u32_t getObjectNodeNum() const
Definition: IRGraph.h:190
SymID getId() const
Get the memory object id.
bool isFieldInsensitive() const
Return true if its field limit is 0.
void performStat() override
Definition: PTAStat.cpp:52
SVFIR * getPAG() const
u32_t getNumOfResolvedIndCallEdge() const
Return number of resolved indirect call edges.
u32_t getFieldObjNodeNum() const
Definition: SVFIR.h:338
u32_t getFieldValNodeNum() const
Node and edge statistics.
Definition: SVFIR.h:334
const MemObj * getBaseObj(NodeID id) const
Definition: SVFIR.h:459
NUMStatMap PTNumStatMap
Definition: SVFStat.h:77
virtual void printStat(std::string str="")
Definition: SVFStat.cpp:66
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
VFGNodeIDToNodeMapTy::iterator iterator
Definition: VFG.h:80
u32_t numOfIteration
num of iterations during constraint solving
Definition: WPASolver.h:200
unsigned SymID
Definition: GeneralType.h:57
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
Definition: GeneralType.h:96

◆ statAddrVarPtsSize()

void FlowSensitiveStat::statAddrVarPtsSize ( )
private

Points-to size

Definition at line 475 of file FlowSensitiveStat.cpp.

476 {
477  SVFG::SVFGNodeIDToNodeMapTy::const_iterator it = fspta->svfg->begin();
478  SVFG::SVFGNodeIDToNodeMapTy::const_iterator eit = fspta->svfg->end();
479  for (; it != eit; ++it)
480  {
481  const SVFGNode* node = it->second;
482  if (const StoreSVFGNode* store = SVFUtil::dyn_cast<StoreSVFGNode>(node))
483  {
484  calculateAddrVarPts(store->getPAGDstNodeID(), store);
485  }
486  }
487 }
void calculateAddrVarPts(NodeID pointer, const SVFGNode *node)

◆ statInOutPtsSize()

void FlowSensitiveStat::statInOutPtsSize ( const DFInOutMap data,
ENUM_INOUT  inOrOut 
)
private

points-to target number

Definition at line 360 of file FlowSensitiveStat.cpp.

361 {
362  // Get number of nodes which have IN/OUT set
363  _NumOfSVFGNodesHaveInOut[inOrOut] = data.size();
364 
365  u32_t inOutPtsSize = 0;
366  DFInOutMap::const_iterator it = data.begin();
367  DFInOutMap::const_iterator eit = data.end();
368  for (; it != eit; ++it)
369  {
370  const SVFGNode* node = fspta->svfg->getSVFGNode(it->first);
371 
372  // Count number of SVFG nodes have IN/OUT set.
373  if (SVFUtil::isa<FormalINSVFGNode>(node))
375  else if (SVFUtil::isa<FormalOUTSVFGNode>(node))
377  else if (SVFUtil::isa<ActualINSVFGNode>(node))
379  else if (SVFUtil::isa<ActualOUTSVFGNode>(node))
381  else if (SVFUtil::isa<LoadSVFGNode>(node))
382  _NumOfLoadSVFGNodesHaveInOut[inOrOut]++;
383  else if (SVFUtil::isa<StoreSVFGNode>(node))
385  else if (SVFUtil::isa<MSSAPHISVFGNode>(node))
387  else
388  assert(false && "unexpected node have IN/OUT set");
389 
390  /*-----------------------------------------------------*/
391 
392  // Count SVFIR nodes and their points-to set size.
393  const PtsMap& cptsMap = it->second;
394  PtsMap::const_iterator ptsIt = cptsMap.begin();
395  PtsMap::const_iterator ptsEit = cptsMap.end();
396  for (; ptsIt != ptsEit; ++ptsIt)
397  {
398  if (ptsIt->second.empty())
399  {
400  _NumOfVarHaveEmptyINOUTPts[inOrOut]++;
401  continue;
402  }
403 
404  u32_t ptsNum = ptsIt->second.count();
405 
406  // Only node with non-empty points-to set are counted.
407  _NumOfVarHaveINOUTPts[inOrOut]++;
408 
409  if (SVFUtil::isa<FormalINSVFGNode>(node))
411  else if (SVFUtil::isa<FormalOUTSVFGNode>(node))
413  else if (SVFUtil::isa<ActualINSVFGNode>(node))
415  else if (SVFUtil::isa<ActualOUTSVFGNode>(node))
417  else if (SVFUtil::isa<LoadSVFGNode>(node))
418  _NumOfVarHaveINOUTPtsInLoad[inOrOut]++;
419  else if (SVFUtil::isa<StoreSVFGNode>(node))
420  _NumOfVarHaveINOUTPtsInStore[inOrOut]++;
421  else if (SVFUtil::isa<MSSAPHISVFGNode>(node))
423  else
424  assert(false && "unexpected node have IN/OUT set");
425 
426  inOutPtsSize += ptsNum;
427 
428  if (ptsNum > _MaxInOutPtsSize[inOrOut])
429  _MaxInOutPtsSize[inOrOut] = ptsNum;
430 
431  if (ptsNum > _MaxPtsSize) _MaxPtsSize = ptsNum;
432  }
433  }
434 
435  if (_NumOfVarHaveINOUTPts[inOrOut] != 0)
436  _AvgInOutPtsSize[inOrOut] = (double)inOutPtsSize / _NumOfVarHaveINOUTPts[inOrOut];
437 
438  _TotalPtsSize += inOutPtsSize;
439 
440  // How many IN/OUT PTSs could we have *potentially* had?
441  // l'-o->l, l''-o->l, ..., means there is a possibility of 1 IN PTS.
442  // *p = q && { o } in pts_ander(p) means there is a possibility of 1 OUT PTS.
443  // For OUTs at stores, we must also account for WU/SUs.
444  const SVFG *svfg = fspta->svfg;
445  for (SVFG::const_iterator it = svfg->begin(); it != svfg->end(); ++it)
446  {
447  const SVFGNode *sn = it->second;
448 
449  // Unique objects coming into s.
450  NodeBS incomingObjects;
451  for (const SVFGEdge *e : sn->getInEdges())
452  {
453  const IndirectSVFGEdge *ie = SVFUtil::dyn_cast<IndirectSVFGEdge>(e);
454  if (!ie) continue;
455  for (NodeID o : ie->getPointsTo()) incomingObjects.set(o);
456  }
457 
458  _PotentialNumOfVarHaveINOUTPts[IN] += incomingObjects.count();
459 
460  if (const StoreSVFGNode *store = SVFUtil::dyn_cast<StoreSVFGNode>(sn))
461  {
462  NodeID p = store->getPAGDstNodeID();
463  // Reuse incomingObjects; what's already in there will be propagated forwarded
464  // as a WU/SU, and what's not (first defined at the store), will be added.
465  for (NodeID o : fspta->ander->getPts(p)) incomingObjects.set(o);
466 
467  _PotentialNumOfVarHaveINOUTPts[OUT] += incomingObjects.count();
468  }
469  }
470 }
cJSON * p
Definition: cJSON.cpp:2559
virtual const PointsTo & getPts(NodeID id)
Operation of points-to set.
Definition: Andersen.h:239
FlowSensitive::PtsMap PtsMap
Definition: WPAStat.h:89
AndersenWaveDiff * ander
const GEdgeSetTy & getInEdges() const
Definition: GenericGraph.h:434
const NodeBS & getPointsTo() const
Definition: SVFGEdge.h:60
Definition: SVFG.h:66
SVFGNode * getSVFGNode(NodeID id) const
Get a SVFG node.
Definition: SVFG.h:150
void set(unsigned Idx)
VFGNodeIDToNodeMapTy::const_iterator const_iterator
Definition: VFG.h:81

◆ statNullPtr()

void FlowSensitiveStat::statNullPtr ( )
private

TODO: change the condition here to fetch the points-to set

Definition at line 270 of file FlowSensitiveStat.cpp.

271 {
272  _NumOfNullPtr = 0;
273  for (SVFIR::iterator iter = fspta->getPAG()->begin(), eiter = fspta->getPAG()->end();
274  iter != eiter; ++iter)
275  {
276  NodeID pagNodeId = iter->first;
277  PAGNode* pagNode = iter->second;
278  SVFStmt::SVFStmtSetTy& inComingStore = pagNode->getIncomingEdges(SVFStmt::Store);
279  SVFStmt::SVFStmtSetTy& outGoingLoad = pagNode->getOutgoingEdges(SVFStmt::Load);
280  if (inComingStore.empty()==false || outGoingLoad.empty()==false)
281  {
283  const PointsTo& pts = fspta->getPts(pagNodeId);
284  if(fspta->containBlackHoleNode(pts))
285  {
287  }
288  if(fspta->containConstantNode(pts))
289  {
291  }
292  if(pts.empty())
293  {
294  std::string str;
295  std::stringstream rawstr(str);
296  if (!SVFUtil::isa<DummyValVar>(pagNode) && !SVFUtil::isa<DummyObjVar>(pagNode))
297  {
298  // if a pointer is in dead function, we do not care
299  if(pagNode->getValue()->ptrInUncalledFunction() == false)
300  {
301  _NumOfNullPtr++;
302  rawstr << "##Null Pointer : (NodeID " << pagNode->getId()
303  << ") PtrName:" << pagNode->getValue()->getName();
304  writeWrnMsg(rawstr.str());
305  }
306  }
307  else
308  {
309  _NumOfNullPtr++;
310  rawstr << "##Null Pointer : (NodeID " << pagNode->getId();
311  writeWrnMsg(rawstr.str());
312  }
313  }
314  }
315  }
316 }
const char *const string
Definition: cJSON.h:172
IDToNodeMapTy::iterator iterator
Node Iterators.
Definition: GenericGraph.h:606
bool containBlackHoleNode(const PointsTo &pts)
Determine whether a points-to contains a black hole or constant node.
bool containConstantNode(const PointsTo &pts)
bool empty() const
Returns true if set is empty.
Definition: PointsTo.cpp:98
NodeID getId() const
Get ID.
Definition: GenericGraph.h:260
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy
const std::string & getName() const
Definition: SVFValue.h:243
bool ptrInUncalledFunction() const
Definition: SVFValue.h:264
SVFStmt::SVFStmtSetTy & getIncomingEdges(SVFStmt::PEDGEK kind)
Get incoming SVFIR statements (edges)
Definition: SVFVariables.h:137
SVFStmt::SVFStmtSetTy & getOutgoingEdges(SVFStmt::PEDGEK kind)
Get outgoing SVFIR statements (edges)
Definition: SVFVariables.h:142
const SVFValue * getValue() const
Get/has methods of the components.
Definition: SVFVariables.h:83
void writeWrnMsg(const std::string &msg)
Writes a message run through wrnMsg.
Definition: SVFUtil.cpp:66

◆ statPtsSize()

void FlowSensitiveStat::statPtsSize ( )
private

Points-to size

get points-to set size information for top-level pointers.

Definition at line 321 of file FlowSensitiveStat.cpp.

322 {
323  // TODO: needs to be made to work for persistent.
324  if (SVFUtil::isa<FlowSensitive::MutDFPTDataTy>(fspta->getPTDataTy()))
325  {
326  // stat of IN set
328  // stat of OUT set
330  }
331 
333  u32_t totalValidTopLvlPointers = 0;
334  u32_t topTopLvlPtsSize = 0;
335  for (SVFIR::iterator iter = fspta->getPAG()->begin(), eiter = fspta->getPAG()->end();
336  iter != eiter; ++iter)
337  {
338  NodeID node = iter->first;
339  if (fspta->getPAG()->isValidTopLevelPtr(iter->second) == false)
340  continue;
341  u32_t size = fspta->getPts(node).count();
342 
343  totalValidTopLvlPointers++;
344  topTopLvlPtsSize+=size;
345 
346  if(size > _MaxPtsSize) _MaxPtsSize = size;
347 
348  if (size > _MaxTopLvlPtsSize) _MaxTopLvlPtsSize = size;
349  }
350 
351  if (totalValidTopLvlPointers != 0)
352  _AvgTopLvlPtsSize = (double)topTopLvlPtsSize/totalValidTopLvlPointers;
353 
354  _TotalPtsSize += topTopLvlPtsSize;
355  u32_t totalPointer = totalValidTopLvlPointers + _NumOfVarHaveINOUTPts[IN] + _NumOfVarHaveINOUTPts[OUT];
356  if (totalPointer != 0)
357  _AvgPtsSize = (double) _TotalPtsSize / totalPointer;
358 }
PTDataTy * getPTDataTy() const
Get points-to data structure.
void statInOutPtsSize(const DFInOutMap &data, ENUM_INOUT inOrOut)
const DFInOutMap & getDFOutputMap() const
const DFInOutMap & getDFInputMap() const
bool isValidTopLevelPtr(const SVFVar *node)
Definition: SVFIR.cpp:673

Member Data Documentation

◆ _AvgAddrTakenVarPtsSize

double SVF::FlowSensitiveStat::_AvgAddrTakenVarPtsSize
private

average points-to set size of addr-taken variables.

Definition at line 159 of file WPAStat.h.

◆ _AvgInOutPtsSize

double SVF::FlowSensitiveStat::_AvgInOutPtsSize[2]
private

average points-to set size in IN set.

Definition at line 158 of file WPAStat.h.

◆ _AvgPtsSize

double SVF::FlowSensitiveStat::_AvgPtsSize
private

average points-to set size.

Definition at line 156 of file WPAStat.h.

◆ _AvgTopLvlPtsSize

double SVF::FlowSensitiveStat::_AvgTopLvlPtsSize
private

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

Definition at line 157 of file WPAStat.h.

◆ _MaxAddrTakenVarPts

u32_t SVF::FlowSensitiveStat::_MaxAddrTakenVarPts
private

max points-to set size of addr-taken variables.

Definition at line 161 of file WPAStat.h.

◆ _MaxInOutPtsSize

u32_t SVF::FlowSensitiveStat::_MaxInOutPtsSize[2]
private

max points-to set size in IN/OUT set.

Definition at line 152 of file WPAStat.h.

◆ _MaxPtsSize

u32_t SVF::FlowSensitiveStat::_MaxPtsSize
private

sizes of points-to set

max points-to set size.

Definition at line 150 of file WPAStat.h.

◆ _MaxTopLvlPtsSize

u32_t SVF::FlowSensitiveStat::_MaxTopLvlPtsSize
private

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

Definition at line 151 of file WPAStat.h.

◆ _NumOfActualInSVFGNodesHaveInOut

u32_t SVF::FlowSensitiveStat::_NumOfActualInSVFGNodesHaveInOut[2]
private

Definition at line 131 of file WPAStat.h.

◆ _NumOfActualOutSVFGNodesHaveInOut

u32_t SVF::FlowSensitiveStat::_NumOfActualOutSVFGNodesHaveInOut[2]
private

Definition at line 132 of file WPAStat.h.

◆ _NumOfAddrTakeVar

u32_t SVF::FlowSensitiveStat::_NumOfAddrTakeVar
private

number of occurrences of addr-taken variables in load/store.

Definition at line 162 of file WPAStat.h.

◆ _NumOfBlackholePtr

u32_t SVF::FlowSensitiveStat::_NumOfBlackholePtr
private

Definition at line 125 of file WPAStat.h.

◆ _NumOfConstantPtr

u32_t SVF::FlowSensitiveStat::_NumOfConstantPtr
private

Definition at line 124 of file WPAStat.h.

◆ _NumOfFormalInSVFGNodesHaveInOut

u32_t SVF::FlowSensitiveStat::_NumOfFormalInSVFGNodesHaveInOut[2]
private

Definition at line 129 of file WPAStat.h.

◆ _NumOfFormalOutSVFGNodesHaveInOut

u32_t SVF::FlowSensitiveStat::_NumOfFormalOutSVFGNodesHaveInOut[2]
private

Definition at line 130 of file WPAStat.h.

◆ _NumOfLoadSVFGNodesHaveInOut

u32_t SVF::FlowSensitiveStat::_NumOfLoadSVFGNodesHaveInOut[2]
private

Definition at line 133 of file WPAStat.h.

◆ _NumOfMSSAPhiSVFGNodesHaveInOut

u32_t SVF::FlowSensitiveStat::_NumOfMSSAPhiSVFGNodesHaveInOut[2]
private

Definition at line 135 of file WPAStat.h.

◆ _NumOfNullPtr

u32_t SVF::FlowSensitiveStat::_NumOfNullPtr
private

Definition at line 123 of file WPAStat.h.

◆ _NumOfStoreSVFGNodesHaveInOut

u32_t SVF::FlowSensitiveStat::_NumOfStoreSVFGNodesHaveInOut[2]
private

Definition at line 134 of file WPAStat.h.

◆ _NumOfSVFGNodesHaveInOut

u32_t SVF::FlowSensitiveStat::_NumOfSVFGNodesHaveInOut[2]
private

number of SVFG nodes which have IN/OUT set.

Definition at line 128 of file WPAStat.h.

◆ _NumOfVarHaveEmptyINOUTPts

u32_t SVF::FlowSensitiveStat::_NumOfVarHaveEmptyINOUTPts[2]
private

Definition at line 139 of file WPAStat.h.

◆ _NumOfVarHaveINOUTPts

u32_t SVF::FlowSensitiveStat::_NumOfVarHaveINOUTPts[2]
private

number of pag nodes which have points-to set in IN/OUT set.

Definition at line 138 of file WPAStat.h.

◆ _NumOfVarHaveINOUTPtsInActualIn

u32_t SVF::FlowSensitiveStat::_NumOfVarHaveINOUTPtsInActualIn[2]
private

Definition at line 142 of file WPAStat.h.

◆ _NumOfVarHaveINOUTPtsInActualOut

u32_t SVF::FlowSensitiveStat::_NumOfVarHaveINOUTPtsInActualOut[2]
private

Definition at line 143 of file WPAStat.h.

◆ _NumOfVarHaveINOUTPtsInFormalIn

u32_t SVF::FlowSensitiveStat::_NumOfVarHaveINOUTPtsInFormalIn[2]
private

Definition at line 140 of file WPAStat.h.

◆ _NumOfVarHaveINOUTPtsInFormalOut

u32_t SVF::FlowSensitiveStat::_NumOfVarHaveINOUTPtsInFormalOut[2]
private

Definition at line 141 of file WPAStat.h.

◆ _NumOfVarHaveINOUTPtsInLoad

u32_t SVF::FlowSensitiveStat::_NumOfVarHaveINOUTPtsInLoad[2]
private

Definition at line 144 of file WPAStat.h.

◆ _NumOfVarHaveINOUTPtsInMSSAPhi

u32_t SVF::FlowSensitiveStat::_NumOfVarHaveINOUTPtsInMSSAPhi[2]
private

Definition at line 146 of file WPAStat.h.

◆ _NumOfVarHaveINOUTPtsInStore

u32_t SVF::FlowSensitiveStat::_NumOfVarHaveINOUTPtsInStore[2]
private

Definition at line 145 of file WPAStat.h.

◆ _PotentialNumOfVarHaveINOUTPts

u32_t SVF::FlowSensitiveStat::_PotentialNumOfVarHaveINOUTPts[2]
private

Definition at line 147 of file WPAStat.h.

◆ _TotalPtsSize

u32_t SVF::FlowSensitiveStat::_TotalPtsSize
private

total points-to set size.

Definition at line 154 of file WPAStat.h.

◆ fspta

FlowSensitive* SVF::FlowSensitiveStat::fspta

Definition at line 91 of file WPAStat.h.


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