svf-lib 1.0.726 → 1.0.730

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.
@@ -68,7 +68,7 @@ public:
68
68
  NodeID allocateValueId(void);
69
69
 
70
70
  /// Notify the allocator that all symbols have had IDs allocated.
71
- void endSymbolAllocation(void);
71
+ NodeID endSymbolAllocation(void);
72
72
 
73
73
  /// Returns the total number of memory objects.
74
74
  NodeID getNumObjects(void) const { return numObjects; }
@@ -241,6 +241,17 @@ inline const SVFFunction* getFunction(StringRef name)
241
241
  return nullptr;
242
242
  }
243
243
 
244
+ /// find the unique defined global across multiple modules
245
+ inline const Value* getGlobalRep(const Value* val)
246
+ {
247
+ if(const GlobalVariable* gvar = SVFUtil::dyn_cast<GlobalVariable>(val))
248
+ {
249
+ if (LLVMModuleSet::getLLVMModuleSet()->hasGlobalRep(gvar))
250
+ val = LLVMModuleSet::getLLVMModuleSet()->getGlobalRep(gvar);
251
+ }
252
+ return val;
253
+ }
254
+
244
255
  /// Get the definition of a function across multiple modules
245
256
  inline const SVFFunction* getDefFunForMultipleModule(const Function* fun)
246
257
  {
@@ -40,7 +40,6 @@
40
40
  namespace SVF
41
41
  {
42
42
 
43
- class PTAType;
44
43
  class SVFModule;
45
44
 
46
45
  /*!
@@ -464,94 +463,6 @@ protected:
464
463
  };
465
464
 
466
465
 
467
-
468
- /**
469
- * Wave propagation with diff points-to set with type filter.
470
- */
471
- class AndersenWaveDiffWithType : public AndersenWaveDiff
472
- {
473
-
474
- private:
475
-
476
- typedef Map<NodeID, Set<const GepCGEdge*>> TypeMismatchedObjToEdgeTy;
477
-
478
- TypeMismatchedObjToEdgeTy typeMismatchedObjToEdges;
479
-
480
- void recordTypeMismatchedGep(NodeID obj, const GepCGEdge* gepEdge)
481
- {
482
- TypeMismatchedObjToEdgeTy::iterator it = typeMismatchedObjToEdges.find(obj);
483
- if (it != typeMismatchedObjToEdges.end())
484
- {
485
- Set<const GepCGEdge*> &edges = it->second;
486
- edges.insert(gepEdge);
487
- }
488
- else
489
- {
490
- Set<const GepCGEdge*> edges;
491
- edges.insert(gepEdge);
492
- typeMismatchedObjToEdges[obj] = edges;
493
- }
494
- }
495
-
496
- static AndersenWaveDiffWithType* diffWaveWithType; // static instance
497
-
498
- /// Handle diff points-to set.
499
- //@{
500
- virtual inline void computeDiffPts(NodeID id)
501
- {
502
- NodeID rep = sccRepNode(id);
503
- getDiffPTDataTy()->computeDiffPts(rep, getDiffPTDataTy()->getPts(rep));
504
- }
505
- virtual inline const PointsTo& getDiffPts(NodeID id)
506
- {
507
- NodeID rep = sccRepNode(id);
508
- return getDiffPTDataTy()->getDiffPts(rep);
509
- }
510
- //@}
511
-
512
- public:
513
- AndersenWaveDiffWithType(PAG* _pag, PTATY type = AndersenWaveDiffWithType_WPA): AndersenWaveDiff(_pag,type)
514
- {
515
- assert(getTypeSystem()!=nullptr && "a type system is required for this pointer analysis");
516
- }
517
-
518
- /// Create an singleton instance directly instead of invoking llvm pass manager
519
- static AndersenWaveDiffWithType* createAndersenWaveDiffWithType(PAG* p)
520
- {
521
- if(diffWaveWithType==nullptr)
522
- {
523
- diffWaveWithType = new AndersenWaveDiffWithType(p);
524
- diffWaveWithType->analyze();
525
- return diffWaveWithType;
526
- }
527
- return diffWaveWithType;
528
- }
529
- static void releaseAndersenWaveDiffWithType()
530
- {
531
- if (diffWaveWithType)
532
- delete diffWaveWithType;
533
- diffWaveWithType = nullptr;
534
- }
535
-
536
- protected:
537
- /// SCC detection
538
- virtual NodeStack& SCCDetect();
539
- /// merge types of nodes in a cycle
540
- void mergeTypeOfNodes(const NodeBS &nodes);
541
- /// process "bitcast" CopyCGEdge
542
- virtual void processCast(const ConstraintEdge *edge);
543
- /// update type of objects when process "bitcast" CopyCGEdge
544
- void updateObjType(const Type *type, const PointsTo &objs);
545
- /// process mismatched gep edges
546
- void processTypeMismatchedGep(NodeID obj, const Type *type);
547
- /// match types for Gep Edges
548
- virtual bool matchType(NodeID ptrid, NodeID objid, const NormalGepCGEdge *normalGepEdge);
549
- /// add type for newly created GepObjNode
550
- virtual void addTypeForGepObjNode(NodeID id, const NormalGepCGEdge* normalGepEdge);
551
- };
552
-
553
-
554
-
555
466
  /*
556
467
  * Lazy Cycle Detection Based Andersen Analysis
557
468
  */
Binary file
@@ -32,7 +32,7 @@
32
32
 
33
33
  #include "Graphs/GenericGraph.h"
34
34
  #include "MemoryModel/MemModel.h"
35
- #include "SVF-FE/SymbolTableInfo.h"
35
+ #include "MemoryModel/SymbolTableInfo.h"
36
36
  #include "SVF-FE/LLVMUtil.h"
37
37
  #include "Graphs/PAGEdge.h"
38
38
 
@@ -93,7 +93,6 @@ public:
93
93
  class LocationSet
94
94
  {
95
95
  friend class SymbolTableInfo;
96
- friend class LocSymTableInfo;
97
96
  public:
98
97
  enum LSRelation
99
98
  {
@@ -0,0 +1,380 @@
1
+ //===- SVFIR.h -- IR of SVF ---------------------------------------------//
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
+ * SVFIR.h
25
+ *
26
+ * Created on: 31, 12, 2021
27
+ * Author: Yulei Sui
28
+ */
29
+
30
+ #ifndef SVFIR_H_
31
+ #define SVFIR_H_
32
+
33
+ #include <set>
34
+ #include <map>
35
+ #include "Util/BasicTypes.h"
36
+
37
+ namespace SVF
38
+ {
39
+
40
+ class SVFStmt{
41
+
42
+ public:
43
+ enum SVFSTMTK
44
+ {
45
+ Alloc, Copy, Phi, Store, Load, Call, FunRet, Gep, Cmp, Binary, Unary, Branch
46
+ };
47
+
48
+ SVFStmt(u32_t k): kind(k){
49
+
50
+ }
51
+
52
+ /// ClassOf
53
+ //@{
54
+ static inline bool classof(const SVFStmt*)
55
+ {
56
+ return true;
57
+ }
58
+ ///@}
59
+ virtual const std::string toString() const;
60
+ //@}
61
+
62
+ /// Overloading operator << for printing
63
+ //@{
64
+ friend raw_ostream& operator<< (raw_ostream &o, const SVFStmt &stmt)
65
+ {
66
+ o << stmt.toString();
67
+ return o;
68
+ }
69
+ //@}
70
+
71
+ inline u32_t getKind() const {
72
+ return kind;
73
+ }
74
+
75
+ private:
76
+ u32_t kind;
77
+ };
78
+
79
+ class AllocStmt : public SVFStmt{
80
+
81
+ public:
82
+
83
+ AllocStmt(SymID src, SymID dst) : SVFStmt(SVFSTMTK::Alloc), srcVar(src), dstVar(dst){
84
+ }
85
+
86
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
87
+ //@{
88
+ static inline bool classof(const AllocStmt *)
89
+ {
90
+ return true;
91
+ }
92
+ static inline bool classof(const SVFStmt *stmt)
93
+ {
94
+ return stmt->getKind() == SVFSTMTK::Alloc;
95
+ }
96
+ //@}
97
+
98
+ virtual const std::string toString() const;
99
+
100
+ private:
101
+ SymID srcVar;
102
+ SymID dstVar;
103
+ };
104
+
105
+ class CopyStmt : public SVFStmt{
106
+
107
+ CopyStmt(SymID src, SymID dst) : SVFStmt(SVFSTMTK::Copy), srcVar(src), dstVar(dst){
108
+ }
109
+
110
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
111
+ //@{
112
+ static inline bool classof(const CopyStmt *)
113
+ {
114
+ return true;
115
+ }
116
+ static inline bool classof(const SVFStmt *stmt)
117
+ {
118
+ return stmt->getKind() == SVFSTMTK::Copy;
119
+ }
120
+ //@}
121
+
122
+ virtual const std::string toString() const;
123
+
124
+ private:
125
+ SymID srcVar;
126
+ SymID dstVar;
127
+ };
128
+
129
+ class PhiStmt : public SVFStmt{
130
+
131
+ PhiStmt(SymID res, SymID op1, SymID op2) : SVFStmt(SVFSTMTK::Phi), resVar(res), op1Var(op1), op2Var(op2){
132
+ }
133
+
134
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
135
+ //@{
136
+ static inline bool classof(const PhiStmt *)
137
+ {
138
+ return true;
139
+ }
140
+ static inline bool classof(const SVFStmt *stmt)
141
+ {
142
+ return stmt->getKind() == SVFSTMTK::Phi;
143
+ }
144
+ //@}
145
+
146
+ virtual const std::string toString() const;
147
+
148
+ private:
149
+ SymID resVar;
150
+ SymID op1Var;
151
+ SymID op2Var;
152
+ };
153
+
154
+ class LoadStmt : public SVFStmt{
155
+
156
+ LoadStmt(SymID src, SymID dst) : SVFStmt(SVFSTMTK::Load), srcVar(src), dstVar(dst){
157
+ }
158
+
159
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
160
+ //@{
161
+ static inline bool classof(const LoadStmt *)
162
+ {
163
+ return true;
164
+ }
165
+ static inline bool classof(const SVFStmt *stmt)
166
+ {
167
+ return stmt->getKind() == SVFSTMTK::Load;
168
+ }
169
+ //@}
170
+
171
+ virtual const std::string toString() const;
172
+
173
+ private:
174
+ SymID srcVar;
175
+ SymID dstVar;
176
+ };
177
+
178
+ class StoreStmt : public SVFStmt{
179
+
180
+ StoreStmt(SymID src, SymID dst) : SVFStmt(SVFSTMTK::Store), srcVar(src), dstVar(dst){
181
+ }
182
+
183
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
184
+ //@{
185
+ static inline bool classof(const StoreStmt *)
186
+ {
187
+ return true;
188
+ }
189
+ static inline bool classof(const SVFStmt *stmt)
190
+ {
191
+ return stmt->getKind() == SVFSTMTK::Store;
192
+ }
193
+ //@}
194
+
195
+ virtual const std::string toString() const;
196
+
197
+ private:
198
+ SymID srcVar;
199
+ SymID dstVar;
200
+ };
201
+
202
+ class GepStmt : public SVFStmt{
203
+
204
+ GepStmt(SymID res, SymID ptr, SymID offset) : SVFStmt(SVFSTMTK::Gep), resVar(res), ptrVar(ptr), offsetVar(offset){
205
+ }
206
+
207
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
208
+ //@{
209
+ static inline bool classof(const GepStmt *)
210
+ {
211
+ return true;
212
+ }
213
+ static inline bool classof(const SVFStmt *stmt)
214
+ {
215
+ return stmt->getKind() == SVFSTMTK::Gep;
216
+ }
217
+ //@}
218
+
219
+ virtual const std::string toString() const;
220
+
221
+ private:
222
+ SymID resVar;
223
+ SymID ptrVar;
224
+ SymID offsetVar;
225
+ };
226
+
227
+ class CmpStmt : public SVFStmt{
228
+
229
+ CmpStmt(SymID res, SymID op1, SymID op2) : SVFStmt(SVFSTMTK::Cmp), resVar(res), op1Var(op1), op2Var(op2){
230
+ }
231
+
232
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
233
+ //@{
234
+ static inline bool classof(const CmpStmt *)
235
+ {
236
+ return true;
237
+ }
238
+ static inline bool classof(const SVFStmt *stmt)
239
+ {
240
+ return stmt->getKind() == SVFSTMTK::Cmp;
241
+ }
242
+ //@}
243
+
244
+ virtual const std::string toString() const;
245
+
246
+ private:
247
+ SymID resVar;
248
+ SymID op1Var;
249
+ SymID op2Var;
250
+ };
251
+
252
+ class BinaryStmt : public SVFStmt{
253
+
254
+ BinaryStmt(SymID res, SymID op1, SymID op2) : SVFStmt(SVFSTMTK::Binary), resVar(res), op1Var(op1), op2Var(op2){
255
+ }
256
+
257
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
258
+ //@{
259
+ static inline bool classof(const BinaryStmt *)
260
+ {
261
+ return true;
262
+ }
263
+ static inline bool classof(const SVFStmt *stmt)
264
+ {
265
+ return stmt->getKind() == SVFSTMTK::Binary;
266
+ }
267
+ //@}
268
+
269
+ virtual const std::string toString() const;
270
+
271
+ private:
272
+ SymID resVar;
273
+ SymID op1Var;
274
+ SymID op2Var;
275
+ };
276
+
277
+ class UnaryStmt : public SVFStmt{
278
+
279
+ UnaryStmt(SymID res, SymID op) : SVFStmt(SVFSTMTK::Unary), resVar(res), opVar(op){
280
+ }
281
+
282
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
283
+ //@{
284
+ static inline bool classof(const UnaryStmt *)
285
+ {
286
+ return true;
287
+ }
288
+ static inline bool classof(const SVFStmt *stmt)
289
+ {
290
+ return stmt->getKind() == SVFSTMTK::Unary;
291
+ }
292
+ //@}
293
+
294
+ virtual const std::string toString() const;
295
+
296
+ private:
297
+ SymID resVar;
298
+ SymID opVar;
299
+ };
300
+
301
+ class CallStmt : public SVFStmt{
302
+
303
+ CallStmt(CallSite cs) : SVFStmt(SVFSTMTK::Call), callsite(cs){
304
+ }
305
+
306
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
307
+ //@{
308
+ static inline bool classof(const CallStmt *)
309
+ {
310
+ return true;
311
+ }
312
+ static inline bool classof(const SVFStmt *stmt)
313
+ {
314
+ return stmt->getKind() == SVFSTMTK::Call;
315
+ }
316
+ //@}
317
+
318
+ virtual const std::string toString() const;
319
+
320
+ private:
321
+ CallSite callsite;
322
+ };
323
+
324
+ class FunRetStmt : public SVFStmt{
325
+
326
+ FunRetStmt(SVFFunction* f) : SVFStmt(SVFSTMTK::FunRet), fun(f){
327
+ }
328
+
329
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
330
+ //@{
331
+ static inline bool classof(const FunRetStmt *)
332
+ {
333
+ return true;
334
+ }
335
+ static inline bool classof(const SVFStmt *stmt)
336
+ {
337
+ return stmt->getKind() == SVFSTMTK::FunRet;
338
+ }
339
+ //@}
340
+
341
+ virtual const std::string toString() const;
342
+
343
+ private:
344
+ SVFFunction* fun;
345
+ };
346
+
347
+ class BranchStmt : public SVFStmt{
348
+
349
+ BranchStmt(SymID cond, SVFStmt* b1, SVFStmt* b2) : SVFStmt(SVFSTMTK::Branch), condition(cond),br1(b1),br2(b2){
350
+ }
351
+
352
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
353
+ //@{
354
+ static inline bool classof(const BranchStmt *)
355
+ {
356
+ return true;
357
+ }
358
+ static inline bool classof(const SVFStmt *stmt)
359
+ {
360
+ return stmt->getKind() == SVFSTMTK::Branch;
361
+ }
362
+ //@}
363
+
364
+ virtual const std::string toString() const;
365
+
366
+ private:
367
+ SymID condition;
368
+ SVFStmt* br1;
369
+ SVFStmt* br2;
370
+ };
371
+
372
+
373
+ class SVFIR{
374
+
375
+
376
+ };
377
+
378
+ } // End namespace SVF
379
+
380
+ #endif /* SVFIR_H_ */