svf-lib 1.0.846 → 1.0.850
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.
- package/SVF-linux/Release-build/lib/libSvf.a +0 -0
- package/SVF-linux/include/MemoryModel/SVFIR.h +5 -37
- package/SVF-linux/include/MemoryModel/SVFVariables.h +4 -21
- package/SVF-linux/include/MemoryModel/SymbolTableInfo.h +8 -24
- package/SVF-linux/include/SVF-FE/SVFIRBuilder.h +34 -35
- package/SVF-linux/include/SVF-FE/SymbolTableBuilder.h +9 -2
- package/SVF-linux/include/Util/Options.h +1 -0
- package/SVF-osx/Release-build/lib/CUDD/libCudd.a +0 -0
- package/SVF-osx/Release-build/lib/libSvf.a +0 -0
- package/SVF-osx/include/MemoryModel/LocationSet.h +0 -6
- package/SVF-osx/include/MemoryModel/SVFIR.h +1 -1
- package/SVF-osx/include/MemoryModel/SVFStatements.h +1 -1
- package/SVF-osx/include/MemoryModel/SVFVariables.h +2 -8
- package/SVF-osx/include/MemoryModel/SymbolTableInfo.h +2 -6
- package/SVF-osx/include/SVF-FE/LLVMUtil.h +1 -1
- package/SVF-osx/include/SVF-FE/SVFIRBuilder.h +91 -108
- package/SVF-osx/include/SVF-FE/SymbolTableBuilder.h +1 -1
- package/SVF-osx/include/Util/Options.h +1 -0
- package/package.json +1 -1
|
Binary file
|
|
@@ -292,20 +292,7 @@ public:
|
|
|
292
292
|
//@}
|
|
293
293
|
|
|
294
294
|
/// Due to constaint expression, curInst is used to distinguish different instructions (e.g., memorycpy) when creating GepValVar.
|
|
295
|
-
|
|
296
|
-
{
|
|
297
|
-
GepValueVarMap::const_iterator iter = GepValObjMap.find(curInst);
|
|
298
|
-
if(iter==GepValObjMap.end()){
|
|
299
|
-
return UINT_MAX;
|
|
300
|
-
}
|
|
301
|
-
else{
|
|
302
|
-
NodeLocationSetMap::const_iterator lit = iter->second.find(std::make_pair(base, ls));
|
|
303
|
-
if(lit==iter->second.end())
|
|
304
|
-
return UINT_MAX;
|
|
305
|
-
else
|
|
306
|
-
return lit->second;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
295
|
+
NodeID getGepValVar(const Value* curInst, NodeID base, const LocationSet& ls) const;
|
|
309
296
|
|
|
310
297
|
/// Add/get indirect callsites
|
|
311
298
|
//@{
|
|
@@ -411,27 +398,8 @@ public:
|
|
|
411
398
|
assert(obj && "not an object node?");
|
|
412
399
|
return SymbolTableInfo::isConstantObj(id) || obj->isConstDataOrConstGlobal();
|
|
413
400
|
}
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
SVFVar* node = getGNode(id);
|
|
417
|
-
if (FIObjVar* fiNode = SVFUtil::dyn_cast<FIObjVar>(node))
|
|
418
|
-
{
|
|
419
|
-
return (fiNode->getMemObj()->hasPtrObj() == false);
|
|
420
|
-
}
|
|
421
|
-
else if (GepObjVar* gepNode = SVFUtil::dyn_cast<GepObjVar>(node))
|
|
422
|
-
{
|
|
423
|
-
return (gepNode->getMemObj()->isNonPtrFieldObj(gepNode->getLocationSet()));
|
|
424
|
-
}
|
|
425
|
-
else if (SVFUtil::isa<DummyObjVar>(node))
|
|
426
|
-
{
|
|
427
|
-
return false;
|
|
428
|
-
}
|
|
429
|
-
else
|
|
430
|
-
{
|
|
431
|
-
assert(false && "expecting a object node");
|
|
432
|
-
return false;
|
|
433
|
-
}
|
|
434
|
-
}
|
|
401
|
+
/// Whether an object can point to any other object or any of its fields is a pointer type.
|
|
402
|
+
bool isNonPointerObj(NodeID id) const;
|
|
435
403
|
//@}
|
|
436
404
|
|
|
437
405
|
/// Base and Offset methods for Value and Object node
|
|
@@ -462,7 +430,7 @@ public:
|
|
|
462
430
|
{
|
|
463
431
|
return addDummyValNode(NodeIDAllocator::get()->allocateValueId());
|
|
464
432
|
}
|
|
465
|
-
inline NodeID addDummyObjNode(const Type* type
|
|
433
|
+
inline NodeID addDummyObjNode(const Type* type)
|
|
466
434
|
{
|
|
467
435
|
return addDummyObjNode(NodeIDAllocator::get()->allocateObjectId(), type);
|
|
468
436
|
}
|
|
@@ -553,7 +521,7 @@ private:
|
|
|
553
521
|
}
|
|
554
522
|
|
|
555
523
|
/// 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
|
|
524
|
+
NodeID addGepValNode(const Value* curInst,const Value* val, const LocationSet& ls, NodeID i, const Type *type);
|
|
557
525
|
/// Add a field obj node, this method can only invoked by getGepObjVar
|
|
558
526
|
NodeID addGepObjNode(const MemObj* obj, const LocationSet& ls);
|
|
559
527
|
/// Add a field-insensitive node, this method can only invoked by getFIGepObjNode
|
|
@@ -81,8 +81,7 @@ protected:
|
|
|
81
81
|
const Value* value; ///< value of this SVFIR node
|
|
82
82
|
SVFStmt::KindToSVFStmtMapTy InEdgeKindToSetMap;
|
|
83
83
|
SVFStmt::KindToSVFStmtMapTy OutEdgeKindToSetMap;
|
|
84
|
-
bool
|
|
85
|
-
bool isATPointer; /// address-taken pointer
|
|
84
|
+
bool isPtr; /// whether it is a pointer (top-level or address-taken)
|
|
86
85
|
|
|
87
86
|
public:
|
|
88
87
|
/// Constructor
|
|
@@ -117,17 +116,7 @@ public:
|
|
|
117
116
|
/// Whether it is a pointer
|
|
118
117
|
virtual inline bool isPointer() const
|
|
119
118
|
{
|
|
120
|
-
return
|
|
121
|
-
}
|
|
122
|
-
/// Whether it is a top-level pointer
|
|
123
|
-
inline bool isTopLevelPtr() const
|
|
124
|
-
{
|
|
125
|
-
return isTLPointer;
|
|
126
|
-
}
|
|
127
|
-
/// Whether it is an address-taken pointer
|
|
128
|
-
inline bool isAddressTakenPtr() const
|
|
129
|
-
{
|
|
130
|
-
return isATPointer;
|
|
119
|
+
return isPtr;
|
|
131
120
|
}
|
|
132
121
|
/// Whether it is constant data, i.e., "0", "1.001", "str"
|
|
133
122
|
/// or llvm's metadata, i.e., metadata !4087
|
|
@@ -395,7 +384,6 @@ class GepValVar: public ValVar
|
|
|
395
384
|
private:
|
|
396
385
|
LocationSet ls; // LocationSet
|
|
397
386
|
const Type *gepValType;
|
|
398
|
-
u32_t fieldIdx;
|
|
399
387
|
|
|
400
388
|
public:
|
|
401
389
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
@@ -419,8 +407,8 @@ public:
|
|
|
419
407
|
//@}
|
|
420
408
|
|
|
421
409
|
/// Constructor
|
|
422
|
-
GepValVar(const Value* val, NodeID i, const LocationSet& l, const Type *ty
|
|
423
|
-
ValVar(val, i, GepValNode), ls(l), gepValType(ty)
|
|
410
|
+
GepValVar(const Value* val, NodeID i, const LocationSet& l, const Type *ty) :
|
|
411
|
+
ValVar(val, i, GepValNode), ls(l), gepValType(ty)
|
|
424
412
|
{
|
|
425
413
|
}
|
|
426
414
|
|
|
@@ -443,11 +431,6 @@ public:
|
|
|
443
431
|
return gepValType;
|
|
444
432
|
}
|
|
445
433
|
|
|
446
|
-
u32_t getFieldIdx() const
|
|
447
|
-
{
|
|
448
|
-
return fieldIdx;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
434
|
virtual const std::string toString() const;
|
|
452
435
|
};
|
|
453
436
|
|
|
@@ -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
|
-
|
|
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
|
-
|
|
362
|
-
/// Flatterned field index information of a struct ignoring any array field
|
|
363
|
-
const std::vector<u32_t>& getFlattenedFieldIdxVec(const Type *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
|
|
|
@@ -393,7 +389,7 @@ protected:
|
|
|
393
389
|
virtual void collectSimpleTypeInfo(const Type* T);
|
|
394
390
|
|
|
395
391
|
/// Create an objectInfo based on LLVM type (value is null, and type could be null, representing a dummy object)
|
|
396
|
-
ObjTypeInfo* createObjTypeInfo(const Type *type
|
|
392
|
+
ObjTypeInfo* createObjTypeInfo(const Type *type);
|
|
397
393
|
|
|
398
394
|
/// Every type T is mapped to StInfo
|
|
399
395
|
/// which contains size (fsize) , offset(foffset)
|
|
@@ -596,7 +592,7 @@ public:
|
|
|
596
592
|
*/
|
|
597
593
|
class ObjTypeInfo
|
|
598
594
|
{
|
|
599
|
-
|
|
595
|
+
friend class SymbolTableBuilder;
|
|
600
596
|
public:
|
|
601
597
|
typedef enum
|
|
602
598
|
{
|
|
@@ -623,30 +619,18 @@ private:
|
|
|
623
619
|
/// maximum number of field object can be created
|
|
624
620
|
/// minimum number is 0 (field insensitive analysis)
|
|
625
621
|
u32_t maxOffsetLimit;
|
|
622
|
+
|
|
623
|
+
void resetTypeForHeapStaticObj(const Type* type);
|
|
626
624
|
public:
|
|
627
625
|
|
|
628
626
|
/// Constructors
|
|
629
|
-
ObjTypeInfo(const
|
|
630
|
-
type(t), flags(0), maxOffsetLimit(max)
|
|
631
|
-
{
|
|
632
|
-
}
|
|
633
|
-
/// Constructor
|
|
634
|
-
ObjTypeInfo(u32_t max, const Type* t) : type(t), flags(0), maxOffsetLimit(max)
|
|
635
|
-
{
|
|
627
|
+
ObjTypeInfo(const Type* t, u32_t max);
|
|
636
628
|
|
|
637
|
-
}
|
|
638
629
|
/// Destructor
|
|
639
630
|
virtual ~ObjTypeInfo()
|
|
640
631
|
{
|
|
641
|
-
|
|
642
632
|
}
|
|
643
|
-
|
|
644
|
-
/// Analyse types of heap and static objects
|
|
645
|
-
void analyzeHeapObjType(const Type* type);
|
|
646
|
-
|
|
647
|
-
/// Analyse types of heap and static objects
|
|
648
|
-
void analyzeStaticObjType(const Type* type);
|
|
649
|
-
|
|
633
|
+
|
|
650
634
|
/// Get LLVM type
|
|
651
635
|
inline const Type* getType() const
|
|
652
636
|
{
|
|
@@ -109,41 +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, const Value* sz);
|
|
132
|
-
|
|
133
|
-
/// Handle direct call
|
|
134
|
-
void handleDirectCall(CallSite cs, const SVFFunction *F);
|
|
135
|
-
|
|
136
|
-
/// Handle indirect call
|
|
137
|
-
void handleIndCall(CallSite cs);
|
|
138
|
-
|
|
139
112
|
/// Update SVFIR given a call graph (creating new CallPE and RetPE for resolved indirect calls)
|
|
140
113
|
void updateCallGraph(PTACallGraph* callgraph);
|
|
141
114
|
|
|
142
|
-
/// Handle external call
|
|
143
|
-
//@{
|
|
144
|
-
virtual void handleExtCall(CallSite cs, const SVFFunction *F);
|
|
145
|
-
void addComplexConsForExt(Value *D, Value *S, const Value* sz);
|
|
146
|
-
//@}
|
|
147
115
|
|
|
148
116
|
/// Our visit overrides.
|
|
149
117
|
//@{
|
|
@@ -238,6 +206,39 @@ public:
|
|
|
238
206
|
}
|
|
239
207
|
//}@
|
|
240
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
|
+
|
|
241
242
|
/// Set current basic block in order to keep track of control flow information
|
|
242
243
|
inline void setCurrentLocation(const Value* val, const BasicBlock* bb)
|
|
243
244
|
{
|
|
@@ -275,9 +276,7 @@ public:
|
|
|
275
276
|
return nullPtr;
|
|
276
277
|
}
|
|
277
278
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
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);
|
|
281
280
|
|
|
282
281
|
void setCurrentBBAndValueForPAGEdge(PAGEdge* edge);
|
|
283
282
|
|
|
@@ -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
|
|
72
|
+
void handleGlobalInitializerCE(const Constant *C);
|
|
73
73
|
void handleCE(const Value *val);
|
|
74
74
|
// @}
|
|
75
75
|
|
|
@@ -79,7 +79,14 @@ public:
|
|
|
79
79
|
/// Initialize TypeInfo based on LLVM Value
|
|
80
80
|
void initTypeInfo(ObjTypeInfo* typeinfo, const Value* value);
|
|
81
81
|
/// Analyse types of all flattened fields of this object
|
|
82
|
-
void
|
|
82
|
+
void analyzeObjType(ObjTypeInfo* typeinfo, const Value* val);
|
|
83
|
+
/// Analyse types of heap and static objects
|
|
84
|
+
void analyzeHeapObjType(ObjTypeInfo* typeinfo, const Value* val);
|
|
85
|
+
/// Analyse types of heap and static objects
|
|
86
|
+
void analyzeStaticObjType(ObjTypeInfo* typeinfo, const Value* val);
|
|
87
|
+
/// Return the bitcast instruction which is val's only use site, otherwise return nullptr
|
|
88
|
+
const Value* getUniqueUseViaCastInst(const Value* val);
|
|
89
|
+
|
|
83
90
|
/// Return size of this object based on LLVM value
|
|
84
91
|
u32_t getObjSize(const Value* val);
|
|
85
92
|
};
|
|
@@ -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
|
|
Binary file
|
|
@@ -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
|
|
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
|
|
423
|
-
ValVar(val, i, GepValNode), ls(l), gepValType(ty)
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
283
|
+
inline void addBlackHoleAddrEdge(NodeID node)
|
|
288
284
|
{
|
|
289
|
-
PAGEdge *edge = pag->addBlackHoleAddrStmt(node)
|
|
290
|
-
|
|
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
|
-
|
|
299
|
-
|
|
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
|
-
|
|
306
|
-
|
|
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
|
|
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
|
|
315
|
+
inline void addSelectStmt(NodeID res, NodeID op1, NodeID op2, NodeID cond)
|
|
319
316
|
{
|
|
320
|
-
SelectStmt *edge = pag->addSelectStmt(res,op1,op2,cond)
|
|
321
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
333
|
+
inline void addUnaryOPEdge(NodeID src, NodeID dst, u32_t opcode)
|
|
340
334
|
{
|
|
341
|
-
UnaryOPStmt *edge = pag->addUnaryOPStmt(src, dst, opcode)
|
|
342
|
-
|
|
343
|
-
return edge;
|
|
335
|
+
if(UnaryOPStmt *edge = pag->addUnaryOPStmt(src, dst, opcode))
|
|
336
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
344
337
|
}
|
|
345
338
|
/// Add Branch statement
|
|
346
|
-
inline
|
|
347
|
-
BranchStmt *edge = pag->addBranchStmt(br, cond, succs)
|
|
348
|
-
|
|
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
|
|
344
|
+
inline void addLoadEdge(NodeID src, NodeID dst)
|
|
353
345
|
{
|
|
354
|
-
LoadStmt *edge = pag->addLoadStmt(src, dst)
|
|
355
|
-
|
|
356
|
-
return edge;
|
|
346
|
+
if(LoadStmt *edge = pag->addLoadStmt(src, dst))
|
|
347
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
357
348
|
}
|
|
358
349
|
/// Add Store edge
|
|
359
|
-
inline
|
|
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
|
-
|
|
368
|
-
return edge;
|
|
357
|
+
if(StoreStmt *edge = pag->addStoreStmt(src, dst, node))
|
|
358
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
369
359
|
}
|
|
370
360
|
/// Add Call edge
|
|
371
|
-
inline
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
379
|
+
inline void addNormalGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
|
|
393
380
|
{
|
|
394
|
-
GepStmt *edge = pag->addNormalGepStmt(src, dst, ls)
|
|
395
|
-
|
|
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
|
|
385
|
+
inline void addVariantGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
|
|
400
386
|
{
|
|
401
|
-
GepStmt *edge = pag->addVariantGepStmt(src, dst, ls)
|
|
402
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|