Static Value-Flow Analysis
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
SVF::SVFStat Class Referenceabstract

#include <SVFStat.h>

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

Public Types

enum  ClockType { Wall , CPU }
 
typedef OrderedMap< std::string, u32_tNUMStatMap
 
typedef OrderedMap< std::string, doubleTIMEStatMap
 

Public Member Functions

 SVFStat ()
 
virtual ~SVFStat ()
 
virtual void startClk ()
 
virtual void endClk ()
 
virtual void performStat ()=0
 
virtual void printStat (std::string str="")
 
virtual void performStatPerQuery (NodeID)
 
virtual void printStatPerQuery (NodeID, const PointsTo &)
 
virtual void callgraphStat ()
 

Static Public Member Functions

static double getClk (bool mark=false)
 

Public Attributes

NUMStatMap generalNumMap
 
NUMStatMap PTNumStatMap
 
TIMEStatMap timeStatMap
 
double startTime
 
double endTime
 

Static Public Attributes

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
 

Private Member Functions

void branchStat ()
 

Private Attributes

std::string moduleName
 

Detailed Description

Pointer Analysis Statistics

Definition at line 40 of file SVFStat.h.

Member Typedef Documentation

◆ NUMStatMap

Definition at line 44 of file SVFStat.h.

◆ TIMEStatMap

Definition at line 46 of file SVFStat.h.

Member Enumeration Documentation

◆ ClockType

Enumerator
Wall 
CPU 

Definition at line 48 of file SVFStat.h.

49 {
50 Wall,
51 CPU,
52 };

Constructor & Destructor Documentation

◆ SVFStat()

SVFStat::SVFStat ( )

Definition at line 42 of file SVFStat.cpp.

42 : startTime(0), endTime(0)
43{
45 && "PTAStat: unknown clock type!");
46}
static const OptionMap< enum PTAStat::ClockType > ClockType
Definition Options.h:24
double endTime
Definition SVFStat.h:81
double startTime
Definition SVFStat.h:80
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ ~SVFStat()

virtual SVF::SVFStat::~SVFStat ( )
inlinevirtual

Definition at line 56 of file SVFStat.h.

56{}

Member Function Documentation

◆ branchStat()

void SVFStat::branchStat ( )
private

Definition at line 222 of file SVFStat.cpp.

223{
227 for (const auto& item: *svfirCallGraph)
228 {
229 const SVFFunction* func = item.second->getFunction();
230 for (SVFFunction::const_iterator bbIt = func->begin(), bbEit = func->end();
231 bbIt != bbEit; ++bbIt)
232 {
233 const SVFBasicBlock* bb = *bbIt;
235 if (numOfSucc == 2)
237 else if (numOfSucc > 2)
239 }
240 }
241
242 generalNumMap["BBWith2Succ"] = numOfBB_2Succ;
243 generalNumMap["BBWith3Succ"] = numOfBB_3Succ;
244}
unsigned u32_t
Definition CommandLine.h:18
cJSON * item
Definition cJSON.h:222
u32_t getNumSuccessors() const
Definition SVFValue.h:626
const_iterator end() const
Definition SVFValue.h:451
const_iterator begin() const
Definition SVFValue.h:446
std::vector< constSVFBasicBlock * >::const_iterator const_iterator
Definition SVFValue.h:305
CallGraph * getCallGraph()
Definition SVFIR.h:193
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
Definition SVFIR.h:116
NUMStatMap generalNumMap
Definition SVFStat.h:76

◆ callgraphStat()

virtual void SVF::SVFStat::callgraphStat ( )
inlinevirtual

Reimplemented in SVF::PTAStat.

Definition at line 91 of file SVFStat.h.

91{}

◆ endClk()

virtual void SVF::SVFStat::endClk ( )
inlinevirtual

Definition at line 63 of file SVFStat.h.

64 {
65 endTime = getClk(true);
66 }
static double getClk(bool mark=false)
Definition SVFStat.cpp:48

◆ getClk()

double SVFStat::getClk ( bool  mark = false)
static

When mark is true, real clock is always returned. When mark is false, it is only returned when Options::MarkedClocksOnly is not set. Default call for getClk is unmarked, while MarkedClocksOnly is false by default.

Definition at line 48 of file SVFStat.cpp.

49{
50 if (Options::MarkedClocksOnly() && !mark) return 0.0;
51
53 {
54 struct timespec time;
56 return (double)(time.tv_nsec + time.tv_sec * 1000000000) / 1000000.0;
57 }
59 {
60 return CLOCK_IN_MS();
61 }
62
63 assert(false && "PTAStat::getClk: unknown clock type");
64 abort();
65}
#define CLOCK_IN_MS()
Definition SVFType.h:513
static const Option< bool > MarkedClocksOnly
Definition Options.h:31

◆ performStat()

void SVFStat::performStat ( )
pure virtual

SVF's general statistics are only printed once even if you run multiple anayses

Implemented in SVF::CFLStat, SVF::ICFGStat, SVF::AndersenStat, SVF::FlowSensitiveStat, SVF::VersionedFlowSensitiveStat, SVF::AEStat, SVF::DDAStat, SVF::MemSSAStat, SVF::SVFGStat, and SVF::PTAStat.

Definition at line 110 of file SVFStat.cpp.

111{
112
114 if(printGeneralStats == false)
115 return;
116
117 SVFIR* pag = SVFIR::getPAG();
119 u32_t numOfGlobal = 0;
120 u32_t numOfStack = 0;
121 u32_t numOfHeap = 0;
126 u32_t numOfScalar = 0;
128 u32_t fiObjNumber = 0;
129 u32_t fsObjNumber = 0;
131 for(SVFIR::iterator it = pag->begin(), eit = pag->end(); it!=eit; ++it)
132 {
133 PAGNode* node = it->second;
134 if(ObjVar* obj = SVFUtil::dyn_cast<ObjVar>(node))
135 {
136 const MemObj* mem = obj->getMemObj();
137 if (memObjSet.insert(mem->getId()).second == false)
138 continue;
139 if(mem->isBlackHoleObj())
140 continue;
141 if(mem->isFunction())
143 if(mem->isGlobalObj())
144 numOfGlobal++;
145 if (pag->getBaseObject(obj->getId()) &&
146 SVFUtil::isa<StackObjVar>(
147 pag->getBaseObject(obj->getId())))
148 numOfStack++;
149 if (pag->getBaseObject(obj->getId()) &&
150 SVFUtil::isa<HeapObjVar, DummyObjVar>(
151 pag->getBaseObject(obj->getId())))
152 {
153 numOfHeap++;
154 }
155 if(mem->isVarArray())
157 if(mem->isVarStruct())
159 if(mem->isConstantArray())
161 if(mem->isConstantStruct())
163 if(mem->getType()->isPointerTy() == false)
164 numOfScalar++;
165 if(mem->isConstDataOrConstGlobal())
167
168 if (mem->isFieldInsensitive())
169 fiObjNumber++;
170 else
171 fsObjNumber++;
172 }
173 }
174
175
176
177 generalNumMap["TotalPointers"] = pag->getValueNodeNum() + pag->getFieldValNodeNum();
178 generalNumMap["TotalObjects"] = pag->getObjectNodeNum();
179 generalNumMap["TotalFieldObjects"] = pag->getFieldObjNodeNum();
181 generalNumMap["TotalSVFStmts"] = pag->getPAGEdgeNum();
182 generalNumMap["TotalPTASVFStmts"] = pag->getPTAPAGEdgeNum();
183 generalNumMap["FIObjNum"] = fiObjNumber;
184 generalNumMap["FSObjNum"] = fsObjNumber;
185
186 generalNumMap["AddrsNum"] = pag->getSVFStmtSet(SVFStmt::Addr).size();
187 generalNumMap["LoadsNum"] = pag->getSVFStmtSet(SVFStmt::Load).size();
188 generalNumMap["StoresNum"] = pag->getSVFStmtSet(SVFStmt::Store).size();
189 generalNumMap["CopysNum"] = pag->getSVFStmtSet(SVFStmt::Copy).size();
190 generalNumMap["GepsNum"] = pag->getSVFStmtSet(SVFStmt::Gep).size();
191 generalNumMap["CallsNum"] = pag->getSVFStmtSet(SVFStmt::Call).size();
192 generalNumMap["ReturnsNum"] = pag->getSVFStmtSet(SVFStmt::Ret).size();
193
194 generalNumMap["FunctionObjs"] = numOfFunction;
195 generalNumMap["GlobalObjs"] = numOfGlobal;
196 generalNumMap["HeapObjs"] = numOfHeap;
197 generalNumMap["StackObjs"] = numOfStack;
198
199 generalNumMap["VarStructObj"] = numOfHasVarStruct;
200 generalNumMap["VarArrayObj"] = numOfHasVarArray;
201 generalNumMap["ConstStructObj"] = numOfHasConstStruct;
202 generalNumMap["ConstArrayObj"] = numOfHasConstArray;
203 generalNumMap["NonPtrObj"] = numOfScalar;
204 generalNumMap["ConstantObj"] = numOfConstant;
205
206 generalNumMap["IndCallSites"] = pag->getIndirectCallsites().size();
207 generalNumMap["TotalCallSite"] = pag->getCallSiteSet().size();
208
212
213 // REFACTOR-TODO bitcastInstStat();
214 branchStat();
215
216 printStat("General Stats");
217
218 printGeneralStats = false;
219}
iterator begin()
Iterators.
IDToNodeMapTy::iterator iterator
Node Iterators.
u32_t getValueNodeNum() const
Definition IRGraph.h:186
u32_t getPTAPAGEdgeNum() const
Definition IRGraph.h:211
u32_t getPAGEdgeNum() const
Definition IRGraph.h:207
u32_t getObjectNodeNum() const
Definition IRGraph.h:190
bool isConstantStruct() const
const SVFType * getType() const
Get obj type.
bool isConstDataOrConstGlobal() const
SymID getId() const
Get the memory object id.
bool isGlobalObj() const
bool isFieldInsensitive() const
Return true if its field limit is 0.
bool isVarArray() const
bool isBlackHoleObj() const
Whether it is a black hole object.
bool isConstantArray() const
bool isVarStruct() const
bool isFunction() const
object attributes methods
const CallSiteSet & getCallSiteSet() const
Get all callsites.
Definition SVFIR.h:255
SVFStmt::SVFStmtSetTy & getSVFStmtSet(SVFStmt::PEDGEK kind)
Get/set methods to get SVFStmts based on their kinds and ICFGNodes.
Definition SVFIR.h:202
u32_t getFieldObjNodeNum() const
Definition SVFIR.h:339
const BaseObjVar * getBaseObject(NodeID id) const
Definition SVFIR.h:405
u32_t getFieldValNodeNum() const
Node and edge statistics.
Definition SVFIR.h:335
const CallSiteToFunPtrMap & getIndirectCallsites() const
Add/get indirect callsites.
Definition SVFIR.h:351
virtual void printStat(std::string str="")
Definition SVFStat.cpp:67
void branchStat()
Definition SVFStat.cpp:222
static bool printGeneralStats
SVF's general statistics are only printed once even if you run multiple anayses.
Definition SVFStat.h:74
TIMEStatMap timeStatMap
Definition SVFStat.h:78
static double timeOfBuildingLLVMModule
Definition SVFStat.h:93
static double timeOfBuildingSymbolTable
Definition SVFStat.h:94
static double timeOfBuildingSVFIR
Definition SVFStat.h:95
bool isPointerTy() const
Definition SVFType.h:249
static SymbolTableInfo * SymbolInfo()
Singleton design here to make sure we only have one instance during any analysis.
u32_t getMaxStructSize() const

◆ performStatPerQuery()

virtual void SVF::SVFStat::performStatPerQuery ( NodeID  )
inlinevirtual

Reimplemented in SVF::DDAStat.

Definition at line 87 of file SVFStat.h.

87{}

◆ printStat()

void SVFStat::printStat ( std::string  str = "")
virtual

Reimplemented in SVF::ICFGStat, SVF::DDAStat, SVF::MemSSAStat, and SVF::SVFGStat.

Definition at line 67 of file SVFStat.cpp.

68{
69
70 std::string moduleName(SVFIR::getPAG()->getModule()->getModuleIdentifier());
71 std::vector<std::string> names = SVFUtil::split(moduleName,'/');
72 if (names.size() > 1)
73 {
74 moduleName = names[names.size() - 1];
75 }
76
77 SVFUtil::outs() << "\n*********" << statname << "***************\n";
78 SVFUtil::outs() << "################ (program : " << moduleName << ")###############\n";
79 SVFUtil::outs().flags(std::ios::left);
80 unsigned field_width = 20;
81
82 for(NUMStatMap::iterator it = generalNumMap.begin(), eit = generalNumMap.end(); it!=eit; ++it)
83 {
84 // format out put with width 20 space
85 std::cout << std::setw(field_width) << it->first << it->second << "\n";
86 }
87
88 if(!timeStatMap.empty())
89 SVFUtil::outs() << "----------------Time and memory stats--------------------\n";
90 for(TIMEStatMap::iterator it = timeStatMap.begin(), eit = timeStatMap.end(); it!=eit; ++it)
91 {
92 // format out put with width 20 space
93 SVFUtil::outs() << std::setw(field_width) << it->first << it->second << "\n";
94 }
95
96 if(!PTNumStatMap.empty())
97 SVFUtil::outs() << "----------------Numbers stats----------------------------\n";
98 for(NUMStatMap::iterator it = PTNumStatMap.begin(), eit = PTNumStatMap.end(); it!=eit; ++it)
99 {
100 // format out put with width 20 space
101 SVFUtil::outs() << std::setw(field_width) << it->first << it->second << "\n";
102 }
103 SVFUtil::outs() << "#######################################################" << std::endl;
104 SVFUtil::outs().flush();
105 generalNumMap.clear();
106 PTNumStatMap.clear();
107 timeStatMap.clear();
108}
NUMStatMap PTNumStatMap
Definition SVFStat.h:77
std::string moduleName
Definition SVFStat.h:99
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:50
std::vector< std::string > split(const std::string &s, char separator)
Split into two substrings around the first occurrence of a separator string.
Definition SVFUtil.h:203

◆ printStatPerQuery()

virtual void SVF::SVFStat::printStatPerQuery ( NodeID  ,
const PointsTo  
)
inlinevirtual

Reimplemented in SVF::DDAStat.

Definition at line 89 of file SVFStat.h.

89{}

◆ startClk()

virtual void SVF::SVFStat::startClk ( )
inlinevirtual

Definition at line 58 of file SVFStat.h.

59 {
60 startTime = getClk(true);
61 }

Member Data Documentation

◆ endTime

double SVF::SVFStat::endTime

Definition at line 81 of file SVFStat.h.

◆ generalNumMap

NUMStatMap SVF::SVFStat::generalNumMap

Definition at line 76 of file SVFStat.h.

◆ moduleName

std::string SVF::SVFStat::moduleName
private

Definition at line 99 of file SVFStat.h.

◆ printGeneralStats

bool SVFStat::printGeneralStats = true
static

SVF's general statistics are only printed once even if you run multiple anayses.

Definition at line 74 of file SVFStat.h.

◆ PTNumStatMap

NUMStatMap SVF::SVFStat::PTNumStatMap

Definition at line 77 of file SVFStat.h.

◆ startTime

double SVF::SVFStat::startTime

Definition at line 80 of file SVFStat.h.

◆ timeOfBuildingLLVMModule

double SVFStat::timeOfBuildingLLVMModule = 0
static

Definition at line 93 of file SVFStat.h.

◆ timeOfBuildingSVFIR

double SVFStat::timeOfBuildingSVFIR = 0
static

Definition at line 95 of file SVFStat.h.

◆ timeOfBuildingSymbolTable

double SVFStat::timeOfBuildingSymbolTable = 0
static

Definition at line 94 of file SVFStat.h.

◆ timeStatMap

TIMEStatMap SVF::SVFStat::timeStatMap

Definition at line 78 of file SVFStat.h.


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