svf-tools 1.0.344 → 1.0.348

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 (65) hide show
  1. package/SVF-doxygen/html/html/Andersen_8cpp_source.html +4 -4
  2. package/SVF-doxygen/html/html/FlowSensitive_8cpp_source.html +5 -5
  3. package/SVF-doxygen/html/html/ICFGNode_8h_source.html +3 -3
  4. package/SVF-doxygen/html/html/ICFG_8h_source.html +2 -2
  5. package/SVF-doxygen/html/html/NodeIDAllocator_8cpp_source.html +41 -41
  6. package/SVF-doxygen/html/html/NodeIDAllocator_8h_source.html +47 -46
  7. package/SVF-doxygen/html/html/Options_8cpp_source.html +1 -1
  8. package/SVF-doxygen/html/html/SVFIRBuilder_8cpp_source.html +2 -1
  9. package/SVF-doxygen/html/html/SVFIRBuilder_8h_source.html +73 -71
  10. package/SVF-doxygen/html/html/SVFIR_8cpp_source.html +1 -1
  11. package/SVF-doxygen/html/html/SymbolTableBuilder_8cpp_source.html +2 -2
  12. package/SVF-doxygen/html/html/VersionedFlowSensitive_8cpp_source.html +2 -2
  13. package/SVF-doxygen/html/html/classSVF_1_1Andersen.html +4 -4
  14. package/SVF-doxygen/html/html/classSVF_1_1CallICFGNode-members.html +2 -2
  15. package/SVF-doxygen/html/html/classSVF_1_1CallICFGNode.html +12 -12
  16. package/SVF-doxygen/html/html/classSVF_1_1FlowSensitive.html +5 -5
  17. package/SVF-doxygen/html/html/classSVF_1_1ICFG.html +1 -1
  18. package/SVF-doxygen/html/html/classSVF_1_1NodeIDAllocator-members.html +5 -4
  19. package/SVF-doxygen/html/html/classSVF_1_1NodeIDAllocator.html +43 -39
  20. package/SVF-doxygen/html/html/classSVF_1_1NodeIDAllocator_1_1Clusterer.html +90 -90
  21. package/SVF-doxygen/html/html/classSVF_1_1SVFIR.html +1 -1
  22. package/SVF-doxygen/html/html/classSVF_1_1SVFIRBuilder-members.html +46 -45
  23. package/SVF-doxygen/html/html/classSVF_1_1SVFIRBuilder.html +275 -224
  24. package/SVF-doxygen/html/html/classSVF_1_1SymbolTableBuilder.html +4 -4
  25. package/SVF-doxygen/html/html/classSVF_1_1VersionedFlowSensitive.html +2 -2
  26. package/SVF-doxygen/html/html/functions_eval_r.html +3 -0
  27. package/SVF-doxygen/html/html/functions_func_g.html +5 -5
  28. package/SVF-doxygen/html/html/functions_func_i.html +13 -10
  29. package/SVF-doxygen/html/html/functions_func_s.html +2 -2
  30. package/SVF-doxygen/html/html/functions_g.html +3 -3
  31. package/SVF-doxygen/html/html/functions_i.html +10 -7
  32. package/SVF-doxygen/html/html/functions_l.html +3 -3
  33. package/SVF-doxygen/html/html/functions_m.html +1 -1
  34. package/SVF-doxygen/html/html/functions_o.html +10 -10
  35. package/SVF-doxygen/html/html/functions_p.html +10 -10
  36. package/SVF-doxygen/html/html/functions_r.html +7 -2
  37. package/SVF-doxygen/html/html/functions_s.html +5 -5
  38. package/SVF-doxygen/html/html/functions_t.html +6 -4
  39. package/SVF-doxygen/html/html/functions_w.html +9 -5
  40. package/SVF-doxygen/html/html/search/all_10.js +9 -9
  41. package/SVF-doxygen/html/html/search/all_12.js +1 -0
  42. package/SVF-doxygen/html/html/search/all_13.js +6 -6
  43. package/SVF-doxygen/html/html/search/all_14.js +5 -5
  44. package/SVF-doxygen/html/html/search/all_16.js +1 -1
  45. package/SVF-doxygen/html/html/search/all_17.js +1 -1
  46. package/SVF-doxygen/html/html/search/all_7.js +2 -2
  47. package/SVF-doxygen/html/html/search/all_9.js +1 -0
  48. package/SVF-doxygen/html/html/search/all_c.js +1 -1
  49. package/SVF-doxygen/html/html/search/all_d.js +2 -2
  50. package/SVF-doxygen/html/html/search/all_e.js +2 -2
  51. package/SVF-doxygen/html/html/search/all_f.js +2 -2
  52. package/SVF-doxygen/html/html/search/enumvalues_e.js +2 -1
  53. package/SVF-doxygen/html/html/search/functions_10.js +2 -2
  54. package/SVF-doxygen/html/html/search/functions_6.js +2 -2
  55. package/SVF-doxygen/html/html/search/functions_8.js +1 -0
  56. package/SVF-doxygen/html/html/search/variables_14.js +2 -2
  57. package/SVF-doxygen/html/html/search/variables_e.js +2 -2
  58. package/include/Graphs/ICFG.h +1 -1
  59. package/include/Graphs/ICFGNode.h +2 -2
  60. package/include/SVF-FE/SVFIRBuilder.h +3 -0
  61. package/include/Util/NodeIDAllocator.h +3 -0
  62. package/lib/SVF-FE/SVFIRBuilder.cpp +66 -30
  63. package/lib/Util/NodeIDAllocator.cpp +12 -0
  64. package/lib/Util/Options.cpp +2 -1
  65. package/package.json +1 -1
@@ -209,6 +209,44 @@ void SVFIRBuilder::initialiseNodes()
209
209
 
210
210
  }
211
211
 
212
+ /*
213
+ Handling single value types, for constant index, including pointer, integer, etc
214
+ e.g. field_idx = getelementptr i8, %i8* %p, i64 -4
215
+ We can obtain the field index by inferring the byteoffset if %p is casted from a pointer to a struct
216
+ */
217
+ u32_t SVFIRBuilder::inferFieldIdxFromByteOffset(const llvm::GEPOperator* gepOp, DataLayout *dl, LocationSet& ls, Size_t idx){
218
+ auto srcptr = gepOp->getOperand(0);
219
+ llvm::BitCastOperator* castop1 = SVFUtil::dyn_cast<llvm::BitCastOperator>(srcptr);
220
+ Type* sttype = nullptr;
221
+ if(castop1 && castop1->getSrcTy()->isPointerTy() && castop1->getSrcTy()->getPointerElementType()->isStructTy()){
222
+ sttype = castop1->getSrcTy()->getPointerElementType();
223
+ }
224
+ else
225
+ {
226
+ for(auto user : srcptr->users()){
227
+ if(SVFUtil::isa<llvm::BitCastOperator>(user)){
228
+ llvm::BitCastOperator* castop2 = SVFUtil::dyn_cast<llvm::BitCastOperator>(user);
229
+ if(castop2 && castop2->getDestTy()->isPointerTy() && castop2->getDestTy()->getPointerElementType()->isStructTy()){
230
+ sttype = castop2->getDestTy()->getPointerElementType();
231
+ break;
232
+ }
233
+ }
234
+ }
235
+ }
236
+ if(sttype){
237
+ // Case 1: Access a field of a struct (which is not ANSI-compliant)
238
+ // Case 2: A pointer-arithematic
239
+ // Since this is a field-index based memory model, for both cases, we set field-index to 0, but we set constant offset to byte offset
240
+ // We conside the whole array of object as one element for field-sensitive analysis, but byteoffset can be used for handling pointer arithematic
241
+ // (This handling is unsound since the program itself is not ANSI-compliant)
242
+ const llvm::StructLayout* stdl = dl->getStructLayout(SVFUtil::dyn_cast<StructType>(sttype));
243
+ return stdl->getElementContainingOffset(idx);
244
+ }else{
245
+ // Case 2: This operation is likely accessing an array through pointer p.
246
+ return 0;
247
+ }
248
+ }
249
+
212
250
  /*!
213
251
  * Return the object node offset according to GEP insn (V).
214
252
  * Given a gep edge p = q + i, if "i" is a constant then we return its offset size
@@ -231,53 +269,51 @@ bool SVFIRBuilder::computeGepOffset(const User *V, LocationSet& ls)
231
269
  gi != ge; ++gi)
232
270
  {
233
271
  ls.addOffsetValue(gi.getOperand());
272
+
234
273
  // Handling array types, skipe array handling here
235
- // We treat whole array as one, then we can distinguish different field of an array of struct
274
+ // We treat whole array as one, but we can distinguish different field of an array of struct
236
275
  // e.g. s[1].f1 is differet from s[0].f2
237
276
  if(SVFUtil::isa<ArrayType>(*gi))
238
277
  continue;
239
278
 
240
- //The int-value object of the current index operand
241
- // (may not be constant for arrays).
279
+ //The int value of the current index operand
242
280
  ConstantInt *op = SVFUtil::dyn_cast<ConstantInt>(gi.getOperand());
243
-
244
- /// given a gep edge p = q + i,
245
- if(!op)
246
- {
247
- return false;
248
- }
249
- //The actual index
250
- Size_t idx = op->getSExtValue();
251
-
252
-
253
- // Handling pointer types
254
- // These GEP instructions are simply making address computations from the base pointer address
255
- // e.g. idx = (char*) &p + 4, at this case gep only one offset index (idx)
256
- // Case 1: This operation is likely accessing an array through pointer p.
257
- // Case 2: It may also be used to access a field of a struct (which is not ANSI-compliant)
258
- // Since this is a field-index based memory model,
259
- // for case 1: we consider the whole array as one element, This can be improved by LocMemModel as it can distinguish different
260
- // elements of the same array.
261
- // for case 2: we treat idx the same as &p by ignoring const 4 (This handling is unsound since the program itself is not ANSI-compliant).
262
- if (SVFUtil::isa<PointerType>(*gi))
263
- {
264
- //off += idx;
265
- }
266
-
267
-
281
+
268
282
  // Handling struct here
269
283
  if (const StructType *ST = SVFUtil::dyn_cast<StructType>(*gi) )
270
284
  {
271
- assert(op && "non-const struct index in GEP");
285
+ // If the first operand is a non-constant, it is likely an array access
286
+ // (e.g., %ptr = getelementptr struct_A, %struct_A* %1, i64 %idx)
287
+ if(!op && op == gepOp->getOperand(1)){
288
+ continue;
289
+ }
290
+ assert(op && "non-const index in an operand in GEP");
291
+ //The actual index
292
+ Size_t idx = op->getSExtValue();
272
293
  const vector<u32_t> &so = SymbolTableInfo::SymbolInfo()->getFlattenedFieldIdxVec(ST);
273
294
  if ((unsigned)idx >= so.size())
274
295
  {
275
296
  outs() << "!! Struct index out of bounds" << idx << "\n";
276
297
  assert(0);
277
298
  }
278
- //add the translated offset
299
+ // add the translated offset
279
300
  ls.setFldIdx(ls.accumulateConstantFieldIdx() + so[idx]);
280
301
  }
302
+
303
+ if ((*gi)->isSingleValueType())
304
+ {
305
+ if(!op){
306
+ // Handle non-constant index
307
+ // Given a gep edge p = q + idx, where idx is non-constant
308
+ return false;
309
+ }
310
+ // The actual index
311
+ Size_t idx = op->getSExtValue();
312
+
313
+ // infer the field offset based on the byte offset
314
+ u32_t fieldOffset = inferFieldIdxFromByteOffset(gepOp, dataLayout, ls, idx);
315
+ ls.setFldIdx(fieldOffset);
316
+ }
281
317
  }
282
318
  return true;
283
319
  }
@@ -54,6 +54,10 @@ namespace SVF
54
54
  // We allocate objects from 0(-ish, considering the special nodes) to # of objects.
55
55
  id = numObjects;
56
56
  }
57
+ else if (strategy == Strategy::REVERSE_DENSE)
58
+ {
59
+ id = UINT_MAX - numObjects;
60
+ }
57
61
  else if (strategy == Strategy::SEQ)
58
62
  {
59
63
  // Everything is sequential and intermixed.
@@ -87,6 +91,10 @@ namespace SVF
87
91
  // Nothing different to the other case.
88
92
  id = numObjects;
89
93
  }
94
+ else if (strategy == Strategy::REVERSE_DENSE)
95
+ {
96
+ id = UINT_MAX - numObjects;
97
+ }
90
98
  else if (strategy == Strategy::SEQ)
91
99
  {
92
100
  // Everything is sequential and intermixed.
@@ -128,6 +136,10 @@ namespace SVF
128
136
  // of NodeID (though it is already in use elsewhere).
129
137
  id = UINT_MAX - numValues;
130
138
  }
139
+ else if (strategy == Strategy::REVERSE_DENSE)
140
+ {
141
+ id = numValues;
142
+ }
131
143
  else if (strategy == Strategy::SEQ)
132
144
  {
133
145
  // Everything is sequential and intermixed.
@@ -25,7 +25,8 @@ namespace SVF
25
25
  llvm::cl::init(NodeIDAllocator::Strategy::SEQ),
26
26
  llvm::cl::desc("Method of allocating (LLVM) values and memory objects as node IDs"),
27
27
  llvm::cl::values(
28
- clEnumValN(NodeIDAllocator::Strategy::DENSE, "dense", "allocate objects together and values together, separately"),
28
+ clEnumValN(NodeIDAllocator::Strategy::DENSE, "dense", "allocate objects together [0-n] and values together [m-MAX], separately"),
29
+ clEnumValN(NodeIDAllocator::Strategy::REVERSE_DENSE, "reverse-dense", "like dense but flipped, objects are [m-MAX], values are [0-n]"),
29
30
  clEnumValN(NodeIDAllocator::Strategy::SEQ, "seq", "allocate values and objects sequentially, intermixed (default)"),
30
31
  clEnumValN(NodeIDAllocator::Strategy::DEBUG, "debug", "allocate value and objects sequentially, intermixed, except GEP objects as offsets")));
31
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.344",
3
+ "version": "1.0.348",
4
4
  "description": "* <b>[TypeClone](https://github.com/SVF-tools/SVF/wiki/TypeClone) published in our [ECOOP paper](https://yuleisui.github.io/publications/ecoop20.pdf) is now available in SVF </b> * <b>SVF now uses a single script for its build. Just type [`source ./build.sh`](https://github.com/SVF-tools/SVF/blob/master/build.sh) in your terminal, that's it!</b> * <b>SVF now supports LLVM-10.0.0! </b> * <b>We thank [bsauce](https://github.com/bsauce) for writing a user manual of SVF ([link1](https://www.jianshu.com/p/068a08ec749c) and [link2](https://www.jianshu.com/p/777c30d4240e)) in Chinese </b> * <b>SVF now supports LLVM-9.0.0 (Thank [Byoungyoung Lee](https://github.com/SVF-tools/SVF/issues/142) for his help!). </b> * <b>SVF now supports a set of [field-sensitive pointer analyses](https://yuleisui.github.io/publications/sas2019a.pdf). </b> * <b>[Use SVF as an external lib](https://github.com/SVF-tools/SVF/wiki/Using-SVF-as-a-lib-in-your-own-tool) for your own project (Contributed by [Hongxu Chen](https://github.com/HongxuChen)). </b> * <b>SVF now supports LLVM-7.0.0. </b> * <b>SVF now supports Docker. [Try SVF in Docker](https://github.com/SVF-tools/SVF/wiki/Try-SVF-in-Docker)! </b> * <b>SVF now supports [LLVM-6.0.0](https://github.com/svf-tools/SVF/pull/38) (Contributed by [Jack Anthony](https://github.com/jackanth)). </b> * <b>SVF now supports [LLVM-4.0.0](https://github.com/svf-tools/SVF/pull/23) (Contributed by Jared Carlson. Thank [Jared](https://github.com/jcarlson23) and [Will](https://github.com/dtzWill) for their in-depth [discussions](https://github.com/svf-tools/SVF/pull/18) about updating SVF!) </b> * <b>SVF now supports analysis for C++ programs.</b> <br />",
5
5
  "main": "index.js",
6
6
  "scripts": {