svf-lib 1.0.2245 → 1.0.2247
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-aarch64/Release-build/bin/ae +0 -0
- package/SVF-linux-aarch64/Release-build/bin/cfl +0 -0
- package/SVF-linux-aarch64/Release-build/bin/dvf +0 -0
- package/SVF-linux-aarch64/Release-build/bin/mta +0 -0
- package/SVF-linux-aarch64/Release-build/bin/saber +0 -0
- package/SVF-linux-aarch64/Release-build/bin/svf-ex +0 -0
- package/SVF-linux-aarch64/Release-build/bin/wpa +0 -0
- package/SVF-linux-aarch64/Release-build/include/Graphs/CHG.h +0 -1
- package/SVF-linux-aarch64/Release-build/include/Graphs/CallGraph.h +0 -1
- package/SVF-linux-aarch64/Release-build/include/Graphs/ThreadCallGraph.h +0 -1
- package/SVF-linux-aarch64/Release-build/include/MTA/MTA.h +0 -1
- package/SVF-linux-aarch64/Release-build/include/MemoryModel/PointerAnalysis.h +0 -1
- package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/BreakConstantExpr.h +0 -1
- package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/CppUtil.h +1 -1
- package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/DCHG.h +3 -7
- package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/LLVMModule.h +67 -139
- package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/LLVMUtil.h +4 -9
- package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/ObjTypeInference.h +0 -1
- package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/SVFIRBuilder.h +21 -18
- package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/SymbolTableBuilder.h +1 -1
- package/SVF-linux-aarch64/Release-build/include/SVFIR/SVFVariables.h +11 -3
- package/SVF-linux-aarch64/Release-build/include/Util/CallGraphBuilder.h +0 -1
- package/SVF-linux-aarch64/Release-build/include/Util/ThreadAPI.h +0 -1
- package/SVF-linux-aarch64/Release-build/include/WPA/Andersen.h +0 -1
- package/SVF-linux-aarch64/Release-build/include/WPA/FlowSensitive.h +0 -1
- package/SVF-linux-aarch64/Release-build/include/WPA/VersionedFlowSensitive.h +0 -1
- package/SVF-linux-aarch64/Release-build/include/WPA/WPAPass.h +0 -1
- package/SVF-linux-aarch64/Release-build/lib/libSvfCore.so +0 -0
- package/SVF-linux-aarch64/Release-build/lib/libSvfLLVM.so.16 +0 -0
- package/SVF-linux-x86_64/Release-build/bin/ae +0 -0
- package/SVF-linux-x86_64/Release-build/bin/cfl +0 -0
- package/SVF-linux-x86_64/Release-build/bin/dvf +0 -0
- package/SVF-linux-x86_64/Release-build/bin/mta +0 -0
- package/SVF-linux-x86_64/Release-build/bin/saber +0 -0
- package/SVF-linux-x86_64/Release-build/bin/svf-ex +0 -0
- package/SVF-linux-x86_64/Release-build/bin/wpa +0 -0
- package/SVF-linux-x86_64/Release-build/include/Graphs/CHG.h +0 -1
- package/SVF-linux-x86_64/Release-build/include/Graphs/CallGraph.h +0 -1
- package/SVF-linux-x86_64/Release-build/include/Graphs/ThreadCallGraph.h +0 -1
- package/SVF-linux-x86_64/Release-build/include/MTA/MTA.h +0 -1
- package/SVF-linux-x86_64/Release-build/include/MemoryModel/PointerAnalysis.h +0 -1
- package/SVF-linux-x86_64/Release-build/include/SVF-LLVM/BreakConstantExpr.h +0 -1
- package/SVF-linux-x86_64/Release-build/include/SVF-LLVM/CppUtil.h +1 -1
- package/SVF-linux-x86_64/Release-build/include/SVF-LLVM/DCHG.h +3 -7
- package/SVF-linux-x86_64/Release-build/include/SVF-LLVM/LLVMModule.h +67 -139
- package/SVF-linux-x86_64/Release-build/include/SVF-LLVM/LLVMUtil.h +4 -9
- package/SVF-linux-x86_64/Release-build/include/SVF-LLVM/ObjTypeInference.h +0 -1
- package/SVF-linux-x86_64/Release-build/include/SVF-LLVM/SVFIRBuilder.h +21 -18
- package/SVF-linux-x86_64/Release-build/include/SVF-LLVM/SymbolTableBuilder.h +1 -1
- package/SVF-linux-x86_64/Release-build/include/SVFIR/SVFVariables.h +11 -3
- package/SVF-linux-x86_64/Release-build/include/Util/CallGraphBuilder.h +0 -1
- package/SVF-linux-x86_64/Release-build/include/Util/ThreadAPI.h +0 -1
- package/SVF-linux-x86_64/Release-build/include/WPA/Andersen.h +0 -1
- package/SVF-linux-x86_64/Release-build/include/WPA/FlowSensitive.h +0 -1
- package/SVF-linux-x86_64/Release-build/include/WPA/VersionedFlowSensitive.h +0 -1
- package/SVF-linux-x86_64/Release-build/include/WPA/WPAPass.h +0 -1
- package/SVF-linux-x86_64/Release-build/lib/libSvfCore.so +0 -0
- package/SVF-linux-x86_64/Release-build/lib/libSvfLLVM.so.16 +0 -0
- package/package.json +1 -1
- package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/SVFLLVMValue.h +0 -387
- package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/SVFModule.h +0 -186
- package/SVF-linux-x86_64/Release-build/include/SVF-LLVM/SVFLLVMValue.h +0 -387
- package/SVF-linux-x86_64/Release-build/include/SVF-LLVM/SVFModule.h +0 -186
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -17,14 +17,12 @@
|
|
|
17
17
|
#include "Graphs/GenericGraph.h"
|
|
18
18
|
#include "Graphs/CHG.h"
|
|
19
19
|
#include "SVF-LLVM/BasicTypes.h"
|
|
20
|
-
#include "SVF-LLVM/SVFModule.h"
|
|
21
20
|
#include "Util/SVFUtil.h"
|
|
22
21
|
#include "Util/WorkList.h"
|
|
23
22
|
|
|
24
23
|
namespace SVF
|
|
25
24
|
{
|
|
26
25
|
|
|
27
|
-
class SVFModule;
|
|
28
26
|
class DCHNode;
|
|
29
27
|
|
|
30
28
|
class DCHEdge : public GenericEdge<DCHNode>
|
|
@@ -230,8 +228,8 @@ public:
|
|
|
230
228
|
static bool isAgg(const DIType* t);
|
|
231
229
|
|
|
232
230
|
public:
|
|
233
|
-
DCHGraph(
|
|
234
|
-
:
|
|
231
|
+
DCHGraph()
|
|
232
|
+
:numTypes(0) // vfID(0), buildingCHGTime(0) {
|
|
235
233
|
{
|
|
236
234
|
this->kind = DI;
|
|
237
235
|
}
|
|
@@ -358,8 +356,6 @@ public:
|
|
|
358
356
|
bool isFirstField(const DIType* f, const DIType* b);
|
|
359
357
|
|
|
360
358
|
protected:
|
|
361
|
-
/// SVF Module this CHG is built from.
|
|
362
|
-
const SVFModule* svfModule;
|
|
363
359
|
/// Whether this CHG is an extended CHG (first-field). Set by buildCHG.
|
|
364
360
|
bool extended = false;
|
|
365
361
|
/// Maps DITypes to their nodes.
|
|
@@ -394,7 +390,7 @@ private:
|
|
|
394
390
|
void handleDISubroutineType(const DISubroutineType* subroutineType);
|
|
395
391
|
|
|
396
392
|
/// Finds all defined virtual functions and attaches them to nodes.
|
|
397
|
-
void buildVTables(
|
|
393
|
+
void buildVTables();
|
|
398
394
|
|
|
399
395
|
/// Returns a set of all children of type (CHA). Also gradually builds chaMap.
|
|
400
396
|
const NodeBS& cha(const DIType* type, bool firstField);
|
|
@@ -31,8 +31,6 @@
|
|
|
31
31
|
#define INCLUDE_SVF_FE_LLVMMODULE_H_
|
|
32
32
|
|
|
33
33
|
#include "SVF-LLVM/BasicTypes.h"
|
|
34
|
-
#include "SVF-LLVM/SVFLLVMValue.h"
|
|
35
|
-
#include "SVF-LLVM/SVFModule.h"
|
|
36
34
|
#include "Util/Options.h"
|
|
37
35
|
#include "Graphs/BasicBlockG.h"
|
|
38
36
|
|
|
@@ -54,14 +52,8 @@ public:
|
|
|
54
52
|
typedef Map<const Function*, FunctionSetType> FunDefToDeclsMapTy;
|
|
55
53
|
typedef Map<const GlobalVariable*, GlobalVariable*> GlobalDefToRepMapTy;
|
|
56
54
|
|
|
57
|
-
typedef Map<const Function*, SVFFunction*> LLVMFun2SVFFunMap;
|
|
58
55
|
typedef Map<const Function*, FunObjVar*> LLVMFun2FunObjVarMap;
|
|
59
56
|
typedef Map<const BasicBlock*, SVFBasicBlock*> LLVMBB2SVFBBMap;
|
|
60
|
-
typedef Map<const Instruction*, SVFLLVMValue*> LLVMInst2SVFInstMap;
|
|
61
|
-
typedef Map<const Argument*, SVFLLVMValue*> LLVMArgument2SVFArgumentMap;
|
|
62
|
-
typedef Map<const Constant*, SVFLLVMValue*> LLVMConst2SVFConstMap;
|
|
63
|
-
typedef Map<const Value*, SVFLLVMValue*> LLVMValue2SVFOtherValueMap;
|
|
64
|
-
typedef Map<const SVFLLVMValue*, const Value*> SVFValue2LLVMValueMap;
|
|
65
57
|
typedef Map<const SVFValue*, const Value*> SVFBaseNode2LLVMValueMap;
|
|
66
58
|
typedef Map<const Type*, SVFType*> LLVMType2SVFTypeMap;
|
|
67
59
|
typedef Map<const Type*, StInfo*> Type2TypeInfoMap;
|
|
@@ -75,16 +67,18 @@ public:
|
|
|
75
67
|
|
|
76
68
|
/// llvm value to sym id map
|
|
77
69
|
/// local (%) and global (@) identifiers are pointer types which have a value node id.
|
|
78
|
-
typedef OrderedMap<const
|
|
70
|
+
typedef OrderedMap<const Value*, NodeID> ValueToIDMapTy;
|
|
79
71
|
|
|
80
|
-
typedef OrderedMap<const
|
|
72
|
+
typedef OrderedMap<const Function*, NodeID> FunToIDMapTy;
|
|
81
73
|
|
|
74
|
+
typedef std::vector<const Function*> FunctionSet;
|
|
75
|
+
typedef Map<const Function*, const SVFBasicBlock*> FunToExitBBMap;
|
|
76
|
+
typedef Map<const Function*, const Function *> FunToRealDefFunMap;
|
|
82
77
|
|
|
83
78
|
private:
|
|
84
79
|
static LLVMModuleSet* llvmModuleSet;
|
|
85
80
|
static bool preProcessed;
|
|
86
81
|
SVFIR* svfir;
|
|
87
|
-
SVFModule* svfModule; ///< Borrowed from singleton SVFModule::svfModule
|
|
88
82
|
std::unique_ptr<LLVMContext> owned_ctx;
|
|
89
83
|
std::vector<std::unique_ptr<Module>> owned_modules;
|
|
90
84
|
std::vector<std::reference_wrapper<Module>> modules;
|
|
@@ -95,19 +89,13 @@ private:
|
|
|
95
89
|
Fun2AnnoMap ExtFun2Annotations;
|
|
96
90
|
|
|
97
91
|
// Map SVFFunction to its annotations
|
|
98
|
-
Map<const
|
|
92
|
+
Map<const Function*, std::vector<std::string>> func2Annotations;
|
|
99
93
|
|
|
100
94
|
/// Global definition to a rep definition map
|
|
101
95
|
GlobalDefToRepMapTy GlobalDefToRepMap;
|
|
102
96
|
|
|
103
|
-
LLVMFun2SVFFunMap LLVMFunc2SVFFunc; ///< Map an LLVM Function to an SVF Function
|
|
104
97
|
LLVMFun2FunObjVarMap LLVMFun2FunObjVar; ///< Map an LLVM Function to an SVF Funobjvar
|
|
105
98
|
LLVMBB2SVFBBMap LLVMBB2SVFBB;
|
|
106
|
-
LLVMInst2SVFInstMap LLVMInst2SVFInst;
|
|
107
|
-
LLVMArgument2SVFArgumentMap LLVMArgument2SVFArgument;
|
|
108
|
-
LLVMConst2SVFConstMap LLVMConst2SVFConst;
|
|
109
|
-
LLVMValue2SVFOtherValueMap LLVMValue2SVFOtherValue;
|
|
110
|
-
SVFValue2LLVMValueMap SVFValue2LLVMValue;
|
|
111
99
|
LLVMType2SVFTypeMap LLVMType2SVFType;
|
|
112
100
|
Type2TypeInfoMap Type2TypeInfo;
|
|
113
101
|
ObjTypeInference* typeInference;
|
|
@@ -126,6 +114,10 @@ private:
|
|
|
126
114
|
FunToIDMapTy returnSymMap; ///< return map
|
|
127
115
|
FunToIDMapTy varargSymMap; ///< vararg map
|
|
128
116
|
|
|
117
|
+
FunctionSet funSet;
|
|
118
|
+
FunToExitBBMap funToExitBB;
|
|
119
|
+
FunToRealDefFunMap funToRealDefFun;
|
|
120
|
+
|
|
129
121
|
/// Constructor
|
|
130
122
|
LLVMModuleSet();
|
|
131
123
|
|
|
@@ -148,15 +140,10 @@ public:
|
|
|
148
140
|
}
|
|
149
141
|
|
|
150
142
|
// Build an SVF module from a given LLVM Module instance (for use e.g. in a LLVM pass)
|
|
151
|
-
static
|
|
143
|
+
static void buildSVFModule(Module& mod);
|
|
152
144
|
|
|
153
145
|
// Build an SVF module from the bitcode files provided in `moduleNameVec`
|
|
154
|
-
static
|
|
155
|
-
|
|
156
|
-
inline SVFModule* getSVFModule()
|
|
157
|
-
{
|
|
158
|
-
return svfModule;
|
|
159
|
-
}
|
|
146
|
+
static void buildSVFModule(const std::vector<std::string>& moduleNameVec);
|
|
160
147
|
|
|
161
148
|
static void preProcessBCs(std::vector<std::string>& moduleNameVec);
|
|
162
149
|
|
|
@@ -186,6 +173,25 @@ public:
|
|
|
186
173
|
|
|
187
174
|
public:
|
|
188
175
|
|
|
176
|
+
inline const SVFBasicBlock* getFunExitBB(const Function* fun) const
|
|
177
|
+
{
|
|
178
|
+
auto it = funToExitBB.find(fun);
|
|
179
|
+
if (it == funToExitBB.end()) return nullptr;
|
|
180
|
+
else return it->second;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
inline const Function* getRealDefFun(const Function* fun) const
|
|
184
|
+
{
|
|
185
|
+
auto it = funToRealDefFun.find(fun);
|
|
186
|
+
if (it == funToRealDefFun.end()) return nullptr;
|
|
187
|
+
else return it->second;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
inline const FunctionSet& getFunctionSet() const
|
|
191
|
+
{
|
|
192
|
+
return funSet;
|
|
193
|
+
}
|
|
194
|
+
|
|
189
195
|
inline u32_t getValueNodeNum() const
|
|
190
196
|
{
|
|
191
197
|
return valSymMap.size();
|
|
@@ -208,36 +214,26 @@ public:
|
|
|
208
214
|
|
|
209
215
|
/// Get SVFIR Node according to LLVM value
|
|
210
216
|
///getNode - Return the node corresponding to the specified pointer.
|
|
211
|
-
NodeID getValueNode(const
|
|
217
|
+
NodeID getValueNode(const Value* V);
|
|
212
218
|
|
|
213
|
-
bool hasValueNode(const
|
|
219
|
+
bool hasValueNode(const Value* V);
|
|
214
220
|
|
|
215
221
|
/// getObject - Return the obj node id refer to the memory object for the
|
|
216
222
|
/// specified global, heap or alloca instruction according to llvm value.
|
|
217
|
-
NodeID getObjectNode(const
|
|
223
|
+
NodeID getObjectNode(const Value* V);
|
|
218
224
|
|
|
219
225
|
void dumpSymTable();
|
|
220
226
|
|
|
221
227
|
public:
|
|
222
|
-
inline void addFunctionMap(const Function* func, SVFFunction* svfFunc)
|
|
223
|
-
{
|
|
224
|
-
LLVMFunc2SVFFunc[func] = svfFunc;
|
|
225
|
-
setValueAttr(func,svfFunc);
|
|
226
|
-
}
|
|
227
228
|
|
|
228
229
|
// create a SVFBasicBlock according to LLVM BasicBlock, then add it to SVFFunction's BasicBlockGraph
|
|
229
|
-
inline void addBasicBlock(
|
|
230
|
+
inline void addBasicBlock(FunObjVar* fun, const BasicBlock* bb)
|
|
230
231
|
{
|
|
231
232
|
SVFBasicBlock* svfBB = fun->getBasicBlockGraph()->addBasicBlock(bb->getName().str());
|
|
232
233
|
LLVMBB2SVFBB[bb] = svfBB;
|
|
233
234
|
SVFBaseNode2LLVMValue[svfBB] = bb;
|
|
234
235
|
}
|
|
235
236
|
|
|
236
|
-
inline void addInstructionMap(const Instruction* inst, SVFLLVMValue* svfInst)
|
|
237
|
-
{
|
|
238
|
-
LLVMInst2SVFInst[inst] = svfInst;
|
|
239
|
-
setValueAttr(inst,svfInst);
|
|
240
|
-
}
|
|
241
237
|
inline void addInstructionMap(const Instruction* inst, CallICFGNode* svfInst)
|
|
242
238
|
{
|
|
243
239
|
CSToCallNodeMap[inst] = svfInst;
|
|
@@ -254,46 +250,6 @@ public:
|
|
|
254
250
|
addToSVFVar2LLVMValueMap(inst, svfInst);
|
|
255
251
|
}
|
|
256
252
|
|
|
257
|
-
inline void addArgumentMap(const Argument* arg, SVFLLVMValue* svfArg)
|
|
258
|
-
{
|
|
259
|
-
LLVMArgument2SVFArgument[arg] = svfArg;
|
|
260
|
-
setValueAttr(arg,svfArg);
|
|
261
|
-
}
|
|
262
|
-
inline void addGlobalValueMap(const GlobalValue* glob, SVFLLVMValue* svfglob)
|
|
263
|
-
{
|
|
264
|
-
if (auto glob_var = llvm::dyn_cast<llvm::GlobalVariable>(glob);
|
|
265
|
-
hasGlobalRep(glob_var))
|
|
266
|
-
{
|
|
267
|
-
glob = getGlobalRep(glob_var);
|
|
268
|
-
}
|
|
269
|
-
LLVMConst2SVFConst[glob] = svfglob;
|
|
270
|
-
setValueAttr(glob,svfglob);
|
|
271
|
-
}
|
|
272
|
-
inline void addConstantDataMap(const ConstantData* cd, SVFLLVMValue* svfcd)
|
|
273
|
-
{
|
|
274
|
-
LLVMConst2SVFConst[cd] = svfcd;
|
|
275
|
-
setValueAttr(cd,svfcd);
|
|
276
|
-
}
|
|
277
|
-
inline void addOtherConstantMap(const Constant* cons, SVFLLVMValue* svfcons)
|
|
278
|
-
{
|
|
279
|
-
LLVMConst2SVFConst[cons] = svfcons;
|
|
280
|
-
setValueAttr(cons,svfcons);
|
|
281
|
-
}
|
|
282
|
-
inline void addOtherValueMap(const Value* ov, SVFLLVMValue* svfov)
|
|
283
|
-
{
|
|
284
|
-
LLVMValue2SVFOtherValue[ov] = svfov;
|
|
285
|
-
setValueAttr(ov,svfov);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
SVFLLVMValue* getSVFValue(const Value* value);
|
|
289
|
-
|
|
290
|
-
const Value* getLLVMValue(const SVFLLVMValue* value) const
|
|
291
|
-
{
|
|
292
|
-
SVFValue2LLVMValueMap::const_iterator it = SVFValue2LLVMValue.find(value);
|
|
293
|
-
assert(it!=SVFValue2LLVMValue.end() && "can't find corresponding llvm value!");
|
|
294
|
-
return it->second;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
253
|
const Value* getLLVMValue(const SVFValue* value) const
|
|
298
254
|
{
|
|
299
255
|
SVFBaseNode2LLVMValueMap ::const_iterator it = SVFBaseNode2LLVMValue.find(value);
|
|
@@ -301,13 +257,6 @@ public:
|
|
|
301
257
|
return it->second;
|
|
302
258
|
}
|
|
303
259
|
|
|
304
|
-
inline SVFFunction* getSVFFunction(const Function* fun) const
|
|
305
|
-
{
|
|
306
|
-
LLVMFun2SVFFunMap::const_iterator it = LLVMFunc2SVFFunc.find(fun);
|
|
307
|
-
assert(it!=LLVMFunc2SVFFunc.end() && "SVF Function not found!");
|
|
308
|
-
return it->second;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
260
|
inline const FunObjVar* getFunObjVar(const Function* fun) const
|
|
312
261
|
{
|
|
313
262
|
LLVMFun2FunObjVarMap::const_iterator it = LLVMFun2FunObjVar.find(fun);
|
|
@@ -325,14 +274,14 @@ public:
|
|
|
325
274
|
return varargSymMap;
|
|
326
275
|
}
|
|
327
276
|
|
|
328
|
-
NodeID getReturnNode(const
|
|
277
|
+
NodeID getReturnNode(const Function *func) const
|
|
329
278
|
{
|
|
330
279
|
FunToIDMapTy::const_iterator iter = returnSymMap.find(func);
|
|
331
280
|
assert(iter!=returnSymMap.end() && "ret sym not found");
|
|
332
281
|
return iter->second;
|
|
333
282
|
}
|
|
334
283
|
|
|
335
|
-
NodeID getVarargNode(const
|
|
284
|
+
NodeID getVarargNode(const Function *func) const
|
|
336
285
|
{
|
|
337
286
|
FunToIDMapTy::const_iterator iter = varargSymMap.find(func);
|
|
338
287
|
assert(iter!=varargSymMap.end() && "vararg sym not found");
|
|
@@ -346,39 +295,8 @@ public:
|
|
|
346
295
|
return it->second;
|
|
347
296
|
}
|
|
348
297
|
|
|
349
|
-
inline SVFLLVMValue* getSVFInstruction(const Instruction* inst) const
|
|
350
|
-
{
|
|
351
|
-
LLVMInst2SVFInstMap::const_iterator it = LLVMInst2SVFInst.find(inst);
|
|
352
|
-
assert(it!=LLVMInst2SVFInst.end() && "SVF Instruction not found!");
|
|
353
|
-
return it->second;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
inline SVFLLVMValue* getSVFArgument(const Argument* arg) const
|
|
357
|
-
{
|
|
358
|
-
LLVMArgument2SVFArgumentMap::const_iterator it = LLVMArgument2SVFArgument.find(arg);
|
|
359
|
-
assert(it!=LLVMArgument2SVFArgument.end() && "SVF Argument not found!");
|
|
360
|
-
return it->second;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
inline SVFLLVMValue* getSVFGlobalValue(const GlobalValue* g) const
|
|
364
|
-
{
|
|
365
|
-
if (auto glob_var = llvm::dyn_cast<llvm::GlobalVariable>(g);
|
|
366
|
-
hasGlobalRep(glob_var))
|
|
367
|
-
{
|
|
368
|
-
g = getGlobalRep(glob_var);
|
|
369
|
-
}
|
|
370
|
-
LLVMConst2SVFConstMap::const_iterator it = LLVMConst2SVFConst.find(g);
|
|
371
|
-
assert(it!=LLVMConst2SVFConst.end() && "SVF Global not found!");
|
|
372
|
-
return it->second;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
SVFLLVMValue* getSVFConstantData(const ConstantData* cd);
|
|
376
|
-
SVFLLVMValue* getOtherSVFConstant(const Constant* oc);
|
|
377
|
-
|
|
378
|
-
SVFLLVMValue* getSVFOtherValue(const Value* ov);
|
|
379
|
-
|
|
380
298
|
/// Get the corresponding Function based on its name
|
|
381
|
-
inline const
|
|
299
|
+
inline const Function* getFunction(const std::string& name)
|
|
382
300
|
{
|
|
383
301
|
Function* fun = nullptr;
|
|
384
302
|
|
|
@@ -388,7 +306,7 @@ public:
|
|
|
388
306
|
fun = mod->getFunction(name);
|
|
389
307
|
if (fun)
|
|
390
308
|
{
|
|
391
|
-
return
|
|
309
|
+
return fun;
|
|
392
310
|
}
|
|
393
311
|
}
|
|
394
312
|
return nullptr;
|
|
@@ -473,45 +391,59 @@ public:
|
|
|
473
391
|
|
|
474
392
|
DominatorTree& getDomTree(const Function* fun);
|
|
475
393
|
|
|
476
|
-
std::string getExtFuncAnnotation(const
|
|
394
|
+
std::string getExtFuncAnnotation(const Function* fun, const std::string& funcAnnotation);
|
|
477
395
|
|
|
478
|
-
const std::vector<std::string>& getExtFuncAnnotations(const
|
|
396
|
+
const std::vector<std::string>& getExtFuncAnnotations(const Function* fun);
|
|
479
397
|
|
|
480
398
|
// Does (F) have some annotation?
|
|
481
|
-
bool hasExtFuncAnnotation(const
|
|
399
|
+
bool hasExtFuncAnnotation(const Function* fun, const std::string& funcAnnotation);
|
|
482
400
|
|
|
483
401
|
// Does (F) have a static var X (unavailable to us) that its return points to?
|
|
484
|
-
bool has_static(const
|
|
402
|
+
bool has_static(const Function *F);
|
|
485
403
|
|
|
486
404
|
// Does (F) have a memcpy_like operation?
|
|
487
|
-
bool is_memcpy(const
|
|
405
|
+
bool is_memcpy(const Function *F);
|
|
488
406
|
|
|
489
407
|
// Does (F) have a memset_like operation?
|
|
490
|
-
bool is_memset(const
|
|
408
|
+
bool is_memset(const Function *F);
|
|
491
409
|
|
|
492
410
|
// Does (F) allocate a new object and return it?
|
|
493
|
-
bool is_alloc(const
|
|
411
|
+
bool is_alloc(const Function *F);
|
|
494
412
|
|
|
495
413
|
// Does (F) allocate a new object and assign it to one of its arguments?
|
|
496
|
-
bool is_arg_alloc(const
|
|
414
|
+
bool is_arg_alloc(const Function *F);
|
|
497
415
|
|
|
498
416
|
// Does (F) allocate a new stack object and return it?
|
|
499
|
-
bool is_alloc_stack_ret(const
|
|
417
|
+
bool is_alloc_stack_ret(const Function *F);
|
|
500
418
|
|
|
501
419
|
// Get the position of argument which holds the new object
|
|
502
|
-
s32_t get_alloc_arg_pos(const
|
|
420
|
+
s32_t get_alloc_arg_pos(const Function *F);
|
|
503
421
|
|
|
504
422
|
// Does (F) reallocate a new object?
|
|
505
|
-
bool is_realloc(const
|
|
423
|
+
bool is_realloc(const Function *F);
|
|
506
424
|
|
|
507
425
|
// Should (F) be considered "external" (either not defined in the program
|
|
508
426
|
// or a user-defined version of a known alloc or no-op)?
|
|
509
|
-
bool is_ext(const
|
|
427
|
+
bool is_ext(const Function *F);
|
|
510
428
|
|
|
511
429
|
// Set the annotation of (F)
|
|
512
|
-
void setExtFuncAnnotations(const
|
|
430
|
+
void setExtFuncAnnotations(const Function* fun, const std::vector<std::string>& funcAnnotations);
|
|
513
431
|
|
|
514
432
|
private:
|
|
433
|
+
inline void addFunctionSet(const Function* svfFunc)
|
|
434
|
+
{
|
|
435
|
+
funSet.push_back(svfFunc);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
inline void setFunExitBB(const Function* fun, const SVFBasicBlock* bb)
|
|
439
|
+
{
|
|
440
|
+
funToExitBB[fun] = bb;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
inline void setFunRealDefFun(const Function* fun, const Function* realDefFun)
|
|
444
|
+
{
|
|
445
|
+
funToRealDefFun[fun] = realDefFun;
|
|
446
|
+
}
|
|
515
447
|
/// Create SVFTypes
|
|
516
448
|
SVFType* addSVFTypeInfo(const Type* t);
|
|
517
449
|
/// Collect a type info
|
|
@@ -531,11 +463,7 @@ private:
|
|
|
531
463
|
void addSVFMain();
|
|
532
464
|
|
|
533
465
|
void createSVFDataStructure();
|
|
534
|
-
|
|
535
|
-
void initSVFFunction();
|
|
536
|
-
void initSVFBasicBlock(const Function* func);
|
|
537
|
-
void initDomTree(SVFFunction* func, const Function* f);
|
|
538
|
-
void setValueAttr(const Value* val, SVFLLVMValue* value);
|
|
466
|
+
|
|
539
467
|
void addToSVFVar2LLVMValueMap(const Value* val, SVFValue* svfBaseNode);
|
|
540
468
|
void buildFunToFunMap();
|
|
541
469
|
void buildGlobalDefToRepMap();
|
|
@@ -32,7 +32,6 @@
|
|
|
32
32
|
|
|
33
33
|
#include "Util/SVFUtil.h"
|
|
34
34
|
#include "SVF-LLVM/BasicTypes.h"
|
|
35
|
-
#include "SVF-LLVM/SVFLLVMValue.h"
|
|
36
35
|
#include "Util/ThreadAPI.h"
|
|
37
36
|
|
|
38
37
|
namespace SVF
|
|
@@ -355,15 +354,14 @@ std::vector<const Function *> getCalledFunctions(const Function *F);
|
|
|
355
354
|
// Converts a mangled name to C naming style to match functions in extapi.c.
|
|
356
355
|
std::string restoreFuncName(std::string funcName);
|
|
357
356
|
|
|
358
|
-
bool isExtCall(const
|
|
357
|
+
bool isExtCall(const Function* fun);
|
|
359
358
|
|
|
360
|
-
bool isMemcpyExtFun(const
|
|
359
|
+
bool isMemcpyExtFun(const Function *fun);
|
|
361
360
|
|
|
362
|
-
bool isMemsetExtFun(const
|
|
361
|
+
bool isMemsetExtFun(const Function* fun);
|
|
363
362
|
|
|
364
|
-
u32_t getHeapAllocHoldingArgPosition(const
|
|
363
|
+
u32_t getHeapAllocHoldingArgPosition(const Function* fun);
|
|
365
364
|
|
|
366
|
-
const SVFFunction* getFunction(const std::string& name);
|
|
367
365
|
const FunObjVar* getFunObjVar(const std::string&name);
|
|
368
366
|
|
|
369
367
|
/// Return true if the value refers to constant data, e.g., i32 0
|
|
@@ -376,9 +374,6 @@ inline bool isConstDataOrAggData(const Value* val)
|
|
|
376
374
|
/// find the unique defined global across multiple modules
|
|
377
375
|
const Value* getGlobalRep(const Value* val);
|
|
378
376
|
|
|
379
|
-
/// Check whether this value points-to a constant object
|
|
380
|
-
bool isConstantObjSym(const SVFLLVMValue* val);
|
|
381
|
-
|
|
382
377
|
/// Check whether this value points-to a constant object
|
|
383
378
|
bool isConstantObjSym(const Value* val);
|
|
384
379
|
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
namespace SVF
|
|
40
40
|
{
|
|
41
41
|
|
|
42
|
-
class SVFModule;
|
|
43
42
|
/*!
|
|
44
43
|
* SVFIR Builder to create SVF variables and statements and PAG
|
|
45
44
|
*/
|
|
@@ -48,13 +47,12 @@ class SVFIRBuilder: public llvm::InstVisitor<SVFIRBuilder>
|
|
|
48
47
|
|
|
49
48
|
private:
|
|
50
49
|
SVFIR* pag;
|
|
51
|
-
SVFModule* svfModule;
|
|
52
50
|
const SVFBasicBlock* curBB; ///< Current basic block during SVFIR construction when visiting the module
|
|
53
|
-
const
|
|
51
|
+
const Value* curVal; ///< Current Value during SVFIR construction when visiting the module
|
|
54
52
|
|
|
55
53
|
public:
|
|
56
54
|
/// Constructor
|
|
57
|
-
SVFIRBuilder(
|
|
55
|
+
SVFIRBuilder(): pag(SVFIR::getPAG()), curBB(nullptr),curVal(nullptr)
|
|
58
56
|
{
|
|
59
57
|
}
|
|
60
58
|
/// Destructor
|
|
@@ -71,12 +69,19 @@ public:
|
|
|
71
69
|
return pag;
|
|
72
70
|
}
|
|
73
71
|
|
|
72
|
+
void createFunObjVars();
|
|
73
|
+
void initFunObjVar();
|
|
74
|
+
|
|
74
75
|
/// Initialize nodes and edges
|
|
75
76
|
//@{
|
|
76
77
|
void initialiseNodes();
|
|
77
78
|
void initialiseBaseObjVars();
|
|
78
79
|
void initialiseValVars();
|
|
79
|
-
|
|
80
|
+
|
|
81
|
+
void initSVFBasicBlock(const Function* func);
|
|
82
|
+
|
|
83
|
+
void initDomTree(FunObjVar* func, const Function* f);
|
|
84
|
+
|
|
80
85
|
void addEdge(NodeID src, NodeID dst, SVFStmt::PEDGEK kind,
|
|
81
86
|
APOffset offset = 0, Instruction* cs = nullptr);
|
|
82
87
|
// @}
|
|
@@ -93,15 +98,13 @@ public:
|
|
|
93
98
|
processCE(V);
|
|
94
99
|
|
|
95
100
|
// strip off the constant cast and return the value node
|
|
96
|
-
|
|
97
|
-
return llvmModuleSet()->getValueNode(svfVal);
|
|
101
|
+
return llvmModuleSet()->getValueNode(V);
|
|
98
102
|
}
|
|
99
103
|
|
|
100
104
|
/// GetObject - Return the object node (stack/global/heap/function) according to a LLVM Value
|
|
101
105
|
inline NodeID getObjectNode(const Value* V)
|
|
102
106
|
{
|
|
103
|
-
|
|
104
|
-
return llvmModuleSet()->getObjectNode(svfVal);
|
|
107
|
+
return llvmModuleSet()->getObjectNode(V);
|
|
105
108
|
}
|
|
106
109
|
|
|
107
110
|
/// getReturnNode - Return the node representing the unique return value of a function.
|
|
@@ -209,7 +212,7 @@ public:
|
|
|
209
212
|
protected:
|
|
210
213
|
/// Handle globals including (global variable and functions)
|
|
211
214
|
//@{
|
|
212
|
-
void visitGlobal(
|
|
215
|
+
void visitGlobal();
|
|
213
216
|
void InitialGlobal(const GlobalVariable *gvar, Constant *C,
|
|
214
217
|
u32_t offset);
|
|
215
218
|
NodeID getGlobalVarField(const GlobalVariable *gvar, u32_t offset, SVFType* tpy);
|
|
@@ -237,21 +240,21 @@ protected:
|
|
|
237
240
|
//@{
|
|
238
241
|
virtual const Type *getBaseTypeAndFlattenedFields(const Value *V, std::vector<AccessPath> &fields, const Value* szValue);
|
|
239
242
|
virtual void addComplexConsForExt(Value *D, Value *S, const Value* sz);
|
|
240
|
-
virtual void handleExtCall(const CallBase* cs, const
|
|
243
|
+
virtual void handleExtCall(const CallBase* cs, const Function* callee);
|
|
241
244
|
//@}
|
|
242
245
|
|
|
243
246
|
/// Set current basic block in order to keep track of control flow information
|
|
244
247
|
inline void setCurrentLocation(const Value* val, const BasicBlock* bb)
|
|
245
248
|
{
|
|
246
249
|
curBB = (bb == nullptr? nullptr : llvmModuleSet()->getSVFBasicBlock(bb));
|
|
247
|
-
curVal = (val == nullptr ? nullptr:
|
|
250
|
+
curVal = (val == nullptr ? nullptr: val);
|
|
248
251
|
}
|
|
249
|
-
inline void setCurrentLocation(const
|
|
252
|
+
inline void setCurrentLocation(const Value* val, const SVFBasicBlock* bb)
|
|
250
253
|
{
|
|
251
254
|
curBB = bb;
|
|
252
255
|
curVal = val;
|
|
253
256
|
}
|
|
254
|
-
inline const
|
|
257
|
+
inline const Value* getCurrentValue() const
|
|
255
258
|
{
|
|
256
259
|
return curVal;
|
|
257
260
|
}
|
|
@@ -263,9 +266,9 @@ protected:
|
|
|
263
266
|
/// Add global black hole Address edge
|
|
264
267
|
void addGlobalBlackHoleAddrEdge(NodeID node, const ConstantExpr *int2Ptrce)
|
|
265
268
|
{
|
|
266
|
-
const
|
|
269
|
+
const Value* cval = getCurrentValue();
|
|
267
270
|
const SVFBasicBlock* cbb = getCurrentBB();
|
|
268
|
-
setCurrentLocation(int2Ptrce,nullptr);
|
|
271
|
+
setCurrentLocation(int2Ptrce,(SVFBasicBlock*) nullptr);
|
|
269
272
|
addBlackHoleAddrEdge(node);
|
|
270
273
|
setCurrentLocation(cval,cbb);
|
|
271
274
|
}
|
|
@@ -277,7 +280,7 @@ protected:
|
|
|
277
280
|
ConstantPointerNull* constNull = ConstantPointerNull::get(PointerType::getUnqual(cxt));
|
|
278
281
|
NodeID nullPtr = pag->addConstantNullPtrValNode(pag->getNullPtr(), nullptr, llvmModuleSet()->getSVFType(constNull->getType()));
|
|
279
282
|
llvmModuleSet()->addToSVFVar2LLVMValueMap(constNull, pag->getGNode(pag->getNullPtr()));
|
|
280
|
-
setCurrentLocation(constNull, nullptr);
|
|
283
|
+
setCurrentLocation(constNull, (SVFBasicBlock*) nullptr);
|
|
281
284
|
addBlackHoleAddrEdge(pag->getBlkPtr());
|
|
282
285
|
return nullPtr;
|
|
283
286
|
}
|
|
@@ -454,7 +457,7 @@ protected:
|
|
|
454
457
|
inline void addStoreEdge(NodeID src, NodeID dst)
|
|
455
458
|
{
|
|
456
459
|
ICFGNode* node;
|
|
457
|
-
if (const Instruction* inst = SVFUtil::dyn_cast<Instruction>(
|
|
460
|
+
if (const Instruction* inst = SVFUtil::dyn_cast<Instruction>(curVal))
|
|
458
461
|
node = llvmModuleSet()->getICFGNode(
|
|
459
462
|
SVFUtil::cast<Instruction>(inst));
|
|
460
463
|
else
|