svf-lib 1.0.1892 → 1.0.1893

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
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -27,20 +27,24 @@
27
27
  //
28
28
  // Created by Jiawei Wang on 2024/1/10.
29
29
  //
30
- #include <exception>
31
- #include <string>
32
- #include "AE/Svfexe/SVFIR2ItvExeState.h"
33
- #include "Util/WorkList.h"
34
- #include "MSSA/SVFGBuilder.h"
30
+
31
+ #include "Util/SVFBugReport.h"
35
32
  #include "AE/Core/ICFGWTO.h"
36
33
  #include "WPA/Andersen.h"
37
- #include "Util/SVFBugReport.h"
34
+ #include "AE/Svfexe/SVFIR2ItvExeState.h"
38
35
 
39
36
  namespace SVF
40
37
  {
41
38
  class AbstractExecution;
42
39
  class AEStat;
43
40
  class AEAPI;
41
+ class IntervalValue;
42
+ class ExeState;
43
+
44
+ template<typename T> class FILOWorkList;
45
+
46
+
47
+
44
48
 
45
49
 
46
50
  enum class AEKind
@@ -118,7 +122,7 @@ public:
118
122
 
119
123
  virtual void initExtAPI();
120
124
 
121
- virtual void runOnModule(SVFIR* svfModule);
125
+ virtual void runOnModule(ICFG* icfg);
122
126
 
123
127
  /// Destructor
124
128
  virtual ~AbstractExecution();
@@ -276,13 +280,12 @@ private:
276
280
  Map<const ICFGNode*, IntervalExeState> _postES;
277
281
  std::string _moduleName;
278
282
 
283
+
279
284
  };
280
285
 
281
286
  class AEAPI
282
287
  {
283
288
  public:
284
-
285
- typedef ExeState::Addrs Addrs;
286
289
  enum ExtAPIType { UNCLASSIFIED, MEMCPY, MEMSET, STRCPY, STRCAT };
287
290
  static bool classof(const AEAPI* api)
288
291
  {
@@ -430,5 +433,6 @@ protected:
430
433
 
431
434
  Set<const CallICFGNode*> _checkpoints;
432
435
  Set<std::string> _checkpoint_names;
436
+
433
437
  };
434
438
  }
@@ -0,0 +1,46 @@
1
+ //===- ICFGSimplification.h -- Simplify ICFG----------------------------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-> <Yulei Sui>
6
+ //
7
+
8
+ // This program is free software: you can redistribute it and/or modify
9
+ // it under the terms of the GNU Affero General Public License as published by
10
+ // the Free Software Foundation, either version 3 of the License, or
11
+ // (at your option) any later version.
12
+
13
+ // This program is distributed in the hope that it will be useful,
14
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ // GNU Affero General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU Affero General Public License
19
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ //
21
+ // The implementation is based on
22
+ // Xiao Cheng, Jiawei Wang and Yulei Sui. Precise Sparse Abstract Execution via Cross-Domain Interaction.
23
+ // 46th International Conference on Software Engineering. (ICSE24)
24
+ //===----------------------------------------------------------------------===//
25
+
26
+
27
+ //
28
+ // Created by Jiawei Wang on 2024/2/25.
29
+ //
30
+ #include "Graphs/ICFG.h"
31
+ #include "AE/Svfexe/SVFIR2ItvExeState.h"
32
+
33
+
34
+ namespace SVF
35
+ {
36
+
37
+ class ICFGSimplification
38
+ {
39
+ public:
40
+ ICFGSimplification() = default;
41
+
42
+ virtual ~ICFGSimplification() = default;
43
+
44
+ static void mergeAdjacentNodes(ICFG* icfg);
45
+ };
46
+ }
@@ -49,6 +49,7 @@ class ICFG : public GenericICFGTy
49
49
  friend class ICFGBuilder;
50
50
  friend class SVFIRWriter;
51
51
  friend class SVFIRReader;
52
+ friend class ICFGSimplification;
52
53
 
53
54
  public:
54
55
 
@@ -76,6 +77,9 @@ private:
76
77
  GlobalICFGNode* globalBlockNode; ///< unique basic block for all globals
77
78
  ICFGNodeToSVFLoopVec icfgNodeToSVFLoopVec; ///< map ICFG node to the SVF loops where it resides
78
79
 
80
+ Map<const ICFGNode*, std::vector<const ICFGNode*>> _subNodes; ///<map a node(1st node of basicblock) to its subnodes
81
+ Map<const ICFGNode*, const ICFGNode*> _repNode; ///<map a subnode to its representative node(1st node of basicblock)
82
+
79
83
 
80
84
  public:
81
85
  /// Constructor
@@ -148,27 +152,27 @@ public:
148
152
  }
149
153
 
150
154
  protected:
151
- /// Remove a SVFG edge
155
+ /// Add intraprocedural and interprocedural control-flow edges.
156
+ //@{
157
+ ICFGEdge* addIntraEdge(ICFGNode* srcNode, ICFGNode* dstNode);
158
+ ICFGEdge* addConditionalIntraEdge(ICFGNode* srcNode, ICFGNode* dstNode, const SVFValue* condition, s32_t branchCondVal);
159
+ ICFGEdge* addCallEdge(ICFGNode* srcNode, ICFGNode* dstNode, const SVFInstruction* cs);
160
+ ICFGEdge* addRetEdge(ICFGNode* srcNode, ICFGNode* dstNode, const SVFInstruction* cs);
161
+ //@}
162
+ /// Remove a ICFG edge
152
163
  inline void removeICFGEdge(ICFGEdge* edge)
153
164
  {
154
165
  edge->getDstNode()->removeIncomingEdge(edge);
155
166
  edge->getSrcNode()->removeOutgoingEdge(edge);
156
167
  delete edge;
157
168
  }
169
+
158
170
  /// Remove a ICFGNode
159
171
  inline void removeICFGNode(ICFGNode* node)
160
172
  {
161
173
  removeGNode(node);
162
174
  }
163
175
 
164
- /// Add control-flow edges for top level pointers
165
- //@{
166
- ICFGEdge* addIntraEdge(ICFGNode* srcNode, ICFGNode* dstNode);
167
- ICFGEdge* addConditionalIntraEdge(ICFGNode* srcNode, ICFGNode* dstNode, const SVFValue* condition, s32_t branchCondVal);
168
- ICFGEdge* addCallEdge(ICFGNode* srcNode, ICFGNode* dstNode, const SVFInstruction* cs);
169
- ICFGEdge* addRetEdge(ICFGNode* srcNode, ICFGNode* dstNode, const SVFInstruction* cs);
170
- //@}
171
-
172
176
  /// sanitize Intra edges, verify that both nodes belong to the same function.
173
177
  inline void checkIntraEdgeParents(const ICFGNode *srcNode, const ICFGNode *dstNode)
174
178
  {
@@ -180,20 +184,12 @@ protected:
180
184
  }
181
185
  }
182
186
 
183
- /// Add ICFG edge
184
- inline bool addICFGEdge(ICFGEdge* edge)
185
- {
186
- bool added1 = edge->getDstNode()->addIncomingEdge(edge);
187
- bool added2 = edge->getSrcNode()->addOutgoingEdge(edge);
188
- bool all_added = added1 && added2;
189
- assert(all_added && "ICFGEdge not added?");
190
- return all_added;
191
- }
192
-
193
187
  /// Add a ICFG node
194
188
  virtual inline void addICFGNode(ICFGNode* node)
195
189
  {
196
190
  addGNode(node->getId(),node);
191
+ _repNode[node] = node;
192
+ _subNodes[node].push_back(node);
197
193
  }
198
194
 
199
195
  public:
@@ -221,9 +217,51 @@ public:
221
217
  globalBlockNode = new GlobalICFGNode(totalICFGNode++);
222
218
  addICFGNode(globalBlockNode);
223
219
  }
220
+
221
+ const std::vector<const ICFGNode*>& getSubNodes(const ICFGNode* node) const
222
+ {
223
+ return _subNodes.at(node);
224
+ }
225
+
226
+ const ICFGNode* getRepNode(const ICFGNode* node) const
227
+ {
228
+ return _repNode.at(node);
229
+ }
230
+
231
+
232
+ void updateSubAndRep(const ICFGNode* rep, const ICFGNode* sub)
233
+ {
234
+ addSubNode(rep, sub);
235
+ updateRepNode(rep, sub);
236
+ }
224
237
  //@}
225
238
 
226
239
  private:
240
+ /// when ICFG is simplified, SubNode would merge repNode, then update the map
241
+ void addSubNode(const ICFGNode* rep, const ICFGNode* sub)
242
+ {
243
+ std::vector<const ICFGNode*>& subNodes = _subNodes[sub];
244
+ if(std::find(subNodes.begin(), subNodes.end(), rep) == subNodes.end())
245
+ {
246
+ subNodes.push_back(rep);
247
+ }
248
+ }
249
+
250
+ /// when ICFG is simplified, some node would be removed, this map records the removed node to its rep node
251
+ void updateRepNode(const ICFGNode* rep, const ICFGNode* sub)
252
+ {
253
+ _repNode[rep] = sub;
254
+ }
255
+
256
+ /// Add ICFG edge, only used by addIntraEdge, addCallEdge, addRetEdge etc.
257
+ inline bool addICFGEdge(ICFGEdge* edge)
258
+ {
259
+ bool added1 = edge->getDstNode()->addIncomingEdge(edge);
260
+ bool added2 = edge->getSrcNode()->addOutgoingEdge(edge);
261
+ bool all_added = added1 && added2;
262
+ assert(all_added && "ICFGEdge not added?");
263
+ return all_added;
264
+ }
227
265
 
228
266
  /// Get/Add IntraBlock ICFGNode
229
267
  inline IntraICFGNode* getIntraBlock(const SVFInstruction* inst)
@@ -272,6 +272,8 @@ public:
272
272
  /// if the access index of gepstmt is unknown, skip it, Default: false
273
273
  static const Option<bool> GepUnknownIdx;
274
274
  static const Option<bool> RunUncallFuncs;
275
+
276
+ static const Option<bool> ICFGMergeAdjacentNodes;
275
277
  };
276
278
  } // namespace SVF
277
279
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.1892",
3
+ "version": "1.0.1893",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {