svf-lib 1.0.840 → 1.0.841

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.
Binary file
@@ -128,7 +128,7 @@ protected:
128
128
  /// Add control-flow edges for top level pointers
129
129
  //@{
130
130
  ICFGEdge* addIntraEdge(ICFGNode* srcNode, ICFGNode* dstNode);
131
- ICFGEdge* addConditionalIntraEdge(ICFGNode* srcNode, ICFGNode* dstNode, const Value* condition, NodeID branchID);
131
+ ICFGEdge* addConditionalIntraEdge(ICFGNode* srcNode, ICFGNode* dstNode, const Value* condition, s64_t branchCondVal);
132
132
  ICFGEdge* addCallEdge(ICFGNode* srcNode, ICFGNode* dstNode, const Instruction* cs);
133
133
  ICFGEdge* addRetEdge(ICFGNode* srcNode, ICFGNode* dstNode, const Instruction* cs);
134
134
  //@}
@@ -112,15 +112,8 @@ class IntraCFGEdge : public ICFGEdge
112
112
  {
113
113
 
114
114
  public:
115
- /// the first element is a boolean (for if/else) or numeric condition value (for switch)
116
- /// the second element is the value when this condition should hold to execute this CFGEdge.
117
- /// e.g., Inst1: br %cmp label 0, label 1, Inst2 is label 0 and Inst 3 is label 1;
118
- /// for edge between Inst1 and Inst 2, the first element is %cmp and second element is 0
119
-
120
- typedef std::pair<const Value*,NodeID> BranchCondition;
121
-
122
115
  /// Constructor
123
- IntraCFGEdge(ICFGNode* s, ICFGNode* d): ICFGEdge(s,d,IntraCF)
116
+ IntraCFGEdge(ICFGNode* s, ICFGNode* d): ICFGEdge(s,d,IntraCF), conditionVar(nullptr), branchCondVal(0)
124
117
  {
125
118
  }
126
119
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -139,19 +132,29 @@ public:
139
132
  }
140
133
  //@}
141
134
 
142
- const BranchCondition& getBranchCondtion() const{
143
- return brCondition;
135
+ const Value* getCondition() const{
136
+ return conditionVar;
144
137
  }
145
138
 
146
- void setBranchCondtion(const Value* pNode, NodeID branchID){
147
- brCondition = std::make_pair(pNode,branchID);
139
+ const s64_t getSuccessorCondValue() const{
140
+ assert(getCondition() && "this is not a conditional branch edge");
141
+ return branchCondVal;
142
+ }
143
+
144
+ void setBranchCondition(const Value* c, s64_t bVal){
145
+ conditionVar = c;
146
+ branchCondVal = bVal;
148
147
  }
149
148
 
150
149
  virtual const std::string toString() const;
151
150
 
152
151
  private:
153
- BranchCondition brCondition;
154
-
152
+ /// conditionVar is a boolean (for if/else) or numeric condition variable (for switch)
153
+ /// branchCondVal is the value when this condition should hold to execute this CFGEdge.
154
+ /// e.g., Inst1: br %cmp label 0, label 1, Inst2 is label 0 and Inst 3 is label 1;
155
+ /// for edge between Inst1 and Inst 2, the first element is %cmp and second element is 0
156
+ const Value* conditionVar;
157
+ s64_t branchCondVal;
155
158
  };
156
159
 
157
160
 
@@ -639,15 +639,6 @@ public:
639
639
  {
640
640
  return SVFStmt::getDstNode();
641
641
  }
642
- /// Return the position of this op
643
- const u32_t getOpPos(const SVFVar* op) const{
644
- for(u32_t i = 0; i < getOpVarNum(); i++){
645
- if(getOpVar(i)==op)
646
- return i;
647
- }
648
- assert(false && "this operand not found!");
649
- abort();
650
- }
651
642
 
652
643
  NodeID getOpVarID(u32_t pos) const;
653
644
  NodeID getResID() const;
@@ -718,8 +709,8 @@ public:
718
709
  }
719
710
 
720
711
  /// Return the corresponding ICFGNode of this operand
721
- inline const ICFGNode* getOpICFGNode(const SVFVar* op) const{
722
- return opICFGNodes.at(getOpPos(op));
712
+ inline const ICFGNode* getOpICFGNode(u32_t op_idx) const{
713
+ return opICFGNodes.at(op_idx);
723
714
  }
724
715
 
725
716
  /// Return true if this is a phi at the function exit
@@ -309,7 +309,9 @@ public:
309
309
  inline PhiStmt* addPhiStmt(NodeID res, NodeID opnd, const ICFGNode* pred)
310
310
  {
311
311
  PhiStmt *edge = pag->addPhiStmt(res,opnd,pred);
312
- setCurrentBBAndValueForPAGEdge(edge);
312
+ /// If we already added this phi node, then skip this adding
313
+ if(edge)
314
+ setCurrentBBAndValueForPAGEdge(edge);
313
315
  return edge;
314
316
  }
315
317
  /// Add SelectStmt
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.840",
3
+ "version": "1.0.841",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {