svf-lib 1.0.845 → 1.0.849

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.
@@ -90,12 +90,6 @@ public:
90
90
  {
91
91
  }
92
92
 
93
- /// Initialization from FlattenedFieldInfo
94
- LocationSet(const FlattenedFieldInfo& fi)
95
- : fldIdx(fi.getFlattenFldIdx())
96
- {
97
- }
98
-
99
93
  ~LocationSet() {}
100
94
 
101
95
  /// Overload operators
@@ -553,7 +553,7 @@ private:
553
553
  }
554
554
 
555
555
  /// Add a temp field value node, this method can only invoked by getGepValVar
556
- NodeID addGepValNode(const Value* curInst,const Value* val, const LocationSet& ls, NodeID i, const Type *type, u32_t fieldidx);
556
+ NodeID addGepValNode(const Value* curInst,const Value* val, const LocationSet& ls, NodeID i, const Type *type);
557
557
  /// Add a field obj node, this method can only invoked by getGepObjVar
558
558
  NodeID addGepObjNode(const MemObj* obj, const LocationSet& ls);
559
559
  /// Add a field-insensitive node, this method can only invoked by getFIGepObjNode
@@ -434,7 +434,6 @@ public:
434
434
 
435
435
  inline const LocationSet& getLocationSet() const
436
436
  {
437
- assert(isVariantFieldGep()==false && "Can't retrieve the LocationSet if using a variable field index (pointer arithmetic) for struct field access ");
438
437
  return ls;
439
438
  }
440
439
  inline const LocationSet::OffsetValueVec& getOffsetValueVec() const
@@ -453,6 +452,7 @@ public:
453
452
  /// Field index of the gep statement if it access the field of a struct
454
453
  inline s64_t getConstantFieldIdx() const
455
454
  {
455
+ assert(isVariantFieldGep()==false && "Can't retrieve the LocationSet if using a variable field index (pointer arithmetic) for struct field access ");
456
456
  return getLocationSet().accumulateConstantFieldIdx();
457
457
  }
458
458
  /// Gep statement with a variant field index (pointer arithmetic) for struct field access
@@ -395,7 +395,6 @@ class GepValVar: public ValVar
395
395
  private:
396
396
  LocationSet ls; // LocationSet
397
397
  const Type *gepValType;
398
- u32_t fieldIdx;
399
398
 
400
399
  public:
401
400
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -419,8 +418,8 @@ public:
419
418
  //@}
420
419
 
421
420
  /// Constructor
422
- GepValVar(const Value* val, NodeID i, const LocationSet& l, const Type *ty, u32_t idx) :
423
- ValVar(val, i, GepValNode), ls(l), gepValType(ty), fieldIdx(idx)
421
+ GepValVar(const Value* val, NodeID i, const LocationSet& l, const Type *ty) :
422
+ ValVar(val, i, GepValNode), ls(l), gepValType(ty)
424
423
  {
425
424
  }
426
425
 
@@ -443,11 +442,6 @@ public:
443
442
  return gepValType;
444
443
  }
445
444
 
446
- u32_t getFieldIdx() const
447
- {
448
- return fieldIdx;
449
- }
450
-
451
445
  virtual const std::string toString() const;
452
446
  };
453
447
 
@@ -354,13 +354,9 @@ public:
354
354
 
355
355
  ///Get a reference to the components of struct_info.
356
356
  /// Number of flattenned elements of an array or struct
357
- const u32_t getNumOfFlattenElements(const Type *T);
358
- /// Number of flattenned fields of a struct
359
- const u32_t getNumOfFlattenFields(const StructType *T);
357
+ u32_t getNumOfFlattenElements(const Type *T);
360
358
  /// Flatterned element idx of an array or struct by considering stride
361
- const std::vector<u32_t>& getFlattenedElemIdxVec(const Type *T);
362
- /// Flatterned field index information of a struct ignoring any array field
363
- const std::vector<u32_t>& getFlattenedFieldIdxVec(const StructType *T);
359
+ u32_t getFlattenedElemIdx(const Type *T, s64_t origId);
364
360
 
365
361
  const std::vector<FlattenedFieldInfo>& getFlattenedFieldInfoVec(const Type *T);
366
362
 
@@ -510,7 +510,7 @@ inline const BasicBlock* getFunExitBB(const Function* fun)
510
510
  const Value * stripConstantCasts(const Value *val);
511
511
 
512
512
  /// Strip off the all casts
513
- Value *stripAllCasts(Value *val) ;
513
+ const Value *stripAllCasts(const Value *val) ;
514
514
 
515
515
  /// Get the type of the heap allocation
516
516
  const Type *getTypeOfHeapAlloc(const llvm::Instruction *inst) ;
@@ -109,44 +109,9 @@ public:
109
109
  return pag->getVarargNode(func);
110
110
  }
111
111
  //@}
112
-
113
- /// Handle globals including (global variable and functions)
114
- //@{
115
- void visitGlobal(SVFModule* svfModule);
116
- void InitialGlobal(const GlobalVariable *gvar, Constant *C,
117
- u32_t offset);
118
- NodeID getGlobalVarField(const GlobalVariable *gvar, u32_t offset);
119
- //@}
120
-
121
- /// Process constant expression
122
- void processCE(const Value *val);
123
-
124
- /// Infer field index from byteoffset.
125
- u32_t inferFieldIdxFromByteOffset(const llvm::GEPOperator* gepOp, DataLayout *dl, LocationSet& ls, s64_t idx);
126
-
127
- /// Compute offset of a gep instruction or gep constant expression
128
- bool computeGepOffset(const User *V, LocationSet& ls);
129
-
130
- /// Get the base type and max offset
131
- const Type *getBaseTypeAndFlattenedFields(const Value *V, std::vector<LocationSet> &fields);
132
-
133
- /// Replace fields with flatten fields of T if the number of its fields is larger than msz.
134
- u32_t getFields(std::vector<LocationSet>& fields, const Type* T, u32_t msz);
135
-
136
- /// Handle direct call
137
- void handleDirectCall(CallSite cs, const SVFFunction *F);
138
-
139
- /// Handle indirect call
140
- void handleIndCall(CallSite cs);
141
-
142
112
  /// Update SVFIR given a call graph (creating new CallPE and RetPE for resolved indirect calls)
143
113
  void updateCallGraph(PTACallGraph* callgraph);
144
114
 
145
- /// Handle external call
146
- //@{
147
- virtual void handleExtCall(CallSite cs, const SVFFunction *F);
148
- void addComplexConsForExt(Value *D, Value *S,u32_t sz = 0);
149
- //@}
150
115
 
151
116
  /// Our visit overrides.
152
117
  //@{
@@ -241,6 +206,39 @@ public:
241
206
  }
242
207
  //}@
243
208
 
209
+ protected:
210
+ /// Handle globals including (global variable and functions)
211
+ //@{
212
+ void visitGlobal(SVFModule* svfModule);
213
+ void InitialGlobal(const GlobalVariable *gvar, Constant *C,
214
+ u32_t offset);
215
+ NodeID getGlobalVarField(const GlobalVariable *gvar, u32_t offset);
216
+ //@}
217
+
218
+ /// Process constant expression
219
+ void processCE(const Value *val);
220
+
221
+ /// Infer field index from byteoffset.
222
+ u32_t inferFieldIdxFromByteOffset(const llvm::GEPOperator* gepOp, DataLayout *dl, LocationSet& ls, s64_t idx);
223
+
224
+ /// Compute offset of a gep instruction or gep constant expression
225
+ bool computeGepOffset(const User *V, LocationSet& ls);
226
+
227
+ /// Get the base type and max offset
228
+ const Type *getBaseTypeAndFlattenedFields(const Value *V, std::vector<LocationSet> &fields, const Value* sz);
229
+
230
+ /// Handle direct call
231
+ void handleDirectCall(CallSite cs, const SVFFunction *F);
232
+
233
+ /// Handle indirect call
234
+ void handleIndCall(CallSite cs);
235
+
236
+ /// Handle external call
237
+ //@{
238
+ virtual void handleExtCall(CallSite cs, const SVFFunction *F);
239
+ void addComplexConsForExt(Value *D, Value *S, const Value* sz);
240
+ //@}
241
+
244
242
  /// Set current basic block in order to keep track of control flow information
245
243
  inline void setCurrentLocation(const Value* val, const BasicBlock* bb)
246
244
  {
@@ -278,143 +276,128 @@ public:
278
276
  return nullPtr;
279
277
  }
280
278
 
281
- public:
282
-
283
- NodeID getGepValVar(const Value* val, const LocationSet& ls, const Type *baseType, u32_t fieldidx);
279
+ NodeID getGepValVar(const Value* val, const LocationSet& ls, const Type *baseType);
284
280
 
285
281
  void setCurrentBBAndValueForPAGEdge(PAGEdge* edge);
286
282
 
287
- inline PAGEdge* addBlackHoleAddrEdge(NodeID node)
283
+ inline void addBlackHoleAddrEdge(NodeID node)
288
284
  {
289
- PAGEdge *edge = pag->addBlackHoleAddrStmt(node);
290
- setCurrentBBAndValueForPAGEdge(edge);
291
- return edge;
285
+ if(PAGEdge *edge = pag->addBlackHoleAddrStmt(node))
286
+ setCurrentBBAndValueForPAGEdge(edge);
292
287
  }
293
288
 
294
289
  /// Add Address edge
295
290
  inline AddrStmt* addAddrEdge(NodeID src, NodeID dst)
296
291
  {
297
- AddrStmt *edge = pag->addAddrStmt(src, dst);
298
- setCurrentBBAndValueForPAGEdge(edge);
299
- return edge;
292
+ if(AddrStmt *edge = pag->addAddrStmt(src, dst)){
293
+ setCurrentBBAndValueForPAGEdge(edge);
294
+ return edge;
295
+ }
296
+ return nullptr;
300
297
  }
301
298
  /// Add Copy edge
302
299
  inline CopyStmt* addCopyEdge(NodeID src, NodeID dst)
303
300
  {
304
- CopyStmt *edge = pag->addCopyStmt(src, dst);
305
- setCurrentBBAndValueForPAGEdge(edge);
306
- return edge;
301
+ if(CopyStmt *edge = pag->addCopyStmt(src, dst)){
302
+ setCurrentBBAndValueForPAGEdge(edge);
303
+ return edge;
304
+ }
305
+ return nullptr;
307
306
  }
308
307
  /// Add Copy edge
309
- inline PhiStmt* addPhiStmt(NodeID res, NodeID opnd, const ICFGNode* pred)
308
+ inline void addPhiStmt(NodeID res, NodeID opnd, const ICFGNode* pred)
310
309
  {
311
- PhiStmt *edge = pag->addPhiStmt(res,opnd,pred);
312
310
  /// If we already added this phi node, then skip this adding
313
- if(edge)
311
+ if(PhiStmt *edge = pag->addPhiStmt(res,opnd,pred))
314
312
  setCurrentBBAndValueForPAGEdge(edge);
315
- return edge;
316
313
  }
317
314
  /// Add SelectStmt
318
- inline SelectStmt* addSelectStmt(NodeID res, NodeID op1, NodeID op2, NodeID cond)
315
+ inline void addSelectStmt(NodeID res, NodeID op1, NodeID op2, NodeID cond)
319
316
  {
320
- SelectStmt *edge = pag->addSelectStmt(res,op1,op2,cond);
321
- setCurrentBBAndValueForPAGEdge(edge);
322
- return edge;
317
+ if(SelectStmt *edge = pag->addSelectStmt(res,op1,op2,cond))
318
+ setCurrentBBAndValueForPAGEdge(edge);
323
319
  }
324
320
  /// Add Copy edge
325
- inline CmpStmt* addCmpEdge(NodeID op1, NodeID op2, NodeID dst, u32_t predict)
321
+ inline void addCmpEdge(NodeID op1, NodeID op2, NodeID dst, u32_t predict)
326
322
  {
327
- CmpStmt *edge = pag->addCmpStmt(op1, op2, dst, predict);
328
- setCurrentBBAndValueForPAGEdge(edge);
329
- return edge;
323
+ if(CmpStmt *edge = pag->addCmpStmt(op1, op2, dst, predict))
324
+ setCurrentBBAndValueForPAGEdge(edge);
330
325
  }
331
326
  /// Add Copy edge
332
- inline BinaryOPStmt* addBinaryOPEdge(NodeID op1, NodeID op2, NodeID dst, u32_t opcode)
327
+ inline void addBinaryOPEdge(NodeID op1, NodeID op2, NodeID dst, u32_t opcode)
333
328
  {
334
- BinaryOPStmt *edge = pag->addBinaryOPStmt(op1, op2, dst, opcode);
335
- setCurrentBBAndValueForPAGEdge(edge);
336
- return edge;
329
+ if(BinaryOPStmt *edge = pag->addBinaryOPStmt(op1, op2, dst, opcode))
330
+ setCurrentBBAndValueForPAGEdge(edge);
337
331
  }
338
332
  /// Add Unary edge
339
- inline UnaryOPStmt* addUnaryOPEdge(NodeID src, NodeID dst, u32_t opcode)
333
+ inline void addUnaryOPEdge(NodeID src, NodeID dst, u32_t opcode)
340
334
  {
341
- UnaryOPStmt *edge = pag->addUnaryOPStmt(src, dst, opcode);
342
- setCurrentBBAndValueForPAGEdge(edge);
343
- return edge;
335
+ if(UnaryOPStmt *edge = pag->addUnaryOPStmt(src, dst, opcode))
336
+ setCurrentBBAndValueForPAGEdge(edge);
344
337
  }
345
338
  /// Add Branch statement
346
- inline BranchStmt* addBranchStmt(NodeID br, NodeID cond, const BranchStmt::SuccAndCondPairVec& succs){
347
- BranchStmt *edge = pag->addBranchStmt(br, cond, succs);
348
- setCurrentBBAndValueForPAGEdge(edge);
349
- return edge;
339
+ inline void addBranchStmt(NodeID br, NodeID cond, const BranchStmt::SuccAndCondPairVec& succs){
340
+ if(BranchStmt *edge = pag->addBranchStmt(br, cond, succs))
341
+ setCurrentBBAndValueForPAGEdge(edge);
350
342
  }
351
343
  /// Add Load edge
352
- inline LoadStmt* addLoadEdge(NodeID src, NodeID dst)
344
+ inline void addLoadEdge(NodeID src, NodeID dst)
353
345
  {
354
- LoadStmt *edge = pag->addLoadStmt(src, dst);
355
- setCurrentBBAndValueForPAGEdge(edge);
356
- return edge;
346
+ if(LoadStmt *edge = pag->addLoadStmt(src, dst))
347
+ setCurrentBBAndValueForPAGEdge(edge);
357
348
  }
358
349
  /// Add Store edge
359
- inline StoreStmt* addStoreEdge(NodeID src, NodeID dst)
350
+ inline void addStoreEdge(NodeID src, NodeID dst)
360
351
  {
361
352
  IntraICFGNode* node;
362
353
  if(const Instruction* inst = SVFUtil::dyn_cast<Instruction>(curVal))
363
354
  node = pag->getICFG()->getIntraICFGNode(inst);
364
355
  else
365
356
  node = nullptr;
366
- StoreStmt *edge = pag->addStoreStmt(src, dst, node);
367
- setCurrentBBAndValueForPAGEdge(edge);
368
- return edge;
357
+ if(StoreStmt *edge = pag->addStoreStmt(src, dst, node))
358
+ setCurrentBBAndValueForPAGEdge(edge);
369
359
  }
370
360
  /// Add Call edge
371
- inline CallPE* addCallEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunEntryICFGNode* entry)
361
+ inline void addCallEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunEntryICFGNode* entry)
372
362
  {
373
- CallPE *edge = pag->addCallPE(src, dst, cs, entry);
374
- setCurrentBBAndValueForPAGEdge(edge);
375
- return edge;
363
+ if(CallPE *edge = pag->addCallPE(src, dst, cs, entry))
364
+ setCurrentBBAndValueForPAGEdge(edge);
376
365
  }
377
366
  /// Add Return edge
378
- inline RetPE* addRetEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunExitICFGNode* exit)
367
+ inline void addRetEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunExitICFGNode* exit)
379
368
  {
380
- RetPE *edge = pag->addRetPE(src, dst, cs, exit);
381
- setCurrentBBAndValueForPAGEdge(edge);
382
- return edge;
369
+ if(RetPE *edge = pag->addRetPE(src, dst, cs, exit))
370
+ setCurrentBBAndValueForPAGEdge(edge);
383
371
  }
384
372
  /// Add Gep edge
385
- inline GepStmt* addGepEdge(NodeID src, NodeID dst, const LocationSet& ls, bool constGep)
373
+ inline void addGepEdge(NodeID src, NodeID dst, const LocationSet& ls, bool constGep)
386
374
  {
387
- GepStmt *edge = pag->addGepStmt(src, dst, ls, constGep);
388
- setCurrentBBAndValueForPAGEdge(edge);
389
- return edge;
375
+ if(GepStmt *edge = pag->addGepStmt(src, dst, ls, constGep))
376
+ setCurrentBBAndValueForPAGEdge(edge);
390
377
  }
391
378
  /// Add Offset(Gep) edge
392
- inline GepStmt* addNormalGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
379
+ inline void addNormalGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
393
380
  {
394
- GepStmt *edge = pag->addNormalGepStmt(src, dst, ls);
395
- setCurrentBBAndValueForPAGEdge(edge);
396
- return edge;
381
+ if(GepStmt *edge = pag->addNormalGepStmt(src, dst, ls))
382
+ setCurrentBBAndValueForPAGEdge(edge);
397
383
  }
398
384
  /// Add Variant(Gep) edge
399
- inline GepStmt* addVariantGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
385
+ inline void addVariantGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
400
386
  {
401
- GepStmt *edge = pag->addVariantGepStmt(src, dst, ls);
402
- setCurrentBBAndValueForPAGEdge(edge);
403
- return edge;
387
+ if(GepStmt *edge = pag->addVariantGepStmt(src, dst, ls))
388
+ setCurrentBBAndValueForPAGEdge(edge);
404
389
  }
405
390
  /// Add Thread fork edge for parameter passing
406
- inline TDForkPE* addThreadForkEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunEntryICFGNode* entry)
391
+ inline void addThreadForkEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunEntryICFGNode* entry)
407
392
  {
408
- TDForkPE *edge = pag->addThreadForkPE(src, dst, cs, entry);
409
- setCurrentBBAndValueForPAGEdge(edge);
410
- return edge;
393
+ if(TDForkPE *edge = pag->addThreadForkPE(src, dst, cs, entry))
394
+ setCurrentBBAndValueForPAGEdge(edge);
411
395
  }
412
396
  /// Add Thread join edge for parameter passing
413
- inline TDJoinPE* addThreadJoinEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunExitICFGNode* exit)
397
+ inline void addThreadJoinEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunExitICFGNode* exit)
414
398
  {
415
- TDJoinPE *edge = pag->addThreadJoinPE(src, dst, cs, exit);
416
- setCurrentBBAndValueForPAGEdge(edge);
417
- return edge;
399
+ if(TDJoinPE *edge = pag->addThreadJoinPE(src, dst, cs, exit))
400
+ setCurrentBBAndValueForPAGEdge(edge);
418
401
  }
419
402
  //@}
420
403
 
@@ -69,7 +69,7 @@ public:
69
69
  /// Handle constant expression
70
70
  // @{
71
71
  void handleGlobalCE(const GlobalVariable *G);
72
- void handleGlobalInitializerCE(const Constant *C, u32_t offset);
72
+ void handleGlobalInitializerCE(const Constant *C);
73
73
  void handleCE(const Value *val);
74
74
  // @}
75
75
 
@@ -211,6 +211,7 @@ public:
211
211
  // SymbolTableInfo.cpp
212
212
  static const llvm::cl::opt<bool> LocMemModel;
213
213
  static const llvm::cl::opt<bool> ModelConsts;
214
+ static const llvm::cl::opt<bool> ModelArrays;
214
215
  static const llvm::cl::opt<bool> SymTabPrint;
215
216
 
216
217
  // Conditions.cpp
Binary file
@@ -90,12 +90,6 @@ public:
90
90
  {
91
91
  }
92
92
 
93
- /// Initialization from FlattenedFieldInfo
94
- LocationSet(const FlattenedFieldInfo& fi)
95
- : fldIdx(fi.getFlattenFldIdx())
96
- {
97
- }
98
-
99
93
  ~LocationSet() {}
100
94
 
101
95
  /// Overload operators
@@ -553,7 +553,7 @@ private:
553
553
  }
554
554
 
555
555
  /// Add a temp field value node, this method can only invoked by getGepValVar
556
- NodeID addGepValNode(const Value* curInst,const Value* val, const LocationSet& ls, NodeID i, const Type *type, u32_t fieldidx);
556
+ NodeID addGepValNode(const Value* curInst,const Value* val, const LocationSet& ls, NodeID i, const Type *type);
557
557
  /// Add a field obj node, this method can only invoked by getGepObjVar
558
558
  NodeID addGepObjNode(const MemObj* obj, const LocationSet& ls);
559
559
  /// Add a field-insensitive node, this method can only invoked by getFIGepObjNode
@@ -434,7 +434,6 @@ public:
434
434
 
435
435
  inline const LocationSet& getLocationSet() const
436
436
  {
437
- assert(isVariantFieldGep()==false && "Can't retrieve the LocationSet if using a variable field index (pointer arithmetic) for struct field access ");
438
437
  return ls;
439
438
  }
440
439
  inline const LocationSet::OffsetValueVec& getOffsetValueVec() const
@@ -453,6 +452,7 @@ public:
453
452
  /// Field index of the gep statement if it access the field of a struct
454
453
  inline s64_t getConstantFieldIdx() const
455
454
  {
455
+ assert(isVariantFieldGep()==false && "Can't retrieve the LocationSet if using a variable field index (pointer arithmetic) for struct field access ");
456
456
  return getLocationSet().accumulateConstantFieldIdx();
457
457
  }
458
458
  /// Gep statement with a variant field index (pointer arithmetic) for struct field access
@@ -395,7 +395,6 @@ class GepValVar: public ValVar
395
395
  private:
396
396
  LocationSet ls; // LocationSet
397
397
  const Type *gepValType;
398
- u32_t fieldIdx;
399
398
 
400
399
  public:
401
400
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -419,8 +418,8 @@ public:
419
418
  //@}
420
419
 
421
420
  /// Constructor
422
- GepValVar(const Value* val, NodeID i, const LocationSet& l, const Type *ty, u32_t idx) :
423
- ValVar(val, i, GepValNode), ls(l), gepValType(ty), fieldIdx(idx)
421
+ GepValVar(const Value* val, NodeID i, const LocationSet& l, const Type *ty) :
422
+ ValVar(val, i, GepValNode), ls(l), gepValType(ty)
424
423
  {
425
424
  }
426
425
 
@@ -443,11 +442,6 @@ public:
443
442
  return gepValType;
444
443
  }
445
444
 
446
- u32_t getFieldIdx() const
447
- {
448
- return fieldIdx;
449
- }
450
-
451
445
  virtual const std::string toString() const;
452
446
  };
453
447
 
@@ -354,13 +354,9 @@ public:
354
354
 
355
355
  ///Get a reference to the components of struct_info.
356
356
  /// Number of flattenned elements of an array or struct
357
- const u32_t getNumOfFlattenElements(const Type *T);
358
- /// Number of flattenned fields of a struct
359
- const u32_t getNumOfFlattenFields(const StructType *T);
357
+ u32_t getNumOfFlattenElements(const Type *T);
360
358
  /// Flatterned element idx of an array or struct by considering stride
361
- const std::vector<u32_t>& getFlattenedElemIdxVec(const Type *T);
362
- /// Flatterned field index information of a struct ignoring any array field
363
- const std::vector<u32_t>& getFlattenedFieldIdxVec(const StructType *T);
359
+ u32_t getFlattenedElemIdx(const Type *T, s64_t origId);
364
360
 
365
361
  const std::vector<FlattenedFieldInfo>& getFlattenedFieldInfoVec(const Type *T);
366
362
 
@@ -510,7 +510,7 @@ inline const BasicBlock* getFunExitBB(const Function* fun)
510
510
  const Value * stripConstantCasts(const Value *val);
511
511
 
512
512
  /// Strip off the all casts
513
- Value *stripAllCasts(Value *val) ;
513
+ const Value *stripAllCasts(const Value *val) ;
514
514
 
515
515
  /// Get the type of the heap allocation
516
516
  const Type *getTypeOfHeapAlloc(const llvm::Instruction *inst) ;
@@ -109,44 +109,9 @@ public:
109
109
  return pag->getVarargNode(func);
110
110
  }
111
111
  //@}
112
-
113
- /// Handle globals including (global variable and functions)
114
- //@{
115
- void visitGlobal(SVFModule* svfModule);
116
- void InitialGlobal(const GlobalVariable *gvar, Constant *C,
117
- u32_t offset);
118
- NodeID getGlobalVarField(const GlobalVariable *gvar, u32_t offset);
119
- //@}
120
-
121
- /// Process constant expression
122
- void processCE(const Value *val);
123
-
124
- /// Infer field index from byteoffset.
125
- u32_t inferFieldIdxFromByteOffset(const llvm::GEPOperator* gepOp, DataLayout *dl, LocationSet& ls, s64_t idx);
126
-
127
- /// Compute offset of a gep instruction or gep constant expression
128
- bool computeGepOffset(const User *V, LocationSet& ls);
129
-
130
- /// Get the base type and max offset
131
- const Type *getBaseTypeAndFlattenedFields(const Value *V, std::vector<LocationSet> &fields);
132
-
133
- /// Replace fields with flatten fields of T if the number of its fields is larger than msz.
134
- u32_t getFields(std::vector<LocationSet>& fields, const Type* T, u32_t msz);
135
-
136
- /// Handle direct call
137
- void handleDirectCall(CallSite cs, const SVFFunction *F);
138
-
139
- /// Handle indirect call
140
- void handleIndCall(CallSite cs);
141
-
142
112
  /// Update SVFIR given a call graph (creating new CallPE and RetPE for resolved indirect calls)
143
113
  void updateCallGraph(PTACallGraph* callgraph);
144
114
 
145
- /// Handle external call
146
- //@{
147
- virtual void handleExtCall(CallSite cs, const SVFFunction *F);
148
- void addComplexConsForExt(Value *D, Value *S,u32_t sz = 0);
149
- //@}
150
115
 
151
116
  /// Our visit overrides.
152
117
  //@{
@@ -241,6 +206,39 @@ public:
241
206
  }
242
207
  //}@
243
208
 
209
+ protected:
210
+ /// Handle globals including (global variable and functions)
211
+ //@{
212
+ void visitGlobal(SVFModule* svfModule);
213
+ void InitialGlobal(const GlobalVariable *gvar, Constant *C,
214
+ u32_t offset);
215
+ NodeID getGlobalVarField(const GlobalVariable *gvar, u32_t offset);
216
+ //@}
217
+
218
+ /// Process constant expression
219
+ void processCE(const Value *val);
220
+
221
+ /// Infer field index from byteoffset.
222
+ u32_t inferFieldIdxFromByteOffset(const llvm::GEPOperator* gepOp, DataLayout *dl, LocationSet& ls, s64_t idx);
223
+
224
+ /// Compute offset of a gep instruction or gep constant expression
225
+ bool computeGepOffset(const User *V, LocationSet& ls);
226
+
227
+ /// Get the base type and max offset
228
+ const Type *getBaseTypeAndFlattenedFields(const Value *V, std::vector<LocationSet> &fields, const Value* sz);
229
+
230
+ /// Handle direct call
231
+ void handleDirectCall(CallSite cs, const SVFFunction *F);
232
+
233
+ /// Handle indirect call
234
+ void handleIndCall(CallSite cs);
235
+
236
+ /// Handle external call
237
+ //@{
238
+ virtual void handleExtCall(CallSite cs, const SVFFunction *F);
239
+ void addComplexConsForExt(Value *D, Value *S, const Value* sz);
240
+ //@}
241
+
244
242
  /// Set current basic block in order to keep track of control flow information
245
243
  inline void setCurrentLocation(const Value* val, const BasicBlock* bb)
246
244
  {
@@ -278,143 +276,128 @@ public:
278
276
  return nullPtr;
279
277
  }
280
278
 
281
- public:
282
-
283
- NodeID getGepValVar(const Value* val, const LocationSet& ls, const Type *baseType, u32_t fieldidx);
279
+ NodeID getGepValVar(const Value* val, const LocationSet& ls, const Type *baseType);
284
280
 
285
281
  void setCurrentBBAndValueForPAGEdge(PAGEdge* edge);
286
282
 
287
- inline PAGEdge* addBlackHoleAddrEdge(NodeID node)
283
+ inline void addBlackHoleAddrEdge(NodeID node)
288
284
  {
289
- PAGEdge *edge = pag->addBlackHoleAddrStmt(node);
290
- setCurrentBBAndValueForPAGEdge(edge);
291
- return edge;
285
+ if(PAGEdge *edge = pag->addBlackHoleAddrStmt(node))
286
+ setCurrentBBAndValueForPAGEdge(edge);
292
287
  }
293
288
 
294
289
  /// Add Address edge
295
290
  inline AddrStmt* addAddrEdge(NodeID src, NodeID dst)
296
291
  {
297
- AddrStmt *edge = pag->addAddrStmt(src, dst);
298
- setCurrentBBAndValueForPAGEdge(edge);
299
- return edge;
292
+ if(AddrStmt *edge = pag->addAddrStmt(src, dst)){
293
+ setCurrentBBAndValueForPAGEdge(edge);
294
+ return edge;
295
+ }
296
+ return nullptr;
300
297
  }
301
298
  /// Add Copy edge
302
299
  inline CopyStmt* addCopyEdge(NodeID src, NodeID dst)
303
300
  {
304
- CopyStmt *edge = pag->addCopyStmt(src, dst);
305
- setCurrentBBAndValueForPAGEdge(edge);
306
- return edge;
301
+ if(CopyStmt *edge = pag->addCopyStmt(src, dst)){
302
+ setCurrentBBAndValueForPAGEdge(edge);
303
+ return edge;
304
+ }
305
+ return nullptr;
307
306
  }
308
307
  /// Add Copy edge
309
- inline PhiStmt* addPhiStmt(NodeID res, NodeID opnd, const ICFGNode* pred)
308
+ inline void addPhiStmt(NodeID res, NodeID opnd, const ICFGNode* pred)
310
309
  {
311
- PhiStmt *edge = pag->addPhiStmt(res,opnd,pred);
312
310
  /// If we already added this phi node, then skip this adding
313
- if(edge)
311
+ if(PhiStmt *edge = pag->addPhiStmt(res,opnd,pred))
314
312
  setCurrentBBAndValueForPAGEdge(edge);
315
- return edge;
316
313
  }
317
314
  /// Add SelectStmt
318
- inline SelectStmt* addSelectStmt(NodeID res, NodeID op1, NodeID op2, NodeID cond)
315
+ inline void addSelectStmt(NodeID res, NodeID op1, NodeID op2, NodeID cond)
319
316
  {
320
- SelectStmt *edge = pag->addSelectStmt(res,op1,op2,cond);
321
- setCurrentBBAndValueForPAGEdge(edge);
322
- return edge;
317
+ if(SelectStmt *edge = pag->addSelectStmt(res,op1,op2,cond))
318
+ setCurrentBBAndValueForPAGEdge(edge);
323
319
  }
324
320
  /// Add Copy edge
325
- inline CmpStmt* addCmpEdge(NodeID op1, NodeID op2, NodeID dst, u32_t predict)
321
+ inline void addCmpEdge(NodeID op1, NodeID op2, NodeID dst, u32_t predict)
326
322
  {
327
- CmpStmt *edge = pag->addCmpStmt(op1, op2, dst, predict);
328
- setCurrentBBAndValueForPAGEdge(edge);
329
- return edge;
323
+ if(CmpStmt *edge = pag->addCmpStmt(op1, op2, dst, predict))
324
+ setCurrentBBAndValueForPAGEdge(edge);
330
325
  }
331
326
  /// Add Copy edge
332
- inline BinaryOPStmt* addBinaryOPEdge(NodeID op1, NodeID op2, NodeID dst, u32_t opcode)
327
+ inline void addBinaryOPEdge(NodeID op1, NodeID op2, NodeID dst, u32_t opcode)
333
328
  {
334
- BinaryOPStmt *edge = pag->addBinaryOPStmt(op1, op2, dst, opcode);
335
- setCurrentBBAndValueForPAGEdge(edge);
336
- return edge;
329
+ if(BinaryOPStmt *edge = pag->addBinaryOPStmt(op1, op2, dst, opcode))
330
+ setCurrentBBAndValueForPAGEdge(edge);
337
331
  }
338
332
  /// Add Unary edge
339
- inline UnaryOPStmt* addUnaryOPEdge(NodeID src, NodeID dst, u32_t opcode)
333
+ inline void addUnaryOPEdge(NodeID src, NodeID dst, u32_t opcode)
340
334
  {
341
- UnaryOPStmt *edge = pag->addUnaryOPStmt(src, dst, opcode);
342
- setCurrentBBAndValueForPAGEdge(edge);
343
- return edge;
335
+ if(UnaryOPStmt *edge = pag->addUnaryOPStmt(src, dst, opcode))
336
+ setCurrentBBAndValueForPAGEdge(edge);
344
337
  }
345
338
  /// Add Branch statement
346
- inline BranchStmt* addBranchStmt(NodeID br, NodeID cond, const BranchStmt::SuccAndCondPairVec& succs){
347
- BranchStmt *edge = pag->addBranchStmt(br, cond, succs);
348
- setCurrentBBAndValueForPAGEdge(edge);
349
- return edge;
339
+ inline void addBranchStmt(NodeID br, NodeID cond, const BranchStmt::SuccAndCondPairVec& succs){
340
+ if(BranchStmt *edge = pag->addBranchStmt(br, cond, succs))
341
+ setCurrentBBAndValueForPAGEdge(edge);
350
342
  }
351
343
  /// Add Load edge
352
- inline LoadStmt* addLoadEdge(NodeID src, NodeID dst)
344
+ inline void addLoadEdge(NodeID src, NodeID dst)
353
345
  {
354
- LoadStmt *edge = pag->addLoadStmt(src, dst);
355
- setCurrentBBAndValueForPAGEdge(edge);
356
- return edge;
346
+ if(LoadStmt *edge = pag->addLoadStmt(src, dst))
347
+ setCurrentBBAndValueForPAGEdge(edge);
357
348
  }
358
349
  /// Add Store edge
359
- inline StoreStmt* addStoreEdge(NodeID src, NodeID dst)
350
+ inline void addStoreEdge(NodeID src, NodeID dst)
360
351
  {
361
352
  IntraICFGNode* node;
362
353
  if(const Instruction* inst = SVFUtil::dyn_cast<Instruction>(curVal))
363
354
  node = pag->getICFG()->getIntraICFGNode(inst);
364
355
  else
365
356
  node = nullptr;
366
- StoreStmt *edge = pag->addStoreStmt(src, dst, node);
367
- setCurrentBBAndValueForPAGEdge(edge);
368
- return edge;
357
+ if(StoreStmt *edge = pag->addStoreStmt(src, dst, node))
358
+ setCurrentBBAndValueForPAGEdge(edge);
369
359
  }
370
360
  /// Add Call edge
371
- inline CallPE* addCallEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunEntryICFGNode* entry)
361
+ inline void addCallEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunEntryICFGNode* entry)
372
362
  {
373
- CallPE *edge = pag->addCallPE(src, dst, cs, entry);
374
- setCurrentBBAndValueForPAGEdge(edge);
375
- return edge;
363
+ if(CallPE *edge = pag->addCallPE(src, dst, cs, entry))
364
+ setCurrentBBAndValueForPAGEdge(edge);
376
365
  }
377
366
  /// Add Return edge
378
- inline RetPE* addRetEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunExitICFGNode* exit)
367
+ inline void addRetEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunExitICFGNode* exit)
379
368
  {
380
- RetPE *edge = pag->addRetPE(src, dst, cs, exit);
381
- setCurrentBBAndValueForPAGEdge(edge);
382
- return edge;
369
+ if(RetPE *edge = pag->addRetPE(src, dst, cs, exit))
370
+ setCurrentBBAndValueForPAGEdge(edge);
383
371
  }
384
372
  /// Add Gep edge
385
- inline GepStmt* addGepEdge(NodeID src, NodeID dst, const LocationSet& ls, bool constGep)
373
+ inline void addGepEdge(NodeID src, NodeID dst, const LocationSet& ls, bool constGep)
386
374
  {
387
- GepStmt *edge = pag->addGepStmt(src, dst, ls, constGep);
388
- setCurrentBBAndValueForPAGEdge(edge);
389
- return edge;
375
+ if(GepStmt *edge = pag->addGepStmt(src, dst, ls, constGep))
376
+ setCurrentBBAndValueForPAGEdge(edge);
390
377
  }
391
378
  /// Add Offset(Gep) edge
392
- inline GepStmt* addNormalGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
379
+ inline void addNormalGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
393
380
  {
394
- GepStmt *edge = pag->addNormalGepStmt(src, dst, ls);
395
- setCurrentBBAndValueForPAGEdge(edge);
396
- return edge;
381
+ if(GepStmt *edge = pag->addNormalGepStmt(src, dst, ls))
382
+ setCurrentBBAndValueForPAGEdge(edge);
397
383
  }
398
384
  /// Add Variant(Gep) edge
399
- inline GepStmt* addVariantGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
385
+ inline void addVariantGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
400
386
  {
401
- GepStmt *edge = pag->addVariantGepStmt(src, dst, ls);
402
- setCurrentBBAndValueForPAGEdge(edge);
403
- return edge;
387
+ if(GepStmt *edge = pag->addVariantGepStmt(src, dst, ls))
388
+ setCurrentBBAndValueForPAGEdge(edge);
404
389
  }
405
390
  /// Add Thread fork edge for parameter passing
406
- inline TDForkPE* addThreadForkEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunEntryICFGNode* entry)
391
+ inline void addThreadForkEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunEntryICFGNode* entry)
407
392
  {
408
- TDForkPE *edge = pag->addThreadForkPE(src, dst, cs, entry);
409
- setCurrentBBAndValueForPAGEdge(edge);
410
- return edge;
393
+ if(TDForkPE *edge = pag->addThreadForkPE(src, dst, cs, entry))
394
+ setCurrentBBAndValueForPAGEdge(edge);
411
395
  }
412
396
  /// Add Thread join edge for parameter passing
413
- inline TDJoinPE* addThreadJoinEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunExitICFGNode* exit)
397
+ inline void addThreadJoinEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunExitICFGNode* exit)
414
398
  {
415
- TDJoinPE *edge = pag->addThreadJoinPE(src, dst, cs, exit);
416
- setCurrentBBAndValueForPAGEdge(edge);
417
- return edge;
399
+ if(TDJoinPE *edge = pag->addThreadJoinPE(src, dst, cs, exit))
400
+ setCurrentBBAndValueForPAGEdge(edge);
418
401
  }
419
402
  //@}
420
403
 
@@ -69,7 +69,7 @@ public:
69
69
  /// Handle constant expression
70
70
  // @{
71
71
  void handleGlobalCE(const GlobalVariable *G);
72
- void handleGlobalInitializerCE(const Constant *C, u32_t offset);
72
+ void handleGlobalInitializerCE(const Constant *C);
73
73
  void handleCE(const Value *val);
74
74
  // @}
75
75
 
@@ -211,6 +211,7 @@ public:
211
211
  // SymbolTableInfo.cpp
212
212
  static const llvm::cl::opt<bool> LocMemModel;
213
213
  static const llvm::cl::opt<bool> ModelConsts;
214
+ static const llvm::cl::opt<bool> ModelArrays;
214
215
  static const llvm::cl::opt<bool> SymTabPrint;
215
216
 
216
217
  // Conditions.cpp
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.845",
3
+ "version": "1.0.849",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {