Static Value-Flow Analysis
Public Member Functions | Public Attributes | Protected Attributes | List of all members
SVF::PTAStat Class Reference

#include <PTAStat.h>

Inheritance diagram for SVF::PTAStat:
SVF::SVFStat SVF::AndersenStat SVF::CFLStat SVF::DDAStat SVF::FlowSensitiveStat SVF::ICFGStat SVF::MTAStat SVF::MemSSAStat SVF::SVFGStat SVF::VersionedFlowSensitiveStat

Public Member Functions

 PTAStat (PointerAnalysis *p)
 
virtual ~PTAStat ()
 
void setMemUsageBefore (u32_t vmrss, u32_t vmsize)
 
void setMemUsageAfter (u32_t vmrss, u32_t vmsize)
 
void performStat () override
 
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

NodeBS localVarInRecursion
 
- Public Attributes inherited from SVF::SVFStat
NUMStatMap generalNumMap
 
NUMStatMap PTNumStatMap
 
TIMEStatMap timeStatMap
 
double startTime
 
double endTime
 

Protected Attributes

PointerAnalysispta
 
u32_t _vmrssUsageBefore
 
u32_t _vmrssUsageAfter
 
u32_t _vmsizeUsageBefore
 
u32_t _vmsizeUsageAfter
 

Additional Inherited Members

- Public Types inherited from SVF::SVFStat
enum  ClockType { Wall , CPU }
 
typedef OrderedMap< std::string, u32_tNUMStatMap
 
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. More...
 
static double timeOfBuildingLLVMModule = 0
 
static double timeOfBuildingSymbolTable = 0
 
static double timeOfBuildingSVFIR = 0
 

Detailed Description

Pointer Analysis Statistics

Definition at line 48 of file PTAStat.h.

Constructor & Destructor Documentation

◆ PTAStat()

PTAStat::PTAStat ( PointerAnalysis p)

Definition at line 39 of file PTAStat.cpp.

39  : SVFStat(),
40  pta(p),
45 {
46  u32_t vmrss = 0;
47  u32_t vmsize = 0;
48  SVFUtil::getMemoryUsageKB(&vmrss, &vmsize);
49  setMemUsageBefore(vmrss, vmsize);
50 }
unsigned u32_t
Definition: CommandLine.h:18
cJSON * p
Definition: cJSON.cpp:2559
void setMemUsageBefore(u32_t vmrss, u32_t vmsize)
Definition: PTAStat.h:56
u32_t _vmsizeUsageBefore
Definition: PTAStat.h:77
PointerAnalysis * pta
Definition: PTAStat.h:74
u32_t _vmsizeUsageAfter
Definition: PTAStat.h:78
u32_t _vmrssUsageAfter
Definition: PTAStat.h:76
u32_t _vmrssUsageBefore
Definition: PTAStat.h:75
bool getMemoryUsageKB(u32_t *vmrss_kb, u32_t *vmsize_kb)
Get memory usage from system file. Return TRUE if succeed.
Definition: SVFUtil.cpp:177

◆ ~PTAStat()

virtual SVF::PTAStat::~PTAStat ( )
inlinevirtual

Definition at line 52 of file PTAStat.h.

52 {}

Member Function Documentation

◆ callgraphStat()

void PTAStat::callgraphStat ( )
overridevirtual

Reimplemented from SVF::SVFStat.

Definition at line 81 of file PTAStat.cpp.

82 {
83 
84  PTACallGraph* graph = pta->getCallGraph();
86  callgraphSCC->find();
87 
88  unsigned totalNode = 0;
89  unsigned totalCycle = 0;
90  unsigned nodeInCycle = 0;
91  unsigned maxNodeInCycle = 0;
92  unsigned totalEdge = 0;
93  unsigned edgeInCycle = 0;
94 
95  NodeSet sccRepNodeSet;
96  PTACallGraph::iterator it = graph->begin();
97  PTACallGraph::iterator eit = graph->end();
98  for (; it != eit; ++it)
99  {
100  totalNode++;
101  if(callgraphSCC->isInCycle(it->first))
102  {
103  sccRepNodeSet.insert(callgraphSCC->repNode(it->first));
104  nodeInCycle++;
105  const NodeBS& subNodes = callgraphSCC->subNodes(it->first);
106  if(subNodes.count() > maxNodeInCycle)
107  maxNodeInCycle = subNodes.count();
108  }
109 
110  PTACallGraphNode::const_iterator edgeIt = it->second->InEdgeBegin();
111  PTACallGraphNode::const_iterator edgeEit = it->second->InEdgeEnd();
112  for (; edgeIt != edgeEit; ++edgeIt)
113  {
114  PTACallGraphEdge*edge = *edgeIt;
115  totalEdge+= edge->getDirectCalls().size() + edge->getIndirectCalls().size();
116  if(callgraphSCC->repNode(edge->getSrcID()) == callgraphSCC->repNode(edge->getDstID()))
117  {
118  edgeInCycle+=edge->getDirectCalls().size() + edge->getIndirectCalls().size();
119  }
120  }
121  }
122 
123  totalCycle = sccRepNodeSet.size();
124 
125  PTNumStatMap["TotalNode"] = totalNode;
126  PTNumStatMap["TotalCycle"] = totalCycle;
127  PTNumStatMap["NodeInCycle"] = nodeInCycle;
128  PTNumStatMap["MaxNodeInCycle"] = maxNodeInCycle;
129  PTNumStatMap["TotalEdge"] = totalEdge;
130  PTNumStatMap["CalRetPairInCycle"] = edgeInCycle;
131 
132  if(pta->getAnalysisTy() >= PointerAnalysis::PTATY::Andersen_BASE && pta->getAnalysisTy() <= PointerAnalysis::PTATY::Steensgaard_WPA)
133  SVFStat::printStat("PTACallGraph Stats (Andersen analysis)");
134  else if(pta->getAnalysisTy() >= PointerAnalysis::PTATY::FSDATAFLOW_WPA && pta->getAnalysisTy() <= PointerAnalysis::PTATY::FSCS_WPA)
135  SVFStat::printStat("PTACallGraph Stats (Flow-sensitive analysis)");
136  else if(pta->getAnalysisTy() >= PointerAnalysis::PTATY::CFLFICI_WPA && pta->getAnalysisTy() <= PointerAnalysis::PTATY::CFLFSCS_WPA)
137  SVFStat::printStat("PTACallGraph Stats (CFL-R analysis)");
138  else if(pta->getAnalysisTy() >= PointerAnalysis::PTATY::FieldS_DDA && pta->getAnalysisTy() <= PointerAnalysis::PTATY::Cxt_DDA)
139  SVFStat::printStat("PTACallGraph Stats (DDA analysis)");
140  else
141  SVFStat::printStat("PTACallGraph Stats");
142 
143  delete callgraphSCC;
144 }
NodeID getDstID() const
Definition: GenericGraph.h:85
NodeID getSrcID() const
get methods of the components
Definition: GenericGraph.h:81
iterator begin()
Iterators.
Definition: GenericGraph.h:627
IDToNodeMapTy::iterator iterator
Node Iterators.
Definition: GenericGraph.h:606
CallInstSet & getIndirectCalls()
Definition: PTACallGraph.h:99
CallInstSet & getDirectCalls()
Definition: PTACallGraph.h:95
PTACallGraphEdge::CallGraphEdgeSet::const_iterator const_iterator
Definition: PTACallGraph.h:180
PTACallGraph * getCallGraph() const
Return call graph.
PTATY getAnalysisTy() const
Type of pointer analysis.
SCCDetection< PTACallGraph * > CallGraphSCC
void find(void)
Definition: SCC.h:308
NodeID repNode(NodeID n) const
get the rep node if not found return itself
Definition: SCC.h:139
bool isInCycle(NodeID n) const
whether the node is in a cycle
Definition: SCC.h:149
const NodeBS & subNodes(NodeID n) const
get all subnodes in one scc, if size is empty insert itself into the set
Definition: SCC.h:173
NUMStatMap PTNumStatMap
Definition: SVFStat.h:77
virtual void printStat(std::string str="")
Definition: SVFStat.cpp:66
unsigned count() const
Set< NodeID > NodeSet
Definition: GeneralType.h:113

◆ performStat()

void PTAStat::performStat ( )
overridevirtual

Implements SVF::SVFStat.

Reimplemented in SVF::VersionedFlowSensitiveStat, SVF::FlowSensitiveStat, and SVF::AndersenStat.

Definition at line 52 of file PTAStat.cpp.

53 {
54 
56 
57  callgraphStat();
58 
59  SVFIR* pag = SVFIR::getPAG();
60  for(SVFIR::iterator it = pag->begin(), eit = pag->end(); it!=eit; ++it)
61  {
62  PAGNode* node = it->second;
63  if(SVFUtil::isa<ObjVar>(node))
64  {
65  if(pta->isLocalVarInRecursiveFun(node->getId()))
66  {
67  localVarInRecursion.set(node->getId());
68  }
69  }
70  }
71  PTNumStatMap["LocalVarInRecur"] = localVarInRecursion.count();
72 
73  u32_t vmrss = 0;
74  u32_t vmsize = 0;
75  SVFUtil::getMemoryUsageKB(&vmrss, &vmsize);
76  setMemUsageAfter(vmrss, vmsize);
77  timeStatMap["MemoryUsageVmrss"] = _vmrssUsageAfter - _vmrssUsageBefore;
78  timeStatMap["MemoryUsageVmsize"] = _vmsizeUsageAfter - _vmsizeUsageBefore;
79 }
void setMemUsageAfter(u32_t vmrss, u32_t vmsize)
Definition: PTAStat.h:62
NodeBS localVarInRecursion
Definition: PTAStat.h:54
void callgraphStat() override
Definition: PTAStat.cpp:81
bool isLocalVarInRecursiveFun(NodeID id) const
Whether a local variable is in function recursions.
NodeID getId() const
Get ID.
Definition: GenericGraph.h:260
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
Definition: SVFIR.h:115
TIMEStatMap timeStatMap
Definition: SVFStat.h:78
virtual void performStat()=0
Definition: SVFStat.cpp:109
void set(unsigned Idx)

◆ setMemUsageAfter()

void SVF::PTAStat::setMemUsageAfter ( u32_t  vmrss,
u32_t  vmsize 
)
inline

Definition at line 62 of file PTAStat.h.

63  {
64  _vmrssUsageAfter = vmrss;
65  _vmsizeUsageAfter = vmsize;
66  }

◆ setMemUsageBefore()

void SVF::PTAStat::setMemUsageBefore ( u32_t  vmrss,
u32_t  vmsize 
)
inline

Definition at line 56 of file PTAStat.h.

57  {
58  _vmrssUsageBefore = vmrss;
59  _vmsizeUsageBefore = vmsize;
60  }

Member Data Documentation

◆ _vmrssUsageAfter

u32_t SVF::PTAStat::_vmrssUsageAfter
protected

Definition at line 76 of file PTAStat.h.

◆ _vmrssUsageBefore

u32_t SVF::PTAStat::_vmrssUsageBefore
protected

Definition at line 75 of file PTAStat.h.

◆ _vmsizeUsageAfter

u32_t SVF::PTAStat::_vmsizeUsageAfter
protected

Definition at line 78 of file PTAStat.h.

◆ _vmsizeUsageBefore

u32_t SVF::PTAStat::_vmsizeUsageBefore
protected

Definition at line 77 of file PTAStat.h.

◆ localVarInRecursion

NodeBS SVF::PTAStat::localVarInRecursion

Definition at line 54 of file PTAStat.h.

◆ pta

PointerAnalysis* SVF::PTAStat::pta
protected

Definition at line 74 of file PTAStat.h.


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