svf-lib 1.0.1301 → 1.0.1302

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 (45) hide show
  1. package/package.json +1 -1
  2. package/SVF-linux/include/SVF-FE/BasicTypes.h +0 -219
  3. package/SVF-linux/include/SVF-FE/BreakConstantExpr.h +0 -94
  4. package/SVF-linux/include/SVF-FE/CHG.h +0 -334
  5. package/SVF-linux/include/SVF-FE/CHGBuilder.h +0 -73
  6. package/SVF-linux/include/SVF-FE/CPPUtil.h +0 -130
  7. package/SVF-linux/include/SVF-FE/CallGraphBuilder.h +0 -74
  8. package/SVF-linux/include/SVF-FE/CommonCHG.h +0 -49
  9. package/SVF-linux/include/SVF-FE/DCHG.h +0 -470
  10. package/SVF-linux/include/SVF-FE/DataFlowUtil.h +0 -190
  11. package/SVF-linux/include/SVF-FE/GEPTypeBridgeIterator.h +0 -183
  12. package/SVF-linux/include/SVF-FE/Graph2Json.h +0 -30
  13. package/SVF-linux/include/SVF-FE/ICFGBuilder.h +0 -106
  14. package/SVF-linux/include/SVF-FE/IRAnnotator.h +0 -323
  15. package/SVF-linux/include/SVF-FE/LLVMLoopAnalysis.h +0 -59
  16. package/SVF-linux/include/SVF-FE/LLVMModule.h +0 -319
  17. package/SVF-linux/include/SVF-FE/LLVMUtil.h +0 -303
  18. package/SVF-linux/include/SVF-FE/LocMemModel.h +0 -35
  19. package/SVF-linux/include/SVF-FE/MemModelBuilder.h +0 -102
  20. package/SVF-linux/include/SVF-FE/PAGBuilder.h +0 -390
  21. package/SVF-linux/include/SVF-FE/SVFIRBuilder.h +0 -412
  22. package/SVF-linux/include/SVF-FE/SymbolTableBuilder.h +0 -99
  23. package/SVF-linux/include/SVF-FE/SymbolTableInfo.h +0 -439
  24. package/SVF-osx/include/SVF-FE/BasicTypes.h +0 -219
  25. package/SVF-osx/include/SVF-FE/BreakConstantExpr.h +0 -94
  26. package/SVF-osx/include/SVF-FE/CHG.h +0 -334
  27. package/SVF-osx/include/SVF-FE/CHGBuilder.h +0 -73
  28. package/SVF-osx/include/SVF-FE/CPPUtil.h +0 -130
  29. package/SVF-osx/include/SVF-FE/CallGraphBuilder.h +0 -74
  30. package/SVF-osx/include/SVF-FE/CommonCHG.h +0 -49
  31. package/SVF-osx/include/SVF-FE/DCHG.h +0 -470
  32. package/SVF-osx/include/SVF-FE/DataFlowUtil.h +0 -190
  33. package/SVF-osx/include/SVF-FE/GEPTypeBridgeIterator.h +0 -183
  34. package/SVF-osx/include/SVF-FE/Graph2Json.h +0 -30
  35. package/SVF-osx/include/SVF-FE/ICFGBuilder.h +0 -106
  36. package/SVF-osx/include/SVF-FE/IRAnnotator.h +0 -323
  37. package/SVF-osx/include/SVF-FE/LLVMLoopAnalysis.h +0 -59
  38. package/SVF-osx/include/SVF-FE/LLVMModule.h +0 -319
  39. package/SVF-osx/include/SVF-FE/LLVMUtil.h +0 -303
  40. package/SVF-osx/include/SVF-FE/LocMemModel.h +0 -35
  41. package/SVF-osx/include/SVF-FE/MemModelBuilder.h +0 -102
  42. package/SVF-osx/include/SVF-FE/PAGBuilder.h +0 -390
  43. package/SVF-osx/include/SVF-FE/SVFIRBuilder.h +0 -412
  44. package/SVF-osx/include/SVF-FE/SymbolTableBuilder.h +0 -99
  45. package/SVF-osx/include/SVF-FE/SymbolTableInfo.h +0 -439
@@ -1,470 +0,0 @@
1
- //===----- DCHG.h -- CHG using DWARF debug info ---------------------------//
2
- // This is based upon the original CHA.h (now CHG.h).
3
-
4
- /*
5
- * DCHG.h
6
- *
7
- * Created on: Aug 23, 2019
8
- * Author: Mohamad Barbar
9
- */
10
-
11
- // TODO: add a flag such that getCanonicalType returns its arg so
12
- // that the impl. does not "node collapsing" based on teq.
13
-
14
- #ifndef DCHG_H_
15
- #define DCHG_H_
16
-
17
- #include "Graphs/GenericGraph.h"
18
- #include "Graphs/CHG.h"
19
- #include "SVF-FE/CPPUtil.h"
20
- #include "Util/SVFModule.h"
21
- #include "Util/SVFUtil.h"
22
- #include "Util/WorkList.h"
23
-
24
- namespace SVF
25
- {
26
-
27
- class SVFModule;
28
- class DCHNode;
29
-
30
- class DCHEdge : public GenericEdge<DCHNode>
31
- {
32
- public:
33
- enum
34
- {
35
- INHERITANCE, // inheritance relation
36
- INSTANCE, // template-instance relation
37
- FIRST_FIELD, // src -ff-> dst => dst is first field of src
38
- STD_DEF // Edges defined by the standard like (int -std-> char)
39
- // We also make the char --> void edge a STD_DEF edge.
40
- };
41
-
42
- typedef GenericNode<DCHNode, DCHEdge>::GEdgeSetTy DCHEdgeSetTy;
43
-
44
- DCHEdge(DCHNode *src, DCHNode *dst, GEdgeFlag k = 0)
45
- : GenericEdge<DCHNode>(src, dst, k), offset(0)
46
- {
47
- }
48
-
49
- u32_t getConstantFieldIdx(void) const
50
- {
51
- return offset;
52
- }
53
-
54
- void setOffset(u32_t offset)
55
- {
56
- this->offset = offset;
57
- }
58
-
59
- private:
60
- u32_t offset;
61
- };
62
-
63
- class DCHNode : public GenericNode<DCHNode, DCHEdge>
64
- {
65
- public:
66
- typedef enum
67
- {
68
- PURE_ABSTRACT = 0x1, // pure virtual abstract class
69
- MULTI_INHERITANCE = 0x2, // multi inheritance class
70
- TEMPLATE = 0x04, // template class
71
- SCALAR = 0x08 // non-class scalar type
72
- } CLASSATTR;
73
-
74
- typedef std::vector<const Function*> FuncVector;
75
-
76
- DCHNode(const DIType *diType, NodeID i = 0, GNodeK k = 0)
77
- : GenericNode<DCHNode, DCHEdge>(i, k), vtable(nullptr), flags(0)
78
- {
79
- this->diType = diType;
80
- if (diType == nullptr)
81
- {
82
- typeName = "null-void";
83
- }
84
- else if (diType->getRawName() != nullptr)
85
- {
86
- typeName = diType->getName().str();
87
- }
88
- else
89
- {
90
- typeName = "unnamed!";
91
- }
92
- }
93
-
94
- ~DCHNode() { }
95
-
96
- const DIType *getType(void) const
97
- {
98
- return diType;
99
- }
100
-
101
- std::string getName() const
102
- {
103
- return typeName;
104
- }
105
-
106
- /// Flags
107
- //@{
108
- inline void setFlag(CLASSATTR mask)
109
- {
110
- flags |= mask;
111
- }
112
- inline bool hasFlag(CLASSATTR mask) const
113
- {
114
- return (flags & mask) == mask;
115
- }
116
- //@}
117
-
118
- /// Attribute
119
- //@{
120
- inline void setPureAbstract()
121
- {
122
- setFlag(PURE_ABSTRACT);
123
- }
124
- inline void setMultiInheritance()
125
- {
126
- setFlag(MULTI_INHERITANCE);
127
- }
128
- inline void setTemplate()
129
- {
130
- setFlag(TEMPLATE);
131
- }
132
- inline void setScalar()
133
- {
134
- setFlag(SCALAR);
135
- }
136
- inline bool isPureAbstract() const
137
- {
138
- return hasFlag(PURE_ABSTRACT);
139
- }
140
- inline bool isMultiInheritance() const
141
- {
142
- return hasFlag(MULTI_INHERITANCE);
143
- }
144
- inline bool isTemplate() const
145
- {
146
- return hasFlag(TEMPLATE);
147
- }
148
- inline bool isScalar() const
149
- {
150
- return hasFlag(SCALAR);
151
- }
152
- //@}
153
-
154
- void addTypedef(const DIDerivedType *diTypedef)
155
- {
156
- typedefs.insert(diTypedef);
157
- }
158
-
159
- const Set<const DIDerivedType *> &getTypedefs(void) const
160
- {
161
- return typedefs;
162
- }
163
-
164
- void setVTable(const GlobalValue *vtbl)
165
- {
166
- vtable = vtbl;
167
- }
168
-
169
- const GlobalValue *getVTable() const
170
- {
171
- return vtable;
172
- }
173
-
174
- /// Returns the vector of virtual function vectors.
175
- const std::vector<std::vector<const Function* >> &getVfnVectors(void) const
176
- {
177
- return vfnVectors;
178
- }
179
-
180
- /// Return the nth virtual function vector in the vtable.
181
- std::vector<const Function* > &getVfnVector(unsigned n)
182
- {
183
- if (vfnVectors.size() < n + 1)
184
- {
185
- vfnVectors.resize(n + 1);
186
- }
187
-
188
- return vfnVectors[n];
189
- }
190
-
191
- private:
192
- /// Type of this node.
193
- const DIType *diType;
194
- /// Typedefs which map to this type.
195
- Set<const DIDerivedType *> typedefs;
196
- const GlobalValue* vtable;
197
- std::string typeName;
198
- size_t flags;
199
- /// The virtual functions which this class actually defines/overrides.
200
- std::vector<const Function* > primaryVTable;
201
- /// If a vtable is split into more than one vfn vector for multiple inheritance,
202
- /// 0 would be the primary base + this classes virtual functions, 1 would be
203
- /// the second parent, 2 would be third parent, etc.
204
- std::vector<std::vector<const Function*>> vfnVectors;
205
- };
206
-
207
- /// Dwarf based CHG.
208
- class DCHGraph : public CommonCHGraph, public GenericGraph<DCHNode, DCHEdge>
209
- {
210
- public:
211
- /// Returns the DIType beneath the qualifiers. Does not strip away "DW_TAG_members".
212
- static const DIType *stripQualifiers(const DIType *);
213
-
214
- /// Returns the DIType beneath all qualifiers and arrays.
215
- static const DIType *stripArray(const DIType *);
216
-
217
- /// Returns true if t1 and t2 are equivalent, ignoring qualifiers.
218
- /// For equality...
219
- /// Tags always need to be equal.
220
- /// DIBasicType: shallow pointer equality.
221
- /// DIDerivedType: base types (teq).
222
- /// DICompositeType: shallow pointer equality.
223
- /// DISubroutineType: shallow pointer equality.
224
- static bool teq(const DIType *t1, const DIType *t2);
225
-
226
- /// Returns a human-readable version of the DIType.
227
- static std::string diTypeToStr(const DIType *);
228
-
229
- // Returns whether t is an array, a struct, a class, a union, or neither.
230
- static bool isAgg(const DIType *t);
231
-
232
- public:
233
- DCHGraph(const SVFModule *svfMod)
234
- : svfModule(svfMod), numTypes(0) // vfID(0), buildingCHGTime(0) {
235
- {
236
- this->kind = DI;
237
- }
238
-
239
- virtual ~DCHGraph() { };
240
-
241
- /// Builds the CHG from DWARF debug information. extend determines
242
- /// whether to extend the CHG with first field edges.
243
- virtual void buildCHG(bool extend);
244
-
245
- void dump(const std::string& filename)
246
- {
247
- GraphPrinter::WriteGraphToFile(SVFUtil::outs(), filename, this);
248
- }
249
-
250
- void print(void);
251
-
252
- virtual bool csHasVFnsBasedonCHA(CallSite cs) override
253
- {
254
- return csHasVtblsBasedonCHA(cs);
255
- }
256
-
257
- virtual const VFunSet &getCSVFsBasedonCHA(CallSite cs) override;
258
-
259
- virtual bool csHasVtblsBasedonCHA(CallSite cs) override
260
- {
261
- const DIType *type = getCanonicalType(getCSStaticType(cs));
262
- if (!hasNode(type))
263
- {
264
- return false;
265
- }
266
-
267
- return getNode(type)->getVTable() != nullptr;
268
- }
269
-
270
- virtual const VTableSet &getCSVtblsBasedonCHA(CallSite cs) override;
271
- virtual void getVFnsFromVtbls(CallSite cs, const VTableSet &vtbls, VFunSet &virtualFunctions) override;
272
-
273
- /// Returns true if a is a transitive base of b. firstField determines
274
- /// whether to consider first-field edges.
275
- virtual bool isBase(const DIType *a, const DIType *b, bool firstField);
276
-
277
- /// Returns true if f is a field of b (fields from getFieldTypes).
278
- virtual bool isFieldOf(const DIType *f, const DIType *b);
279
-
280
- static inline bool classof(const CommonCHGraph *chg)
281
- {
282
- return chg->getKind() == DI;
283
- }
284
-
285
- /// Returns the type representing all qualifier-variations of t.
286
- /// This should only matter in the case of DerivedTypes where
287
- /// qualifiers and have qualified base types cause a mess.
288
- const DIType *getCanonicalType(const DIType *t);
289
-
290
- /// Returns the type of field number idx (flattened) in base.
291
- const DIType *getFieldType(const DIType *base, unsigned idx)
292
- {
293
- base = getCanonicalType(base);
294
- if (base == nullptr)
295
- {
296
- // Conservative; the base object is untyped, sadly.
297
- return nullptr;
298
- }
299
-
300
- // For TBHC this is conservative because the union type is lower in the DCHG
301
- // than its fields. TODO: make more precise.
302
- if (base->getTag() == dwarf::DW_TAG_union_type)
303
- {
304
- return base;
305
- }
306
-
307
- if (base->getTag() == dwarf::DW_TAG_array_type)
308
- {
309
- const DICompositeType *cbase = SVFUtil::dyn_cast<DICompositeType>(base);
310
- assert(cbase && "DCHG: bad DIComposite case");
311
- return cbase->getBaseType();
312
- }
313
-
314
- if (!(base->getTag() == dwarf::DW_TAG_class_type
315
- || base->getTag() == dwarf::DW_TAG_structure_type))
316
- {
317
- return nullptr;
318
- }
319
-
320
- assert(fieldTypes.find(base) != fieldTypes.end() && "DCHG: base not flattened!");
321
- std::vector<const DIType *> &fields = fieldTypes[base];
322
- assert(fields.size() > idx && "DCHG: idx into struct larger than # fields!");
323
- return getCanonicalType(fields[idx]);
324
- }
325
-
326
- /// Returns a vector of the types of all fields in base.
327
- const std::vector<const DIType *> &getFieldTypes(const DIType *base)
328
- {
329
- base = getCanonicalType(base);
330
- assert(fieldTypes.find(base) != fieldTypes.end() && "DCHG: base not flattened!");
331
- return fieldTypes[base];
332
- }
333
-
334
- // Returns the number of fields in base (length of getFieldTypes).
335
- unsigned getNumFields(const DIType *base)
336
- {
337
- base = getCanonicalType(base);
338
- assert(fieldTypes.find(base) != fieldTypes.end() && "DCHG: base not flattened!");
339
- return fieldTypes[base].size();
340
- }
341
-
342
- /// Returns all the aggregates contained (transitively) in base.
343
- const Set<const DIType *> &getAggs(const DIType *base)
344
- {
345
- base = getCanonicalType(base);
346
- assert(containingAggs.find(base) != containingAggs.end() && "DCHG: aggregates not gathered for base!");
347
- return containingAggs[base];
348
- }
349
-
350
- bool isFirstField(const DIType *f, const DIType *b);
351
-
352
- protected:
353
- /// SVF Module this CHG is built from.
354
- const SVFModule *svfModule;
355
- /// Whether this CHG is an extended CHG (first-field). Set by buildCHG.
356
- bool extended = false;
357
- /// Maps DITypes to their nodes.
358
- Map<const DIType *, DCHNode *> diTypeToNodeMap;
359
- /// Maps VTables to the DIType associated with them.
360
- Map<const GlobalValue *, const DIType *> vtblToTypeMap;
361
- /// Maps types to all children (i.e. CHA).
362
- Map<const DIType *, NodeBS> chaMap;
363
- /// Maps types to all children but also considering first field.
364
- Map<const DIType *, NodeBS> chaFFMap;
365
- /// Maps types to a set with their vtable and all their children's.
366
- Map<const DIType *, VTableSet> vtblCHAMap;
367
- /// Maps callsites to a set of potential virtual functions based on CHA.
368
- Map<CallSite, VFunSet> csCHAMap;
369
- /// Maps types to their canonical type (many-to-one).
370
- Map<const DIType *, const DIType *> canonicalTypeMap;
371
- /// Set of all possible canonical types (i.e. values of canonicalTypeMap).
372
- Set<const DIType *> canonicalTypes;
373
- /// Maps types to their flattened fields' types.
374
- Map<const DIType *, std::vector<const DIType *>> fieldTypes;
375
- /// Maps aggregate types to all the aggregate types it transitively contains.
376
- Map<const DIType *, Set<const DIType *>> containingAggs;
377
-
378
- private:
379
- /// Construction helper to process DIBasicTypes.
380
- void handleDIBasicType(const DIBasicType *basicType);
381
- /// Construction helper to process DICompositeTypes.
382
- void handleDICompositeType(const DICompositeType *compositeType);
383
- /// Construction helper to process DIDerivedTypes.
384
- void handleDIDerivedType(const DIDerivedType *derivedType);
385
- /// Construction helper to process DISubroutineTypes.
386
- void handleDISubroutineType(const DISubroutineType *subroutineType);
387
-
388
- /// Finds all defined virtual functions and attaches them to nodes.
389
- void buildVTables(const SVFModule &module);
390
-
391
- /// Returns a set of all children of type (CHA). Also gradually builds chaMap.
392
- const NodeBS &cha(const DIType *type, bool firstField);
393
-
394
- /// Attaches the typedef(s) to the base node.
395
- void handleTypedef(const DIType *typedefType);
396
-
397
- /// Populates fieldTypes for type and all its elements.
398
- void flatten(const DICompositeType *type);
399
-
400
- /// Populates containingAggs for type and all its elements.
401
- void gatherAggs(const DICompositeType *type);
402
-
403
- /// Creates a node from type, or returns it if it exists.
404
- DCHNode *getOrCreateNode(const DIType *type);
405
-
406
- /// Retrieves the metadata associated with a *virtual* callsite.
407
- const DIType *getCSStaticType(CallSite cs) const
408
- {
409
- MDNode *md = cs.getInstruction()->getLLVMInstruction()->getMetadata(cppUtil::ctir::derefMDName);
410
- assert(md != nullptr && "Missing type metadata at virtual callsite");
411
- DIType *diType = SVFUtil::dyn_cast<DIType>(md);
412
- assert(diType != nullptr && "Incorrect metadata type at virtual callsite");
413
- return diType;
414
- }
415
-
416
- /// Checks if a node exists for type.
417
- bool hasNode(const DIType *type)
418
- {
419
- type = getCanonicalType(type);
420
- return diTypeToNodeMap.find(type) != diTypeToNodeMap.end();
421
- }
422
-
423
- /// Returns the node for type (nullptr if it doesn't exist).
424
- DCHNode *getNode(const DIType *type)
425
- {
426
- type = getCanonicalType(type);
427
- if (hasNode(type))
428
- {
429
- return diTypeToNodeMap.at(type);
430
- }
431
-
432
- return nullptr;
433
- }
434
-
435
-
436
- /// Creates an edge between from t1 to t2.
437
- DCHEdge *addEdge(const DIType *t1, const DIType *t2, DCHEdge::GEdgeKind et);
438
- /// Returns the edge between t1 and t2 if it exists, returns nullptr otherwise.
439
- DCHEdge *hasEdge(const DIType *t1, const DIType *t2, DCHEdge::GEdgeKind et);
440
-
441
- /// Number of types (nodes) in the graph.
442
- NodeID numTypes;
443
- };
444
-
445
- } // End namespace SVF
446
-
447
- namespace llvm
448
- {
449
- /* !
450
- * GraphTraits specializations for generic graph algorithms.
451
- * Provide graph traits for traversing from a constraint node using standard graph traversals.
452
- */
453
- template<> struct GraphTraits<SVF::DCHNode*> : public GraphTraits<SVF::GenericNode<SVF::DCHNode,SVF::DCHEdge>* >
454
- {
455
- };
456
-
457
- /// Inverse GraphTraits specializations for call graph node, it is used for inverse traversal.
458
- template<>
459
- struct GraphTraits<Inverse<SVF::DCHNode*> > : public GraphTraits<Inverse<SVF::GenericNode<SVF::DCHNode,SVF::DCHEdge>* > >
460
- {
461
- };
462
-
463
- template<> struct GraphTraits<SVF::DCHGraph*> : public GraphTraits<SVF::GenericGraph<SVF::DCHNode,SVF::DCHEdge>* >
464
- {
465
- typedef SVF::DCHNode *NodeRef;
466
- };
467
-
468
- } // End namespace llvm
469
-
470
- #endif /* DCHG_H_ */
@@ -1,190 +0,0 @@
1
- //===- DataFlowUtil.h -- Helper functions for data-flow 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
- * DataFlowUtil.h
25
- *
26
- * Created on: Jun 4, 2013
27
- * Author: Yulei Sui
28
- */
29
-
30
- #ifndef DATAFLOWUTIL_H_
31
- #define DATAFLOWUTIL_H_
32
-
33
- #include "Util/BasicTypes.h"
34
- #include "llvm/IR/LegacyPassManager.h"
35
- #include "llvm/Transforms/IPO/PassManagerBuilder.h"
36
- #include "SVF-FE/BasicTypes.h"
37
-
38
- namespace SVF
39
- {
40
-
41
- /*!
42
- * Wrapper for SCEV collected from function pass ScalarEvolution
43
- */
44
- class PTASCEV
45
- {
46
-
47
- public:
48
- PTASCEV():scev(nullptr), start(nullptr), step(nullptr),ptr(nullptr),inloop(false),tripcount(0) {}
49
-
50
- /// Constructor
51
- PTASCEV(const Value* p, const SCEV* s, ScalarEvolution* SE): scev(s),start(nullptr), step(nullptr), ptr(p), inloop(false), tripcount(0)
52
- {
53
- /*if(const SCEVAddRecExpr* ar = SVFUtil::dyn_cast<SCEVAddRecExpr>(s))
54
- {
55
- if (const SCEVConstant *startExpr = SVFUtil::dyn_cast<SCEVConstant>(ar->getStart()))
56
- start = startExpr->getValue();
57
- if (const SCEVConstant *stepExpr = SVFUtil::dyn_cast<SCEVConstant>(ar->getStepRecurrence(*SE)))
58
- step = stepExpr->getValue();
59
- tripcount = SE->getSmallConstantTripCount(const_cast<Loop*>(ar->getLoop()));
60
- inloop = true;
61
- }*/
62
- inloop = false;
63
- }
64
- /// Copy Constructor
65
- PTASCEV(const PTASCEV& ptase): scev(ptase.scev), start(ptase.start), step(ptase.step), ptr(ptase.ptr), inloop(ptase.inloop),tripcount(ptase.tripcount)
66
- {
67
-
68
- }
69
-
70
- /// Destructor
71
- virtual ~PTASCEV()
72
- {
73
- }
74
-
75
- const SCEV *scev;
76
- const Value* start;
77
- const Value* step;
78
- const Value* ptr;
79
- bool inloop;
80
- unsigned tripcount;
81
-
82
- /// Enable compare operator to avoid duplicated item insertion in map or set
83
- /// to be noted that two vectors can also overload operator()
84
- inline bool operator< (const PTASCEV& rhs) const
85
- {
86
- if(start!=rhs.start)
87
- return start < rhs.start;
88
- else if(step!=rhs.step)
89
- return step < rhs.step;
90
- else if(ptr!=rhs.ptr)
91
- return ptr < rhs.ptr;
92
- else if(tripcount!=rhs.tripcount)
93
- return tripcount < rhs.tripcount;
94
- else
95
- return inloop < rhs.inloop;
96
- }
97
- /// Overloading operator=
98
- inline PTASCEV& operator= (const PTASCEV& rhs)
99
- {
100
- if(*this!=rhs)
101
- {
102
- start = rhs.start;
103
- step = rhs.step;
104
- ptr = rhs.ptr;
105
- tripcount = rhs.tripcount;
106
- inloop = rhs.inloop;
107
- }
108
- return *this;
109
- }
110
- /// Overloading operator==
111
- inline bool operator== (const PTASCEV& rhs) const
112
- {
113
- return (start == rhs.start && step == rhs.step && ptr == rhs.ptr && tripcount == rhs.tripcount && inloop == rhs.inloop);
114
- }
115
- /// Overloading operator==
116
- inline bool operator!= (const PTASCEV& rhs) const
117
- {
118
- return !(*this==rhs);
119
- }
120
- };
121
-
122
-
123
- class PTACFInfoBuilder
124
- {
125
- public:
126
- typedef Map<const Function*, DominatorTree*> FunToDTMap; ///< map a function to its dominator tree
127
- typedef Map<const Function*, PostDominatorTree*> FunToPostDTMap; ///< map a function to its post dominator tree
128
- typedef Map<const Function*, LoopInfo*> FunToLoopInfoMap; ///< map a function to its loop info
129
-
130
- /// Constructor
131
- PTACFInfoBuilder();
132
-
133
- ~PTACFInfoBuilder();
134
-
135
- /// Get loop info of a function
136
- LoopInfo* getLoopInfo(const Function* f);
137
-
138
- /// Get post dominator tree of a function
139
- PostDominatorTree* getPostDT(const Function* f);
140
-
141
- /// Get dominator tree of a function
142
- DominatorTree* getDT(const Function* f);
143
-
144
- private:
145
- FunToLoopInfoMap funToLoopInfoMap; ///< map a function to its loop info
146
- FunToDTMap funToDTMap; ///< map a function to its dominator tree
147
- FunToPostDTMap funToPDTMap; ///< map a function to its post dominator tree
148
- };
149
-
150
-
151
- /*!
152
- * Iterated dominance frontier
153
- */
154
- class IteratedDominanceFrontier: public llvm::DominanceFrontierBase<BasicBlock, false>
155
- {
156
-
157
- private:
158
- const DominanceFrontier *DF;
159
-
160
- void calculate(BasicBlock *, const DominanceFrontier &DF);
161
-
162
- public:
163
- static char ID;
164
-
165
- IteratedDominanceFrontier() :
166
- DominanceFrontierBase(), DF(nullptr)
167
- {
168
- }
169
-
170
- virtual ~IteratedDominanceFrontier()
171
- {
172
- }
173
-
174
- // virtual bool runOnFunction(Function &m) {
175
- // Frontiers.clear();
176
- // DF = &getAnalysis<DominanceFrontier>();
177
- // return false;
178
- // }
179
-
180
- iterator getIDFSet(BasicBlock *B)
181
- {
182
- if (Frontiers.find(B) == Frontiers.end())
183
- calculate(B, *DF);
184
- return Frontiers.find(B);
185
- }
186
- };
187
-
188
- } // End namespace SVF
189
-
190
- #endif /* DATAFLOWUTIL_H_ */