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.
Files changed (166) hide show
  1. package/SVF-doxygen/html/html/CFLAlias_8cpp.html +0 -1
  2. package/SVF-doxygen/html/html/CFLAlias_8cpp_source.html +10 -42
  3. package/SVF-doxygen/html/html/CFLAlias_8h.html +1 -8
  4. package/SVF-doxygen/html/html/CFLAlias_8h_source.html +22 -49
  5. package/SVF-doxygen/html/html/CFLBase_8cpp.html +89 -0
  6. package/SVF-doxygen/html/html/CFLBase_8cpp_source.html +119 -0
  7. package/SVF-doxygen/html/html/CFLBase_8h.html +104 -0
  8. package/SVF-doxygen/html/html/CFLBase_8h_source.html +117 -0
  9. package/SVF-doxygen/html/html/CFLGraph_8cpp_source.html +2 -2
  10. package/SVF-doxygen/html/html/CFLGraph_8h_source.html +5 -4
  11. package/SVF-doxygen/html/html/CFLStat_8cpp_source.html +17 -58
  12. package/SVF-doxygen/html/html/CFLStat_8h.html +1 -0
  13. package/SVF-doxygen/html/html/CFLStat_8h_source.html +12 -22
  14. package/SVF-doxygen/html/html/CFLVF_8cpp.html +0 -2
  15. package/SVF-doxygen/html/html/CFLVF_8cpp_source.html +4 -15
  16. package/SVF-doxygen/html/html/CFLVF_8h.html +3 -8
  17. package/SVF-doxygen/html/html/CFLVF_8h_source.html +11 -26
  18. package/SVF-doxygen/html/html/CHG_8cpp_source.html +1 -1
  19. package/SVF-doxygen/html/html/CHG_8h_source.html +1 -1
  20. package/SVF-doxygen/html/html/ConsGNode_8h_source.html +5 -5
  21. package/SVF-doxygen/html/html/ConsG_8cpp_source.html +1 -1
  22. package/SVF-doxygen/html/html/ConsG_8h_source.html +1 -1
  23. package/SVF-doxygen/html/html/DCHG_8h_source.html +1 -1
  24. package/SVF-doxygen/html/html/DataFlowUtil_8cpp_source.html +1 -1
  25. package/SVF-doxygen/html/html/GEPTypeBridgeIterator_8h_source.html +1 -1
  26. package/SVF-doxygen/html/html/GenericGraph_8h_source.html +1 -1
  27. package/SVF-doxygen/html/html/GraphPrinter_8h_source.html +1 -1
  28. package/SVF-doxygen/html/html/ICFG_8cpp_source.html +1 -1
  29. package/SVF-doxygen/html/html/ICFG_8h_source.html +1 -1
  30. package/SVF-doxygen/html/html/IRGraph_8cpp_source.html +1 -1
  31. package/SVF-doxygen/html/html/IRGraph_8h_source.html +1 -1
  32. package/SVF-doxygen/html/html/PTACallGraph_8cpp_source.html +1 -1
  33. package/SVF-doxygen/html/html/PTACallGraph_8h_source.html +1 -1
  34. package/SVF-doxygen/html/html/SVFG_8cpp_source.html +1 -1
  35. package/SVF-doxygen/html/html/SVFG_8h_source.html +1 -1
  36. package/SVF-doxygen/html/html/TCT_8cpp_source.html +1 -1
  37. package/SVF-doxygen/html/html/TCT_8h_source.html +1 -1
  38. package/SVF-doxygen/html/html/VFG_8cpp_source.html +1 -1
  39. package/SVF-doxygen/html/html/VFG_8h_source.html +1 -1
  40. package/SVF-doxygen/html/html/annotated.html +271 -270
  41. package/SVF-doxygen/html/html/cfl_8cpp.html +6 -9
  42. package/SVF-doxygen/html/html/cfl_8cpp_source.html +6 -8
  43. package/SVF-doxygen/html/html/classSVF_1_1BVDataPTAImpl.html +9 -8
  44. package/SVF-doxygen/html/html/classSVF_1_1BVDataPTAImpl.png +0 -0
  45. package/SVF-doxygen/html/html/classSVF_1_1CFLAlias-members.html +120 -121
  46. package/SVF-doxygen/html/html/classSVF_1_1CFLAlias.html +212 -713
  47. package/SVF-doxygen/html/html/classSVF_1_1CFLAlias.png +0 -0
  48. package/SVF-doxygen/html/html/classSVF_1_1CFLBase-members.html +270 -0
  49. package/SVF-doxygen/html/html/classSVF_1_1CFLBase.html +1199 -0
  50. package/SVF-doxygen/html/html/classSVF_1_1CFLBase.png +0 -0
  51. package/SVF-doxygen/html/html/classSVF_1_1CFLGraph-members.html +21 -20
  52. package/SVF-doxygen/html/html/classSVF_1_1CFLGraph.html +33 -3
  53. package/SVF-doxygen/html/html/classSVF_1_1CFLStat-members.html +21 -31
  54. package/SVF-doxygen/html/html/classSVF_1_1CFLStat.html +62 -358
  55. package/SVF-doxygen/html/html/classSVF_1_1CFLVF-members.html +94 -80
  56. package/SVF-doxygen/html/html/classSVF_1_1CFLVF.html +207 -287
  57. package/SVF-doxygen/html/html/classSVF_1_1CFLVF.png +0 -0
  58. package/SVF-doxygen/html/html/classSVF_1_1ConstraintNode-members.html +26 -26
  59. package/SVF-doxygen/html/html/classSVF_1_1ConstraintNode.html +43 -43
  60. package/SVF-doxygen/html/html/classSVF_1_1GenericNode.html +21 -20
  61. package/SVF-doxygen/html/html/classSVF_1_1GenericNode.png +0 -0
  62. package/SVF-doxygen/html/html/classSVF_1_1PointerAnalysis.html +12 -11
  63. package/SVF-doxygen/html/html/classSVF_1_1PointerAnalysis.png +0 -0
  64. package/SVF-doxygen/html/html/classSVF_1_1SVFStat.html +1 -1
  65. package/SVF-doxygen/html/html/classes.html +96 -95
  66. package/SVF-doxygen/html/html/dda_8cpp_source.html +1 -1
  67. package/SVF-doxygen/html/html/dir_98f9a352f241e0e917d4efaa4086f6e8.html +2 -0
  68. package/SVF-doxygen/html/html/dir_ae8aa099e368efaa962140c6624142bc.html +2 -0
  69. package/SVF-doxygen/html/html/files.html +15 -13
  70. package/SVF-doxygen/html/html/functions.html +0 -8
  71. package/SVF-doxygen/html/html/functions_0x7e.html +2 -5
  72. package/SVF-doxygen/html/html/functions_a.html +9 -11
  73. package/SVF-doxygen/html/html/functions_b.html +11 -4
  74. package/SVF-doxygen/html/html/functions_c.html +33 -32
  75. package/SVF-doxygen/html/html/functions_f.html +16 -14
  76. package/SVF-doxygen/html/html/functions_func.html +6 -7
  77. package/SVF-doxygen/html/html/functions_func_0x7e.html +2 -5
  78. package/SVF-doxygen/html/html/functions_func_b.html +7 -0
  79. package/SVF-doxygen/html/html/functions_func_c.html +31 -23
  80. package/SVF-doxygen/html/html/functions_func_f.html +3 -1
  81. package/SVF-doxygen/html/html/functions_func_g.html +14 -11
  82. package/SVF-doxygen/html/html/functions_func_i.html +9 -7
  83. package/SVF-doxygen/html/html/functions_func_n.html +3 -0
  84. package/SVF-doxygen/html/html/functions_func_p.html +1 -1
  85. package/SVF-doxygen/html/html/functions_func_s.html +14 -13
  86. package/SVF-doxygen/html/html/functions_g.html +19 -15
  87. package/SVF-doxygen/html/html/functions_i.html +16 -14
  88. package/SVF-doxygen/html/html/functions_l.html +6 -6
  89. package/SVF-doxygen/html/html/functions_m.html +1 -2
  90. package/SVF-doxygen/html/html/functions_n.html +15 -8
  91. package/SVF-doxygen/html/html/functions_p.html +10 -10
  92. package/SVF-doxygen/html/html/functions_r.html +1 -1
  93. package/SVF-doxygen/html/html/functions_s.html +22 -21
  94. package/SVF-doxygen/html/html/functions_t.html +17 -13
  95. package/SVF-doxygen/html/html/functions_type_c.html +0 -1
  96. package/SVF-doxygen/html/html/functions_v.html +3 -3
  97. package/SVF-doxygen/html/html/functions_vars.html +0 -8
  98. package/SVF-doxygen/html/html/functions_vars_a.html +0 -1
  99. package/SVF-doxygen/html/html/functions_vars_c.html +0 -2
  100. package/SVF-doxygen/html/html/functions_vars_g.html +5 -4
  101. package/SVF-doxygen/html/html/functions_vars_m.html +0 -1
  102. package/SVF-doxygen/html/html/functions_vars_n.html +12 -8
  103. package/SVF-doxygen/html/html/functions_vars_p.html +1 -1
  104. package/SVF-doxygen/html/html/functions_vars_s.html +2 -4
  105. package/SVF-doxygen/html/html/functions_vars_t.html +12 -6
  106. package/SVF-doxygen/html/html/hierarchy.html +58 -57
  107. package/SVF-doxygen/html/html/mta_8cpp_source.html +1 -1
  108. package/SVF-doxygen/html/html/namespaceSVF.html +3 -0
  109. package/SVF-doxygen/html/html/saber_8cpp_source.html +1 -1
  110. package/SVF-doxygen/html/html/search/all_0.js +8 -8
  111. package/SVF-doxygen/html/html/search/all_1.js +2 -2
  112. package/SVF-doxygen/html/html/search/all_10.js +6 -6
  113. package/SVF-doxygen/html/html/search/all_11.js +1 -1
  114. package/SVF-doxygen/html/html/search/all_12.js +11 -11
  115. package/SVF-doxygen/html/html/search/all_13.js +16 -12
  116. package/SVF-doxygen/html/html/search/all_15.js +3 -3
  117. package/SVF-doxygen/html/html/search/all_16.js +1 -1
  118. package/SVF-doxygen/html/html/search/all_19.js +1 -2
  119. package/SVF-doxygen/html/html/search/all_2.js +2 -0
  120. package/SVF-doxygen/html/html/search/all_3.js +12 -7
  121. package/SVF-doxygen/html/html/search/all_6.js +4 -4
  122. package/SVF-doxygen/html/html/search/all_7.js +5 -4
  123. package/SVF-doxygen/html/html/search/all_9.js +4 -4
  124. package/SVF-doxygen/html/html/search/all_b.js +1 -1
  125. package/SVF-doxygen/html/html/search/all_c.js +4 -4
  126. package/SVF-doxygen/html/html/search/all_d.js +1 -1
  127. package/SVF-doxygen/html/html/search/all_e.js +14 -9
  128. package/SVF-doxygen/html/html/search/classes_2.js +1 -0
  129. package/SVF-doxygen/html/html/search/files_2.js +2 -0
  130. package/SVF-doxygen/html/html/search/functions_0.js +1 -1
  131. package/SVF-doxygen/html/html/search/functions_1.js +2 -0
  132. package/SVF-doxygen/html/html/search/functions_11.js +3 -3
  133. package/SVF-doxygen/html/html/search/functions_17.js +1 -2
  134. package/SVF-doxygen/html/html/search/functions_2.js +5 -2
  135. package/SVF-doxygen/html/html/search/functions_5.js +1 -1
  136. package/SVF-doxygen/html/html/search/functions_6.js +2 -1
  137. package/SVF-doxygen/html/html/search/functions_8.js +1 -1
  138. package/SVF-doxygen/html/html/search/functions_d.js +1 -0
  139. package/SVF-doxygen/html/html/search/functions_f.js +1 -1
  140. package/SVF-doxygen/html/html/search/typedefs_2.js +1 -1
  141. package/SVF-doxygen/html/html/search/variables_0.js +8 -8
  142. package/SVF-doxygen/html/html/search/variables_1.js +1 -1
  143. package/SVF-doxygen/html/html/search/variables_10.js +1 -1
  144. package/SVF-doxygen/html/html/search/variables_12.js +2 -2
  145. package/SVF-doxygen/html/html/search/variables_13.js +13 -9
  146. package/SVF-doxygen/html/html/search/variables_3.js +2 -2
  147. package/SVF-doxygen/html/html/search/variables_7.js +3 -2
  148. package/SVF-doxygen/html/html/search/variables_9.js +1 -1
  149. package/SVF-doxygen/html/html/search/variables_d.js +1 -1
  150. package/SVF-doxygen/html/html/search/variables_e.js +12 -8
  151. package/SVF-doxygen/html/html/structllvm_1_1GraphTraits_3_01Inverse_3_01SVF_1_1CFLNode_01_5_01_4_01_4.html +1 -1
  152. package/SVF-doxygen/html/html/structllvm_1_1GraphTraits_3_01SVF_1_1CFLGraph_01_5_01_4.html +2 -2
  153. package/SVF-doxygen/html/html/structllvm_1_1GraphTraits_3_01SVF_1_1CFLNode_01_5_01_4.html +1 -1
  154. package/SVF-doxygen/html/html/svf-ex_8cpp_source.html +1 -1
  155. package/SVF-doxygen/html/html/wpa_8cpp_source.html +1 -1
  156. package/include/CFL/CFLAlias.h +12 -51
  157. package/include/CFL/CFLBase.h +110 -0
  158. package/include/CFL/CFLStat.h +7 -18
  159. package/include/CFL/CFLVF.h +13 -25
  160. package/include/Graphs/CFLGraph.h +5 -0
  161. package/lib/CFL/CFLAlias.cpp +33 -66
  162. package/lib/CFL/CFLBase.cpp +133 -0
  163. package/lib/CFL/CFLStat.cpp +22 -149
  164. package/lib/CFL/CFLVF.cpp +28 -38
  165. package/package.json +1 -1
  166. package/tools/CFL/cfl.cpp +12 -25
@@ -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
- CFLAlias* pta;
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(CFLAlias* p);
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 /* FLOWSENSITIVESTAT_H_ */
77
+ #endif /* CFL_CFLSTAT_H_ */
@@ -30,44 +30,32 @@
30
30
  #ifndef INCLUDE_CFL_CFLVF_H_
31
31
  #define INCLUDE_CFL_CFLVF_H_
32
32
 
33
- #include "CFL/CFLSolver.h"
34
- #include "CFL/CFGNormalizer.h"
35
- #include "CFL/GrammarBuilder.h"
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
- typedef OrderedMap<CallSite, NodeID> CallSite2DummyValPN;
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
- /// Destructor
57
- virtual ~CFLVF()
58
- {
59
- delete solver;
60
- }
49
+ /// Initialize the grammar, graph, solver
50
+ virtual void initialize();
51
+
52
+ /// Print grammar and graph
53
+ virtual void finalize();
61
54
 
62
- /// Start Analysis here (main part of pointer analysis).
63
- virtual void analyze();
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
  };
@@ -109,6 +109,11 @@ public:
109
109
 
110
110
  void view();
111
111
 
112
+ inline const CFLEdgeSet& getCFLEdges() const
113
+ {
114
+ return cflEdgeSet;
115
+ }
116
+
112
117
  private:
113
118
  CFLEdgeSet cflEdgeSet;
114
119
  };
@@ -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::analyze()
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
- cflChecker.check(grammarBase, &cflGraphBuilder, graph);
239
- grammar = normalizer.normalize(grammarBase);
240
- cflChecker.check(grammar, &cflGraphBuilder, graph);
241
- delete consCG;
242
- delete grammarBase;
243
- }
244
- else
245
- {
246
- GrammarBase *grammarBase = grammarBuilder.build();
247
- graph = cflGraphBuilder.buildFromDot(Options::CFLGraph, grammarBase);
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
- solver->solve();
255
- while (updateCallGraph(svfir->getIndirectCallsites()))
256
- solver->solve();
205
+ }
206
+
207
+ void CFLAlias::finalize()
208
+ {
257
209
  if(Options::PrintCFL == true)
258
210
  {
259
- svfir->dump("IR");
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
@@ -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(CFLAlias* p): PTAStat(p),pta(p)
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
- _NumOfCycles = 0;
61
- _NumOfPWCCycles = 0;
62
- _NumOfNodesInCycles = 0;
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
- // stat null ptr number
234
- statNullPtr();
123
+ pta->countSumEdges();
235
124
 
236
- u32_t totalPointers = 0;
237
- u32_t totalTopLevPointers = 0;
238
- u32_t totalPtsSize = 0;
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
- if(size > _MaxPtsSize )
256
- _MaxPtsSize = size;
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