Static Value-Flow Analysis
Loading...
Searching...
No Matches
ICFGStat.h
Go to the documentation of this file.
1//===- ICFGStat.h ----------------------------------------------------------//
2//
3// SVF: Static Value-Flow Analysis
4//
5// Copyright (C) <2013-2018> <Yulei Sui>
6//
7
8// This program is free software: you can redistribute it and/or modify
9// it under the terms of the GNU Affero General Public License as published by
10// the Free Software Foundation, either version 3 of the License, or
11// (at your option) any later version.
12
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU Affero General Public License for more details.
17
18// You should have received a copy of the GNU Affero General Public License
19// along with this program. If not, see <http://www.gnu.org/licenses/>.
20//
21//===----------------------------------------------------------------------===//
22/*
23 * ICFGStat.h
24 *
25 * Created on: 12Sep.,2018
26 * Author: yulei
27 */
28
29#ifndef INCLUDE_UTIL_ICFGSTAT_H_
30#define INCLUDE_UTIL_ICFGSTAT_H_
31
32#include "Util/PTAStat.h"
33#include "Graphs/ICFG.h"
34#include <iomanip>
35
36namespace SVF
37{
38
39class ICFGStat : public PTAStat
40{
41
42private:
50
55
56public:
58
60 {
61 numOfNodes = 0;
63 numOfRetNodes = 0;
67
68 numOfEdges = 0;
70 numOfRetEdges = 0;
72
73 }
74
76 {
77
78 countStat();
79
80 PTNumStatMap["ICFGNode"] = numOfNodes;
81 PTNumStatMap["IntraICFGNode"] = numOfIntraNodes;
82 PTNumStatMap["CallICFGNode"] = numOfCallNodes;
83 PTNumStatMap["RetICFGNode"] = numOfRetNodes;
84 PTNumStatMap["FunEntryICFGNode"] = numOfEntryNodes;
85 PTNumStatMap["FunExitICFGNode"] = numOfExitNodes;
86
87 PTNumStatMap["ICFGEdge"] = numOfEdges;
88 PTNumStatMap["CallCFGEdge"] = numOfCallEdges;
89 PTNumStatMap["RetCFGEdge"] = numOfRetEdges;
90 PTNumStatMap["IntraCFGEdge"] = numOfIntraEdges;
91
92 printStat("ICFG Stat");
93 }
94
96 {
97
98 countStat();
99 PTNumStatMap["ICFGNode(N)"] = numOfNodes;
100 PTNumStatMap["CallICFGNode(Call)"] = numOfCallNodes;
101 PTNumStatMap["ICFGEdge(E)"] = numOfEdges;
102 printStat("IFDS Stat");
103 }
104
106 {
107 ICFG::ICFGNodeIDToNodeMapTy::iterator it = icfg->begin();
108 ICFG::ICFGNodeIDToNodeMapTy::iterator eit = icfg->end();
109 for (; it != eit; ++it)
110 {
111 numOfNodes++;
112
113 ICFGNode *node = it->second;
114
115 if (SVFUtil::isa<IntraICFGNode>(node))
117 else if (SVFUtil::isa<CallICFGNode>(node))
119 else if (SVFUtil::isa<RetICFGNode>(node))
121 else if (SVFUtil::isa<FunEntryICFGNode>(node))
123 else if (SVFUtil::isa<FunExitICFGNode>(node))
125
126
127 ICFGEdge::ICFGEdgeSetTy::iterator edgeIt =
128 it->second->OutEdgeBegin();
129 ICFGEdge::ICFGEdgeSetTy::iterator edgeEit =
130 it->second->OutEdgeEnd();
131 for (; edgeIt != edgeEit; ++edgeIt)
132 {
133 const ICFGEdge *edge = *edgeIt;
134 numOfEdges++;
135 if (edge->isCallCFGEdge())
137 else if (edge->isRetCFGEdge())
139 else if (edge->isIntraCFGEdge())
141 }
142 }
143 }
144
145 void printStat(std::string statname)
146 {
147
148 SVFUtil::outs() << "\n************ " << statname << " ***************\n";
149 SVFUtil::outs().flags(std::ios::left);
150 unsigned field_width = 20;
151 for(NUMStatMap::iterator it = PTNumStatMap.begin(), eit = PTNumStatMap.end(); it!=eit; ++it)
152 {
153 // format out put with width 20 space
154 SVFUtil::outs() << std::setw(field_width) << it->first << it->second << "\n";
155 }
156 PTNumStatMap.clear();
157 SVFUtil::outs().flush();
158 }
159};
160
161} // End namespace SVF
162
163#endif /* INCLUDE_UTIL_ICFGSTAT_H_ */
164
iterator begin()
Iterators.
iterator OutEdgeBegin()
iterators
ICFG * icfg
Definition ICFGStat.h:43
void performStatforIFDS()
Definition ICFGStat.h:95
ICFGStat(ICFG *cfg)
Definition ICFGStat.h:59
int numOfRetEdges
Definition ICFGStat.h:53
int numOfIntraEdges
Definition ICFGStat.h:54
void countStat()
Definition ICFGStat.h:105
Set< const ICFGNode * > ICFGNodeSet
Definition ICFGStat.h:57
int numOfCallNodes
Definition ICFGStat.h:45
void performStat()
Definition ICFGStat.h:75
int numOfCallEdges
Definition ICFGStat.h:52
int numOfRetNodes
Definition ICFGStat.h:46
int numOfEntryNodes
Definition ICFGStat.h:47
int numOfExitNodes
Definition ICFGStat.h:48
int numOfIntraNodes
Definition ICFGStat.h:49
void printStat(std::string statname)
Definition ICFGStat.h:145
NUMStatMap PTNumStatMap
Definition SVFStat.h:77
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:50
for isBitcode
Definition BasicTypes.h:68
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74