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 class  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 42 of file SVFStat.h.

Member Typedef Documentation

◆ NUMStatMap

Definition at line 46 of file SVFStat.h.

◆ TIMEStatMap

Definition at line 48 of file SVFStat.h.

Member Enumeration Documentation

◆ ClockType

Enumerator
Wall 
CPU 

Definition at line 50 of file SVFStat.h.

Constructor & Destructor Documentation

◆ SVFStat()

SVFStat::SVFStat ( )

Definition at line 45 of file SVFStat.cpp.

45 : startTime(0), endTime(0)
46{
48 && "PTAStat: unknown clock type!");
49}
static const OptionMap< SVFStat::ClockType > ClockType
Definition Options.h:21
double endTime
Definition SVFStat.h:83
double startTime
Definition SVFStat.h:82
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

◆ ~SVFStat()

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

Definition at line 58 of file SVFStat.h.

58{}

Member Function Documentation

◆ branchStat()

void SVFStat::branchStat ( )
private

Definition at line 225 of file SVFStat.cpp.

226{
230 for (const auto& item: *svfirCallGraph)
231 {
232 const FunObjVar* func = item.second->getFunction();
233 for (FunObjVar::const_bb_iterator bbIt = func->begin(), bbEit = func->end();
234 bbIt != bbEit; ++bbIt)
235 {
236 const SVFBasicBlock* bb = bbIt->second;
238 if (numOfSucc == 2)
240 else if (numOfSucc > 2)
242 }
243 }
244
245 generalNumMap["BBWith2Succ"] = numOfBB_2Succ;
246 generalNumMap["BBWith3Succ"] = numOfBB_3Succ;
247}
unsigned u32_t
Definition CommandLine.h:18
cJSON * item
Definition cJSON.h:222
BasicBlockGraph::IDToNodeMapTy::const_iterator const_bb_iterator
u32_t getNumSuccessors() const
const CallGraph * getCallGraph()
Get CG.
Definition SVFIR.h:246
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
Definition SVFIR.h:118
NUMStatMap generalNumMap
Definition SVFStat.h:78

◆ callgraphStat()

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

Reimplemented in SVF::PTAStat.

Definition at line 93 of file SVFStat.h.

93{}

◆ endClk()

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

Definition at line 65 of file SVFStat.h.

66 {
67 endTime = getClk(true);
68 }
static double getClk(bool mark=false)
Definition SVFStat.cpp:51

◆ 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 51 of file SVFStat.cpp.

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

◆ 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 113 of file SVFStat.cpp.

114{
115
117 if(printGeneralStats == false)
118 return;
119
120 SVFIR* pag = SVFIR::getPAG();
122 u32_t numOfGlobal = 0;
123 u32_t numOfStack = 0;
124 u32_t numOfHeap = 0;
129 u32_t numOfScalar = 0;
131 u32_t fiObjNumber = 0;
132 u32_t fsObjNumber = 0;
134 for(SVFIR::iterator it = pag->begin(), eit = pag->end(); it!=eit; ++it)
135 {
136 PAGNode* node = it->second;
137 if(ObjVar* obj = SVFUtil::dyn_cast<ObjVar>(node))
138 {
139 const BaseObjVar* mem = pag->getBaseObject(obj->getId());
140 if (memObjSet.insert(mem->getId()).second == false)
141 continue;
142 if(mem->isBlackHoleObj())
143 continue;
144 if(mem->isFunction())
146 if(mem->isGlobalObj())
147 numOfGlobal++;
148 if (pag->getBaseObject(obj->getId()) &&
149 SVFUtil::isa<StackObjVar>(
150 pag->getBaseObject(obj->getId())))
151 numOfStack++;
152 if (pag->getBaseObject(obj->getId()) &&
153 SVFUtil::isa<HeapObjVar, DummyObjVar>(
154 pag->getBaseObject(obj->getId())))
155 {
156 numOfHeap++;
157 }
158 if(mem->isVarArray())
160 if(mem->isVarStruct())
162 if(mem->isConstantArray())
164 if(mem->isConstantStruct())
166 if(mem->getType()->isPointerTy() == false)
167 numOfScalar++;
168 if(mem->isConstDataOrConstGlobal())
170
171 if (mem->isFieldInsensitive())
172 fiObjNumber++;
173 else
174 fsObjNumber++;
175 }
176 }
177
178
179
180 generalNumMap["TotalPointers"] = pag->getValueNodeNum();
181 generalNumMap["TotalObjects"] = pag->getObjectNodeNum();
182 generalNumMap["TotalFieldObjects"] = pag->getFieldObjNodeNum();
183 generalNumMap["MaxStructSize"] = pag->getMaxStructSize();
184 generalNumMap["TotalSVFStmts"] = pag->getSVFStmtNum();
185 generalNumMap["TotalPTASVFStmts"] = pag->getPTAPAGEdgeNum();
186 generalNumMap["FIObjNum"] = fiObjNumber;
187 generalNumMap["FSObjNum"] = fsObjNumber;
188
189 generalNumMap["AddrsNum"] = pag->getSVFStmtSet(SVFStmt::Addr).size();
190 generalNumMap["LoadsNum"] = pag->getSVFStmtSet(SVFStmt::Load).size();
191 generalNumMap["StoresNum"] = pag->getSVFStmtSet(SVFStmt::Store).size();
192 generalNumMap["CopysNum"] = pag->getSVFStmtSet(SVFStmt::Copy).size();
193 generalNumMap["GepsNum"] = pag->getSVFStmtSet(SVFStmt::Gep).size();
194 generalNumMap["CallsNum"] = pag->getSVFStmtSet(SVFStmt::Call).size();
195 generalNumMap["ReturnsNum"] = pag->getSVFStmtSet(SVFStmt::Ret).size();
196
197 generalNumMap["FunctionObjs"] = numOfFunction;
198 generalNumMap["GlobalObjs"] = numOfGlobal;
199 generalNumMap["HeapObjs"] = numOfHeap;
200 generalNumMap["StackObjs"] = numOfStack;
201
202 generalNumMap["VarStructObj"] = numOfHasVarStruct;
203 generalNumMap["VarArrayObj"] = numOfHasVarArray;
204 generalNumMap["ConstStructObj"] = numOfHasConstStruct;
205 generalNumMap["ConstArrayObj"] = numOfHasConstArray;
206 generalNumMap["NonPtrObj"] = numOfScalar;
207 generalNumMap["ConstantObj"] = numOfConstant;
208
209 generalNumMap["IndCallSites"] = pag->getIndirectCallsites().size();
210 generalNumMap["TotalCallSite"] = pag->getCallSiteSet().size();
211
215
216 // REFACTOR-TODO bitcastInstStat();
217 branchStat();
218
219 printStat("General Stats");
220
221 printGeneralStats = false;
222}
bool isFunction() const
object attributes methods
bool isConstDataOrConstGlobal() const
bool isGlobalObj() const
bool isConstantStruct() const
bool isVarStruct() const
NodeID getId() const
Get the memory object id.
bool isBlackHoleObj() const
Whether it is a black hole object.
bool isVarArray() const
bool isFieldInsensitive() const
Return true if its field limit is 0.
const SVFType * getType() const
Get obj type.
bool isConstantArray() const
iterator begin()
Iterators.
IDToNodeMapTy::iterator iterator
Node Iterators.
u32_t getMaxStructSize() const
Definition IRGraph.h:204
u32_t getObjectNodeNum()
Definition IRGraph.cpp:343
u32_t getSVFStmtNum() const
Definition IRGraph.h:334
u32_t getPTAPAGEdgeNum() const
Definition IRGraph.h:338
u32_t getValueNodeNum()
Definition IRGraph.cpp:330
const CallSiteSet & getCallSiteSet() const
Get all callsites.
Definition SVFIR.h:349
SVFStmt::SVFStmtSetTy & getSVFStmtSet(SVFStmt::PEDGEK kind)
Get/set methods to get SVFStmts based on their kinds and ICFGNodes.
Definition SVFIR.h:296
u32_t getFieldObjNodeNum() const
Definition SVFIR.h:439
const BaseObjVar * getBaseObject(NodeID id) const
Definition SVFIR.h:496
const CallSiteToFunPtrMap & getIndirectCallsites() const
Add/get indirect callsites.
Definition SVFIR.h:451
virtual void printStat(std::string str="")
Definition SVFStat.cpp:70
void branchStat()
Definition SVFStat.cpp:225
static bool printGeneralStats
SVF's general statistics are only printed once even if you run multiple anayses.
Definition SVFStat.h:76
TIMEStatMap timeStatMap
Definition SVFStat.h:80
static double timeOfBuildingLLVMModule
Definition SVFStat.h:95
static double timeOfBuildingSymbolTable
Definition SVFStat.h:96
static double timeOfBuildingSVFIR
Definition SVFStat.h:97
bool isPointerTy() const
Definition SVFType.h:294

◆ performStatPerQuery()

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

Reimplemented in SVF::DDAStat.

Definition at line 89 of file SVFStat.h.

89{}

◆ printStat()

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

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

Definition at line 70 of file SVFStat.cpp.

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

◆ printStatPerQuery()

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

Reimplemented in SVF::DDAStat.

Definition at line 91 of file SVFStat.h.

91{}

◆ startClk()

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

Definition at line 60 of file SVFStat.h.

61 {
62 startTime = getClk(true);
63 }

Member Data Documentation

◆ endTime

double SVF::SVFStat::endTime

Definition at line 83 of file SVFStat.h.

◆ generalNumMap

NUMStatMap SVF::SVFStat::generalNumMap

Definition at line 78 of file SVFStat.h.

◆ moduleName

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

Definition at line 101 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 76 of file SVFStat.h.

◆ PTNumStatMap

NUMStatMap SVF::SVFStat::PTNumStatMap

Definition at line 79 of file SVFStat.h.

◆ startTime

double SVF::SVFStat::startTime

Definition at line 82 of file SVFStat.h.

◆ timeOfBuildingLLVMModule

double SVFStat::timeOfBuildingLLVMModule = 0
static

Definition at line 95 of file SVFStat.h.

◆ timeOfBuildingSVFIR

double SVFStat::timeOfBuildingSVFIR = 0
static

Definition at line 97 of file SVFStat.h.

◆ timeOfBuildingSymbolTable

double SVFStat::timeOfBuildingSymbolTable = 0
static

Definition at line 96 of file SVFStat.h.

◆ timeStatMap

TIMEStatMap SVF::SVFStat::timeStatMap

Definition at line 80 of file SVFStat.h.


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