svf-lib 1.0.1183 → 1.0.1184

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
@@ -45,11 +45,6 @@ public:
45
45
  typedef ConstraintEdge::ConstraintEdgeSetTy::const_iterator const_iterator;
46
46
  bool _isPWCNode;
47
47
 
48
- enum SCCEdgeFlag
49
- {
50
- Copy, Direct
51
- };
52
-
53
48
  private:
54
49
  ConstraintEdge::ConstraintEdgeSetTy loadInEdges; ///< all incoming load edge of this node
55
50
  ConstraintEdge::ConstraintEdgeSetTy loadOutEdges; ///< all outgoing load edge of this node
@@ -72,19 +67,11 @@ private:
72
67
  ConstraintEdge::ConstraintEdgeSetTy addressOutEdges; ///< all outgoing address edge of this node
73
68
 
74
69
  public:
75
-
76
- static SCCEdgeFlag sccEdgeFlag;
77
-
70
+ /// For stride-based field representation
78
71
  NodeBS strides;
79
- bool newExpand;
80
72
  NodeBS baseIds;
81
73
 
82
- static void setSCCEdgeFlag(SCCEdgeFlag f)
83
- {
84
- sccEdgeFlag = f;
85
- }
86
-
87
- ConstraintNode(NodeID i) : GenericConsNodeTy(i, 0), _isPWCNode(false), newExpand(false)
74
+ ConstraintNode(NodeID i) : GenericConsNodeTy(i, 0), _isPWCNode(false)
88
75
  {
89
76
 
90
77
  }
@@ -165,69 +152,14 @@ public:
165
152
 
166
153
  /// Iterators
167
154
  //@{
168
- inline iterator directOutEdgeBegin()
169
- {
170
- if (sccEdgeFlag == Copy)
171
- return copyOutEdges.begin();
172
- else
173
- return directOutEdges.begin();
174
- }
175
-
176
- inline iterator directOutEdgeEnd()
177
- {
178
- if (sccEdgeFlag == Copy)
179
- return copyOutEdges.end();
180
- else
181
- return directOutEdges.end();
182
- }
183
-
184
- inline iterator directInEdgeBegin()
185
- {
186
- if (sccEdgeFlag == Copy)
187
- return copyInEdges.begin();
188
- else
189
- return directInEdges.begin();
190
- }
191
-
192
- inline iterator directInEdgeEnd()
193
- {
194
- if (sccEdgeFlag == Copy)
195
- return copyInEdges.end();
196
- else
197
- return directInEdges.end();
198
- }
199
-
200
- inline const_iterator directOutEdgeBegin() const
201
- {
202
- if (sccEdgeFlag == Copy)
203
- return copyOutEdges.begin();
204
- else
205
- return directOutEdges.begin();
206
- }
207
-
208
- inline const_iterator directOutEdgeEnd() const
209
- {
210
- if (sccEdgeFlag == Copy)
211
- return copyOutEdges.end();
212
- else
213
- return directOutEdges.end();
214
- }
215
-
216
- inline const_iterator directInEdgeBegin() const
217
- {
218
- if (sccEdgeFlag == Copy)
219
- return copyInEdges.begin();
220
- else
221
- return directInEdges.begin();
222
- }
223
-
224
- inline const_iterator directInEdgeEnd() const
225
- {
226
- if (sccEdgeFlag == Copy)
227
- return copyInEdges.end();
228
- else
229
- return directInEdges.end();
230
- }
155
+ iterator directOutEdgeBegin();
156
+ iterator directOutEdgeEnd();
157
+ iterator directInEdgeBegin();
158
+ iterator directInEdgeEnd();
159
+ const_iterator directOutEdgeBegin() const;
160
+ const_iterator directOutEdgeEnd() const;
161
+ const_iterator directInEdgeBegin() const;
162
+ const_iterator directInEdgeEnd() const;
231
163
 
232
164
  ConstraintEdge::ConstraintEdgeSetTy& incomingAddrEdges()
233
165
  {
@@ -234,8 +234,8 @@ public:
234
234
  static const llvm::cl::opt<std :: string> WriteAnder;
235
235
  // static const llvm::cl::opt<string> ReadAnder;
236
236
  static const llvm::cl::opt<std :: string> ReadAnder;
237
- static const llvm::cl::opt<bool> PtsDiff;
238
- static const llvm::cl::opt<bool> MergePWC;
237
+ static const llvm::cl::opt<bool> DiffPts;
238
+ static llvm::cl::opt<bool> DetectPWC;
239
239
  static const llvm::cl::opt<bool> VtableInSVFIR;
240
240
 
241
241
  // WPAPass.cpp
@@ -35,6 +35,7 @@
35
35
  #include "WPA/WPASolver.h"
36
36
  #include "MemoryModel/SVFIR.h"
37
37
  #include "Graphs/ConsG.h"
38
+ #include "Util/Options.h"
38
39
 
39
40
  namespace SVF
40
41
  {
@@ -151,7 +152,7 @@ public:
151
152
 
152
153
  /// Constructor
153
154
  Andersen(SVFIR* _pag, PTATY type = Andersen_WPA, bool alias_check = true)
154
- : AndersenBase(_pag, type, alias_check), pwcOpt(false), diffOpt(true)
155
+ : AndersenBase(_pag, type, alias_check)
155
156
  {
156
157
  }
157
158
 
@@ -223,28 +224,9 @@ public:
223
224
 
224
225
  void dumpTopLevelPtsTo();
225
226
 
226
- void setPWCOpt(bool flag)
227
+ void setDetectPWC(bool flag)
227
228
  {
228
- pwcOpt = flag;
229
- if (pwcOpt)
230
- setSCCEdgeFlag(ConstraintNode::Direct);
231
- else
232
- setSCCEdgeFlag(ConstraintNode::Copy);
233
- }
234
-
235
- bool mergePWC() const
236
- {
237
- return pwcOpt;
238
- }
239
-
240
- void setDiffOpt(bool flag)
241
- {
242
- diffOpt = flag;
243
- }
244
-
245
- bool enableDiff() const
246
- {
247
- return diffOpt;
229
+ Options::DetectPWC = flag;
248
230
  }
249
231
 
250
232
  protected:
@@ -252,13 +234,10 @@ protected:
252
234
  CallSite2DummyValPN callsite2DummyValPN; ///< Map an instruction to a dummy obj which created at an indirect callsite, which invokes a heap allocator
253
235
  void heapAllocatorViaIndCall(CallSite cs,NodePairSet &cpySrcNodes);
254
236
 
255
- bool pwcOpt;
256
- bool diffOpt;
257
-
258
237
  /// Handle diff points-to set.
259
238
  virtual inline void computeDiffPts(NodeID id)
260
239
  {
261
- if (enableDiff())
240
+ if (Options::DiffPts)
262
241
  {
263
242
  NodeID rep = sccRepNode(id);
264
243
  getDiffPTDataTy()->computeDiffPts(rep, getDiffPTDataTy()->getPts(rep));
@@ -267,7 +246,7 @@ protected:
267
246
  virtual inline const PointsTo& getDiffPts(NodeID id)
268
247
  {
269
248
  NodeID rep = sccRepNode(id);
270
- if (enableDiff())
249
+ if (Options::DiffPts)
271
250
  return getDiffPTDataTy()->getDiffPts(rep);
272
251
  else
273
252
  return getPTDataTy()->getPts(rep);
@@ -276,7 +255,7 @@ protected:
276
255
  /// Handle propagated points-to set.
277
256
  inline void updatePropaPts(NodeID dstId, NodeID srcId)
278
257
  {
279
- if (!enableDiff())
258
+ if (!Options::DiffPts)
280
259
  return;
281
260
  NodeID srcRep = sccRepNode(srcId);
282
261
  NodeID dstRep = sccRepNode(dstId);
@@ -284,7 +263,7 @@ protected:
284
263
  }
285
264
  inline void clearPropaPts(NodeID src)
286
265
  {
287
- if (enableDiff())
266
+ if (Options::DiffPts)
288
267
  {
289
268
  NodeID rep = sccRepNode(src);
290
269
  getDiffPTDataTy()->clearPropaPts(rep);
@@ -293,11 +272,6 @@ protected:
293
272
 
294
273
  virtual void initWorklist() {}
295
274
 
296
- virtual void setSCCEdgeFlag(ConstraintNode::SCCEdgeFlag f)
297
- {
298
- ConstraintNode::sccEdgeFlag = f;
299
- }
300
-
301
275
  /// Override WPASolver function in order to use the default solver
302
276
  virtual void processNode(NodeID nodeId);
303
277
 
@@ -424,6 +398,7 @@ public:
424
398
  diffWave = nullptr;
425
399
  }
426
400
 
401
+ virtual void initialize();
427
402
  virtual void solveWorklist();
428
403
  virtual void processNode(NodeID nodeId);
429
404
  virtual void postProcessNode(NodeID nodeId);
@@ -0,0 +1,160 @@
1
+ //===- AndersenSFR.h -- SFR based field-sensitive Andersen's analysis-------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-2017> <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
+ * AndersenSFR.h
25
+ *
26
+ * Created on: 09, Feb, 2019
27
+ * Author: Yuxiang Lei
28
+ */
29
+
30
+ #ifndef PROJECT_ANDERSENSFR_H
31
+ #define PROJECT_ANDERSENSFR_H
32
+
33
+
34
+ #include "WPA/Andersen.h"
35
+ #include "WPA/CSC.h"
36
+ #include "MemoryModel/PointsTo.h"
37
+
38
+ namespace SVF
39
+ {
40
+
41
+ /*!
42
+ * Selective Cycle Detection Based Andersen Analysis
43
+ */
44
+ class AndersenSCD : public Andersen
45
+ {
46
+ public:
47
+ typedef Map<NodeID, NodeID> NodeToNodeMap;
48
+
49
+ protected:
50
+ static AndersenSCD* scdAndersen;
51
+ NodeSet sccCandidates;
52
+ NodeToNodeMap pwcReps;
53
+
54
+ public:
55
+ AndersenSCD(SVFIR* _pag, PTATY type = AndersenSCD_WPA) :
56
+ Andersen(_pag,type)
57
+ {
58
+ }
59
+
60
+ /// Create an singleton instance directly instead of invoking llvm pass manager
61
+ static AndersenSCD *createAndersenSCD(SVFIR* _pag)
62
+ {
63
+ if (scdAndersen == nullptr)
64
+ {
65
+ new AndersenSCD(_pag);
66
+ scdAndersen->analyze();
67
+ return scdAndersen;
68
+ }
69
+ return scdAndersen;
70
+ }
71
+
72
+ static void releaseAndersenSCD()
73
+ {
74
+ if (scdAndersen)
75
+ delete scdAndersen;
76
+ scdAndersen = nullptr;
77
+ }
78
+
79
+ protected:
80
+ inline void addSccCandidate(NodeID nodeId)
81
+ {
82
+ sccCandidates.insert(sccRepNode(nodeId));
83
+ }
84
+
85
+ virtual NodeStack& SCCDetect();
86
+ virtual void PWCDetect();
87
+ virtual void solveWorklist();
88
+ virtual void handleLoadStore(ConstraintNode* node);
89
+ virtual void processAddr(const AddrCGEdge* addr);
90
+ virtual bool addCopyEdge(NodeID src, NodeID dst);
91
+ virtual bool updateCallGraph(const CallSiteToFunPtrMap& callsites);
92
+ virtual void processPWC(ConstraintNode* rep);
93
+ virtual void handleCopyGep(ConstraintNode* node);
94
+
95
+ };
96
+
97
+
98
+
99
+ /*!
100
+ * Selective Cycle Detection with Stride-based Field Representation
101
+ */
102
+ class AndersenSFR : public AndersenSCD
103
+ {
104
+ public:
105
+ typedef Map<NodeID, NodeBS> NodeStrides;
106
+ typedef Map<NodeID, NodeSet> FieldReps;
107
+ typedef Map<NodeID, pair<NodeID, NodeSet>> SFRTrait;
108
+
109
+ private:
110
+ static AndersenSFR* sfrAndersen;
111
+
112
+ CSC* csc;
113
+ NodeSet sfrObjNodes;
114
+ FieldReps fieldReps;
115
+
116
+ public:
117
+ AndersenSFR(SVFIR* _pag, PTATY type = AndersenSFR_WPA) :
118
+ AndersenSCD(_pag, type), csc(nullptr)
119
+ {
120
+ }
121
+
122
+ /// Create an singleton instance directly instead of invoking llvm pass manager
123
+ static AndersenSFR *createAndersenSFR(SVFIR* _pag)
124
+ {
125
+ if (sfrAndersen == nullptr)
126
+ {
127
+ new AndersenSFR(_pag);
128
+ sfrAndersen->analyze();
129
+ return sfrAndersen;
130
+ }
131
+ return sfrAndersen;
132
+ }
133
+
134
+ static void releaseAndersenSFR()
135
+ {
136
+ if (sfrAndersen)
137
+ delete sfrAndersen;
138
+ }
139
+
140
+ ~AndersenSFR()
141
+ {
142
+ if (csc != nullptr)
143
+ {
144
+ delete(csc);
145
+ csc = nullptr;
146
+ }
147
+ }
148
+
149
+ protected:
150
+ void initialize();
151
+ void PWCDetect();
152
+ void fieldExpand(NodeSet& initials, s32_t offset, NodeBS& strides, PointsTo& expandPts);
153
+ bool processGepPts(const PointsTo& pts, const GepCGEdge* edge);
154
+ bool mergeSrcToTgt(NodeID nodeId, NodeID newRepId);
155
+
156
+ };
157
+
158
+ } // End namespace SVF
159
+
160
+ #endif //PROJECT_ANDERSENSFR_H
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.1183",
3
+ "version": "1.0.1184",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {