svf-lib 1.0.804 → 1.0.808

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.
@@ -290,7 +290,7 @@ protected:
290
290
  virtual inline void buildSVFG(SVFIR* pag)
291
291
  {
292
292
  _ander = AndersenWaveDiff::createAndersenWaveDiff(pag);
293
- _svfg = svfgBuilder.buildPTROnlySVFGWithoutOPT(_ander);
293
+ _svfg = svfgBuilder.buildPTROnlySVFG(_ander);
294
294
  _pag = _svfg->getPAG();
295
295
  }
296
296
  /// Reset visited map for next points-to query
@@ -74,9 +74,7 @@ public:
74
74
  static SVFG* globalSvfg;
75
75
 
76
76
  SVFG* buildPTROnlySVFG(BVDataPTAImpl* pta);
77
- SVFG* buildPTROnlySVFGWithoutOPT(BVDataPTAImpl* pta);
78
77
  SVFG* buildFullSVFG(BVDataPTAImpl* pta);
79
- SVFG* buildFullSVFGWithoutOPT(BVDataPTAImpl* pta);
80
78
 
81
79
  /// Clean up
82
80
  static void releaseSVFG()
Binary file
@@ -290,7 +290,7 @@ protected:
290
290
  virtual inline void buildSVFG(SVFIR* pag)
291
291
  {
292
292
  _ander = AndersenWaveDiff::createAndersenWaveDiff(pag);
293
- _svfg = svfgBuilder.buildPTROnlySVFGWithoutOPT(_ander);
293
+ _svfg = svfgBuilder.buildPTROnlySVFG(_ander);
294
294
  _pag = _svfg->getPAG();
295
295
  }
296
296
  /// Reset visited map for next points-to query
@@ -67,7 +67,7 @@ protected:
67
67
 
68
68
  void destroy();
69
69
 
70
- PAGEdge::SVFStmtSetTy& getPAGEdgeSet(PAGEdge::PEDGEK kind)
70
+ SVFStmt::SVFStmtSetTy& getPAGEdgeSet(SVFStmt::PEDGEK kind)
71
71
  {
72
72
  return pag->getPTASVFStmtSet(kind);
73
73
  }
@@ -291,7 +291,7 @@ public:
291
291
  inline bool isZeroOffsettedGepCGEdge(ConstraintEdge *edge) const
292
292
  {
293
293
  if (NormalGepCGEdge *normalGepCGEdge = SVFUtil::dyn_cast<NormalGepCGEdge>(edge))
294
- if (0 == normalGepCGEdge->getFieldOffset())
294
+ if (0 == normalGepCGEdge->getConstantFieldIdx())
295
295
  return true;
296
296
  return false;
297
297
  }
@@ -304,7 +304,7 @@ public:
304
304
  }
305
305
 
306
306
  /// Get location set of the gep edge
307
- inline s64_t getFieldOffset() const
307
+ inline s64_t getConstantFieldIdx() const
308
308
  {
309
309
  return ls.accumulateConstantFieldIdx();
310
310
  }
@@ -427,7 +427,7 @@ protected:
427
427
  void addVFGNodes();
428
428
 
429
429
  /// Get PAGEdge set
430
- virtual inline PAGEdge::SVFStmtSetTy& getPAGEdgeSet(PAGEdge::PEDGEK kind)
430
+ virtual inline SVFStmt::SVFStmtSetTy& getPAGEdgeSet(SVFStmt::PEDGEK kind)
431
431
  {
432
432
  if (isPtrOnlySVFG())
433
433
  return pag->getPTASVFStmtSet(kind);
@@ -435,7 +435,7 @@ protected:
435
435
  return pag->getSVFStmtSet(kind);
436
436
  }
437
437
 
438
- virtual inline bool isInterestedPAGNode(const PAGNode* node) const
438
+ virtual inline bool isInterestedPAGNode(const SVFVar* node) const
439
439
  {
440
440
  if (isPtrOnlySVFG())
441
441
  return node->isPointer();
@@ -74,9 +74,7 @@ public:
74
74
  static SVFG* globalSvfg;
75
75
 
76
76
  SVFG* buildPTROnlySVFG(BVDataPTAImpl* pta);
77
- SVFG* buildPTROnlySVFGWithoutOPT(BVDataPTAImpl* pta);
78
77
  SVFG* buildFullSVFG(BVDataPTAImpl* pta);
79
- SVFG* buildFullSVFGWithoutOPT(BVDataPTAImpl* pta);
80
78
 
81
79
  /// Clean up
82
80
  static void releaseSVFG()
@@ -131,8 +131,12 @@ public:
131
131
  }
132
132
  //@}
133
133
 
134
+ /// Return accumulated constant offset given OffsetValueVec
134
135
  s64_t accumulateConstantOffset() const;
135
136
 
137
+ /// Return element number of a type.
138
+ u32_t getElementNum(const Type* type) const;
139
+
136
140
  bool addOffsetValue(const Value* offsetValue, const Type* type);
137
141
 
138
142
  /// Return TRUE if this is a constant location set.
@@ -649,9 +649,9 @@ private:
649
649
  /// Add Gep edge
650
650
  GepStmt* addGepStmt(NodeID src, NodeID dst, const LocationSet& ls, bool constGep);
651
651
  /// Add Offset(Gep) edge
652
- NormalGepStmt* addNormalGepStmt(NodeID src, NodeID dst, const LocationSet& ls);
652
+ GepStmt* addNormalGepStmt(NodeID src, NodeID dst, const LocationSet& ls);
653
653
  /// Add Variant(Gep) edge
654
- VariantGepStmt* addVariantGepStmt(NodeID src, NodeID dst, const LocationSet& ls);
654
+ GepStmt* addVariantGepStmt(NodeID src, NodeID dst, const LocationSet& ls);
655
655
  /// Add Thread fork edge for parameter passing
656
656
  TDForkPE* addThreadForkPE(NodeID src, NodeID dst, const CallICFGNode* cs);
657
657
  /// Add Thread join edge for parameter passing
@@ -53,7 +53,7 @@ public:
53
53
  /// ThreadFork/ThreadJoin is to model parameter passings between thread spawners and spawnees.
54
54
  enum PEDGEK
55
55
  {
56
- Addr, Copy, Store, Load, Call, Ret, NormalGep, VariantGep, Phi, Cmp, BinaryOp, UnaryOp, Branch, ThreadFork, ThreadJoin
56
+ Addr, Copy, Store, Load, Call, Ret, Gep, Phi, Cmp, BinaryOp, UnaryOp, Branch, ThreadFork, ThreadJoin
57
57
  };
58
58
 
59
59
  private:
@@ -85,8 +85,7 @@ public:
85
85
  edge->getEdgeKind() == SVFStmt::Load ||
86
86
  edge->getEdgeKind() == SVFStmt::Call ||
87
87
  edge->getEdgeKind() == SVFStmt::Ret ||
88
- edge->getEdgeKind() == SVFStmt::NormalGep ||
89
- edge->getEdgeKind() == SVFStmt::VariantGep ||
88
+ edge->getEdgeKind() == SVFStmt::Gep ||
90
89
  edge->getEdgeKind() == SVFStmt::Cmp ||
91
90
  edge->getEdgeKind() == SVFStmt::BinaryOp ||
92
91
  edge->getEdgeKind() == SVFStmt::UnaryOp ||
@@ -227,8 +226,7 @@ public:
227
226
  edge->getEdgeKind() == SVFStmt::Load ||
228
227
  edge->getEdgeKind() == SVFStmt::Call ||
229
228
  edge->getEdgeKind() == SVFStmt::Ret ||
230
- edge->getEdgeKind() == SVFStmt::NormalGep ||
231
- edge->getEdgeKind() == SVFStmt::VariantGep ||
229
+ edge->getEdgeKind() == SVFStmt::Gep ||
232
230
  edge->getEdgeKind() == SVFStmt::ThreadFork ||
233
231
  edge->getEdgeKind() == SVFStmt::ThreadJoin;
234
232
  }
@@ -240,8 +238,7 @@ public:
240
238
  edge->getEdgeKind() == SVFStmt::Load ||
241
239
  edge->getEdgeKind() == SVFStmt::Call ||
242
240
  edge->getEdgeKind() == SVFStmt::Ret ||
243
- edge->getEdgeKind() == SVFStmt::NormalGep ||
244
- edge->getEdgeKind() == SVFStmt::VariantGep ||
241
+ edge->getEdgeKind() == SVFStmt::Gep ||
245
242
  edge->getEdgeKind() == SVFStmt::ThreadFork ||
246
243
  edge->getEdgeKind() == SVFStmt::ThreadJoin;
247
244
  }
@@ -417,7 +414,7 @@ private:
417
414
  void operator=(const GepStmt &); ///< place holder
418
415
 
419
416
  LocationSet ls; ///< location set of the gep edge
420
-
417
+ bool variantField; ///< Gep statement with a variant field index (pointer arithmetic) for struct field access (e.g., p = &(q + f), where f is a variable)
421
418
  public:
422
419
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
423
420
  //@{
@@ -427,111 +424,41 @@ public:
427
424
  }
428
425
  static inline bool classof(const SVFStmt *edge)
429
426
  {
430
- return edge->getEdgeKind() == SVFStmt::NormalGep ||
431
- edge->getEdgeKind() == SVFStmt::VariantGep;
427
+ return edge->getEdgeKind() == SVFStmt::Gep;
432
428
  }
433
429
  static inline bool classof(const GenericPAGEdgeTy *edge)
434
430
  {
435
- return edge->getEdgeKind() == SVFStmt::NormalGep ||
436
- edge->getEdgeKind() == SVFStmt::VariantGep;
431
+ return edge->getEdgeKind() == SVFStmt::Gep;
437
432
  }
438
433
  //@}
439
434
 
440
435
  inline const LocationSet& getLocationSet() const
441
436
  {
437
+ assert(isVariantFieldGep()==false && "Can't retrieve the LocationSet if using a variable field index (pointer arithmetic) for struct field access ");
442
438
  return ls;
443
439
  }
444
440
 
445
- protected:
446
- /// constructor
447
- GepStmt(SVFVar* s, SVFVar* d, const LocationSet& l, PEDGEK k) : AssignStmt(s,d,k), ls(l)
441
+ inline s64_t accumulateConstantOffset() const
448
442
  {
443
+ return ls.accumulateConstantOffset();
449
444
  }
450
-
451
- virtual const std::string toString() const;
452
-
453
- };
454
-
455
-
456
- /*!
457
- * Gep statement with a fixed field index for struct field access
458
- */
459
- class NormalGepStmt : public GepStmt
460
- {
461
- private:
462
- NormalGepStmt(); ///< place holder
463
- NormalGepStmt(const NormalGepStmt&); ///< place holder
464
- void operator=(const NormalGepStmt&); ///< place holder
465
-
466
- public:
467
- /// Methods for support type inquiry through isa, cast, and dyn_cast:
468
- //@{
469
- static inline bool classof(const NormalGepStmt *)
470
- {
471
- return true;
472
- }
473
- static inline bool classof(const GepStmt *edge)
474
- {
475
- return edge->getEdgeKind() == SVFStmt::NormalGep;
476
- }
477
- static inline bool classof(const SVFStmt *edge)
445
+ /// offset of the gep statement
446
+ inline s64_t getConstantFieldIdx() const
478
447
  {
479
- return edge->getEdgeKind() == SVFStmt::NormalGep;
448
+ return getLocationSet().accumulateConstantFieldIdx();
480
449
  }
481
- static inline bool classof(const GenericPAGEdgeTy *edge)
450
+ /// Gep statement with a variant field index (pointer arithmetic) for struct field access
451
+ inline bool isVariantFieldGep() const
482
452
  {
483
- return edge->getEdgeKind() == SVFStmt::NormalGep;
484
- }
485
- //@}
453
+ return variantField;
454
+ }
486
455
 
487
456
  /// constructor
488
- NormalGepStmt(SVFVar* s, SVFVar* d, const LocationSet& l) : GepStmt(s,d,l, SVFStmt::NormalGep)
489
- {}
490
-
491
- /// offset of the gep edge
492
- inline s64_t getFieldOffset() const
457
+ GepStmt(SVFVar* s, SVFVar* d, const LocationSet& l, bool varfld=false) : AssignStmt(s,d,SVFStmt::Gep), ls(l), variantField(varfld)
493
458
  {
494
- return getLocationSet().accumulateConstantFieldIdx();
495
459
  }
496
460
 
497
- virtual const std::string toString() const override;
498
- };
499
-
500
- /*!
501
- * Gep statement with a variant field index for struct field access
502
- */
503
- class VariantGepStmt : public GepStmt
504
- {
505
- private:
506
- VariantGepStmt(); ///< place holder
507
- VariantGepStmt(const VariantGepStmt&); ///< place holder
508
- void operator=(const VariantGepStmt&); ///< place holder
509
-
510
- public:
511
- /// Methods for support type inquiry through isa, cast, and dyn_cast:
512
- //@{
513
- static inline bool classof(const VariantGepStmt *)
514
- {
515
- return true;
516
- }
517
- static inline bool classof(const GepStmt *edge)
518
- {
519
- return edge->getEdgeKind() == SVFStmt::VariantGep;
520
- }
521
- static inline bool classof(const SVFStmt *edge)
522
- {
523
- return edge->getEdgeKind() == SVFStmt::VariantGep;
524
- }
525
- static inline bool classof(const GenericPAGEdgeTy *edge)
526
- {
527
- return edge->getEdgeKind() == SVFStmt::VariantGep;
528
- }
529
- //@}
530
-
531
- /// constructor
532
- VariantGepStmt(SVFVar* s, SVFVar* d, const LocationSet& l) : GepStmt(s,d,l, SVFStmt::VariantGep) {}
533
-
534
- virtual const std::string toString() const override;
461
+ virtual const std::string toString() const;
535
462
 
536
463
  };
537
464
 
@@ -241,10 +241,13 @@ private:
241
241
  /// Has incoming VariantGepEdges
242
242
  inline bool hasIncomingVariantGepEdge() const
243
243
  {
244
- SVFStmt::KindToSVFStmtMapTy::const_iterator it = InEdgeKindToSetMap.find(SVFStmt::VariantGep);
244
+ SVFStmt::KindToSVFStmtMapTy::const_iterator it = InEdgeKindToSetMap.find(SVFStmt::Gep);
245
245
  if (it != InEdgeKindToSetMap.end())
246
246
  {
247
- return (!it->second.empty());
247
+ for(auto gep : it->second){
248
+ if(SVFUtil::cast<GepStmt>(gep)->isVariantFieldGep())
249
+ return true;
250
+ }
248
251
  }
249
252
  return false;
250
253
  }
@@ -422,7 +425,7 @@ public:
422
425
  }
423
426
 
424
427
  /// offset of the base value variable
425
- inline s64_t getFieldOffset() const
428
+ inline s64_t getConstantFieldIdx() const
426
429
  {
427
430
  return ls.accumulateConstantFieldIdx();
428
431
  }
@@ -431,8 +434,8 @@ public:
431
434
  inline const std::string getValueName() const
432
435
  {
433
436
  if (value && value->hasName())
434
- return value->getName().str() + "_" + llvm::utostr(getFieldOffset());
435
- return "offset_" + llvm::utostr(getFieldOffset());
437
+ return value->getName().str() + "_" + llvm::utostr(getConstantFieldIdx());
438
+ return "offset_" + llvm::utostr(getConstantFieldIdx());
436
439
  }
437
440
 
438
441
  inline const Type* getType() const
@@ -497,7 +500,7 @@ public:
497
500
  }
498
501
 
499
502
  /// offset of the mem object
500
- inline s64_t getFieldOffset() const
503
+ inline s64_t getConstantFieldIdx() const
501
504
  {
502
505
  return ls.accumulateConstantFieldIdx();
503
506
  }
@@ -364,7 +364,11 @@ public:
364
364
  }
365
365
 
366
366
  ///Get a reference to the components of struct_info.
367
- const std::vector<u32_t>& getFlattenedFieldIdxVec(const Type *T);
367
+ /// Flatterned full offset information of a struct including its array fields
368
+ const std::vector<u32_t>& getFlattenedOffsetVec(const StructType *T);
369
+ /// Flatterned field index information of a struct ignoring any array field
370
+ const std::vector<u32_t>& getFlattenedFieldIdxVec(const StructType *T);
371
+
368
372
  const std::vector<FlattenedFieldInfo>& getFlattenedFieldInfoVec(const Type *T);
369
373
 
370
374
  /// struct A { int id; int salary; }; struct B { char name[20]; struct A a;} B b;
@@ -501,25 +505,32 @@ public:
501
505
 
502
506
 
503
507
  /*!
504
- * Struct information
508
+ * Flatterned type information of StructType, ArrayType and SingleValueType
505
509
  */
506
510
  class StInfo
507
511
  {
508
512
 
509
513
  private:
510
- /// flattened field indices of a struct
514
+ /// flattened field indices of a struct (ignoring arrays)
511
515
  std::vector<u32_t> fldIdxVec;
516
+ /// flattened full offset (including array strides)
517
+ std::vector<u32_t> fullOffsetVec;
512
518
  /// Types of all fields of a struct
513
519
  Map<u32_t, const Type*> fldIdx2TypeMap;
514
520
  /// All field infos after flattening a struct
515
521
  std::vector<FlattenedFieldInfo> finfo;
516
-
522
+ /// stride represents the number of repetitive elements if this StInfo represent an ArrayType. stride is 1 by default.
523
+ u32_t stride;
517
524
  /// Max field limit
518
525
  static u32_t maxFieldLimit;
519
526
 
527
+ StInfo(); ///< place holder
528
+ StInfo(const StInfo& st); ///< place holder
529
+ void operator=(const StInfo&); ///< place holder
530
+
520
531
  public:
521
532
  /// Constructor
522
- StInfo()
533
+ StInfo(u32_t s) : stride(s)
523
534
  {
524
535
  }
525
536
  /// Destructor
@@ -560,6 +571,10 @@ public:
560
571
  {
561
572
  return fldIdxVec;
562
573
  }
574
+ inline std::vector<u32_t>& getFlattenedOffsetVec()
575
+ {
576
+ return fullOffsetVec;
577
+ }
563
578
  inline std::vector<FlattenedFieldInfo>& getFlattenedFieldInfoVec()
564
579
  {
565
580
  return finfo;
@@ -567,11 +582,17 @@ public:
567
582
  //@}
568
583
 
569
584
  /// Add field (index and offset) with its corresponding type
570
- inline void addFldWithType(u32_t fldIdx, const Type* type)
585
+ inline void addFldWithType(u32_t fldIdx, const Type* type, u32_t fullOffset)
571
586
  {
572
587
  fldIdxVec.push_back(fldIdx);
588
+ fullOffsetVec.push_back(fullOffset);
573
589
  fldIdx2TypeMap[fldIdx] = type;
574
590
  }
591
+
592
+ /// Array Type can have
593
+ inline u32_t getStride() const {
594
+ return stride;
595
+ }
575
596
  };
576
597
 
577
598
  /*!
@@ -46,7 +46,7 @@ public:
46
46
  {
47
47
  }
48
48
 
49
- u32_t getFieldOffset(void) const
49
+ u32_t getConstantFieldIdx(void) const
50
50
  {
51
51
  return offset;
52
52
  }
@@ -72,7 +72,7 @@ public:
72
72
  /// Initialize nodes and edges
73
73
  //@{
74
74
  void initialiseNodes();
75
- void addEdge(NodeID src, NodeID dst, PAGEdge::PEDGEK kind,
75
+ void addEdge(NodeID src, NodeID dst, SVFStmt::PEDGEK kind,
76
76
  s64_t offset = 0, Instruction* cs = nullptr);
77
77
  // @}
78
78
 
@@ -377,16 +377,16 @@ public:
377
377
  return edge;
378
378
  }
379
379
  /// Add Offset(Gep) edge
380
- inline NormalGepStmt* addNormalGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
380
+ inline GepStmt* addNormalGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
381
381
  {
382
- NormalGepStmt *edge = pag->addNormalGepStmt(src, dst, ls);
382
+ GepStmt *edge = pag->addNormalGepStmt(src, dst, ls);
383
383
  setCurrentBBAndValueForPAGEdge(edge);
384
384
  return edge;
385
385
  }
386
386
  /// Add Variant(Gep) edge
387
- inline VariantGepStmt* addVariantGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
387
+ inline GepStmt* addVariantGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
388
388
  {
389
- VariantGepStmt *edge = pag->addVariantGepStmt(src, dst, ls);
389
+ GepStmt *edge = pag->addVariantGepStmt(src, dst, ls);
390
390
  setCurrentBBAndValueForPAGEdge(edge);
391
391
  return edge;
392
392
  }
@@ -64,7 +64,7 @@ private:
64
64
  void writePAGgepNode(SVF::NodeID nodeId, GepObjVar* gepNode)
65
65
  {
66
66
  auto baseNodeId = gepNode->getBaseNode();
67
- auto locationSetOffset = gepNode->getFieldOffset();
67
+ auto locationSetOffset = gepNode->getConstantFieldIdx();
68
68
 
69
69
  LLVMContext &context = mainModule->getContext();
70
70
  llvm::SmallVector<llvm::Metadata *, 32> operands;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.804",
3
+ "version": "1.0.808",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {