svf-lib 1.0.747 → 1.0.751

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.
@@ -243,13 +243,15 @@ public:
243
243
  // TypeAnalysis.cpp
244
244
  static const llvm::cl::opt<bool> GenICFG;
245
245
 
246
- //WPAPass.cpp
246
+ // WPAPass.cpp
247
247
  static const llvm::cl::opt<bool> AnderSVFG;
248
248
  static const llvm::cl::opt<bool> SABERFULLSVFG;
249
249
  static const llvm::cl::opt<bool> PrintAliases;
250
250
  static llvm::cl::bits<PointerAnalysis::PTATY> PASelected;
251
251
  static llvm::cl::bits<WPAPass::AliasCheckRule> AliasRule;
252
252
 
253
+ // DOTGraphTraits
254
+ static const llvm::cl::opt<bool> ShowHiddenNode;
253
255
  };
254
256
  } // namespace SVF
255
257
 
Binary file
@@ -310,9 +310,9 @@ public:
310
310
  {
311
311
  return pag->isBlkObjOrConstantObj(id);
312
312
  }
313
- inline NodeBS& getAllFieldsObjNode(NodeID id)
313
+ inline NodeBS& getAllFieldsObjVars(NodeID id)
314
314
  {
315
- return pag->getAllFieldsObjNode(id);
315
+ return pag->getAllFieldsObjVars(id);
316
316
  }
317
317
  inline NodeID getBaseObjVar(NodeID id)
318
318
  {
@@ -358,9 +358,9 @@ public:
358
358
  {
359
359
  return pag->getGepObjVar(id,ls);
360
360
  }
361
- virtual inline const NodeBS& getAllFieldsObjNode(NodeID id)
361
+ virtual inline const NodeBS& getAllFieldsObjVars(NodeID id)
362
362
  {
363
- return pag->getAllFieldsObjNode(id);
363
+ return pag->getAllFieldsObjVars(id);
364
364
  }
365
365
  inline void setObjFieldInsensitive(NodeID id)
366
366
  {
@@ -354,7 +354,7 @@ public:
354
354
  {
355
355
  if(pag->getBaseObjVar(cit->get_id())==cit->get_id())
356
356
  {
357
- NodeBS& fields = pag->getAllFieldsObjNode(cit->get_id());
357
+ NodeBS& fields = pag->getAllFieldsObjVars(cit->get_id());
358
358
  for(NodeBS::iterator it = fields.begin(), eit = fields.end(); it!=eit; ++it)
359
359
  {
360
360
  CVar cvar(cit->get_cond(),*it);
@@ -61,7 +61,7 @@ public:
61
61
  typedef Map<const RetBlockNode*,const SVFVar*> CSToRetMap;
62
62
  typedef Map<const SVFFunction*,const SVFVar*> FunToRetMap;
63
63
  typedef Map<const SVFFunction*,SVFStmtSet> FunToPAGEdgeSetMap;
64
- typedef Map<const ICFGNode*,SVFStmtList> Inst2PAGEdgesMap;
64
+ typedef Map<const ICFGNode*,SVFStmtList> ICFGNode2SVFStmtsMap;
65
65
  typedef Map<NodeID, NodeID> NodeToNodeMap;
66
66
  typedef std::pair<NodeID, Size_t> NodeOffset;
67
67
  typedef std::pair<NodeID, LocationSet> NodeLocationSet;
@@ -73,8 +73,8 @@ public:
73
73
  private:
74
74
  /// ValueNodes - This map indicates the Node that a particular Value* is
75
75
  /// represented by. This contains entries for all pointers.
76
- Inst2PAGEdgesMap inst2SVFStmtsMap; ///< Map a instruction to its PAGEdges
77
- Inst2PAGEdgesMap inst2PTASVFStmtsMap; ///< Map a instruction to its PointerAnalysis related PAGEdges
76
+ ICFGNode2SVFStmtsMap icfgNode2SVFStmtsMap; ///< Map an ICFGNode to its SVFStmts
77
+ ICFGNode2SVFStmtsMap icfgNode2PTASVFStmtsMap; ///< Map an ICFGNode to its PointerAnalysis related SVFStmts
78
78
  GepValueVarMap GepValObjMap; ///< Map a pair<base,off> to a gep value node id
79
79
  NodeLocationSetMap GepObjVarMap; ///< Map a pair<base,off> to a gep obj node id
80
80
  MemObjToFieldsMap memToFieldsMap; ///< Map a mem object id to all its fields
@@ -171,29 +171,29 @@ public:
171
171
  /// Whether this instruction has SVFIR Edge
172
172
  inline bool hasSVFStmtList(const ICFGNode* inst) const
173
173
  {
174
- return inst2SVFStmtsMap.find(inst)!=inst2SVFStmtsMap.end();
174
+ return icfgNode2SVFStmtsMap.find(inst)!=icfgNode2SVFStmtsMap.end();
175
175
  }
176
176
  inline bool hasPTASVFStmtList(const ICFGNode* inst) const
177
177
  {
178
- return inst2PTASVFStmtsMap.find(inst)!=inst2PTASVFStmtsMap.end();
178
+ return icfgNode2PTASVFStmtsMap.find(inst)!=icfgNode2PTASVFStmtsMap.end();
179
179
  }
180
180
  /// Given an instruction, get all its PAGEdges
181
181
  inline SVFStmtList& getSVFStmtList(const ICFGNode* inst)
182
182
  {
183
- return inst2SVFStmtsMap[inst];
183
+ return icfgNode2SVFStmtsMap[inst];
184
184
  }
185
185
  /// Given an instruction, get all its PTA PAGEdges
186
186
  inline SVFStmtList& getPTASVFStmtList(const ICFGNode* inst)
187
187
  {
188
- return inst2PTASVFStmtsMap[inst];
188
+ return icfgNode2PTASVFStmtsMap[inst];
189
189
  }
190
190
  /// Add a SVFStmt into instruction map
191
191
  inline void addToSVFStmtList(ICFGNode* inst, SVFStmt* edge)
192
192
  {
193
193
  edge->setICFGNode(inst);
194
- inst2SVFStmtsMap[inst].push_back(edge);
194
+ icfgNode2SVFStmtsMap[inst].push_back(edge);
195
195
  if (edge->isPTAEdge())
196
- inst2PTASVFStmtsMap[inst].push_back(edge);
196
+ icfgNode2PTASVFStmtsMap[inst].push_back(edge);
197
197
  }
198
198
  /// Get global PAGEdges (not in a procedure)
199
199
  inline SVFStmtSet& getGlobalSVFStmtSet()
@@ -454,8 +454,8 @@ public:
454
454
 
455
455
  /// Get all fields of an object
456
456
  //@{
457
- NodeBS& getAllFieldsObjNode(const MemObj* obj);
458
- NodeBS& getAllFieldsObjNode(NodeID id);
457
+ NodeBS& getAllFieldsObjVars(const MemObj* obj);
458
+ NodeBS& getAllFieldsObjVars(NodeID id);
459
459
  NodeBS getFieldsAfterCollapse(NodeID id);
460
460
  //@}
461
461
  inline NodeID addDummyValNode()
@@ -631,7 +631,7 @@ private:
631
631
  /// Add phi node information
632
632
  PhiStmt* addPhiStmt(NodeID res, NodeID opnd);
633
633
  /// Add Copy edge
634
- CmpStmt* addCmpStmt(NodeID op1, NodeID op2, NodeID dst, u32_t opcode);
634
+ CmpStmt* addCmpStmt(NodeID op1, NodeID op2, NodeID dst, u32_t predict);
635
635
  /// Add Copy edge
636
636
  BinaryOPStmt* addBinaryOPStmt(NodeID op1, NodeID op2, NodeID dst, u32_t opcode);
637
637
  /// Add Unary edge
@@ -41,15 +41,15 @@ namespace SVF
41
41
  class SVFVar;
42
42
 
43
43
  /*
44
- * SVFIR edge between nodes
44
+ * SVFIR program statements (PAGEdges)
45
45
  */
46
46
  typedef GenericEdge<SVFVar> GenericPAGEdgeTy;
47
47
  class SVFStmt : public GenericPAGEdgeTy
48
48
  {
49
49
 
50
50
  public:
51
- /// Thirteen kinds of SVFIR edges
52
- /// Gep represents offset edge for field sensitivity
51
+ /// Types of SVFIR statements
52
+ /// Gep represents (base + offset) for field sensitivity
53
53
  /// ThreadFork/ThreadJoin is to model parameter passings between thread spawners and spawnees.
54
54
  enum PEDGEK
55
55
  {
@@ -192,7 +192,7 @@ private:
192
192
 
193
193
 
194
194
  /*!
195
- * Copy edge
195
+ * Address statement (memory allocations)
196
196
  */
197
197
  class AddrStmt: public SVFStmt
198
198
  {
@@ -227,7 +227,7 @@ public:
227
227
 
228
228
 
229
229
  /*!
230
- * Copy edge
230
+ * Copy statements (simple assignment and casting)
231
231
  */
232
232
  class CopyStmt: public SVFStmt
233
233
  {
@@ -260,6 +260,9 @@ public:
260
260
  virtual const std::string toString() const override;
261
261
  };
262
262
 
263
+ /*
264
+ * Program statements with multiple operands including BinaryOPStmt, CmpStmt and PhiStmt
265
+ */
263
266
  class MultiOpndStmt : public SVFStmt{
264
267
  public:
265
268
  typedef std::vector<SVFVar*> OPVars;
@@ -324,7 +327,8 @@ public:
324
327
  };
325
328
 
326
329
  /*!
327
- * Phi instruction edge
330
+ * Phi statement (e.g., p = phi(q,r) which receives values from variables q and r from different paths)
331
+ * it is typically at a joint point of the control-flow graph
328
332
  */
329
333
  class PhiStmt: public MultiOpndStmt
330
334
  {
@@ -370,7 +374,7 @@ public:
370
374
 
371
375
 
372
376
  /*!
373
- * Compare instruction edge
377
+ * Comparison statement
374
378
  */
375
379
  class CmpStmt: public MultiOpndStmt
376
380
  {
@@ -383,7 +387,7 @@ private:
383
387
  SVFVar* getSrcID(); ///< place holder, use getOpVarID(pos) instead
384
388
  SVFVar* getDstID(); ///< place holder, use getResID() instead
385
389
 
386
- u32_t opcode;
390
+ u32_t predicate;
387
391
  public:
388
392
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
389
393
  //@{
@@ -406,13 +410,13 @@ public:
406
410
  //@}
407
411
 
408
412
  /// constructor
409
- CmpStmt(SVFVar* s, const OPVars& opnds, u32_t oc) : MultiOpndStmt(s,opnds,SVFStmt::Cmp), opcode(oc)
413
+ CmpStmt(SVFVar* s, const OPVars& opnds, u32_t pre) : MultiOpndStmt(s,opnds,SVFStmt::Cmp), predicate(pre)
410
414
  {
411
415
  }
412
416
 
413
- u32_t getOpcode() const
417
+ u32_t getPredicate() const
414
418
  {
415
- return opcode;
419
+ return predicate;
416
420
  }
417
421
 
418
422
  virtual const std::string toString() const override;
@@ -420,7 +424,7 @@ public:
420
424
 
421
425
 
422
426
  /*!
423
- * Binary instruction edge
427
+ * Binary statement
424
428
  */
425
429
  class BinaryOPStmt: public MultiOpndStmt
426
430
  {
@@ -470,7 +474,7 @@ public:
470
474
  };
471
475
 
472
476
  /*!
473
- * Unary instruction edge
477
+ * Unary statement
474
478
  */
475
479
  class UnaryOPStmt: public SVFStmt
476
480
  {
@@ -587,7 +591,7 @@ public:
587
591
  };
588
592
 
589
593
  /*!
590
- * Store edge
594
+ * Store statement
591
595
  */
592
596
  class StoreStmt: public SVFStmt
593
597
  {
@@ -624,7 +628,7 @@ public:
624
628
 
625
629
 
626
630
  /*!
627
- * Load edge
631
+ * Load statement
628
632
  */
629
633
  class LoadStmt: public SVFStmt
630
634
  {
@@ -660,7 +664,7 @@ public:
660
664
 
661
665
 
662
666
  /*!
663
- * Gep edge
667
+ * Gep statement for field access and pointer arithmetic
664
668
  */
665
669
  class GepStmt: public SVFStmt
666
670
  {
@@ -700,7 +704,7 @@ protected:
700
704
 
701
705
 
702
706
  /*!
703
- * Gep edge with a fixed offset
707
+ * Gep statement with a fixed offset
704
708
  */
705
709
  class NormalGepStmt : public GepStmt
706
710
  {
@@ -750,7 +754,7 @@ public:
750
754
  };
751
755
 
752
756
  /*!
753
- * Gep edge with a variant offset
757
+ * Gep statement with a variant offset
754
758
  */
755
759
  class VariantGepStmt : public GepStmt
756
760
  {
@@ -789,7 +793,7 @@ public:
789
793
 
790
794
 
791
795
  /*!
792
- * Call edge
796
+ * Call
793
797
  */
794
798
  class CallPE: public SVFStmt
795
799
  {
@@ -841,7 +845,7 @@ public:
841
845
 
842
846
 
843
847
  /*!
844
- * Return edge
848
+ * Return
845
849
  */
846
850
  class RetPE: public SVFStmt
847
851
  {
@@ -893,7 +897,7 @@ public:
893
897
 
894
898
 
895
899
  /*!
896
- * Thread Fork Edge
900
+ * Thread Fork
897
901
  */
898
902
  class TDForkPE: public CallPE
899
903
  {
@@ -931,7 +935,7 @@ public:
931
935
 
932
936
 
933
937
  /*!
934
- * Thread Join Edge
938
+ * Thread Join
935
939
  */
936
940
  class TDJoinPE: public RetPE
937
941
  {
@@ -40,14 +40,14 @@ namespace SVF
40
40
 
41
41
  class SVFVar;
42
42
  /*
43
- * SVFIR node
43
+ * SVFIR program variables (PAGNodes)
44
44
  */
45
45
  typedef GenericNode<SVFVar,SVFStmt> GenericPAGNodeTy;
46
46
  class SVFVar : public GenericPAGNodeTy
47
47
  {
48
48
 
49
49
  public:
50
- /// Nine kinds of SVFIR nodes
50
+ /// Nine kinds of SVFIR variables
51
51
  /// ValNode: llvm pointer value
52
52
  /// ObjNode: memory object
53
53
  /// RetNode: unique return node
@@ -157,19 +157,19 @@ public:
157
157
  return nullptr;
158
158
  }
159
159
 
160
- /// Get incoming SVFIR edges
160
+ /// Get incoming SVFIR statements (edges)
161
161
  inline SVFStmt::SVFStmtSetTy& getIncomingEdges(SVFStmt::PEDGEK kind)
162
162
  {
163
163
  return InEdgeKindToSetMap[kind];
164
164
  }
165
165
 
166
- /// Get outgoing SVFIR edges
166
+ /// Get outgoing SVFIR statements (edges)
167
167
  inline SVFStmt::SVFStmtSetTy& getOutgoingEdges(SVFStmt::PEDGEK kind)
168
168
  {
169
169
  return OutEdgeKindToSetMap[kind];
170
170
  }
171
171
 
172
- /// Has incoming SVFIR edges
172
+ /// Has incoming SVFIR statements (edges)
173
173
  inline bool hasIncomingEdges(SVFStmt::PEDGEK kind) const
174
174
  {
175
175
  SVFStmt::KindToSVFStmtMapTy::const_iterator it = InEdgeKindToSetMap.find(kind);
@@ -206,7 +206,7 @@ public:
206
206
  return it->second.end();
207
207
  }
208
208
 
209
- /// Has outgoing SVFIR edges
209
+ /// Has outgoing SVFIR statements (edges)
210
210
  inline bool hasOutgoingEdges(SVFStmt::PEDGEK kind) const
211
211
  {
212
212
  SVFStmt::KindToSVFStmtMapTy::const_iterator it = OutEdgeKindToSetMap.find(kind);
@@ -268,7 +268,7 @@ public:
268
268
 
269
269
 
270
270
  /*
271
- * Value(Pointer) node
271
+ * Value (Pointer) variable
272
272
  */
273
273
  class ValVar: public SVFVar
274
274
  {
@@ -312,7 +312,7 @@ public:
312
312
 
313
313
 
314
314
  /*
315
- * Memory Object node
315
+ * Memory Object variable
316
316
  */
317
317
  class ObjVar: public SVFVar
318
318
  {
@@ -377,9 +377,9 @@ public:
377
377
 
378
378
 
379
379
  /*
380
- * Gep Value (Pointer) node, this node can be dynamic generated for field sensitive analysis
381
- * e.g. memcpy, temp gep value node needs to be created
382
- * Each Gep Value node is connected to base value node via gep edge
380
+ * Gep Value (Pointer) variable, this variable can be dynamic generated for field sensitive analysis
381
+ * e.g. memcpy, temp gep value variable needs to be created
382
+ * Each Gep Value variable is connected to base value variable via gep edge
383
383
  */
384
384
  class GepValVar: public ValVar
385
385
  {
@@ -416,7 +416,7 @@ public:
416
416
  {
417
417
  }
418
418
 
419
- /// offset of the base value node
419
+ /// offset of the base value variable
420
420
  inline u32_t getOffset() const
421
421
  {
422
422
  return ls.getOffset();
@@ -445,8 +445,8 @@ public:
445
445
 
446
446
 
447
447
  /*
448
- * Gep Obj node, this is dynamic generated for field sensitive analysis
449
- * Each gep obj node is one field of a MemObj (base)
448
+ * Gep Obj variable, this is dynamic generated for field sensitive analysis
449
+ * Each gep obj variable is one field of a MemObj (base)
450
450
  */
451
451
  class GepObjPN: public ObjVar
452
452
  {
@@ -521,7 +521,7 @@ public:
521
521
  };
522
522
 
523
523
  /*
524
- * Field-insensitive Gep Obj node, this is dynamic generated for field sensitive analysis
524
+ * Field-insensitive Gep Obj variable, this is dynamic generated for field sensitive analysis
525
525
  * Each field-insensitive gep obj node represents all fields of a MemObj (base)
526
526
  */
527
527
  class FIObjVar: public ObjVar
@@ -649,7 +649,7 @@ public:
649
649
 
650
650
 
651
651
  /*
652
- * Dummy node
652
+ * Dummy variable without any LLVM value
653
653
  */
654
654
  class DummyValVar: public ValVar
655
655
  {
@@ -688,7 +688,7 @@ public:
688
688
 
689
689
 
690
690
  /*
691
- * Dummy node
691
+ * Dummy object variable
692
692
  */
693
693
  class DummyObjVar: public ObjVar
694
694
  {
@@ -138,6 +138,10 @@ public:
138
138
  }
139
139
  //@}
140
140
 
141
+ bool isNegCond(const Condition *condition) {
142
+ return condMgr->isNegCond(condition);
143
+ }
144
+
141
145
  /// Get dominators
142
146
  inline DominatorTree* getDT(const Function* fun)
143
147
  {
@@ -302,9 +302,9 @@ public:
302
302
  return edge;
303
303
  }
304
304
  /// Add Copy edge
305
- inline CmpStmt* addCmpEdge(NodeID op1, NodeID op2, NodeID dst, u32_t opcode)
305
+ inline CmpStmt* addCmpEdge(NodeID op1, NodeID op2, NodeID dst, u32_t predict)
306
306
  {
307
- CmpStmt *edge = pag->addCmpStmt(op1, op2, dst, opcode);
307
+ CmpStmt *edge = pag->addCmpStmt(op1, op2, dst, predict);
308
308
  setCurrentBBAndValueForPAGEdge(edge);
309
309
  return edge;
310
310
  }
@@ -287,6 +287,15 @@ public:
287
287
  assert(condToInstMap.find(cond)==condToInstMap.end() && "this should be a fresh condition");
288
288
  condToInstMap[cond] = inst;
289
289
  }
290
+
291
+ inline void setNegCondInst(const CondExpr *cond, const Instruction *inst) {
292
+ setCondInst(cond, inst);
293
+ negConds.set(cond->getId());
294
+ }
295
+
296
+ inline bool isNegCond(const CondExpr *cond) const {
297
+ return negConds.test(cond->getId());
298
+ }
290
299
  //@}
291
300
 
292
301
  private:
@@ -298,6 +307,7 @@ private:
298
307
  BranchCondToCondExprMap branchCondToCondExpr; ///< map branch condition to its Condition wrapper
299
308
  CondToTermInstMap condToInstMap; ///< map condition to llvm instruction
300
309
  BranchCondManager branchCondManager; ///< branch condition manager
310
+ NodeBS negConds;
301
311
  };
302
312
 
303
313
  } // End namespace SVF
@@ -243,13 +243,15 @@ public:
243
243
  // TypeAnalysis.cpp
244
244
  static const llvm::cl::opt<bool> GenICFG;
245
245
 
246
- //WPAPass.cpp
246
+ // WPAPass.cpp
247
247
  static const llvm::cl::opt<bool> AnderSVFG;
248
248
  static const llvm::cl::opt<bool> SABERFULLSVFG;
249
249
  static const llvm::cl::opt<bool> PrintAliases;
250
250
  static llvm::cl::bits<PointerAnalysis::PTATY> PASelected;
251
251
  static llvm::cl::bits<WPAPass::AliasCheckRule> AliasRule;
252
252
 
253
+ // DOTGraphTraits
254
+ static const llvm::cl::opt<bool> ShowHiddenNode;
253
255
  };
254
256
  } // namespace SVF
255
257
 
@@ -383,7 +383,7 @@ protected:
383
383
 
384
384
  for (NodeID o : fldInsenObjs)
385
385
  {
386
- const NodeBS &allFields = consCG->getAllFieldsObjNode(o);
386
+ const NodeBS &allFields = consCG->getAllFieldsObjVars(o);
387
387
  for (NodeID f : allFields) addPts(it->first, f);
388
388
  }
389
389
  }
@@ -73,7 +73,7 @@ public:
73
73
  virtual bool processPhi(const PHISVFGNode* phi) override;
74
74
  virtual bool processCopy(const CopySVFGNode* copy) override;
75
75
 
76
- virtual inline const NodeBS& getAllFieldsObjNode(NodeID id) override;
76
+ virtual inline const NodeBS& getAllFieldsObjVars(NodeID id) override;
77
77
 
78
78
  virtual inline bool updateInFromIn(const SVFGNode* srcStmt, NodeID srcVar, const SVFGNode* dstStmt, NodeID dstVar) override;
79
79
  virtual inline bool updateInFromOut(const SVFGNode* srcStmt, NodeID srcVar, const SVFGNode* dstStmt, NodeID dstVar) override;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.747",
3
+ "version": "1.0.751",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {