svf-lib 1.0.840 → 1.0.844

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.
@@ -34,6 +34,8 @@ namespace SVF
34
34
  {
35
35
 
36
36
  class ICFGNode;
37
+ class CallPE;
38
+ class RetPE;
37
39
 
38
40
  /*!
39
41
  * Interprocedural control-flow and value-flow edge, representing the control- and value-flow dependence between two nodes
@@ -157,8 +159,6 @@ private:
157
159
  s64_t branchCondVal;
158
160
  };
159
161
 
160
-
161
-
162
162
  /*!
163
163
  * Call ICFG edge representing parameter passing/return from a caller to a callee
164
164
  */
@@ -167,6 +167,7 @@ class CallCFGEdge : public ICFGEdge
167
167
 
168
168
  private:
169
169
  const Instruction* cs;
170
+ std::vector<const CallPE*> callPEs;
170
171
  public:
171
172
  /// Constructor
172
173
  CallCFGEdge(ICFGNode* s, ICFGNode* d, const Instruction* c):
@@ -178,6 +179,14 @@ public:
178
179
  {
179
180
  return cs;
180
181
  }
182
+ /// Add call parameter edge to this CallCFGEdge
183
+ inline void addCallPE(const CallPE* callPE){
184
+ callPEs.push_back(callPE);
185
+ }
186
+ /// Add get parameter edge to this CallCFGEdge
187
+ inline const std::vector<const CallPE*>& getCallPEs() const{
188
+ return callPEs;
189
+ }
181
190
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
182
191
  //@{
183
192
  static inline bool classof(const CallCFGEdge *)
@@ -204,10 +213,11 @@ class RetCFGEdge : public ICFGEdge
204
213
 
205
214
  private:
206
215
  const Instruction* cs;
216
+ const RetPE* retPE;
207
217
  public:
208
218
  /// Constructor
209
219
  RetCFGEdge(ICFGNode* s, ICFGNode* d, const Instruction* c):
210
- ICFGEdge(s,d,RetCF),cs(c)
220
+ ICFGEdge(s,d,RetCF),cs(c),retPE(nullptr)
211
221
  {
212
222
  }
213
223
  /// Return callsite ID
@@ -215,6 +225,15 @@ public:
215
225
  {
216
226
  return cs;
217
227
  }
228
+ /// Add call parameter edge to this CallCFGEdge
229
+ inline void addRetPE(const RetPE* ret){
230
+ assert(retPE==nullptr && "we can only have one retPE for each RetCFGEdge");
231
+ retPE = ret;
232
+ }
233
+ /// Add get parameter edge to this CallCFGEdge
234
+ inline const RetPE* getRetPE() const{
235
+ return retPE;
236
+ }
218
237
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
219
238
  //@{
220
239
  static inline bool classof(const RetCFGEdge *)
@@ -384,7 +384,7 @@ public:
384
384
  }
385
385
 
386
386
  /// Return callsite
387
- inline const RetICFGNode* getRetBlock() const
387
+ inline const RetICFGNode* getRetICFGNode() const
388
388
  {
389
389
  assert(ret && "RetICFGNode not set?");
390
390
  return ret;
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
  //@}
@@ -34,6 +34,8 @@ namespace SVF
34
34
  {
35
35
 
36
36
  class ICFGNode;
37
+ class CallPE;
38
+ class RetPE;
37
39
 
38
40
  /*!
39
41
  * Interprocedural control-flow and value-flow edge, representing the control- and value-flow dependence between two nodes
@@ -112,15 +114,8 @@ class IntraCFGEdge : public ICFGEdge
112
114
  {
113
115
 
114
116
  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
117
  /// Constructor
123
- IntraCFGEdge(ICFGNode* s, ICFGNode* d): ICFGEdge(s,d,IntraCF)
118
+ IntraCFGEdge(ICFGNode* s, ICFGNode* d): ICFGEdge(s,d,IntraCF), conditionVar(nullptr), branchCondVal(0)
124
119
  {
125
120
  }
126
121
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -139,23 +134,31 @@ public:
139
134
  }
140
135
  //@}
141
136
 
142
- const BranchCondition& getBranchCondtion() const{
143
- return brCondition;
137
+ const Value* getCondition() const{
138
+ return conditionVar;
144
139
  }
145
140
 
146
- void setBranchCondtion(const Value* pNode, NodeID branchID){
147
- brCondition = std::make_pair(pNode,branchID);
141
+ const s64_t getSuccessorCondValue() const{
142
+ assert(getCondition() && "this is not a conditional branch edge");
143
+ return branchCondVal;
144
+ }
145
+
146
+ void setBranchCondition(const Value* c, s64_t bVal){
147
+ conditionVar = c;
148
+ branchCondVal = bVal;
148
149
  }
149
150
 
150
151
  virtual const std::string toString() const;
151
152
 
152
153
  private:
153
- BranchCondition brCondition;
154
-
154
+ /// conditionVar is a boolean (for if/else) or numeric condition variable (for switch)
155
+ /// branchCondVal is the value when this condition should hold to execute this CFGEdge.
156
+ /// e.g., Inst1: br %cmp label 0, label 1, Inst2 is label 0 and Inst 3 is label 1;
157
+ /// for edge between Inst1 and Inst 2, the first element is %cmp and second element is 0
158
+ const Value* conditionVar;
159
+ s64_t branchCondVal;
155
160
  };
156
161
 
157
-
158
-
159
162
  /*!
160
163
  * Call ICFG edge representing parameter passing/return from a caller to a callee
161
164
  */
@@ -164,6 +167,7 @@ class CallCFGEdge : public ICFGEdge
164
167
 
165
168
  private:
166
169
  const Instruction* cs;
170
+ std::vector<const CallPE*> callPEs;
167
171
  public:
168
172
  /// Constructor
169
173
  CallCFGEdge(ICFGNode* s, ICFGNode* d, const Instruction* c):
@@ -175,6 +179,14 @@ public:
175
179
  {
176
180
  return cs;
177
181
  }
182
+ /// Add call parameter edge to this CallCFGEdge
183
+ inline void addCallPE(const CallPE* callPE){
184
+ callPEs.push_back(callPE);
185
+ }
186
+ /// Add get parameter edge to this CallCFGEdge
187
+ inline const std::vector<const CallPE*>& getCallPEs() const{
188
+ return callPEs;
189
+ }
178
190
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
179
191
  //@{
180
192
  static inline bool classof(const CallCFGEdge *)
@@ -201,10 +213,11 @@ class RetCFGEdge : public ICFGEdge
201
213
 
202
214
  private:
203
215
  const Instruction* cs;
216
+ const RetPE* retPE;
204
217
  public:
205
218
  /// Constructor
206
219
  RetCFGEdge(ICFGNode* s, ICFGNode* d, const Instruction* c):
207
- ICFGEdge(s,d,RetCF),cs(c)
220
+ ICFGEdge(s,d,RetCF),cs(c),retPE(nullptr)
208
221
  {
209
222
  }
210
223
  /// Return callsite ID
@@ -212,6 +225,15 @@ public:
212
225
  {
213
226
  return cs;
214
227
  }
228
+ /// Add call parameter edge to this CallCFGEdge
229
+ inline void addRetPE(const RetPE* ret){
230
+ assert(retPE==nullptr && "we can only have one retPE for each RetCFGEdge");
231
+ retPE = ret;
232
+ }
233
+ /// Add get parameter edge to this CallCFGEdge
234
+ inline const RetPE* getRetPE() const{
235
+ return retPE;
236
+ }
215
237
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
216
238
  //@{
217
239
  static inline bool classof(const RetCFGEdge *)
@@ -384,7 +384,7 @@ public:
384
384
  }
385
385
 
386
386
  /// Return callsite
387
- inline const RetICFGNode* getRetBlock() const
387
+ inline const RetICFGNode* getRetICFGNode() const
388
388
  {
389
389
  assert(ret && "RetICFGNode not set?");
390
390
  return ret;
@@ -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.844",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {