svf-lib 1.0.826 → 1.0.830

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.
@@ -569,7 +569,7 @@ protected:
569
569
  PAGNodeToActualRetMap[ret] = sNode;
570
570
  }
571
571
  /// Add an llvm PHI VFG node
572
- inline void addIntraPHIVFGNode(const PhiStmt* edge)
572
+ inline void addIntraPHIVFGNode(const MultiOpndStmt* edge)
573
573
  {
574
574
  IntraPHIVFGNode* sNode = new IntraPHIVFGNode(totalVFGNode++,edge->getRes());
575
575
  u32_t pos = 0;
@@ -629,7 +629,9 @@ private:
629
629
  /// Add Copy edge
630
630
  CopyStmt* addCopyStmt(NodeID src, NodeID dst);
631
631
  /// Add phi node information
632
- PhiStmt* addPhiStmt(NodeID res, NodeID opnd);
632
+ PhiStmt* addPhiStmt(NodeID res, NodeID opnd, const ICFGNode* pred);
633
+ /// Add SelectStmt
634
+ SelectStmt* addSelectStmt(NodeID res, NodeID op1, NodeID op2, NodeID cond);
633
635
  /// Add Copy edge
634
636
  CmpStmt* addCmpStmt(NodeID op1, NodeID op2, NodeID dst, u32_t predict);
635
637
  /// Add Copy edge
@@ -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, Gep, Phi, Cmp, BinaryOp, UnaryOp, Branch, ThreadFork, ThreadJoin
56
+ Addr, Copy, Store, Load, Call, Ret, Gep, Phi, Select, Cmp, BinaryOp, UnaryOp, Branch, ThreadFork, ThreadJoin
57
57
  };
58
58
 
59
59
  private:
@@ -605,12 +605,14 @@ public:
605
605
  static inline bool classof(const SVFStmt *node)
606
606
  {
607
607
  return node->getEdgeKind() == Phi ||
608
+ node->getEdgeKind() == Select ||
608
609
  node->getEdgeKind() == BinaryOp ||
609
610
  node->getEdgeKind() == Cmp;
610
611
  }
611
612
  static inline bool classof(const GenericPAGEdgeTy *node)
612
613
  {
613
614
  return node->getEdgeKind() == Phi ||
615
+ node->getEdgeKind() == Select ||
614
616
  node->getEdgeKind() == BinaryOp ||
615
617
  node->getEdgeKind() == Cmp;
616
618
  }
@@ -627,7 +629,16 @@ public:
627
629
  {
628
630
  return SVFStmt::getDstNode();
629
631
  }
630
-
632
+ /// Return the position of this op
633
+ const u32_t getOpPos(const SVFVar* op) const{
634
+ for(u32_t i = 0; i < getOpVarNum(); i++){
635
+ if(getOpVar(i)==op)
636
+ return i;
637
+ }
638
+ assert(false && "this operand not found!");
639
+ abort();
640
+ }
641
+
631
642
  NodeID getOpVarID(u32_t pos) const;
632
643
  NodeID getResID() const;
633
644
 
@@ -655,11 +666,15 @@ public:
655
666
  */
656
667
  class PhiStmt: public MultiOpndStmt
657
668
  {
669
+ public:
670
+ typedef std::vector<const ICFGNode* > OpICFGNodeVec;
671
+
658
672
  private:
659
673
  PhiStmt(); ///< place holder
660
674
  PhiStmt(const PhiStmt &); ///< place holder
661
675
  void operator=(const PhiStmt &); ///< place holder
662
676
 
677
+ OpICFGNodeVec opICFGNodes;
663
678
  public:
664
679
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
665
680
  //@{
@@ -682,11 +697,19 @@ public:
682
697
  //@}
683
698
 
684
699
  /// constructor
685
- PhiStmt(SVFVar* s, const OPVars& opnds) : MultiOpndStmt(s,opnds,SVFStmt::Phi)
700
+ PhiStmt(SVFVar* s, const OPVars& opnds, const OpICFGNodeVec& icfgNodes) : MultiOpndStmt(s,opnds,SVFStmt::Phi), opICFGNodes(icfgNodes)
686
701
  {
702
+ assert(opnds.size()==icfgNodes.size() && "Numbers of operands and their ICFGNodes are not consistent?");
687
703
  }
688
- void addOpVar(SVFVar* op){
704
+ void addOpVar(SVFVar* op, const ICFGNode* inode){
689
705
  opVars.push_back(op);
706
+ opICFGNodes.push_back(inode);
707
+ assert(opVars.size()==opICFGNodes.size() && "Numbers of operands and their ICFGNodes are not consistent?");
708
+ }
709
+
710
+ /// Return the corresponding ICFGNode of this operand
711
+ inline const ICFGNode* getOpICFGNode(const SVFVar* op) const{
712
+ return opICFGNodes.at(getOpPos(op));
690
713
  }
691
714
 
692
715
  /// Return true if this is a phi at the function exit
@@ -696,6 +719,55 @@ public:
696
719
  virtual const std::string toString() const override;
697
720
  };
698
721
 
722
+ /*!
723
+ * Select statement (e.g., p ? q: r which receives values from variables q and r based on condition p)
724
+ */
725
+ class SelectStmt: public MultiOpndStmt
726
+ {
727
+ private:
728
+ SelectStmt(); ///< place holder
729
+ SelectStmt(const SelectStmt &); ///< place holder
730
+ void operator=(const SelectStmt &); ///< place holder
731
+
732
+ const SVFVar* condition;
733
+ public:
734
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
735
+ //@{
736
+ static inline bool classof(const SelectStmt *)
737
+ {
738
+ return true;
739
+ }
740
+ static inline bool classof(const SVFStmt *edge)
741
+ {
742
+ return edge->getEdgeKind() == SVFStmt::Select;
743
+ }
744
+ static inline bool classof(const MultiOpndStmt *edge)
745
+ {
746
+ return edge->getEdgeKind() == SVFStmt::Select;
747
+ }
748
+ static inline bool classof(const GenericPAGEdgeTy *edge)
749
+ {
750
+ return edge->getEdgeKind() == SVFStmt::Select;
751
+ }
752
+ //@}
753
+
754
+ /// constructor
755
+ SelectStmt(SVFVar* s, const OPVars& opnds, const SVFVar* cond) : MultiOpndStmt(s,opnds,SVFStmt::Select), condition(cond)
756
+ {
757
+ assert(opnds.size()==2 && "SelectStmt can only have two operands!");
758
+ }
759
+ virtual const std::string toString() const override;
760
+
761
+ inline const SVFVar* getCondition() const{
762
+ return condition;
763
+ }
764
+ inline const SVFVar* getTrueValue() const{
765
+ return getOpVar(0);
766
+ }
767
+ inline const SVFVar* getFalseValue() const{
768
+ return getOpVar(1);
769
+ }
770
+ };
699
771
 
700
772
  /*!
701
773
  * Comparison statement
@@ -306,9 +306,16 @@ public:
306
306
  return edge;
307
307
  }
308
308
  /// Add Copy edge
309
- inline PhiStmt* addPhiStmt(NodeID res, NodeID opnd)
309
+ inline PhiStmt* addPhiStmt(NodeID res, NodeID opnd, const ICFGNode* pred)
310
310
  {
311
- PhiStmt *edge = pag->addPhiStmt(res,opnd);
311
+ PhiStmt *edge = pag->addPhiStmt(res,opnd,pred);
312
+ setCurrentBBAndValueForPAGEdge(edge);
313
+ return edge;
314
+ }
315
+ /// Add SelectStmt
316
+ inline SelectStmt* addSelectStmt(NodeID res, NodeID op1, NodeID op2, NodeID cond)
317
+ {
318
+ SelectStmt *edge = pag->addSelectStmt(res,op1,op2,cond);
312
319
  setCurrentBBAndValueForPAGEdge(edge);
313
320
  return edge;
314
321
  }
Binary file
@@ -569,7 +569,7 @@ protected:
569
569
  PAGNodeToActualRetMap[ret] = sNode;
570
570
  }
571
571
  /// Add an llvm PHI VFG node
572
- inline void addIntraPHIVFGNode(const PhiStmt* edge)
572
+ inline void addIntraPHIVFGNode(const MultiOpndStmt* edge)
573
573
  {
574
574
  IntraPHIVFGNode* sNode = new IntraPHIVFGNode(totalVFGNode++,edge->getRes());
575
575
  u32_t pos = 0;
@@ -629,7 +629,9 @@ private:
629
629
  /// Add Copy edge
630
630
  CopyStmt* addCopyStmt(NodeID src, NodeID dst);
631
631
  /// Add phi node information
632
- PhiStmt* addPhiStmt(NodeID res, NodeID opnd);
632
+ PhiStmt* addPhiStmt(NodeID res, NodeID opnd, const ICFGNode* pred);
633
+ /// Add SelectStmt
634
+ SelectStmt* addSelectStmt(NodeID res, NodeID op1, NodeID op2, NodeID cond);
633
635
  /// Add Copy edge
634
636
  CmpStmt* addCmpStmt(NodeID op1, NodeID op2, NodeID dst, u32_t predict);
635
637
  /// Add Copy edge
@@ -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, Gep, Phi, Cmp, BinaryOp, UnaryOp, Branch, ThreadFork, ThreadJoin
56
+ Addr, Copy, Store, Load, Call, Ret, Gep, Phi, Select, Cmp, BinaryOp, UnaryOp, Branch, ThreadFork, ThreadJoin
57
57
  };
58
58
 
59
59
  private:
@@ -605,12 +605,14 @@ public:
605
605
  static inline bool classof(const SVFStmt *node)
606
606
  {
607
607
  return node->getEdgeKind() == Phi ||
608
+ node->getEdgeKind() == Select ||
608
609
  node->getEdgeKind() == BinaryOp ||
609
610
  node->getEdgeKind() == Cmp;
610
611
  }
611
612
  static inline bool classof(const GenericPAGEdgeTy *node)
612
613
  {
613
614
  return node->getEdgeKind() == Phi ||
615
+ node->getEdgeKind() == Select ||
614
616
  node->getEdgeKind() == BinaryOp ||
615
617
  node->getEdgeKind() == Cmp;
616
618
  }
@@ -627,7 +629,16 @@ public:
627
629
  {
628
630
  return SVFStmt::getDstNode();
629
631
  }
630
-
632
+ /// Return the position of this op
633
+ const u32_t getOpPos(const SVFVar* op) const{
634
+ for(u32_t i = 0; i < getOpVarNum(); i++){
635
+ if(getOpVar(i)==op)
636
+ return i;
637
+ }
638
+ assert(false && "this operand not found!");
639
+ abort();
640
+ }
641
+
631
642
  NodeID getOpVarID(u32_t pos) const;
632
643
  NodeID getResID() const;
633
644
 
@@ -655,11 +666,15 @@ public:
655
666
  */
656
667
  class PhiStmt: public MultiOpndStmt
657
668
  {
669
+ public:
670
+ typedef std::vector<const ICFGNode* > OpICFGNodeVec;
671
+
658
672
  private:
659
673
  PhiStmt(); ///< place holder
660
674
  PhiStmt(const PhiStmt &); ///< place holder
661
675
  void operator=(const PhiStmt &); ///< place holder
662
676
 
677
+ OpICFGNodeVec opICFGNodes;
663
678
  public:
664
679
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
665
680
  //@{
@@ -682,11 +697,19 @@ public:
682
697
  //@}
683
698
 
684
699
  /// constructor
685
- PhiStmt(SVFVar* s, const OPVars& opnds) : MultiOpndStmt(s,opnds,SVFStmt::Phi)
700
+ PhiStmt(SVFVar* s, const OPVars& opnds, const OpICFGNodeVec& icfgNodes) : MultiOpndStmt(s,opnds,SVFStmt::Phi), opICFGNodes(icfgNodes)
686
701
  {
702
+ assert(opnds.size()==icfgNodes.size() && "Numbers of operands and their ICFGNodes are not consistent?");
687
703
  }
688
- void addOpVar(SVFVar* op){
704
+ void addOpVar(SVFVar* op, const ICFGNode* inode){
689
705
  opVars.push_back(op);
706
+ opICFGNodes.push_back(inode);
707
+ assert(opVars.size()==opICFGNodes.size() && "Numbers of operands and their ICFGNodes are not consistent?");
708
+ }
709
+
710
+ /// Return the corresponding ICFGNode of this operand
711
+ inline const ICFGNode* getOpICFGNode(const SVFVar* op) const{
712
+ return opICFGNodes.at(getOpPos(op));
690
713
  }
691
714
 
692
715
  /// Return true if this is a phi at the function exit
@@ -696,6 +719,55 @@ public:
696
719
  virtual const std::string toString() const override;
697
720
  };
698
721
 
722
+ /*!
723
+ * Select statement (e.g., p ? q: r which receives values from variables q and r based on condition p)
724
+ */
725
+ class SelectStmt: public MultiOpndStmt
726
+ {
727
+ private:
728
+ SelectStmt(); ///< place holder
729
+ SelectStmt(const SelectStmt &); ///< place holder
730
+ void operator=(const SelectStmt &); ///< place holder
731
+
732
+ const SVFVar* condition;
733
+ public:
734
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
735
+ //@{
736
+ static inline bool classof(const SelectStmt *)
737
+ {
738
+ return true;
739
+ }
740
+ static inline bool classof(const SVFStmt *edge)
741
+ {
742
+ return edge->getEdgeKind() == SVFStmt::Select;
743
+ }
744
+ static inline bool classof(const MultiOpndStmt *edge)
745
+ {
746
+ return edge->getEdgeKind() == SVFStmt::Select;
747
+ }
748
+ static inline bool classof(const GenericPAGEdgeTy *edge)
749
+ {
750
+ return edge->getEdgeKind() == SVFStmt::Select;
751
+ }
752
+ //@}
753
+
754
+ /// constructor
755
+ SelectStmt(SVFVar* s, const OPVars& opnds, const SVFVar* cond) : MultiOpndStmt(s,opnds,SVFStmt::Select), condition(cond)
756
+ {
757
+ assert(opnds.size()==2 && "SelectStmt can only have two operands!");
758
+ }
759
+ virtual const std::string toString() const override;
760
+
761
+ inline const SVFVar* getCondition() const{
762
+ return condition;
763
+ }
764
+ inline const SVFVar* getTrueValue() const{
765
+ return getOpVar(0);
766
+ }
767
+ inline const SVFVar* getFalseValue() const{
768
+ return getOpVar(1);
769
+ }
770
+ };
699
771
 
700
772
  /*!
701
773
  * Comparison statement
@@ -139,6 +139,9 @@ public:
139
139
  /// Handle indirect call
140
140
  void handleIndCall(CallSite cs);
141
141
 
142
+ /// Update SVFIR given a call graph (creating new CallPE and RetPE for resolved indirect calls)
143
+ void updateCallGraph(PTACallGraph* callgraph);
144
+
142
145
  /// Handle external call
143
146
  //@{
144
147
  virtual void handleExtCall(CallSite cs, const SVFFunction *F);
@@ -303,9 +306,16 @@ public:
303
306
  return edge;
304
307
  }
305
308
  /// Add Copy edge
306
- inline PhiStmt* addPhiStmt(NodeID res, NodeID opnd)
309
+ inline PhiStmt* addPhiStmt(NodeID res, NodeID opnd, const ICFGNode* pred)
310
+ {
311
+ PhiStmt *edge = pag->addPhiStmt(res,opnd,pred);
312
+ setCurrentBBAndValueForPAGEdge(edge);
313
+ return edge;
314
+ }
315
+ /// Add SelectStmt
316
+ inline SelectStmt* addSelectStmt(NodeID res, NodeID op1, NodeID op2, NodeID cond)
307
317
  {
308
- PhiStmt *edge = pag->addPhiStmt(res,opnd);
318
+ SelectStmt *edge = pag->addSelectStmt(res,op1,op2,cond);
309
319
  setCurrentBBAndValueForPAGEdge(edge);
310
320
  return edge;
311
321
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.826",
3
+ "version": "1.0.830",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {