Static Value-Flow Analysis
Loading...
Searching...
No Matches
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

PointerAnalysis * pta
u32_t _vmrssUsageBefore
u32_t _vmrssUsageAfter
u32_t _vmsizeUsageBefore
u32_t _vmsizeUsageAfter

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

Detailed Description

Pointer Analysis Statistics

Definition at line 47 of file PTAStat.h.

Constructor & Destructor Documentation

◆ PTAStat()

PTAStat::PTAStat ( PointerAnalysis * p)

Definition at line 40 of file PTAStat.cpp.

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

◆ ~PTAStat()

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

Definition at line 51 of file PTAStat.h.

51{}

Member Function Documentation

◆ callgraphStat()

void PTAStat::callgraphStat ( )
overridevirtual

Reimplemented from SVF::SVFStat.

Definition at line 82 of file PTAStat.cpp.

83{
84
85 CallGraph* graph = pta->getCallGraph();
87 callgraphSCC->find();
88
89 unsigned totalNode = 0;
90 unsigned totalCycle = 0;
91 unsigned nodeInCycle = 0;
92 unsigned maxNodeInCycle = 0;
93 unsigned totalEdge = 0;
94 unsigned edgeInCycle = 0;
95
96 NodeSet sccRepNodeSet;
97 CallGraph::iterator it = graph->begin();
98 CallGraph::iterator eit = graph->end();
99 for (; it != eit; ++it)
100 {
101 totalNode++;
102 if(callgraphSCC->isInCycle(it->first))
103 {
104 sccRepNodeSet.insert(callgraphSCC->repNode(it->first));
105 nodeInCycle++;
106 const NodeBS& subNodes = callgraphSCC->subNodes(it->first);
107 if(subNodes.count() > maxNodeInCycle)
108 maxNodeInCycle = subNodes.count();
109 }
110
111 CallGraphNode::const_iterator edgeIt = it->second->InEdgeBegin();
112 CallGraphNode::const_iterator edgeEit = it->second->InEdgeEnd();
113 for (; edgeIt != edgeEit; ++edgeIt)
114 {
115 CallGraphEdge*edge = *edgeIt;
116 totalEdge+= edge->getDirectCalls().size() + edge->getIndirectCalls().size();
117 if(callgraphSCC->repNode(edge->getSrcID()) == callgraphSCC->repNode(edge->getDstID()))
118 {
119 edgeInCycle+=edge->getDirectCalls().size() + edge->getIndirectCalls().size();
120 }
121 }
122 }
123
124 totalCycle = sccRepNodeSet.size();
125
126 PTNumStatMap["TotalNode"] = totalNode;
127 PTNumStatMap["TotalCycle"] = totalCycle;
128 PTNumStatMap["NodeInCycle"] = nodeInCycle;
129 PTNumStatMap["MaxNodeInCycle"] = maxNodeInCycle;
130 PTNumStatMap["TotalEdge"] = totalEdge;
131 PTNumStatMap["CalRetPairInCycle"] = edgeInCycle;
132
133 if(pta->getAnalysisTy() >= PTATY::Andersen_BASE && pta->getAnalysisTy() <= PTATY::Steensgaard_WPA)
134 SVFStat::printStat("PTACallGraph Stats (Andersen analysis)");
135 else if(pta->getAnalysisTy() >= PTATY::FSDATAFLOW_WPA && pta->getAnalysisTy() <= PTATY::FSCS_WPA)
136 SVFStat::printStat("PTACallGraph Stats (Flow-sensitive analysis)");
137 else if(pta->getAnalysisTy() >= PTATY::CFLFICI_WPA && pta->getAnalysisTy() <= PTATY::CFLFSCS_WPA)
138 SVFStat::printStat("PTACallGraph Stats (CFL-R analysis)");
139 else if(pta->getAnalysisTy() >= PTATY::FieldS_DDA && pta->getAnalysisTy() <= PTATY::Cxt_DDA)
140 SVFStat::printStat("PTACallGraph Stats (DDA analysis)");
141 else
142 SVFStat::printStat("PTACallGraph Stats");
143
144 delete callgraphSCC;
145}
CallInstSet & getIndirectCalls()
Definition CallGraph.h:99
CallInstSet & getDirectCalls()
Definition CallGraph.h:95
NodeID getDstID() const
NodeID getSrcID() const
get methods of the components
iterator begin()
Iterators.
SCCDetection< CallGraph * > CallGraphSCC
void find(void)
Definition SCC.h:331
NodeID repNode(NodeID n) const
get the rep node if not found return itself
Definition SCC.h:162
bool isInCycle(NodeID n) const
whether the node is in a cycle
Definition SCC.h:172
const NodeBS & subNodes(NodeID n) const
get all subnodes in one scc, if size is empty insert itself into the set
Definition SCC.h:196
NUMStatMap PTNumStatMap
Definition SVFStat.h:80
virtual void printStat(std::string str="")
Definition SVFStat.cpp:71
unsigned count() const
Set< NodeID > NodeSet
Definition GeneralType.h:87
@ Cxt_DDA
context sensitive DDA
Definition PTATY.h:32
@ FieldS_DDA
Field sensitive DDA.
Definition PTATY.h:29
@ CFLFICI_WPA
Flow-, context-, insensitive CFL-reachability-based analysis.
Definition PTATY.h:23
@ FSDATAFLOW_WPA
Traditional Dataflow-based flow sensitive WPA.
Definition PTATY.h:19
@ Steensgaard_WPA
Steensgaard PTA.
Definition PTATY.h:16
@ FSCS_WPA
Flow-, context- sensitive WPA.
Definition PTATY.h:22
@ CFLFSCS_WPA
Flow-, context-, CFL-reachability-based analysis.
Definition PTATY.h:25
@ Andersen_BASE
Base Andersen PTA.
Definition PTATY.h:11
SparseBitVector NodeBS
Definition GeneralType.h:82

◆ performStat()

void PTAStat::performStat ( )
overridevirtual

Implements SVF::SVFStat.

Reimplemented in SVF::SVFGStat, and SVF::VersionedFlowSensitiveStat.

Definition at line 53 of file PTAStat.cpp.

54{
55
57
59
60 SVFIR* pag = SVFIR::getPAG();
61 for(SVFIR::iterator it = pag->begin(), eit = pag->end(); it!=eit; ++it)
62 {
63 PAGNode* node = it->second;
64 if(SVFUtil::isa<ObjVar>(node))
65 {
66 if(pta->isLocalVarInRecursiveFun(node->getId()))
67 {
68 localVarInRecursion.set(node->getId());
69 }
70 }
71 }
72 PTNumStatMap["LocalVarInRecur"] = localVarInRecursion.count();
73
74 u32_t vmrss = 0;
75 u32_t vmsize = 0;
76 SVFUtil::getMemoryUsageKB(&vmrss, &vmsize);
77 setMemUsageAfter(vmrss, vmsize);
78 timeStatMap["MemoryUsageVmrss"] = _vmrssUsageAfter - _vmrssUsageBefore;
79 timeStatMap["MemoryUsageVmsize"] = _vmsizeUsageAfter - _vmsizeUsageBefore;
80}
void setMemUsageAfter(u32_t vmrss, u32_t vmsize)
Definition PTAStat.h:61
NodeBS localVarInRecursion
Definition PTAStat.h:53
void callgraphStat() override
Definition PTAStat.cpp:82
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
Definition SVFIR.h:121
TIMEStatMap timeStatMap
Definition SVFStat.h:81
virtual void performStat()=0
Definition SVFStat.cpp:114
NodeID getId() const
Get ID.
Definition SVFValue.h:158
LLVM_NODISCARD bool isa(const Y &Val)
Definition Casting.h:241
SVFVar PAGNode
Definition IRGraph.h:40

◆ setMemUsageAfter()

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

Definition at line 61 of file PTAStat.h.

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

◆ setMemUsageBefore()

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

Definition at line 55 of file PTAStat.h.

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

Member Data Documentation

◆ _vmrssUsageAfter

u32_t SVF::PTAStat::_vmrssUsageAfter
protected

Definition at line 75 of file PTAStat.h.

◆ _vmrssUsageBefore

u32_t SVF::PTAStat::_vmrssUsageBefore
protected

Definition at line 74 of file PTAStat.h.

◆ _vmsizeUsageAfter

u32_t SVF::PTAStat::_vmsizeUsageAfter
protected

Definition at line 77 of file PTAStat.h.

◆ _vmsizeUsageBefore

u32_t SVF::PTAStat::_vmsizeUsageBefore
protected

Definition at line 76 of file PTAStat.h.

◆ localVarInRecursion

NodeBS SVF::PTAStat::localVarInRecursion

Definition at line 53 of file PTAStat.h.

◆ pta

PointerAnalysis* SVF::PTAStat::pta
protected

Definition at line 73 of file PTAStat.h.


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