svf-lib 1.0.1256 → 1.0.1258

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.
@@ -188,6 +188,9 @@ typedef llvm::SCEVConstant SCEVConstant;
188
188
  typedef llvm::ScalarEvolution ScalarEvolution;
189
189
  typedef llvm::SCEV SCEV;
190
190
 
191
+ /// LLVM outputs
192
+ typedef llvm::raw_fd_ostream raw_fd_ostream;
193
+
191
194
  // LLVM Types.
192
195
  typedef llvm::VectorType VectorType;
193
196
  #if (LLVM_VERSION_MAJOR >= 9)
@@ -76,7 +76,6 @@ typedef llvm::GlobalVariable GlobalVariable;
76
76
 
77
77
  /// LLVM outputs
78
78
  typedef llvm::raw_string_ostream raw_string_ostream;
79
- typedef llvm::raw_fd_ostream raw_fd_ostream;
80
79
 
81
80
  /// LLVM types
82
81
  typedef llvm::StructType StructType;
@@ -214,17 +213,7 @@ public:
214
213
  return bb2LoopMap.find(bb)!=bb2LoopMap.end();
215
214
  }
216
215
 
217
- inline const std::vector<const BasicBlock*>& getLoopInfo(const BasicBlock* bb) const
218
- {
219
- Map<const BasicBlock*, std::vector<const BasicBlock*>>::const_iterator mapIter = bb2LoopMap.find(bb);
220
- if(mapIter != bb2LoopMap.end())
221
- return mapIter->second;
222
- else
223
- {
224
- assert(hasLoopInfo(bb) && "loopinfo does not exit(bb not in a loop)");
225
- abort();
226
- }
227
- }
216
+ const std::vector<const BasicBlock*>& getLoopInfo(const BasicBlock* bb) const;
228
217
 
229
218
  inline void addToBB2LoopMap(const BasicBlock* bb, const BasicBlock* loopBB)
230
219
  {
@@ -266,95 +255,13 @@ public:
266
255
  return this->exitBB;
267
256
  }
268
257
 
269
- void getExitBlocksOfLoop(const BasicBlock* bb, Set<const BasicBlock*>& exitbbs) const
270
- {
271
- if (hasLoopInfo(bb))
272
- {
273
- const std::vector<const BasicBlock*>& blocks = getLoopInfo(bb);
274
- assert(!blocks.empty() && "no available loop info?");
275
- for (const BasicBlock* block : blocks)
276
- {
277
- for (succ_const_iterator succIt = succ_begin(block); succIt != succ_end(block); succIt++)
278
- {
279
- const BasicBlock* succ = *succIt;
280
- if ((std::find(blocks.begin(), blocks.end(), succ)==blocks.end()))
281
- exitbbs.insert(succ);
282
- }
283
- }
284
- }
285
- }
286
-
287
- bool isLoopHeader(const BasicBlock* bb) const
288
- {
289
- if (hasLoopInfo(bb))
290
- {
291
- const std::vector<const BasicBlock*>& blocks = getLoopInfo(bb);
292
- assert(!blocks.empty() && "no available loop info?");
293
- return blocks.front() == bb;
294
- }
295
- return false;
296
- }
297
-
298
- bool dominate(const BasicBlock* bbKey, const BasicBlock* bbValue) const
299
- {
300
- if (bbKey == bbValue)
301
- return true;
302
-
303
- // An unreachable node is dominated by anything.
304
- if (isUnreachable(bbValue))
305
- {
306
- return true;
307
- }
308
-
309
- // And dominates nothing.
310
- if (isUnreachable(bbKey))
311
- {
312
- return false;
313
- }
314
-
315
- const Map<const BasicBlock*,Set<const BasicBlock*>>& dtBBsMap = getDomTreeMap();
316
- Map<const BasicBlock*,Set<const BasicBlock*>>::const_iterator mapIter = dtBBsMap.find(bbKey);
317
- if (mapIter != dtBBsMap.end())
318
- {
319
- const Set<const BasicBlock*> & dtBBs = mapIter->second;
320
- if (dtBBs.find(bbValue) != dtBBs.end())
321
- {
322
- return true;
323
- }
324
- }
325
-
326
- return false;
327
- }
328
-
329
- bool postDominate(const BasicBlock* bbKey, const BasicBlock* bbValue) const
330
- {
331
- if (bbKey == bbValue)
332
- return true;
333
-
334
- // An unreachable node is dominated by anything.
335
- if (isUnreachable(bbValue))
336
- {
337
- return true;
338
- }
339
-
340
- // And dominates nothing.
341
- if (isUnreachable(bbKey))
342
- {
343
- return false;
344
- }
345
-
346
- const Map<const BasicBlock*,Set<const BasicBlock*>>& dtBBsMap = getPostDomTreeMap();
347
- Map<const BasicBlock*,Set<const BasicBlock*>>::const_iterator mapIter = dtBBsMap.find(bbKey);
348
- if (mapIter != dtBBsMap.end())
349
- {
350
- const Set<const BasicBlock*> & dtBBs = mapIter->second;
351
- if (dtBBs.find(bbValue) != dtBBs.end())
352
- {
353
- return true;
354
- }
355
- }
356
- return false;
357
- }
258
+ void getExitBlocksOfLoop(const BasicBlock* bb, Set<const BasicBlock*>& exitbbs) const;
259
+
260
+ bool isLoopHeader(const BasicBlock* bb) const;
261
+
262
+ bool dominate(const BasicBlock* bbKey, const BasicBlock* bbValue) const;
263
+
264
+ bool postDominate(const BasicBlock* bbKey, const BasicBlock* bbValue) const;
358
265
 
359
266
  // Dump Control Flow Graph of llvm function, with instructions
360
267
  void viewCFG();
Binary file
@@ -54,12 +54,10 @@ public:
54
54
  /// Print grammar and graph
55
55
  virtual void finalize();
56
56
 
57
- /// Start Analysis here (main part of pointer analysis).
58
- virtual void analyze();
57
+ /// Solving CFL Reachability
58
+ virtual void solve();
59
59
 
60
- virtual void countSumEdges();
61
-
62
- /// Interface exposed to users of our pointer analysis, given Value infos
60
+ /// Interface exposed to users of our Alias analysis, given Value infos
63
61
  virtual AliasResult alias(const Value* v1, const Value* v2)
64
62
  {
65
63
  NodeID n1 = svfir->getValueNode(v1);
@@ -67,7 +65,7 @@ public:
67
65
  return alias(n1,n2);
68
66
  }
69
67
 
70
- /// Interface exposed to users of our pointer analysis, given PAGNodeID
68
+ /// Interface exposed to users of our Alias analysis, given PAGNodeID
71
69
  virtual AliasResult alias(NodeID node1, NodeID node2)
72
70
  {
73
71
  if(graph->hasEdge(graph->getGNode(node1), graph->getGNode(node2), graph->startKind))
@@ -21,7 +21,7 @@
21
21
  //===----------------------------------------------------------------------===//
22
22
 
23
23
  /*
24
- * CFLAlias.h
24
+ * CFLBase.h
25
25
  *
26
26
  * Created on: Oct 12, 2022
27
27
  * Author: Pei Xu
@@ -45,6 +45,7 @@ namespace SVF
45
45
 
46
46
  class CFLStat;
47
47
 
48
+ /// CFL Client Base Class
48
49
  class CFLBase : public BVDataPTAImpl
49
50
  {
50
51
 
@@ -57,53 +58,51 @@ public:
57
58
  virtual ~CFLBase()
58
59
  {
59
60
  delete solver;
61
+ delete grammarBase;
60
62
  }
61
63
 
62
- /// Initialize the grammar, graph, solver
63
- virtual void initialize() = 0;
64
+ /// Build Grammar from text file
65
+ virtual void buildCFLGrammar();
64
66
 
65
- /// Print grammar and graph
66
- virtual void finalize() = 0;
67
+ /// Build CFLGraph based on Option
68
+ virtual void buildCFLGraph();
67
69
 
68
- /// Start Analysis here (main part of pointer analysis).
69
- virtual void analyze() = 0;
70
+ /// Normalize grammar
71
+ virtual void normalizeCFLGrammar();
70
72
 
71
73
  /// Get CFL graph
72
- CFLGraph* getCFLGraph()
73
- {
74
- return graph;
75
- }
74
+ CFLGraph* getCFLGraph();
75
+
76
+ /// Count the num of Nonterminal Edges
77
+ virtual void countSumEdges();
78
+
79
+ /// Solving CFL Reachability
80
+ virtual void solve();
76
81
 
77
- virtual void countSumEdges() = 0;
82
+ /// Perform analyze (main part of CFLR Analysis)
83
+ virtual void analyze();
78
84
 
79
85
  /// Statistics
80
86
  //@{
81
- static u32_t numOfProcessedAddr; /// Number of processed Addr edge
82
- static u32_t numOfProcessedCopy; /// Number of processed Copy edge
83
- static u32_t numOfProcessedGep; /// Number of processed Gep edge
84
- static u32_t numOfProcessedLoad; /// Number of processed Load edge
85
- static u32_t numOfProcessedStore; /// Number of processed Store edge
86
- static u32_t numOfSfrs;
87
- static u32_t numOfFieldExpand;
88
-
89
- static u32_t numOfSCCDetection;
90
- static double timeOfSCCDetection;
91
- static double timeOfSCCMerges;
92
- static double timeOfCollapse;
93
- static u32_t AveragePointsToSetSize;
94
- static u32_t MaxPointsToSetSize;
95
- static double timeOfProcessCopyGep;
96
- static double timeOfProcessLoadStore;
97
- static double timeOfUpdateCallGraph;
98
- static double timeOfSolving;
99
- static double numOfSumEdges;
87
+ // Grammar
88
+ static double timeOfBuildCFLGrammar; // Time of building grammarBase from text file
89
+ static double timeOfNormalizeGrammar; // Time of normalizing grammarBase to CFLGrammar
90
+ // Graph
91
+ static double timeOfBuildCFLGraph; // Time of building CFLGraph
92
+ static double numOfTerminalEdges; // Number of terminal labeled edges
93
+ static double numOfTemporaryNonterminalEdges; // Number of temporary (ie. X0, X1..) nonterminal labeled edges
94
+ static double numOfNonterminalEdges; // Number of nonterminal labeled edges
95
+ static double numOfStartEdges; // Number of start nonterminal labeled edges
96
+ // Solver
97
+ static double timeOfSolving; // time of solving CFL Reachability
100
98
  //@}
101
99
 
102
100
  protected:
103
101
  SVFIR* svfir;
104
102
  CFLGraph* graph;
103
+ GrammarBase* grammarBase;
105
104
  CFLGrammar* grammar;
106
- CFLSolver *solver;
105
+ CFLSolver* solver;
107
106
  };
108
107
 
109
108
  } // End namespace SVF
@@ -53,17 +53,6 @@ private:
53
53
  CFLBase* pta;
54
54
 
55
55
  public:
56
- static const char* CollapseTime;
57
-
58
- static u32_t _MaxPtsSize;
59
- static u32_t _NumOfCycles;
60
- static u32_t _NumOfPWCCycles;
61
- static u32_t _NumOfNodesInCycles;
62
- static u32_t _MaxNumOfNodesInSCC;
63
- u32_t _NumOfNullPtr;
64
- u32_t _NumOfConstantPtr;
65
- u32_t _NumOfBlackholePtr;
66
-
67
56
  /// CFL Stat
68
57
  u32_t _NumofCFLGraphNode;
69
58
 
@@ -76,15 +65,13 @@ public:
76
65
 
77
66
  virtual void performStat();
78
67
 
79
- void collectCycleInfo(ConstraintGraph* consCG);
80
-
81
68
  void collectCFLInfo(CFLGraph* CFLGraph);
82
69
 
83
- void statNullPtr();
84
-
85
70
  void constraintGraphStat();
71
+
72
+ void CFLGrammarStat();
86
73
  };
87
74
 
88
75
  } // End namespace SVF
89
76
 
90
- #endif /* FLOWSENSITIVESTAT_H_ */
77
+ #endif /* CFL_CFLSTAT_H_ */
@@ -52,10 +52,8 @@ public:
52
52
  /// Print grammar and graph
53
53
  virtual void finalize();
54
54
 
55
- /// Start Analysis here (main part of pointer analysis).
56
- virtual void analyze();
57
-
58
- virtual void countSumEdges();
55
+ /// Build CFLGraph via VFG
56
+ void buildCFLGraph();
59
57
 
60
58
  private:
61
59
  SaberSVFGBuilder memSSA;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.1256",
3
+ "version": "1.0.1258",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {