svf-tools 1.0.577 → 1.0.579
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SVF-doxygen/html/html/CFLAlias_8cpp.html +0 -1
- package/SVF-doxygen/html/html/CFLAlias_8cpp_source.html +10 -42
- package/SVF-doxygen/html/html/CFLAlias_8h.html +1 -8
- package/SVF-doxygen/html/html/CFLAlias_8h_source.html +22 -49
- package/SVF-doxygen/html/html/CFLBase_8cpp.html +89 -0
- package/SVF-doxygen/html/html/CFLBase_8cpp_source.html +119 -0
- package/SVF-doxygen/html/html/CFLBase_8h.html +104 -0
- package/SVF-doxygen/html/html/CFLBase_8h_source.html +117 -0
- package/SVF-doxygen/html/html/CFLGraph_8cpp_source.html +2 -2
- package/SVF-doxygen/html/html/CFLGraph_8h_source.html +5 -4
- package/SVF-doxygen/html/html/CFLStat_8cpp_source.html +17 -58
- package/SVF-doxygen/html/html/CFLStat_8h.html +1 -0
- package/SVF-doxygen/html/html/CFLStat_8h_source.html +12 -22
- package/SVF-doxygen/html/html/CFLVF_8cpp.html +0 -2
- package/SVF-doxygen/html/html/CFLVF_8cpp_source.html +4 -15
- package/SVF-doxygen/html/html/CFLVF_8h.html +3 -8
- package/SVF-doxygen/html/html/CFLVF_8h_source.html +11 -26
- package/SVF-doxygen/html/html/CHG_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/CHG_8h_source.html +1 -1
- package/SVF-doxygen/html/html/ConsGNode_8h_source.html +5 -5
- package/SVF-doxygen/html/html/ConsG_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/ConsG_8h_source.html +1 -1
- package/SVF-doxygen/html/html/DCHG_8h_source.html +1 -1
- package/SVF-doxygen/html/html/DataFlowUtil_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/GEPTypeBridgeIterator_8h_source.html +1 -1
- package/SVF-doxygen/html/html/GenericGraph_8h_source.html +1 -1
- package/SVF-doxygen/html/html/GraphPrinter_8h_source.html +1 -1
- package/SVF-doxygen/html/html/ICFG_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/ICFG_8h_source.html +1 -1
- package/SVF-doxygen/html/html/IRGraph_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/IRGraph_8h_source.html +1 -1
- package/SVF-doxygen/html/html/PTACallGraph_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/PTACallGraph_8h_source.html +1 -1
- package/SVF-doxygen/html/html/SVFG_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/SVFG_8h_source.html +1 -1
- package/SVF-doxygen/html/html/TCT_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/TCT_8h_source.html +1 -1
- package/SVF-doxygen/html/html/VFG_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/VFG_8h_source.html +1 -1
- package/SVF-doxygen/html/html/annotated.html +271 -270
- package/SVF-doxygen/html/html/cfl_8cpp.html +6 -9
- package/SVF-doxygen/html/html/cfl_8cpp_source.html +6 -8
- package/SVF-doxygen/html/html/classSVF_1_1BVDataPTAImpl.html +9 -8
- package/SVF-doxygen/html/html/classSVF_1_1BVDataPTAImpl.png +0 -0
- package/SVF-doxygen/html/html/classSVF_1_1CFLAlias-members.html +120 -121
- package/SVF-doxygen/html/html/classSVF_1_1CFLAlias.html +212 -713
- package/SVF-doxygen/html/html/classSVF_1_1CFLAlias.png +0 -0
- package/SVF-doxygen/html/html/classSVF_1_1CFLBase-members.html +270 -0
- package/SVF-doxygen/html/html/classSVF_1_1CFLBase.html +1199 -0
- package/SVF-doxygen/html/html/classSVF_1_1CFLBase.png +0 -0
- package/SVF-doxygen/html/html/classSVF_1_1CFLGraph-members.html +21 -20
- package/SVF-doxygen/html/html/classSVF_1_1CFLGraph.html +33 -3
- package/SVF-doxygen/html/html/classSVF_1_1CFLStat-members.html +21 -31
- package/SVF-doxygen/html/html/classSVF_1_1CFLStat.html +62 -358
- package/SVF-doxygen/html/html/classSVF_1_1CFLVF-members.html +94 -80
- package/SVF-doxygen/html/html/classSVF_1_1CFLVF.html +207 -287
- package/SVF-doxygen/html/html/classSVF_1_1CFLVF.png +0 -0
- package/SVF-doxygen/html/html/classSVF_1_1ConstraintNode-members.html +26 -26
- package/SVF-doxygen/html/html/classSVF_1_1ConstraintNode.html +43 -43
- package/SVF-doxygen/html/html/classSVF_1_1GenericNode.html +21 -20
- package/SVF-doxygen/html/html/classSVF_1_1GenericNode.png +0 -0
- package/SVF-doxygen/html/html/classSVF_1_1PointerAnalysis.html +12 -11
- package/SVF-doxygen/html/html/classSVF_1_1PointerAnalysis.png +0 -0
- package/SVF-doxygen/html/html/classSVF_1_1SVFStat.html +1 -1
- package/SVF-doxygen/html/html/classes.html +96 -95
- package/SVF-doxygen/html/html/dda_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/dir_98f9a352f241e0e917d4efaa4086f6e8.html +2 -0
- package/SVF-doxygen/html/html/dir_ae8aa099e368efaa962140c6624142bc.html +2 -0
- package/SVF-doxygen/html/html/files.html +15 -13
- package/SVF-doxygen/html/html/functions.html +0 -8
- package/SVF-doxygen/html/html/functions_0x7e.html +2 -5
- package/SVF-doxygen/html/html/functions_a.html +9 -11
- package/SVF-doxygen/html/html/functions_b.html +11 -4
- package/SVF-doxygen/html/html/functions_c.html +33 -32
- package/SVF-doxygen/html/html/functions_f.html +16 -14
- package/SVF-doxygen/html/html/functions_func.html +6 -7
- package/SVF-doxygen/html/html/functions_func_0x7e.html +2 -5
- package/SVF-doxygen/html/html/functions_func_b.html +7 -0
- package/SVF-doxygen/html/html/functions_func_c.html +31 -23
- package/SVF-doxygen/html/html/functions_func_f.html +3 -1
- package/SVF-doxygen/html/html/functions_func_g.html +14 -11
- package/SVF-doxygen/html/html/functions_func_i.html +9 -7
- package/SVF-doxygen/html/html/functions_func_n.html +3 -0
- package/SVF-doxygen/html/html/functions_func_p.html +1 -1
- package/SVF-doxygen/html/html/functions_func_s.html +14 -13
- package/SVF-doxygen/html/html/functions_g.html +19 -15
- package/SVF-doxygen/html/html/functions_i.html +16 -14
- package/SVF-doxygen/html/html/functions_l.html +6 -6
- package/SVF-doxygen/html/html/functions_m.html +1 -2
- package/SVF-doxygen/html/html/functions_n.html +15 -8
- package/SVF-doxygen/html/html/functions_p.html +10 -10
- package/SVF-doxygen/html/html/functions_r.html +1 -1
- package/SVF-doxygen/html/html/functions_s.html +22 -21
- package/SVF-doxygen/html/html/functions_t.html +17 -13
- package/SVF-doxygen/html/html/functions_type_c.html +0 -1
- package/SVF-doxygen/html/html/functions_v.html +3 -3
- package/SVF-doxygen/html/html/functions_vars.html +0 -8
- package/SVF-doxygen/html/html/functions_vars_a.html +0 -1
- package/SVF-doxygen/html/html/functions_vars_c.html +0 -2
- package/SVF-doxygen/html/html/functions_vars_g.html +5 -4
- package/SVF-doxygen/html/html/functions_vars_m.html +0 -1
- package/SVF-doxygen/html/html/functions_vars_n.html +12 -8
- package/SVF-doxygen/html/html/functions_vars_p.html +1 -1
- package/SVF-doxygen/html/html/functions_vars_s.html +2 -4
- package/SVF-doxygen/html/html/functions_vars_t.html +12 -6
- package/SVF-doxygen/html/html/hierarchy.html +58 -57
- package/SVF-doxygen/html/html/mta_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/namespaceSVF.html +3 -0
- package/SVF-doxygen/html/html/saber_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/search/all_0.js +8 -8
- package/SVF-doxygen/html/html/search/all_1.js +2 -2
- package/SVF-doxygen/html/html/search/all_10.js +6 -6
- package/SVF-doxygen/html/html/search/all_11.js +1 -1
- package/SVF-doxygen/html/html/search/all_12.js +11 -11
- package/SVF-doxygen/html/html/search/all_13.js +16 -12
- package/SVF-doxygen/html/html/search/all_15.js +3 -3
- package/SVF-doxygen/html/html/search/all_16.js +1 -1
- package/SVF-doxygen/html/html/search/all_19.js +1 -2
- package/SVF-doxygen/html/html/search/all_2.js +2 -0
- package/SVF-doxygen/html/html/search/all_3.js +12 -7
- package/SVF-doxygen/html/html/search/all_6.js +4 -4
- package/SVF-doxygen/html/html/search/all_7.js +5 -4
- package/SVF-doxygen/html/html/search/all_9.js +4 -4
- package/SVF-doxygen/html/html/search/all_b.js +1 -1
- package/SVF-doxygen/html/html/search/all_c.js +4 -4
- package/SVF-doxygen/html/html/search/all_d.js +1 -1
- package/SVF-doxygen/html/html/search/all_e.js +14 -9
- package/SVF-doxygen/html/html/search/classes_2.js +1 -0
- package/SVF-doxygen/html/html/search/files_2.js +2 -0
- package/SVF-doxygen/html/html/search/functions_0.js +1 -1
- package/SVF-doxygen/html/html/search/functions_1.js +2 -0
- package/SVF-doxygen/html/html/search/functions_11.js +3 -3
- package/SVF-doxygen/html/html/search/functions_17.js +1 -2
- package/SVF-doxygen/html/html/search/functions_2.js +5 -2
- package/SVF-doxygen/html/html/search/functions_5.js +1 -1
- package/SVF-doxygen/html/html/search/functions_6.js +2 -1
- package/SVF-doxygen/html/html/search/functions_8.js +1 -1
- package/SVF-doxygen/html/html/search/functions_d.js +1 -0
- package/SVF-doxygen/html/html/search/functions_f.js +1 -1
- package/SVF-doxygen/html/html/search/typedefs_2.js +1 -1
- package/SVF-doxygen/html/html/search/variables_0.js +8 -8
- package/SVF-doxygen/html/html/search/variables_1.js +1 -1
- package/SVF-doxygen/html/html/search/variables_10.js +1 -1
- package/SVF-doxygen/html/html/search/variables_12.js +2 -2
- package/SVF-doxygen/html/html/search/variables_13.js +13 -9
- package/SVF-doxygen/html/html/search/variables_3.js +2 -2
- package/SVF-doxygen/html/html/search/variables_7.js +3 -2
- package/SVF-doxygen/html/html/search/variables_9.js +1 -1
- package/SVF-doxygen/html/html/search/variables_d.js +1 -1
- package/SVF-doxygen/html/html/search/variables_e.js +12 -8
- package/SVF-doxygen/html/html/structllvm_1_1GraphTraits_3_01Inverse_3_01SVF_1_1CFLNode_01_5_01_4_01_4.html +1 -1
- package/SVF-doxygen/html/html/structllvm_1_1GraphTraits_3_01SVF_1_1CFLGraph_01_5_01_4.html +2 -2
- package/SVF-doxygen/html/html/structllvm_1_1GraphTraits_3_01SVF_1_1CFLNode_01_5_01_4.html +1 -1
- package/SVF-doxygen/html/html/svf-ex_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/wpa_8cpp_source.html +1 -1
- package/include/CFL/CFLAlias.h +12 -51
- package/include/CFL/CFLBase.h +110 -0
- package/include/CFL/CFLStat.h +7 -18
- package/include/CFL/CFLVF.h +13 -25
- package/include/Graphs/CFLGraph.h +5 -0
- package/lib/CFL/CFLAlias.cpp +33 -66
- package/lib/CFL/CFLBase.cpp +133 -0
- package/lib/CFL/CFLStat.cpp +22 -149
- package/lib/CFL/CFLVF.cpp +28 -38
- package/package.json +1 -1
- package/tools/CFL/cfl.cpp +12 -25
package/include/CFL/CFLStat.h
CHANGED
|
@@ -33,11 +33,13 @@
|
|
|
33
33
|
|
|
34
34
|
#include "Util/PTAStat.h"
|
|
35
35
|
#include "CFL/CFLAlias.h"
|
|
36
|
+
#include "CFL/CFLVF.h"
|
|
36
37
|
|
|
37
38
|
namespace SVF
|
|
38
39
|
{
|
|
39
40
|
|
|
40
41
|
class CFLAlias;
|
|
42
|
+
class CFLVF;
|
|
41
43
|
class SVFIR;
|
|
42
44
|
class ConstraintGraph;
|
|
43
45
|
|
|
@@ -48,24 +50,13 @@ class CFLStat : public PTAStat
|
|
|
48
50
|
{
|
|
49
51
|
|
|
50
52
|
private:
|
|
51
|
-
|
|
53
|
+
CFLBase* pta;
|
|
52
54
|
|
|
53
55
|
public:
|
|
54
|
-
static const char* CollapseTime;
|
|
55
|
-
|
|
56
|
-
static u32_t _MaxPtsSize;
|
|
57
|
-
static u32_t _NumOfCycles;
|
|
58
|
-
static u32_t _NumOfPWCCycles;
|
|
59
|
-
static u32_t _NumOfNodesInCycles;
|
|
60
|
-
static u32_t _MaxNumOfNodesInSCC;
|
|
61
|
-
u32_t _NumOfNullPtr;
|
|
62
|
-
u32_t _NumOfConstantPtr;
|
|
63
|
-
u32_t _NumOfBlackholePtr;
|
|
64
|
-
|
|
65
56
|
/// CFL Stat
|
|
66
57
|
u32_t _NumofCFLGraphNode;
|
|
67
58
|
|
|
68
|
-
CFLStat(
|
|
59
|
+
CFLStat(CFLBase* p);
|
|
69
60
|
|
|
70
61
|
virtual ~CFLStat()
|
|
71
62
|
{
|
|
@@ -74,15 +65,13 @@ public:
|
|
|
74
65
|
|
|
75
66
|
virtual void performStat();
|
|
76
67
|
|
|
77
|
-
void collectCycleInfo(ConstraintGraph* consCG);
|
|
78
|
-
|
|
79
68
|
void collectCFLInfo(CFLGraph* CFLGraph);
|
|
80
69
|
|
|
81
|
-
void statNullPtr();
|
|
82
|
-
|
|
83
70
|
void constraintGraphStat();
|
|
71
|
+
|
|
72
|
+
void CFLGrammarStat();
|
|
84
73
|
};
|
|
85
74
|
|
|
86
75
|
} // End namespace SVF
|
|
87
76
|
|
|
88
|
-
#endif /*
|
|
77
|
+
#endif /* CFL_CFLSTAT_H_ */
|
package/include/CFL/CFLVF.h
CHANGED
|
@@ -30,44 +30,32 @@
|
|
|
30
30
|
#ifndef INCLUDE_CFL_CFLVF_H_
|
|
31
31
|
#define INCLUDE_CFL_CFLVF_H_
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
#include "CFL/
|
|
35
|
-
#include "CFL/
|
|
36
|
-
#include "CFL/CFLGraphBuilder.h"
|
|
37
|
-
#include "CFL/CFLGramGraphChecker.h"
|
|
38
|
-
#include "MemoryModel/PointerAnalysis.h"
|
|
39
|
-
#include "Graphs/ConsG.h"
|
|
40
|
-
#include "Util/Options.h"
|
|
33
|
+
|
|
34
|
+
#include "CFL/CFLBase.h"
|
|
35
|
+
#include "CFL/CFLStat.h"
|
|
41
36
|
#include "SABER/SaberSVFGBuilder.h"
|
|
37
|
+
#include "WPA/Andersen.h"
|
|
42
38
|
|
|
43
39
|
namespace SVF
|
|
44
40
|
{
|
|
45
|
-
|
|
46
|
-
class CFLVF : public BVDataPTAImpl
|
|
41
|
+
class CFLVF : public CFLBase
|
|
47
42
|
{
|
|
48
43
|
|
|
49
44
|
public:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
CFLVF(SVFIR* ir) : BVDataPTAImpl(ir, PointerAnalysis::CFLFSCS_WPA, false), svfir(ir), graph(nullptr), grammar(nullptr), solver(nullptr)
|
|
45
|
+
CFLVF(SVFIR* ir) : CFLBase(ir, PointerAnalysis::CFLFSCS_WPA)
|
|
53
46
|
{
|
|
54
47
|
}
|
|
55
48
|
|
|
56
|
-
///
|
|
57
|
-
virtual
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
49
|
+
/// Initialize the grammar, graph, solver
|
|
50
|
+
virtual void initialize();
|
|
51
|
+
|
|
52
|
+
/// Print grammar and graph
|
|
53
|
+
virtual void finalize();
|
|
61
54
|
|
|
62
|
-
///
|
|
63
|
-
|
|
55
|
+
/// Build CFLGraph via VFG
|
|
56
|
+
void buildCFLGraph();
|
|
64
57
|
|
|
65
58
|
private:
|
|
66
|
-
CallSite2DummyValPN callsite2DummyValPN; ///< Map an instruction to a dummy obj which created at an indirect callsite, which invokes a heap allocator
|
|
67
|
-
SVFIR* svfir;
|
|
68
|
-
CFLGraph* graph;
|
|
69
|
-
CFLGrammar* grammar;
|
|
70
|
-
CFLSolver *solver;
|
|
71
59
|
SaberSVFGBuilder memSSA;
|
|
72
60
|
SVFG* svfg;
|
|
73
61
|
};
|
package/lib/CFL/CFLAlias.cpp
CHANGED
|
@@ -28,31 +28,11 @@
|
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
30
|
#include "CFL/CFLAlias.h"
|
|
31
|
-
#include "Util/SVFBasicTypes.h"
|
|
32
31
|
|
|
33
32
|
using namespace SVF;
|
|
34
33
|
using namespace cppUtil;
|
|
35
34
|
using namespace SVFUtil;
|
|
36
35
|
|
|
37
|
-
u32_t CFLAlias::numOfProcessedAddr = 0;
|
|
38
|
-
u32_t CFLAlias::numOfProcessedCopy = 0;
|
|
39
|
-
u32_t CFLAlias::numOfProcessedGep = 0;
|
|
40
|
-
u32_t CFLAlias::numOfProcessedLoad = 0;
|
|
41
|
-
u32_t CFLAlias::numOfProcessedStore = 0;
|
|
42
|
-
u32_t CFLAlias::numOfSfrs = 0;
|
|
43
|
-
u32_t CFLAlias::numOfFieldExpand = 0;
|
|
44
|
-
|
|
45
|
-
u32_t CFLAlias::numOfSCCDetection = 0;
|
|
46
|
-
double CFLAlias::timeOfSCCDetection = 0;
|
|
47
|
-
double CFLAlias::timeOfSCCMerges = 0;
|
|
48
|
-
double CFLAlias::timeOfCollapse = 0;
|
|
49
|
-
|
|
50
|
-
u32_t CFLAlias::AveragePointsToSetSize = 0;
|
|
51
|
-
u32_t CFLAlias::MaxPointsToSetSize = 0;
|
|
52
|
-
double CFLAlias::timeOfProcessCopyGep = 0;
|
|
53
|
-
double CFLAlias::timeOfProcessLoadStore = 0;
|
|
54
|
-
double CFLAlias::timeOfUpdateCallGraph = 0;
|
|
55
|
-
|
|
56
36
|
/*!
|
|
57
37
|
* On the fly call graph construction
|
|
58
38
|
* callsites is candidate indirect callsites need to be analyzed based on points-to results
|
|
@@ -193,9 +173,6 @@ void CFLAlias::heapAllocatorViaIndCall(CallSite cs)
|
|
|
193
173
|
*/
|
|
194
174
|
bool CFLAlias::updateCallGraph(const CallSiteToFunPtrMap& callsites)
|
|
195
175
|
{
|
|
196
|
-
|
|
197
|
-
// double cgUpdateStart = stat->getClk();
|
|
198
|
-
|
|
199
176
|
CallEdgeMap newEdges;
|
|
200
177
|
onTheFlyCallGraphSolve(callsites,newEdges);
|
|
201
178
|
for(CallEdgeMap::iterator it = newEdges.begin(), eit = newEdges.end(); it!=eit; ++it )
|
|
@@ -203,65 +180,55 @@ bool CFLAlias::updateCallGraph(const CallSiteToFunPtrMap& callsites)
|
|
|
203
180
|
CallSite cs = SVFUtil::getLLVMCallSite(it->first->getCallSite());
|
|
204
181
|
for(FunctionSet::iterator cit = it->second.begin(), ecit = it->second.end(); cit!=ecit; ++cit)
|
|
205
182
|
{
|
|
206
|
-
std::cout << cs.arg_size();
|
|
207
183
|
connectCaller2CalleeParams(cs,*cit);
|
|
208
184
|
}
|
|
209
185
|
}
|
|
210
186
|
|
|
211
|
-
// double cgUpdateEnd = stat->getClk();
|
|
212
|
-
//timeOfUpdateCallGraph += (cgUpdateEnd - cgUpdateStart) / TIMEINTERVAL;
|
|
213
|
-
|
|
214
187
|
return (!solver->isWorklistEmpty());
|
|
215
188
|
}
|
|
216
189
|
|
|
217
|
-
void CFLAlias::
|
|
190
|
+
void CFLAlias::initialize()
|
|
218
191
|
{
|
|
219
192
|
stat = new CFLStat(this);
|
|
220
|
-
GrammarBuilder grammarBuilder = GrammarBuilder(Options::GrammarFilename);
|
|
221
|
-
CFGNormalizer normalizer = CFGNormalizer();
|
|
222
|
-
AliasCFLGraphBuilder cflGraphBuilder = AliasCFLGraphBuilder();
|
|
223
|
-
CFLGramGraphChecker cflChecker = CFLGramGraphChecker();
|
|
224
|
-
if (Options::CFLGraph.empty())
|
|
225
|
-
{
|
|
226
|
-
PointerAnalysis::initialize();
|
|
227
|
-
GrammarBase *grammarBase = grammarBuilder.build();
|
|
228
|
-
ConstraintGraph *consCG = new ConstraintGraph(svfir);
|
|
229
|
-
if (Options::PEGTransfer)
|
|
230
|
-
{
|
|
231
|
-
graph = cflGraphBuilder.buildBiPEGgraph(consCG, grammarBase->getStartKind(), grammarBase, svfir);
|
|
232
|
-
}
|
|
233
|
-
else
|
|
234
|
-
{
|
|
235
|
-
graph = cflGraphBuilder.buildBigraph(consCG, grammarBase->getStartKind(), grammarBase);
|
|
236
|
-
}
|
|
237
193
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
cflChecker.check(grammarBase, &cflGraphBuilder, graph);
|
|
249
|
-
grammar = normalizer.normalize(grammarBase);
|
|
250
|
-
cflChecker.check(grammar, &cflGraphBuilder, graph);
|
|
251
|
-
delete grammarBase;
|
|
252
|
-
}
|
|
194
|
+
// Build CFL Grammar
|
|
195
|
+
buildCFLGrammar();
|
|
196
|
+
|
|
197
|
+
// Build CFL Graph
|
|
198
|
+
buildCFLGraph();
|
|
199
|
+
|
|
200
|
+
// Normalize CFL Grammar
|
|
201
|
+
normalizeCFLGrammar();
|
|
202
|
+
|
|
203
|
+
// Initialize sovler
|
|
253
204
|
solver = new CFLSolver(graph, grammar);
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
void CFLAlias::finalize()
|
|
208
|
+
{
|
|
257
209
|
if(Options::PrintCFL == true)
|
|
258
210
|
{
|
|
259
|
-
|
|
211
|
+
if (Options::CFLGraph.empty())
|
|
212
|
+
svfir->dump("IR");
|
|
260
213
|
grammar->dump("Grammar");
|
|
261
214
|
graph->dump("CFLGraph");
|
|
262
215
|
}
|
|
263
216
|
if (Options::CFLGraph.empty())
|
|
264
|
-
{
|
|
265
217
|
PointerAnalysis::finalize();
|
|
266
|
-
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
void CFLAlias::solve()
|
|
221
|
+
{
|
|
222
|
+
// Start solving
|
|
223
|
+
double start = stat->getClk(true);
|
|
224
|
+
|
|
225
|
+
solver->solve();
|
|
226
|
+
if (Options::CFLGraph.empty())
|
|
227
|
+
{
|
|
228
|
+
while (updateCallGraph(svfir->getIndirectCallsites()))
|
|
229
|
+
solver->solve();
|
|
230
|
+
} // Only cflgraph built from bc could reanlyze by update call graph
|
|
231
|
+
|
|
232
|
+
double end = stat->getClk(true);
|
|
233
|
+
timeOfSolving += (end - start) / TIMEINTERVAL;
|
|
267
234
|
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
//===----- CFLBase.cpp -- CFL Analysis Client Base--------------//
|
|
2
|
+
//
|
|
3
|
+
// SVF: Static Value-Flow Analysis
|
|
4
|
+
//
|
|
5
|
+
// Copyright (C) <2013-> <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 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 General Public License for more details.
|
|
17
|
+
|
|
18
|
+
// You should have received a copy of the GNU General Public License
|
|
19
|
+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
//
|
|
21
|
+
//===----------------------------------------------------------------------===//
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
* CFLBase.cpp
|
|
25
|
+
*
|
|
26
|
+
* Created on: Oct 13, 2022
|
|
27
|
+
* Author: Pei Xu
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
#include "CFL/CFLBase.h"
|
|
32
|
+
|
|
33
|
+
namespace SVF
|
|
34
|
+
{
|
|
35
|
+
|
|
36
|
+
class CFLStat;
|
|
37
|
+
|
|
38
|
+
double CFLBase::timeOfBuildCFLGrammar = 0;
|
|
39
|
+
double CFLBase::timeOfNormalizeGrammar = 0;
|
|
40
|
+
double CFLBase::timeOfBuildCFLGraph = 0;
|
|
41
|
+
double CFLBase::timeOfSolving = 0;
|
|
42
|
+
double CFLBase::numOfStartEdges = 0;
|
|
43
|
+
|
|
44
|
+
void CFLBase::buildCFLGrammar()
|
|
45
|
+
{
|
|
46
|
+
// Start building grammar
|
|
47
|
+
double start = stat->getClk(true);
|
|
48
|
+
|
|
49
|
+
GrammarBuilder grammarBuilder = GrammarBuilder(Options::GrammarFilename);
|
|
50
|
+
grammarBase = grammarBuilder.build();
|
|
51
|
+
|
|
52
|
+
// Get time of build grammar
|
|
53
|
+
double end = stat->getClk(true);
|
|
54
|
+
timeOfBuildCFLGrammar += (end - start) / TIMEINTERVAL;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
void CFLBase::buildCFLGraph()
|
|
58
|
+
{
|
|
59
|
+
// Start building CFLGraph
|
|
60
|
+
double start = stat->getClk(true);
|
|
61
|
+
|
|
62
|
+
AliasCFLGraphBuilder cflGraphBuilder = AliasCFLGraphBuilder();
|
|
63
|
+
if (Options::CFLGraph.empty()) // built from svfir
|
|
64
|
+
{
|
|
65
|
+
PointerAnalysis::initialize();
|
|
66
|
+
ConstraintGraph *consCG = new ConstraintGraph(svfir);
|
|
67
|
+
if (Options::PEGTransfer)
|
|
68
|
+
graph = cflGraphBuilder.buildBiPEGgraph(consCG, grammarBase->getStartKind(), grammarBase, svfir);
|
|
69
|
+
else
|
|
70
|
+
graph = cflGraphBuilder.buildBigraph(consCG, grammarBase->getStartKind(), grammarBase);
|
|
71
|
+
delete consCG;
|
|
72
|
+
}
|
|
73
|
+
else
|
|
74
|
+
graph = cflGraphBuilder.buildFromDot(Options::CFLGraph, grammarBase);
|
|
75
|
+
|
|
76
|
+
// Check CFL Graph and Grammar are accordance with grammar
|
|
77
|
+
CFLGramGraphChecker cflChecker = CFLGramGraphChecker();
|
|
78
|
+
cflChecker.check(grammarBase, &cflGraphBuilder, graph);
|
|
79
|
+
|
|
80
|
+
// Get time of build graph
|
|
81
|
+
double end = stat->getClk(true);
|
|
82
|
+
timeOfBuildCFLGraph += (end - start) / TIMEINTERVAL;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
void CFLBase::normalizeCFLGrammar()
|
|
86
|
+
{
|
|
87
|
+
// Start normalize grammar
|
|
88
|
+
double start = stat->getClk(true);
|
|
89
|
+
|
|
90
|
+
CFGNormalizer normalizer = CFGNormalizer();
|
|
91
|
+
grammar = normalizer.normalize(grammarBase);
|
|
92
|
+
|
|
93
|
+
// Get time of normalize grammar
|
|
94
|
+
double end = stat->getClk(true);
|
|
95
|
+
timeOfNormalizeGrammar += (end - start) / TIMEINTERVAL;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
void CFLBase::solve()
|
|
99
|
+
{
|
|
100
|
+
// Start solving
|
|
101
|
+
double start = stat->getClk(true);
|
|
102
|
+
|
|
103
|
+
solver->solve();
|
|
104
|
+
|
|
105
|
+
double end = stat->getClk(true);
|
|
106
|
+
timeOfSolving += (end - start) / TIMEINTERVAL;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
void CFLBase::analyze()
|
|
110
|
+
{
|
|
111
|
+
initialize();
|
|
112
|
+
|
|
113
|
+
solve();
|
|
114
|
+
|
|
115
|
+
finalize();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
CFLGraph* CFLBase::getCFLGraph()
|
|
119
|
+
{
|
|
120
|
+
return graph;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
void CFLBase::countSumEdges()
|
|
124
|
+
{
|
|
125
|
+
numOfStartEdges = 0;
|
|
126
|
+
for(auto it = getCFLGraph()->getCFLEdges().begin(); it != getCFLGraph()->getCFLEdges().end(); it++ )
|
|
127
|
+
{
|
|
128
|
+
if ((*it)->getEdgeKind() == grammar->getStartKind())
|
|
129
|
+
numOfStartEdges++;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
} // End namespace SVF
|
package/lib/CFL/CFLStat.cpp
CHANGED
|
@@ -33,22 +33,11 @@ using namespace SVF;
|
|
|
33
33
|
using namespace SVFUtil;
|
|
34
34
|
using namespace std;
|
|
35
35
|
|
|
36
|
-
u32_t CFLStat::_MaxPtsSize = 0;
|
|
37
|
-
u32_t CFLStat::_NumOfCycles = 0;
|
|
38
|
-
u32_t CFLStat::_NumOfPWCCycles = 0;
|
|
39
|
-
u32_t CFLStat::_NumOfNodesInCycles = 0;
|
|
40
|
-
u32_t CFLStat::_MaxNumOfNodesInSCC = 0;
|
|
41
|
-
|
|
42
|
-
const char* CFLStat::CollapseTime = "CollapseTime";
|
|
43
|
-
|
|
44
36
|
/*!
|
|
45
37
|
* Constructor
|
|
46
38
|
*/
|
|
47
|
-
CFLStat::CFLStat(
|
|
39
|
+
CFLStat::CFLStat(CFLBase* p): PTAStat(p),pta(p)
|
|
48
40
|
{
|
|
49
|
-
_NumOfNullPtr = 0;
|
|
50
|
-
_NumOfConstantPtr= 0;
|
|
51
|
-
_NumOfBlackholePtr = 0;
|
|
52
41
|
startClk();
|
|
53
42
|
}
|
|
54
43
|
|
|
@@ -57,56 +46,11 @@ CFLStat::CFLStat(CFLAlias* p): PTAStat(p),pta(p)
|
|
|
57
46
|
*/
|
|
58
47
|
void CFLStat::collectCFLInfo(CFLGraph* CFLGraph)
|
|
59
48
|
{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
NodeSet repNodes;
|
|
64
|
-
repNodes.clear();
|
|
65
|
-
}
|
|
49
|
+
timeStatMap["timeOfBuildCFLGraph"] = pta->timeOfBuildCFLGraph;
|
|
50
|
+
PTNumStatMap["NumOfNodes"] = CFLGraph->getTotalNodeNum();
|
|
51
|
+
PTNumStatMap["NumOfEdges"] = CFLGraph->getCFLEdges().size();
|
|
66
52
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
/*!
|
|
70
|
-
* Collect cycle information
|
|
71
|
-
*/
|
|
72
|
-
void CFLStat::collectCycleInfo(ConstraintGraph* consCG)
|
|
73
|
-
{
|
|
74
|
-
_NumOfCycles = 0;
|
|
75
|
-
_NumOfPWCCycles = 0;
|
|
76
|
-
_NumOfNodesInCycles = 0;
|
|
77
|
-
NodeSet repNodes;
|
|
78
|
-
repNodes.clear();
|
|
79
|
-
for(ConstraintGraph::iterator it = consCG->begin(), eit = consCG->end(); it!=eit; ++it)
|
|
80
|
-
{
|
|
81
|
-
// sub nodes have been removed from the constraint graph, only rep nodes are left.
|
|
82
|
-
NodeID repNode = consCG->sccRepNode(it->first);
|
|
83
|
-
NodeBS& subNodes = consCG->sccSubNodes(repNode);
|
|
84
|
-
NodeBS clone = subNodes;
|
|
85
|
-
for (NodeBS::iterator it = subNodes.begin(), eit = subNodes.end(); it != eit; ++it)
|
|
86
|
-
{
|
|
87
|
-
NodeID nodeId = *it;
|
|
88
|
-
PAGNode* pagNode = pta->getPAG()->getGNode(nodeId);
|
|
89
|
-
if (SVFUtil::isa<ObjVar>(pagNode) && pta->isFieldInsensitive(nodeId))
|
|
90
|
-
{
|
|
91
|
-
NodeID baseId = consCG->getBaseObjVar(nodeId);
|
|
92
|
-
clone.reset(nodeId);
|
|
93
|
-
clone.set(baseId);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
u32_t num = clone.count();
|
|
97
|
-
if (num > 1)
|
|
98
|
-
{
|
|
99
|
-
if(repNodes.insert(repNode).second)
|
|
100
|
-
{
|
|
101
|
-
_NumOfNodesInCycles += num;
|
|
102
|
-
if(consCG->isPWCNode(repNode))
|
|
103
|
-
_NumOfPWCCycles ++;
|
|
104
|
-
}
|
|
105
|
-
if( num > _MaxNumOfNodesInSCC)
|
|
106
|
-
_MaxNumOfNodesInSCC = num;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
_NumOfCycles += repNodes.size();
|
|
53
|
+
PTAStat::printStat("CFLGraph Stats");
|
|
110
54
|
}
|
|
111
55
|
|
|
112
56
|
void CFLStat::constraintGraphStat()
|
|
@@ -160,58 +104,12 @@ void CFLStat::constraintGraphStat()
|
|
|
160
104
|
|
|
161
105
|
PTAStat::printStat("CFL Graph Stats");
|
|
162
106
|
}
|
|
163
|
-
/*!
|
|
164
|
-
* Stat null pointers
|
|
165
|
-
*/
|
|
166
|
-
void CFLStat::statNullPtr()
|
|
167
|
-
{
|
|
168
|
-
|
|
169
|
-
_NumOfNullPtr = 0;
|
|
170
|
-
for (SVFIR::iterator iter = pta->getPAG()->begin(), eiter = pta->getPAG()->end();
|
|
171
|
-
iter != eiter; ++iter)
|
|
172
|
-
{
|
|
173
|
-
NodeID pagNodeId = iter->first;
|
|
174
|
-
PAGNode* pagNode = iter->second;
|
|
175
|
-
if (SVFUtil::isa<ValVar>(pagNode) == false)
|
|
176
|
-
continue;
|
|
177
|
-
SVFStmt::SVFStmtSetTy& inComingStore = pagNode->getIncomingEdges(SVFStmt::Store);
|
|
178
|
-
SVFStmt::SVFStmtSetTy& outGoingLoad = pagNode->getOutgoingEdges(SVFStmt::Load);
|
|
179
|
-
if (inComingStore.empty()==false || outGoingLoad.empty()==false)
|
|
180
|
-
{
|
|
181
|
-
///TODO: change the condition here to fetch the points-to set
|
|
182
|
-
const PointsTo& pts = pta->getPts(pagNodeId);
|
|
183
|
-
if (pta->containBlackHoleNode(pts))
|
|
184
|
-
_NumOfBlackholePtr++;
|
|
185
|
-
|
|
186
|
-
if (pta->containConstantNode(pts))
|
|
187
|
-
_NumOfConstantPtr++;
|
|
188
|
-
|
|
189
|
-
if(pts.empty())
|
|
190
|
-
{
|
|
191
|
-
std::string str;
|
|
192
|
-
raw_string_ostream rawstr(str);
|
|
193
|
-
if (!SVFUtil::isa<DummyValVar>(pagNode) && !SVFUtil::isa<DummyObjVar>(pagNode) )
|
|
194
|
-
{
|
|
195
|
-
// if a pointer is in dead function, we do not care
|
|
196
|
-
if(SymbolTableInfo::isPtrInUncalledFunction(pagNode->getValue()) == false)
|
|
197
|
-
{
|
|
198
|
-
_NumOfNullPtr++;
|
|
199
|
-
rawstr << "##Null Pointer : (NodeID " << pagNode->getId()
|
|
200
|
-
<< ") PtrName:" << pagNode->getValue()->getName();
|
|
201
|
-
writeWrnMsg(rawstr.str());
|
|
202
|
-
//pagNode->getValue()->dump();
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
else
|
|
206
|
-
{
|
|
207
|
-
_NumOfNullPtr++;
|
|
208
|
-
rawstr << "##Null Pointer : (NodeID " << pagNode->getId() << ")";
|
|
209
|
-
writeWrnMsg(rawstr.str());
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
107
|
|
|
108
|
+
void CFLStat::CFLGrammarStat()
|
|
109
|
+
{
|
|
110
|
+
timeStatMap["timeOfBuildCFLGrammar"] = pta->timeOfBuildCFLGrammar;
|
|
111
|
+
timeStatMap["timeOfNormalizeGrammar"] = pta->timeOfNormalizeGrammar;
|
|
112
|
+
PTAStat::printStat("CFLGrammar Stats");
|
|
215
113
|
}
|
|
216
114
|
|
|
217
115
|
/*!
|
|
@@ -219,51 +117,26 @@ void CFLStat::statNullPtr()
|
|
|
219
117
|
*/
|
|
220
118
|
void CFLStat::performStat()
|
|
221
119
|
{
|
|
222
|
-
|
|
223
|
-
assert(SVFUtil::isa<CFLAlias>(pta) && "not an CFLAlias pass!! what else??");
|
|
120
|
+
assert((SVFUtil::isa<CFLAlias>(pta)||SVFUtil::isa<CFLVF>(pta)) && "not an CFLAlias pass!! what else??");
|
|
224
121
|
endClk();
|
|
225
|
-
// SVFIR* pag = pta->getPAG();
|
|
226
|
-
CFLGraph* CFLGraph = pta->getCFLGraph();
|
|
227
|
-
// collect cfl graph infor
|
|
228
|
-
collectCFLInfo(CFLGraph);
|
|
229
|
-
// delete CFLGraph;
|
|
230
|
-
// collect constraint graph cycles
|
|
231
|
-
// collectCycleInfo(consCG);
|
|
232
122
|
|
|
233
|
-
|
|
234
|
-
statNullPtr();
|
|
123
|
+
pta->countSumEdges();
|
|
235
124
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
u32_t totalTopLevPtsSize = 0;
|
|
240
|
-
for (SVFIR::iterator iter = pta->getPAG()->begin(), eiter = pta->getPAG()->end();
|
|
241
|
-
iter != eiter; ++iter)
|
|
242
|
-
{
|
|
243
|
-
NodeID node = iter->first;
|
|
244
|
-
const PointsTo& pts = pta->getPts(node);
|
|
245
|
-
u32_t size = pts.count();
|
|
246
|
-
totalPointers++;
|
|
247
|
-
totalPtsSize+=size;
|
|
248
|
-
|
|
249
|
-
if(pta->getPAG()->isValidTopLevelPtr(pta->getPAG()->getGNode(node)))
|
|
250
|
-
{
|
|
251
|
-
totalTopLevPointers++;
|
|
252
|
-
totalTopLevPtsSize+=size;
|
|
253
|
-
}
|
|
125
|
+
// CFLGraph stat
|
|
126
|
+
CFLGraph* CFLGraph = pta->getCFLGraph();
|
|
127
|
+
collectCFLInfo(CFLGraph);
|
|
254
128
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
129
|
+
// Solver stat
|
|
130
|
+
timeStatMap["AnalysisTime"] = pta->timeOfSolving;
|
|
131
|
+
PTNumStatMap["SumEdges"] = pta->numOfStartEdges;
|
|
132
|
+
PTAStat::printStat("CFL-reachability analysis Stats");
|
|
258
133
|
|
|
134
|
+
// Grammar stat
|
|
135
|
+
CFLGrammarStat();
|
|
259
136
|
|
|
260
137
|
PTAStat::performStat();
|
|
261
138
|
|
|
139
|
+
// ConstraintGraph stat
|
|
262
140
|
constraintGraphStat();
|
|
263
|
-
|
|
264
|
-
PTNumStatMap["PointsToConstPtr"] = _NumOfConstantPtr;
|
|
265
|
-
PTNumStatMap["PointsToBlkPtr"] = _NumOfBlackholePtr;
|
|
266
|
-
|
|
267
|
-
PTAStat::printStat("CFL Alias Analysis Stats");
|
|
268
141
|
}
|
|
269
142
|
|