svf-lib 1.0.2112 → 1.0.2113

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.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -31,13 +31,13 @@
31
31
  #define RCG_H_
32
32
 
33
33
  #include "Graphs/CallGraph.h"
34
- #include "MemoryModel/PointerAnalysisImpl.h"
35
34
 
36
35
  namespace SVF
37
36
  {
38
37
 
39
38
  class SVFModule;
40
39
  class ThreadAPI;
40
+ class PointerAnalysis;
41
41
  /*!
42
42
  * PTA thread fork edge from fork site to the entry of a start routine function
43
43
  */
@@ -201,7 +201,8 @@ public:
201
201
  /// whether this call instruction has a valid call graph edge
202
202
  inline bool hasThreadForkEdge(const CallICFGNode* cs) const
203
203
  {
204
- return callinstToThreadForkEdgesMap.find(cs) != callinstToThreadForkEdgesMap.end();
204
+ return callinstToThreadForkEdgesMap.find(cs) !=
205
+ callinstToThreadForkEdgesMap.end();
205
206
  }
206
207
  inline ForkEdgeSet::const_iterator getForkEdgeBegin(const CallICFGNode* cs) const
207
208
  {
@@ -345,8 +346,8 @@ public:
345
346
 
346
347
  /// Add direct/indirect thread fork edges
347
348
  //@{
348
- void addDirectForkEdge(const CallICFGNode* cs);
349
- void addIndirectForkEdge(const CallICFGNode* cs, const SVFFunction* callee);
349
+ bool addDirectForkEdge(const CallICFGNode* cs);
350
+ bool addIndirectForkEdge(const CallICFGNode* cs, const SVFFunction* callee);
350
351
  //@}
351
352
 
352
353
  /// Add thread join edges
@@ -34,7 +34,7 @@
34
34
  #include <signal.h>
35
35
 
36
36
  #include "Graphs/CHG.h"
37
- #include "Graphs/CallGraph.h"
37
+ #include "Graphs/ThreadCallGraph.h"
38
38
  #include "Graphs/SCC.h"
39
39
  #include "MemoryModel/AbstractPointsToDS.h"
40
40
  #include "MemoryModel/ConditionalPT.h"
@@ -199,6 +199,10 @@ protected:
199
199
  /// On the fly call graph construction
200
200
  virtual void onTheFlyCallGraphSolve(const CallSiteToFunPtrMap& callsites, CallEdgeMap& newEdges);
201
201
 
202
+ /// On the fly thread call graph construction respecting forksite
203
+ virtual void onTheFlyThreadCallGraphSolve(const CallSiteToFunPtrMap& callsites,
204
+ CallEdgeMap& newForkEdges);
205
+
202
206
  /// Normalize points-to information for field-sensitive analysis,
203
207
  /// i.e., replace fieldObj with baseObj if it is field-insensitive
204
208
  virtual void normalizePointsTo();
@@ -457,7 +457,7 @@ inline bool isBarrierWaitCall(const CallICFGNode* cs)
457
457
 
458
458
  /// Return sole argument of the thread routine
459
459
  //@{
460
- inline const SVFValue* getActualParmAtForkSite(const CallICFGNode* cs)
460
+ inline const SVFVar* getActualParmAtForkSite(const CallICFGNode* cs)
461
461
  {
462
462
  return ThreadAPI::getThreadAPI()->getActualParmAtForkSite(cs);
463
463
  }
@@ -38,6 +38,7 @@ namespace SVF
38
38
  class SVFModule;
39
39
  class ICFGNode;
40
40
  class CallICFGNode;
41
+ class SVFVar;
41
42
 
42
43
  /*
43
44
  * ThreadAPI class contains interfaces for pthread programs
@@ -128,11 +129,16 @@ public:
128
129
  /// Note that, it could be function type or a void* pointer
129
130
  const SVFValue* getForkedFun(const CallICFGNode *inst) const;
130
131
 
131
- /// Return the forth argument of the call,
132
+ /// Return the actual param of forksite
132
133
  /// Note that, it is the sole argument of start routine ( a void* pointer )
133
- const SVFValue* getActualParmAtForkSite(const CallICFGNode *inst) const;
134
+ const SVFVar* getActualParmAtForkSite(const CallICFGNode *inst) const;
135
+
136
+ /// Return the formal parm of forked function (the first arg in pthread)
137
+ const SVFVar* getFormalParmOfForkedFun(const SVFFunction* F) const;
134
138
  //@}
135
139
 
140
+
141
+
136
142
  /// Return true if this call create a new thread
137
143
  //@{
138
144
  bool isTDFork(const CallICFGNode *inst) const;
@@ -47,6 +47,8 @@ namespace SVF
47
47
 
48
48
  class SVFModule;
49
49
 
50
+ class ThreadCallGraph;
51
+
50
52
  /*!
51
53
  * Abstract class of inclusion-based Pointer Analysis
52
54
  */
@@ -54,6 +56,9 @@ typedef WPASolver<ConstraintGraph*> WPAConstraintSolver;
54
56
 
55
57
  class AndersenBase: public WPAConstraintSolver, public BVDataPTAImpl
56
58
  {
59
+ public:
60
+ typedef OrderedMap<const CallICFGNode*, NodeID> CallSite2DummyValPN;
61
+
57
62
  public:
58
63
 
59
64
  /// Constructor
@@ -81,11 +86,19 @@ public:
81
86
  /// Finalize analysis
82
87
  virtual void finalize() override;
83
88
 
84
- /// Implement it in child class to update call graph
85
- virtual inline bool updateCallGraph(const CallSiteToFunPtrMap&) override
86
- {
87
- return false;
88
- }
89
+ /// Update call graph
90
+ virtual bool updateCallGraph(const CallSiteToFunPtrMap&) override;
91
+
92
+ /// Update thread call graph
93
+ virtual bool updateThreadCallGraph(const CallSiteToFunPtrMap&, NodePairSet&);
94
+
95
+ /// Connect formal and actual parameters for indirect forksites
96
+ virtual void connectCaller2ForkedFunParams(const CallICFGNode* cs, const SVFFunction* F,
97
+ NodePairSet& cpySrcNodes);
98
+
99
+ /// Connect formal and actual parameters for indirect callsites
100
+ virtual void connectCaller2CalleeParams(const CallICFGNode* cs, const SVFFunction* F,
101
+ NodePairSet& cpySrcNodes);
89
102
 
90
103
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
91
104
  //@{
@@ -123,6 +136,9 @@ public:
123
136
  }
124
137
  //@}
125
138
 
139
+ /// Add copy edge on constraint graph
140
+ virtual inline bool addCopyEdge(NodeID src, NodeID dst) = 0;
141
+
126
142
  /// dump statistics
127
143
  inline void printStat()
128
144
  {
@@ -160,6 +176,11 @@ public:
160
176
  protected:
161
177
  /// Constraint Graph
162
178
  ConstraintGraph* consCG;
179
+ CallSite2DummyValPN
180
+ callsite2DummyValPN; ///< Map an instruction to a dummy obj which
181
+ ///< created at an indirect callsite, which invokes
182
+ ///< a heap allocator
183
+ void heapAllocatorViaIndCall(const CallICFGNode* cs, NodePairSet& cpySrcNodes);
163
184
  };
164
185
 
165
186
  /*!
@@ -171,7 +192,6 @@ class Andersen: public AndersenBase
171
192
 
172
193
  public:
173
194
  typedef SCCDetection<ConstraintGraph*> CGSCC;
174
- typedef OrderedMap<const CallICFGNode*, NodeID> CallSite2DummyValPN;
175
195
 
176
196
  /// Constructor
177
197
  Andersen(SVFIR* _pag, PTATY type = Andersen_WPA, bool alias_check = true)
@@ -243,7 +263,6 @@ public:
243
263
  protected:
244
264
 
245
265
  CallSite2DummyValPN callsite2DummyValPN; ///< Map an instruction to a dummy obj which created at an indirect callsite, which invokes a heap allocator
246
- void heapAllocatorViaIndCall(const CallICFGNode* cs,NodePairSet &cpySrcNodes);
247
266
 
248
267
  /// Handle diff points-to set.
249
268
  virtual inline void computeDiffPts(NodeID id)
@@ -311,12 +330,6 @@ protected:
311
330
  return false;
312
331
  }
313
332
 
314
- /// Update call graph for the input indirect callsites
315
- virtual bool updateCallGraph(const CallSiteToFunPtrMap& callsites);
316
-
317
- /// Connect formal and actual parameters for indirect callsites
318
- void connectCaller2CalleeParams(const CallICFGNode* cs, const SVFFunction* F, NodePairSet& cpySrcNodes);
319
-
320
333
  /// Merge sub node to its rep
321
334
  virtual void mergeNodeToRep(NodeID nodeId,NodeID newRepId);
322
335
 
@@ -23,7 +23,6 @@ class Steensgaard : public AndersenBase
23
23
  public:
24
24
  typedef Map<NodeID, NodeID> NodeToEquivClassMap;
25
25
  typedef Map<NodeID, Set<NodeID>> NodeToSubsMap;
26
- typedef OrderedMap<const CallICFGNode*, NodeID> CallSite2DummyValPN;
27
26
 
28
27
  /// Constructor
29
28
  Steensgaard(SVFIR* _pag) : AndersenBase(_pag, Steensgaard_WPA, true) {}
@@ -46,7 +45,7 @@ public:
46
45
  steens = nullptr;
47
46
  }
48
47
 
49
- virtual void solveWorklist();
48
+ virtual void solveWorklist() override;
50
49
 
51
50
  void processAllAddr();
52
51
 
@@ -69,18 +68,18 @@ public:
69
68
  //@}
70
69
 
71
70
  /// Operation of points-to set
72
- virtual inline const PointsTo& getPts(NodeID id)
71
+ virtual inline const PointsTo& getPts(NodeID id) override
73
72
  {
74
73
  return getPTDataTy()->getPts(getEC(id));
75
74
  }
76
75
  /// pts(id) = pts(id) U target
77
- virtual inline bool unionPts(NodeID id, const PointsTo& target)
76
+ virtual inline bool unionPts(NodeID id, const PointsTo& target) override
78
77
  {
79
78
  id = getEC(id);
80
79
  return getPTDataTy()->unionPts(id, target);
81
80
  }
82
81
  /// pts(id) = pts(id) U pts(ptd)
83
- virtual inline bool unionPts(NodeID id, NodeID ptd)
82
+ virtual inline bool unionPts(NodeID id, NodeID ptd) override
84
83
  {
85
84
  id = getEC(id);
86
85
  ptd = getEC(ptd);
@@ -98,6 +97,11 @@ public:
98
97
  else
99
98
  return it->second;
100
99
  }
100
+ /// Return getEC(id)
101
+ inline NodeID sccRepNode(NodeID id) const override
102
+ {
103
+ return getEC(id);
104
+ }
101
105
  void setEC(NodeID node, NodeID rep);
102
106
 
103
107
  inline Set<NodeID>& getSubNodes(NodeID id)
@@ -111,25 +115,11 @@ public:
111
115
  }
112
116
 
113
117
  /// Add copy edge on constraint graph
114
- virtual inline bool addCopyEdge(NodeID src, NodeID dst)
118
+ virtual inline bool addCopyEdge(NodeID src, NodeID dst) override
115
119
  {
116
120
  return consCG->addCopyCGEdge(src, dst);
117
121
  }
118
122
 
119
- protected:
120
- CallSite2DummyValPN
121
- callsite2DummyValPN; ///< Map an instruction to a dummy obj which
122
- ///< created at an indirect callsite, which invokes
123
- ///< a heap allocator
124
- void heapAllocatorViaIndCall(const CallICFGNode* cs, NodePairSet& cpySrcNodes);
125
-
126
- /// Update call graph for the input indirect callsites
127
- virtual bool updateCallGraph(const CallSiteToFunPtrMap& callsites);
128
-
129
- /// Connect formal and actual parameters for indirect callsites
130
- void connectCaller2CalleeParams(const CallICFGNode* cs, const SVFFunction* F,
131
- NodePairSet& cpySrcNodes);
132
-
133
123
  private:
134
124
  static Steensgaard* steens; // static instance
135
125
  NodeToEquivClassMap nodeToECMap;
@@ -51,13 +51,20 @@ public:
51
51
  }
52
52
 
53
53
  /// Type analysis
54
- void analyze();
54
+ void analyze() override;
55
55
 
56
56
  /// Initialize analysis
57
- void initialize();
57
+ void initialize() override;
58
58
 
59
59
  /// Finalize analysis
60
- virtual inline void finalize();
60
+ virtual inline void finalize() override;
61
+
62
+ /// Add copy edge on constraint graph
63
+ inline bool addCopyEdge(NodeID src, NodeID dst) override
64
+ {
65
+ assert(false && "this function should never be executed!");
66
+ return false;
67
+ }
61
68
 
62
69
  /// Resolve callgraph based on CHA
63
70
  void callGraphSolveBasedOnCHA(const CallSiteToFunPtrMap& callsites, CallEdgeMap& newEdges);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.2112",
3
+ "version": "1.0.2113",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {