svf-lib 1.0.2085 → 1.0.2087

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 (41) hide show
  1. package/SVF-linux/Release-build/bin/ae +0 -0
  2. package/SVF-linux/Release-build/bin/cfl +0 -0
  3. package/SVF-linux/Release-build/bin/dvf +0 -0
  4. package/SVF-linux/Release-build/bin/llvm2svf +0 -0
  5. package/SVF-linux/Release-build/bin/mta +0 -0
  6. package/SVF-linux/Release-build/bin/saber +0 -0
  7. package/SVF-linux/Release-build/bin/svf-ex +0 -0
  8. package/SVF-linux/Release-build/bin/wpa +0 -0
  9. package/SVF-linux/Release-build/include/Graphs/ICFG.h +9 -0
  10. package/SVF-linux/Release-build/include/MSSA/MemRegion.h +2 -2
  11. package/SVF-linux/Release-build/include/MTA/MHP.h +1 -2
  12. package/SVF-linux/Release-build/include/SVF-LLVM/ICFGBuilder.h +16 -6
  13. package/SVF-linux/Release-build/include/SVF-LLVM/LLVMUtil.h +11 -0
  14. package/SVF-linux/Release-build/include/SVF-LLVM/SVFIRBuilder.h +2 -2
  15. package/SVF-linux/Release-build/include/SVFIR/SVFIR.h +1 -1
  16. package/SVF-linux/Release-build/include/SVFIR/SVFStatements.h +1 -1
  17. package/SVF-linux/Release-build/include/SVFIR/SVFValue.h +21 -16
  18. package/SVF-linux/Release-build/include/Util/SVFUtil.h +19 -17
  19. package/SVF-linux/Release-build/lib/libSvfCore.a +0 -0
  20. package/SVF-linux/Release-build/lib/libSvfLLVM.a +0 -0
  21. package/SVF-osx/Release-build/bin/ae +0 -0
  22. package/SVF-osx/Release-build/bin/cfl +0 -0
  23. package/SVF-osx/Release-build/bin/dvf +0 -0
  24. package/SVF-osx/Release-build/bin/llvm2svf +0 -0
  25. package/SVF-osx/Release-build/bin/mta +0 -0
  26. package/SVF-osx/Release-build/bin/saber +0 -0
  27. package/SVF-osx/Release-build/bin/svf-ex +0 -0
  28. package/SVF-osx/Release-build/bin/wpa +0 -0
  29. package/SVF-osx/Release-build/include/Graphs/ICFG.h +9 -0
  30. package/SVF-osx/Release-build/include/MSSA/MemRegion.h +2 -2
  31. package/SVF-osx/Release-build/include/MTA/MHP.h +1 -2
  32. package/SVF-osx/Release-build/include/SVF-LLVM/ICFGBuilder.h +16 -6
  33. package/SVF-osx/Release-build/include/SVF-LLVM/LLVMUtil.h +11 -0
  34. package/SVF-osx/Release-build/include/SVF-LLVM/SVFIRBuilder.h +2 -2
  35. package/SVF-osx/Release-build/include/SVFIR/SVFIR.h +1 -1
  36. package/SVF-osx/Release-build/include/SVFIR/SVFStatements.h +1 -1
  37. package/SVF-osx/Release-build/include/SVFIR/SVFValue.h +21 -16
  38. package/SVF-osx/Release-build/include/Util/SVFUtil.h +19 -17
  39. package/SVF-osx/Release-build/lib/libSvfCore.a +0 -0
  40. package/SVF-osx/Release-build/lib/libSvfLLVM.a +0 -0
  41. package/package.json +1 -1
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -198,12 +198,21 @@ public:
198
198
  //@{
199
199
  ICFGNode* getICFGNode(const SVFInstruction* inst);
200
200
 
201
+ /// Whether has the ICFGNode
202
+ bool hasICFGNode(const SVFInstruction* inst);
203
+
201
204
  CallICFGNode* getCallICFGNode(const SVFInstruction* inst);
202
205
 
206
+ CallICFGNode* addCallICFGNode(const SVFInstruction* inst);
207
+
203
208
  RetICFGNode* getRetICFGNode(const SVFInstruction* inst);
204
209
 
210
+ RetICFGNode* addRetICFGNode(const SVFInstruction* inst);
211
+
205
212
  IntraICFGNode* getIntraICFGNode(const SVFInstruction* inst);
206
213
 
214
+ IntraICFGNode* addIntraICFGNode(const SVFInstruction* inst);
215
+
207
216
  FunEntryICFGNode* getFunEntryICFGNode(const SVFFunction* fun);
208
217
 
209
218
  FunExitICFGNode* getFunExitICFGNode(const SVFFunction* fun);
@@ -470,9 +470,9 @@ public:
470
470
  }
471
471
  //@}
472
472
  /// Whether this instruction has SVFIR Edge
473
- bool hasSVFStmtList(const SVFInstruction* inst);
473
+ bool hasSVFStmtList(const ICFGNode* icfgNode);
474
474
  /// Given an instruction, get all its the PAGEdge (statement) in sequence
475
- SVFStmtList& getPAGEdgesFromInst(const SVFInstruction* inst);
475
+ SVFStmtList& getPAGEdgesFromInst(const ICFGNode* node);
476
476
 
477
477
  /// getModRefInfo APIs
478
478
  //@{
@@ -341,8 +341,7 @@ public:
341
341
  NodeID parentTid = tct->getParentThread(tid);
342
342
  const CxtThread& parentct = tct->getTCTNode(parentTid)->getCxtThread();
343
343
  const SVFFunction* parentRoutine = tct->getStartRoutineOfCxtThread(parentct);
344
- const SVFInstruction* inst = parentRoutine->getExitBB()->back();
345
- return tct->getICFGNode(inst);
344
+ return parentRoutine->getExitBB()->back();
346
345
  }
347
346
 
348
347
  /// Get loop for join site
@@ -62,23 +62,30 @@ private:
62
62
  ///@{
63
63
  void processFunEntry(const Function* fun, WorkList& worklist);
64
64
 
65
+ void processNoPrecessorBasicBlocks(const Function* fun, WorkList& worklist);
66
+
65
67
  void processFunBody(WorkList& worklist);
66
68
 
67
69
  void processFunExit(const Function* fun);
68
70
  //@}
69
71
 
72
+ void checkICFGNodesVisited(const Function* fun);
73
+
70
74
  void connectGlobalToProgEntry(SVFModule* svfModule);
71
75
 
72
76
  /// Add/Get an inter block ICFGNode
73
- InterICFGNode* getOrAddInterBlockICFGNode(const SVFInstruction* inst);
77
+ InterICFGNode* addInterBlockICFGNode(const SVFInstruction* inst);
74
78
 
75
79
  /// Add/Get a basic block ICFGNode
76
- inline ICFGNode* getOrAddBlockICFGNode(const SVFInstruction* inst)
80
+ inline ICFGNode* addBlockICFGNode(const SVFInstruction* inst)
77
81
  {
82
+ ICFGNode* node;
78
83
  if(SVFUtil::isNonInstricCallSite(inst))
79
- return getOrAddInterBlockICFGNode(inst);
84
+ node = addInterBlockICFGNode(inst);
80
85
  else
81
- return getOrAddIntraBlockICFGNode(inst);
86
+ node = addIntraBlockICFGNode(inst);
87
+ const_cast<SVFBasicBlock*>(inst->getParent())->addICFGNode(node);
88
+ return node;
82
89
  }
83
90
 
84
91
  /// Create edges between ICFG nodes across functions
@@ -96,10 +103,13 @@ private:
96
103
  }
97
104
 
98
105
  /// Add and get IntraBlock ICFGNode
99
- IntraICFGNode* getOrAddIntraBlockICFGNode(const SVFInstruction* inst)
106
+ IntraICFGNode* addIntraBlockICFGNode(const SVFInstruction* inst)
100
107
  {
101
- return icfg->getIntraICFGNode(inst);
108
+ return icfg->addIntraICFGNode(inst);
102
109
  }
110
+
111
+ private:
112
+ BBSet visited;
103
113
  };
104
114
 
105
115
  } // End namespace SVF
@@ -303,6 +303,17 @@ void getNextInsts(const Instruction* curInst,
303
303
  void getPrevInsts(const Instruction* curInst,
304
304
  std::vector<const Instruction*>& instList);
305
305
 
306
+ /// Basic block does not have predecessors
307
+ /// map-1.cpp.bc
308
+ /// try.cont: ; No predecessors!
309
+ /// call void @llvm.trap()
310
+ /// unreachable
311
+ inline bool isNoPrecessorBasicBlock(const BasicBlock* bb)
312
+ {
313
+ return bb != &bb->getParent()->getEntryBlock() &&
314
+ pred_empty(bb);
315
+ }
316
+
306
317
  /// Get num of BB's predecessors
307
318
  u32_t getBBPredecessorNum(const BasicBlock* BB);
308
319
 
@@ -450,9 +450,9 @@ protected:
450
450
  /// Add Store edge
451
451
  inline void addStoreEdge(NodeID src, NodeID dst)
452
452
  {
453
- IntraICFGNode* node;
453
+ ICFGNode* node;
454
454
  if (const SVFInstruction* inst = SVFUtil::dyn_cast<SVFInstruction>(curVal))
455
- node = pag->getICFG()->getIntraICFGNode(inst);
455
+ node = pag->getICFG()->getICFGNode(inst);
456
456
  else
457
457
  node = nullptr;
458
458
  if (StoreStmt* edge = pag->addStoreStmt(src, dst, node))
@@ -658,7 +658,7 @@ private:
658
658
  /// Add Load edge
659
659
  LoadStmt* addLoadStmt(NodeID src, NodeID dst);
660
660
  /// Add Store edge
661
- StoreStmt* addStoreStmt(NodeID src, NodeID dst, const IntraICFGNode* val);
661
+ StoreStmt* addStoreStmt(NodeID src, NodeID dst, const ICFGNode* val);
662
662
  /// Add Call edge
663
663
  CallPE* addCallPE(NodeID src, NodeID dst, const CallICFGNode* cs,
664
664
  const FunEntryICFGNode* entry);
@@ -478,7 +478,7 @@ public:
478
478
  //@}
479
479
 
480
480
  /// constructor
481
- StoreStmt(SVFVar* s, SVFVar* d, const IntraICFGNode* st);
481
+ StoreStmt(SVFVar* s, SVFVar* d, const ICFGNode* st);
482
482
 
483
483
  virtual const std::string toString() const override;
484
484
  };
@@ -524,6 +524,8 @@ public:
524
524
  }
525
525
  };
526
526
 
527
+ class ICFGNode;
528
+
527
529
  class SVFBasicBlock : public SVFValue
528
530
  {
529
531
  friend class LLVMModuleSet;
@@ -531,21 +533,26 @@ class SVFBasicBlock : public SVFValue
531
533
  friend class SVFIRReader;
532
534
  friend class SVFIRBuilder;
533
535
  friend class SVFFunction;
536
+ friend class ICFGBuilder;
537
+ friend class ICFG;
534
538
 
535
539
  public:
536
- typedef std::vector<const SVFInstruction*>::const_iterator const_iterator;
540
+ typedef std::vector<const ICFGNode*>::const_iterator const_iterator;
537
541
 
538
542
  private:
539
- std::vector<const SVFInstruction*> allInsts; ///< all Instructions in this BasicBlock
543
+ std::vector<const ICFGNode*> allICFGNodes; ///< all ICFGNodes in this BasicBlock
540
544
  std::vector<const SVFBasicBlock*> succBBs; ///< all successor BasicBlocks of this BasicBlock
541
545
  std::vector<const SVFBasicBlock*> predBBs; ///< all predecessor BasicBlocks of this BasicBlock
542
546
  const SVFFunction* fun; /// Function where this BasicBlock is
543
547
 
544
548
  protected:
545
549
  ///@{ attributes to be set only through Module builders e.g., LLVMModule
546
- inline void addInstruction(const SVFInstruction* inst)
550
+
551
+ inline void addICFGNode(const ICFGNode* icfgNode)
547
552
  {
548
- allInsts.push_back(inst);
553
+ assert(std::find(getICFGNodeList().begin(), getICFGNodeList().end(),
554
+ icfgNode) == getICFGNodeList().end() && "duplicated icfgnode");
555
+ allICFGNodes.push_back(icfgNode);
549
556
  }
550
557
 
551
558
  inline void addSuccBasicBlock(const SVFBasicBlock* succ)
@@ -570,19 +577,19 @@ public:
570
577
  return node->getKind() == SVFBB;
571
578
  }
572
579
 
573
- inline const std::vector<const SVFInstruction*>& getInstructionList() const
580
+ inline const std::vector<const ICFGNode*>& getICFGNodeList() const
574
581
  {
575
- return allInsts;
582
+ return allICFGNodes;
576
583
  }
577
584
 
578
585
  inline const_iterator begin() const
579
586
  {
580
- return allInsts.begin();
587
+ return allICFGNodes.begin();
581
588
  }
582
589
 
583
590
  inline const_iterator end() const
584
591
  {
585
- return allInsts.end();
592
+ return allICFGNodes.end();
586
593
  }
587
594
 
588
595
  inline const SVFFunction* getParent() const
@@ -595,20 +602,18 @@ public:
595
602
  return fun;
596
603
  }
597
604
 
598
- inline const SVFInstruction* front() const
605
+ inline const ICFGNode* front() const
599
606
  {
600
- return allInsts.front();
607
+ assert(!allICFGNodes.empty() && "bb empty?");
608
+ return allICFGNodes.front();
601
609
  }
602
610
 
603
- inline const SVFInstruction* back() const
611
+ inline const ICFGNode* back() const
604
612
  {
605
- return allInsts.back();
613
+ assert(!allICFGNodes.empty() && "bb empty?");
614
+ return allICFGNodes.back();
606
615
  }
607
616
 
608
- /// Returns the terminator instruction if the block is well formed or null
609
- /// if the block is not well formed.
610
- const SVFInstruction* getTerminator() const;
611
-
612
617
  inline const std::vector<const SVFBasicBlock*>& getSuccessors() const
613
618
  {
614
619
  return succBBs;
@@ -168,6 +168,8 @@ void dumpPointsToList(const PointsToList& ptl);
168
168
 
169
169
  /// Return true if it is an llvm intrinsic instruction
170
170
  bool isIntrinsicInst(const SVFInstruction* inst);
171
+ bool isIntrinsicInst(const ICFGNode* inst);
172
+
171
173
  //@}
172
174
 
173
175
  /// Whether an instruction is a call or invoke instruction
@@ -184,6 +186,10 @@ inline bool isCallSite(const SVFValue* val)
184
186
  return false;
185
187
  }
186
188
 
189
+ bool isCallSite(const ICFGNode* inst);
190
+
191
+ bool isRetInstNode(const ICFGNode* node);
192
+
187
193
  /// Whether an instruction is a callsite in the application code, excluding llvm intrinsic calls
188
194
  inline bool isNonInstricCallSite(const SVFInstruction* inst)
189
195
  {
@@ -192,6 +198,14 @@ inline bool isNonInstricCallSite(const SVFInstruction* inst)
192
198
  return isCallSite(inst);
193
199
  }
194
200
 
201
+ /// Whether an instruction is a callsite in the application code, excluding llvm intrinsic calls
202
+ inline bool isNonInstricCallSite(const ICFGNode* inst)
203
+ {
204
+ if(isIntrinsicInst(inst))
205
+ return false;
206
+ return isCallSite(inst);
207
+ }
208
+
195
209
  /// Return LLVM callsite given an instruction
196
210
  inline CallSite getSVFCallSite(const SVFInstruction* inst)
197
211
  {
@@ -250,6 +264,8 @@ inline const SVFFunction* getCallee(const SVFInstruction *inst)
250
264
  CallSite cs(inst);
251
265
  return getCallee(cs);
252
266
  }
267
+
268
+ const SVFFunction* getCallee(const ICFGNode *inst);
253
269
  //@}
254
270
 
255
271
  /// Given a map mapping points-to sets to a count, adds from into to.
@@ -402,27 +418,20 @@ inline bool isArgOfUncalledFunction(const SVFValue* svfval)
402
418
 
403
419
  /// Return thread fork function
404
420
  //@{
405
- inline const SVFValue* getForkedFun(const CallSite cs)
406
- {
407
- return ThreadAPI::getThreadAPI()->getForkedFun(cs.getInstruction());
408
- }
409
421
  inline const SVFValue* getForkedFun(const SVFInstruction *inst)
410
422
  {
411
423
  return ThreadAPI::getThreadAPI()->getForkedFun(inst);
412
424
  }
413
425
  //@}
414
426
 
415
- /// This function servers a allocation wrapper detector
416
- inline bool isAnAllocationWraper(const SVFInstruction*)
417
- {
418
- return false;
419
- }
420
427
 
421
428
  inline bool isExtCall(const CallSite cs)
422
429
  {
423
430
  return isExtCall(getCallee(cs));
424
431
  }
425
432
 
433
+ bool isExtCall(const ICFGNode* node);
434
+
426
435
  inline bool isExtCall(const SVFInstruction *inst)
427
436
  {
428
437
  return isExtCall(getCallee(inst));
@@ -451,10 +460,7 @@ inline bool isHeapAllocExtCallViaRet(const SVFInstruction *inst)
451
460
  return isPtrTy && isHeapAllocExtFunViaRet(getCallee(inst));
452
461
  }
453
462
 
454
- inline bool isHeapAllocExtCall(const CallSite cs)
455
- {
456
- return isHeapAllocExtCallViaRet(cs) || isHeapAllocExtCallViaArg(cs);
457
- }
463
+ bool isHeapAllocExtCall(const ICFGNode* cs);
458
464
 
459
465
  inline bool isHeapAllocExtCall(const SVFInstruction *inst)
460
466
  {
@@ -477,10 +483,6 @@ inline bool isReallocExtCall(const CallSite cs)
477
483
 
478
484
  /// Return true if this is a thread creation call
479
485
  ///@{
480
- inline bool isThreadForkCall(const CallSite cs)
481
- {
482
- return ThreadAPI::getThreadAPI()->isTDFork(cs.getInstruction());
483
- }
484
486
  inline bool isThreadForkCall(const SVFInstruction *inst)
485
487
  {
486
488
  return ThreadAPI::getThreadAPI()->isTDFork(inst);
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -198,12 +198,21 @@ public:
198
198
  //@{
199
199
  ICFGNode* getICFGNode(const SVFInstruction* inst);
200
200
 
201
+ /// Whether has the ICFGNode
202
+ bool hasICFGNode(const SVFInstruction* inst);
203
+
201
204
  CallICFGNode* getCallICFGNode(const SVFInstruction* inst);
202
205
 
206
+ CallICFGNode* addCallICFGNode(const SVFInstruction* inst);
207
+
203
208
  RetICFGNode* getRetICFGNode(const SVFInstruction* inst);
204
209
 
210
+ RetICFGNode* addRetICFGNode(const SVFInstruction* inst);
211
+
205
212
  IntraICFGNode* getIntraICFGNode(const SVFInstruction* inst);
206
213
 
214
+ IntraICFGNode* addIntraICFGNode(const SVFInstruction* inst);
215
+
207
216
  FunEntryICFGNode* getFunEntryICFGNode(const SVFFunction* fun);
208
217
 
209
218
  FunExitICFGNode* getFunExitICFGNode(const SVFFunction* fun);
@@ -470,9 +470,9 @@ public:
470
470
  }
471
471
  //@}
472
472
  /// Whether this instruction has SVFIR Edge
473
- bool hasSVFStmtList(const SVFInstruction* inst);
473
+ bool hasSVFStmtList(const ICFGNode* icfgNode);
474
474
  /// Given an instruction, get all its the PAGEdge (statement) in sequence
475
- SVFStmtList& getPAGEdgesFromInst(const SVFInstruction* inst);
475
+ SVFStmtList& getPAGEdgesFromInst(const ICFGNode* node);
476
476
 
477
477
  /// getModRefInfo APIs
478
478
  //@{
@@ -341,8 +341,7 @@ public:
341
341
  NodeID parentTid = tct->getParentThread(tid);
342
342
  const CxtThread& parentct = tct->getTCTNode(parentTid)->getCxtThread();
343
343
  const SVFFunction* parentRoutine = tct->getStartRoutineOfCxtThread(parentct);
344
- const SVFInstruction* inst = parentRoutine->getExitBB()->back();
345
- return tct->getICFGNode(inst);
344
+ return parentRoutine->getExitBB()->back();
346
345
  }
347
346
 
348
347
  /// Get loop for join site
@@ -62,23 +62,30 @@ private:
62
62
  ///@{
63
63
  void processFunEntry(const Function* fun, WorkList& worklist);
64
64
 
65
+ void processNoPrecessorBasicBlocks(const Function* fun, WorkList& worklist);
66
+
65
67
  void processFunBody(WorkList& worklist);
66
68
 
67
69
  void processFunExit(const Function* fun);
68
70
  //@}
69
71
 
72
+ void checkICFGNodesVisited(const Function* fun);
73
+
70
74
  void connectGlobalToProgEntry(SVFModule* svfModule);
71
75
 
72
76
  /// Add/Get an inter block ICFGNode
73
- InterICFGNode* getOrAddInterBlockICFGNode(const SVFInstruction* inst);
77
+ InterICFGNode* addInterBlockICFGNode(const SVFInstruction* inst);
74
78
 
75
79
  /// Add/Get a basic block ICFGNode
76
- inline ICFGNode* getOrAddBlockICFGNode(const SVFInstruction* inst)
80
+ inline ICFGNode* addBlockICFGNode(const SVFInstruction* inst)
77
81
  {
82
+ ICFGNode* node;
78
83
  if(SVFUtil::isNonInstricCallSite(inst))
79
- return getOrAddInterBlockICFGNode(inst);
84
+ node = addInterBlockICFGNode(inst);
80
85
  else
81
- return getOrAddIntraBlockICFGNode(inst);
86
+ node = addIntraBlockICFGNode(inst);
87
+ const_cast<SVFBasicBlock*>(inst->getParent())->addICFGNode(node);
88
+ return node;
82
89
  }
83
90
 
84
91
  /// Create edges between ICFG nodes across functions
@@ -96,10 +103,13 @@ private:
96
103
  }
97
104
 
98
105
  /// Add and get IntraBlock ICFGNode
99
- IntraICFGNode* getOrAddIntraBlockICFGNode(const SVFInstruction* inst)
106
+ IntraICFGNode* addIntraBlockICFGNode(const SVFInstruction* inst)
100
107
  {
101
- return icfg->getIntraICFGNode(inst);
108
+ return icfg->addIntraICFGNode(inst);
102
109
  }
110
+
111
+ private:
112
+ BBSet visited;
103
113
  };
104
114
 
105
115
  } // End namespace SVF
@@ -303,6 +303,17 @@ void getNextInsts(const Instruction* curInst,
303
303
  void getPrevInsts(const Instruction* curInst,
304
304
  std::vector<const Instruction*>& instList);
305
305
 
306
+ /// Basic block does not have predecessors
307
+ /// map-1.cpp.bc
308
+ /// try.cont: ; No predecessors!
309
+ /// call void @llvm.trap()
310
+ /// unreachable
311
+ inline bool isNoPrecessorBasicBlock(const BasicBlock* bb)
312
+ {
313
+ return bb != &bb->getParent()->getEntryBlock() &&
314
+ pred_empty(bb);
315
+ }
316
+
306
317
  /// Get num of BB's predecessors
307
318
  u32_t getBBPredecessorNum(const BasicBlock* BB);
308
319
 
@@ -450,9 +450,9 @@ protected:
450
450
  /// Add Store edge
451
451
  inline void addStoreEdge(NodeID src, NodeID dst)
452
452
  {
453
- IntraICFGNode* node;
453
+ ICFGNode* node;
454
454
  if (const SVFInstruction* inst = SVFUtil::dyn_cast<SVFInstruction>(curVal))
455
- node = pag->getICFG()->getIntraICFGNode(inst);
455
+ node = pag->getICFG()->getICFGNode(inst);
456
456
  else
457
457
  node = nullptr;
458
458
  if (StoreStmt* edge = pag->addStoreStmt(src, dst, node))
@@ -658,7 +658,7 @@ private:
658
658
  /// Add Load edge
659
659
  LoadStmt* addLoadStmt(NodeID src, NodeID dst);
660
660
  /// Add Store edge
661
- StoreStmt* addStoreStmt(NodeID src, NodeID dst, const IntraICFGNode* val);
661
+ StoreStmt* addStoreStmt(NodeID src, NodeID dst, const ICFGNode* val);
662
662
  /// Add Call edge
663
663
  CallPE* addCallPE(NodeID src, NodeID dst, const CallICFGNode* cs,
664
664
  const FunEntryICFGNode* entry);
@@ -478,7 +478,7 @@ public:
478
478
  //@}
479
479
 
480
480
  /// constructor
481
- StoreStmt(SVFVar* s, SVFVar* d, const IntraICFGNode* st);
481
+ StoreStmt(SVFVar* s, SVFVar* d, const ICFGNode* st);
482
482
 
483
483
  virtual const std::string toString() const override;
484
484
  };
@@ -524,6 +524,8 @@ public:
524
524
  }
525
525
  };
526
526
 
527
+ class ICFGNode;
528
+
527
529
  class SVFBasicBlock : public SVFValue
528
530
  {
529
531
  friend class LLVMModuleSet;
@@ -531,21 +533,26 @@ class SVFBasicBlock : public SVFValue
531
533
  friend class SVFIRReader;
532
534
  friend class SVFIRBuilder;
533
535
  friend class SVFFunction;
536
+ friend class ICFGBuilder;
537
+ friend class ICFG;
534
538
 
535
539
  public:
536
- typedef std::vector<const SVFInstruction*>::const_iterator const_iterator;
540
+ typedef std::vector<const ICFGNode*>::const_iterator const_iterator;
537
541
 
538
542
  private:
539
- std::vector<const SVFInstruction*> allInsts; ///< all Instructions in this BasicBlock
543
+ std::vector<const ICFGNode*> allICFGNodes; ///< all ICFGNodes in this BasicBlock
540
544
  std::vector<const SVFBasicBlock*> succBBs; ///< all successor BasicBlocks of this BasicBlock
541
545
  std::vector<const SVFBasicBlock*> predBBs; ///< all predecessor BasicBlocks of this BasicBlock
542
546
  const SVFFunction* fun; /// Function where this BasicBlock is
543
547
 
544
548
  protected:
545
549
  ///@{ attributes to be set only through Module builders e.g., LLVMModule
546
- inline void addInstruction(const SVFInstruction* inst)
550
+
551
+ inline void addICFGNode(const ICFGNode* icfgNode)
547
552
  {
548
- allInsts.push_back(inst);
553
+ assert(std::find(getICFGNodeList().begin(), getICFGNodeList().end(),
554
+ icfgNode) == getICFGNodeList().end() && "duplicated icfgnode");
555
+ allICFGNodes.push_back(icfgNode);
549
556
  }
550
557
 
551
558
  inline void addSuccBasicBlock(const SVFBasicBlock* succ)
@@ -570,19 +577,19 @@ public:
570
577
  return node->getKind() == SVFBB;
571
578
  }
572
579
 
573
- inline const std::vector<const SVFInstruction*>& getInstructionList() const
580
+ inline const std::vector<const ICFGNode*>& getICFGNodeList() const
574
581
  {
575
- return allInsts;
582
+ return allICFGNodes;
576
583
  }
577
584
 
578
585
  inline const_iterator begin() const
579
586
  {
580
- return allInsts.begin();
587
+ return allICFGNodes.begin();
581
588
  }
582
589
 
583
590
  inline const_iterator end() const
584
591
  {
585
- return allInsts.end();
592
+ return allICFGNodes.end();
586
593
  }
587
594
 
588
595
  inline const SVFFunction* getParent() const
@@ -595,20 +602,18 @@ public:
595
602
  return fun;
596
603
  }
597
604
 
598
- inline const SVFInstruction* front() const
605
+ inline const ICFGNode* front() const
599
606
  {
600
- return allInsts.front();
607
+ assert(!allICFGNodes.empty() && "bb empty?");
608
+ return allICFGNodes.front();
601
609
  }
602
610
 
603
- inline const SVFInstruction* back() const
611
+ inline const ICFGNode* back() const
604
612
  {
605
- return allInsts.back();
613
+ assert(!allICFGNodes.empty() && "bb empty?");
614
+ return allICFGNodes.back();
606
615
  }
607
616
 
608
- /// Returns the terminator instruction if the block is well formed or null
609
- /// if the block is not well formed.
610
- const SVFInstruction* getTerminator() const;
611
-
612
617
  inline const std::vector<const SVFBasicBlock*>& getSuccessors() const
613
618
  {
614
619
  return succBBs;
@@ -168,6 +168,8 @@ void dumpPointsToList(const PointsToList& ptl);
168
168
 
169
169
  /// Return true if it is an llvm intrinsic instruction
170
170
  bool isIntrinsicInst(const SVFInstruction* inst);
171
+ bool isIntrinsicInst(const ICFGNode* inst);
172
+
171
173
  //@}
172
174
 
173
175
  /// Whether an instruction is a call or invoke instruction
@@ -184,6 +186,10 @@ inline bool isCallSite(const SVFValue* val)
184
186
  return false;
185
187
  }
186
188
 
189
+ bool isCallSite(const ICFGNode* inst);
190
+
191
+ bool isRetInstNode(const ICFGNode* node);
192
+
187
193
  /// Whether an instruction is a callsite in the application code, excluding llvm intrinsic calls
188
194
  inline bool isNonInstricCallSite(const SVFInstruction* inst)
189
195
  {
@@ -192,6 +198,14 @@ inline bool isNonInstricCallSite(const SVFInstruction* inst)
192
198
  return isCallSite(inst);
193
199
  }
194
200
 
201
+ /// Whether an instruction is a callsite in the application code, excluding llvm intrinsic calls
202
+ inline bool isNonInstricCallSite(const ICFGNode* inst)
203
+ {
204
+ if(isIntrinsicInst(inst))
205
+ return false;
206
+ return isCallSite(inst);
207
+ }
208
+
195
209
  /// Return LLVM callsite given an instruction
196
210
  inline CallSite getSVFCallSite(const SVFInstruction* inst)
197
211
  {
@@ -250,6 +264,8 @@ inline const SVFFunction* getCallee(const SVFInstruction *inst)
250
264
  CallSite cs(inst);
251
265
  return getCallee(cs);
252
266
  }
267
+
268
+ const SVFFunction* getCallee(const ICFGNode *inst);
253
269
  //@}
254
270
 
255
271
  /// Given a map mapping points-to sets to a count, adds from into to.
@@ -402,27 +418,20 @@ inline bool isArgOfUncalledFunction(const SVFValue* svfval)
402
418
 
403
419
  /// Return thread fork function
404
420
  //@{
405
- inline const SVFValue* getForkedFun(const CallSite cs)
406
- {
407
- return ThreadAPI::getThreadAPI()->getForkedFun(cs.getInstruction());
408
- }
409
421
  inline const SVFValue* getForkedFun(const SVFInstruction *inst)
410
422
  {
411
423
  return ThreadAPI::getThreadAPI()->getForkedFun(inst);
412
424
  }
413
425
  //@}
414
426
 
415
- /// This function servers a allocation wrapper detector
416
- inline bool isAnAllocationWraper(const SVFInstruction*)
417
- {
418
- return false;
419
- }
420
427
 
421
428
  inline bool isExtCall(const CallSite cs)
422
429
  {
423
430
  return isExtCall(getCallee(cs));
424
431
  }
425
432
 
433
+ bool isExtCall(const ICFGNode* node);
434
+
426
435
  inline bool isExtCall(const SVFInstruction *inst)
427
436
  {
428
437
  return isExtCall(getCallee(inst));
@@ -451,10 +460,7 @@ inline bool isHeapAllocExtCallViaRet(const SVFInstruction *inst)
451
460
  return isPtrTy && isHeapAllocExtFunViaRet(getCallee(inst));
452
461
  }
453
462
 
454
- inline bool isHeapAllocExtCall(const CallSite cs)
455
- {
456
- return isHeapAllocExtCallViaRet(cs) || isHeapAllocExtCallViaArg(cs);
457
- }
463
+ bool isHeapAllocExtCall(const ICFGNode* cs);
458
464
 
459
465
  inline bool isHeapAllocExtCall(const SVFInstruction *inst)
460
466
  {
@@ -477,10 +483,6 @@ inline bool isReallocExtCall(const CallSite cs)
477
483
 
478
484
  /// Return true if this is a thread creation call
479
485
  ///@{
480
- inline bool isThreadForkCall(const CallSite cs)
481
- {
482
- return ThreadAPI::getThreadAPI()->isTDFork(cs.getInstruction());
483
- }
484
486
  inline bool isThreadForkCall(const SVFInstruction *inst)
485
487
  {
486
488
  return ThreadAPI::getThreadAPI()->isTDFork(inst);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.2085",
3
+ "version": "1.0.2087",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {