svf-lib 1.0.1164 → 1.0.1165
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-osx/Release-build/lib/libSvf.a +0 -0
- package/SVF-osx/include/MTA/MHP.h +2 -1
- package/SVF-osx/include/MemoryModel/SymbolTableInfo.h +7 -2
- package/SVF-osx/include/SVF-FE/LLVMUtil.h +9 -7
- package/SVF-osx/include/SVF-FE/SymbolTableBuilder.h +2 -0
- package/SVF-osx/include/Util/BasicTypes.h +52 -2
- package/SVF-osx/include/Util/DPItem.h +1 -1
- package/SVF-osx/include/Util/SVFModule.h +132 -4
- package/package.json +1 -1
|
Binary file
|
|
@@ -341,7 +341,8 @@ public:
|
|
|
341
341
|
NodeID parentTid = tct->getParentThread(tid);
|
|
342
342
|
const CxtThread& parentct = tct->getTCTNode(parentTid)->getCxtThread();
|
|
343
343
|
const Function* parentRoutine = tct->getStartRoutineOfCxtThread(parentct);
|
|
344
|
-
|
|
344
|
+
const SVFFunction* svfFun = LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(parentRoutine);
|
|
345
|
+
return &(LLVMUtil::getFunExitBB(svfFun)->back());
|
|
345
346
|
}
|
|
346
347
|
|
|
347
348
|
/// Get loop for join site
|
|
@@ -88,8 +88,6 @@ private:
|
|
|
88
88
|
IDToMemMapTy objMap; ///< map a memory sym id to its obj
|
|
89
89
|
|
|
90
90
|
CallSiteSet callSiteSet;
|
|
91
|
-
Set<const Value*> nullPtrSyms;
|
|
92
|
-
Set<const Value*> blackholeSyms;
|
|
93
91
|
|
|
94
92
|
// Singleton pattern here to enable instance of SymbolTableInfo can only be created once.
|
|
95
93
|
static SymbolTableInfo* symInfo;
|
|
@@ -165,6 +163,13 @@ public:
|
|
|
165
163
|
// @{
|
|
166
164
|
static bool isNullPtrSym(const Value *val);
|
|
167
165
|
static bool isBlackholeSym(const Value *val);
|
|
166
|
+
static bool isArgOfUncalledFunction(const Value *val);
|
|
167
|
+
static bool isReturn(const Instruction *inst);
|
|
168
|
+
static bool isPtrInUncalledFunction (const Value * value);
|
|
169
|
+
static const u32_t getBBSuccessorNum(const BasicBlock *bb);
|
|
170
|
+
static const Type* getPtrElementType(const PointerType* pty);
|
|
171
|
+
static const u32_t getBBSuccessorPos(const BasicBlock *BB, const BasicBlock *Succ);
|
|
172
|
+
static const u32_t getBBPredecessorPos(const BasicBlock *BB, const BasicBlock *Pred);
|
|
168
173
|
|
|
169
174
|
static inline bool isBlkPtr(NodeID id)
|
|
170
175
|
{
|
|
@@ -118,13 +118,13 @@ bool isObject (const Value * ref);
|
|
|
118
118
|
/// function address is not taken and never be used in call or invoke instruction
|
|
119
119
|
//@{
|
|
120
120
|
/// whether this is a function without any possible caller?
|
|
121
|
-
bool
|
|
121
|
+
bool isUncalledFunction (const Function * fun);
|
|
122
122
|
|
|
123
123
|
/// whether this is an argument in dead function
|
|
124
124
|
inline bool ArgInDeadFunction (const Value * val)
|
|
125
125
|
{
|
|
126
126
|
return SVFUtil::isa<Argument>(val)
|
|
127
|
-
&&
|
|
127
|
+
&& isUncalledFunction(SVFUtil::cast<Argument>(val)->getParent());
|
|
128
128
|
}
|
|
129
129
|
//@}
|
|
130
130
|
|
|
@@ -135,7 +135,7 @@ inline bool ArgInProgEntryFunction (const Value * val)
|
|
|
135
135
|
&& SVFUtil::isProgEntryFunction(SVFUtil::cast<Argument>(val)->getParent());
|
|
136
136
|
}
|
|
137
137
|
/// Return true if this is value in a dead function (function without any caller)
|
|
138
|
-
bool
|
|
138
|
+
bool isPtrInUncalledFunction (const Value * value);
|
|
139
139
|
//@}
|
|
140
140
|
|
|
141
141
|
//@}
|
|
@@ -145,11 +145,11 @@ bool isPtrInDeadFunction (const Value * value);
|
|
|
145
145
|
/// Return true if the function does not have a caller (either it is a main function or a dead function)
|
|
146
146
|
inline bool isNoCallerFunction (const Function * fun)
|
|
147
147
|
{
|
|
148
|
-
return
|
|
148
|
+
return isUncalledFunction(fun) || SVFUtil::isProgEntryFunction(fun);
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
/// Return true if the argument in a function does not have a caller
|
|
152
|
-
inline bool
|
|
152
|
+
inline bool isArgOfUncalledFunction (const Value * val)
|
|
153
153
|
{
|
|
154
154
|
return SVFUtil::isa<Argument>(val)
|
|
155
155
|
&& isNoCallerFunction(SVFUtil::cast<Argument>(val)->getParent());
|
|
@@ -160,12 +160,14 @@ inline bool ArgInNoCallerFunction (const Value * val)
|
|
|
160
160
|
bool functionDoesNotRet (const Function * fun);
|
|
161
161
|
|
|
162
162
|
/// Get reachable basic block from function entry
|
|
163
|
-
void getFunReachableBBs (const
|
|
163
|
+
void getFunReachableBBs (const SVFFunction* svfFun, std::vector<const BasicBlock*>& bbs);
|
|
164
164
|
|
|
165
165
|
/// Get function exit basic block
|
|
166
166
|
/// FIXME: this back() here is only valid when UnifyFunctionExitNodes pass is invoked
|
|
167
|
-
inline const BasicBlock* getFunExitBB(const
|
|
167
|
+
inline const BasicBlock* getFunExitBB(const SVFFunction* svfFun)
|
|
168
168
|
{
|
|
169
|
+
const Function* fun = svfFun->getLLVMFun();
|
|
170
|
+
assert(!SVFUtil::isExtCall(svfFun) && "The function cannot be an external call");
|
|
169
171
|
return &fun->back();
|
|
170
172
|
}
|
|
171
173
|
/// Strip off the constant casts
|
|
@@ -129,16 +129,26 @@ private:
|
|
|
129
129
|
bool isDecl;
|
|
130
130
|
bool isIntri;
|
|
131
131
|
Function* fun;
|
|
132
|
+
BasicBlock* exitBB;
|
|
133
|
+
std::vector<const BasicBlock*> reachableBBs;
|
|
134
|
+
bool isUncalled;
|
|
135
|
+
bool isNotRet;
|
|
132
136
|
public:
|
|
133
137
|
SVFFunction(const std::string& val): SVFValue(val,SVFValue::SVFFunc),
|
|
134
|
-
isDecl(false), isIntri(false), fun(nullptr)
|
|
138
|
+
isDecl(false), isIntri(false), fun(nullptr), exitBB(nullptr), isUncalled(false), isNotRet(false)
|
|
135
139
|
{
|
|
136
140
|
}
|
|
137
141
|
|
|
138
142
|
SVFFunction(Function* f): SVFValue(f->getName().str(),SVFValue::SVFFunc),
|
|
139
|
-
isDecl(f->isDeclaration()), isIntri(f->isIntrinsic()), fun(f)
|
|
143
|
+
isDecl(f->isDeclaration()), isIntri(f->isIntrinsic()), fun(f), exitBB(nullptr), isUncalled(false), isNotRet(false)
|
|
140
144
|
{
|
|
141
145
|
}
|
|
146
|
+
|
|
147
|
+
SVFFunction(Function* f, BasicBlock* exitBB, std::vector<const BasicBlock*> reachableBBs): SVFValue(f->getName().str(),SVFValue::SVFFunc),
|
|
148
|
+
isDecl(f->isDeclaration()), isIntri(f->isIntrinsic()), fun(f), exitBB(exitBB), reachableBBs(reachableBBs), isUncalled(false), isNotRet(false)
|
|
149
|
+
{
|
|
150
|
+
}
|
|
151
|
+
|
|
142
152
|
inline Function* getLLVMFun() const
|
|
143
153
|
{
|
|
144
154
|
assert(fun && "no LLVM Function found!");
|
|
@@ -170,6 +180,46 @@ public:
|
|
|
170
180
|
return getLLVMFun()->isVarArg();
|
|
171
181
|
}
|
|
172
182
|
|
|
183
|
+
inline const std::vector<const BasicBlock*>& getReachableBBs() const
|
|
184
|
+
{
|
|
185
|
+
return reachableBBs;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
inline const bool isUncalledFunction() const
|
|
189
|
+
{
|
|
190
|
+
return isUncalled;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
inline const void setIsUncalledFunction(const bool isUncalledFunction)
|
|
194
|
+
{
|
|
195
|
+
this->isUncalled = isUncalledFunction;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
inline const void setIsNotRet(const bool doesNotRet)
|
|
199
|
+
{
|
|
200
|
+
this->isNotRet = doesNotRet;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
inline const void setExitBB(BasicBlock* exitBB)
|
|
204
|
+
{
|
|
205
|
+
this->exitBB = exitBB;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
inline const void setReachableBBs(std::vector<const BasicBlock*> reachableBBs)
|
|
209
|
+
{
|
|
210
|
+
this->reachableBBs = reachableBBs;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
inline const bool isNotRetFunction() const
|
|
214
|
+
{
|
|
215
|
+
return isNotRet;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
inline const BasicBlock* getExitBB() const
|
|
219
|
+
{
|
|
220
|
+
return this->exitBB;
|
|
221
|
+
}
|
|
222
|
+
|
|
173
223
|
// Dump Control Flow Graph of llvm function, with instructions
|
|
174
224
|
void viewCFG();
|
|
175
225
|
|
|
@@ -65,6 +65,16 @@ private:
|
|
|
65
65
|
GlobalSetType GlobalSet; ///< The Global Variables in the module
|
|
66
66
|
AliasSetType AliasSet; ///< The Aliases in the module
|
|
67
67
|
LLVMFun2SVFFunMap LLVMFunc2SVFFunc; ///< Map an LLVM Function to an SVF Function
|
|
68
|
+
Set<const Value*> argsOfUncalledFunction;
|
|
69
|
+
Set<const Instruction*> returnInsts;
|
|
70
|
+
Set<const Value*> nullPtrSyms;
|
|
71
|
+
Set<const Value*> blackholeSyms;
|
|
72
|
+
Set<const Value*> ptrsInUncalledFunctions;
|
|
73
|
+
Map<const BasicBlock*, const u32_t> bbSuccessorNumMap;
|
|
74
|
+
Map<const PointerType*, const Type*> ptrElementTypeMap;
|
|
75
|
+
Map<const BasicBlock*, const Map<const BasicBlock*, const u32_t>> bbSuccessorPosMap;
|
|
76
|
+
Map<const BasicBlock*, const Map<const BasicBlock*, const u32_t>> bbPredecessorPosMap;
|
|
77
|
+
|
|
68
78
|
public:
|
|
69
79
|
/// Constructors
|
|
70
80
|
SVFModule(std::string moduleName = "") : moduleIdentifier(moduleName)
|
|
@@ -101,12 +111,11 @@ public:
|
|
|
101
111
|
void buildSymbolTableInfo();
|
|
102
112
|
|
|
103
113
|
///@{
|
|
104
|
-
inline void addFunctionSet(
|
|
114
|
+
inline void addFunctionSet(SVFFunction* svfFunc)
|
|
105
115
|
{
|
|
106
|
-
SVFFunction* svfFunc = new SVFFunction(fun);
|
|
107
116
|
FunctionSet.push_back(svfFunc);
|
|
108
|
-
LLVMFunctionSet.push_back(
|
|
109
|
-
LLVMFunc2SVFFunc[
|
|
117
|
+
LLVMFunctionSet.push_back(svfFunc->getLLVMFun());
|
|
118
|
+
LLVMFunc2SVFFunc[svfFunc->getLLVMFun()] = svfFunc;
|
|
110
119
|
}
|
|
111
120
|
inline void addGlobalSet(GlobalVariable* glob)
|
|
112
121
|
{
|
|
@@ -209,6 +218,125 @@ public:
|
|
|
209
218
|
}
|
|
210
219
|
}
|
|
211
220
|
|
|
221
|
+
inline const FunctionSetType& getFunctionSet() const
|
|
222
|
+
{
|
|
223
|
+
return FunctionSet;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
inline const Set<const Value*>& getNullPtrSyms() const
|
|
227
|
+
{
|
|
228
|
+
return nullPtrSyms;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
inline const Set<const Value*>& getBlackholeSyms() const
|
|
232
|
+
{
|
|
233
|
+
return blackholeSyms;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
inline const Set<const Value*>& getArgsOfUncalledFunction() const
|
|
237
|
+
{
|
|
238
|
+
return argsOfUncalledFunction;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
inline const Set<const Instruction*>& getReturns() const
|
|
242
|
+
{
|
|
243
|
+
return returnInsts;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
inline const Set<const Value*>& getPtrsInUncalledFunctions() const
|
|
247
|
+
{
|
|
248
|
+
return ptrsInUncalledFunctions;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
inline const Map<const BasicBlock*, const u32_t>& getBBSuccessorNumMap()
|
|
252
|
+
{
|
|
253
|
+
return bbSuccessorNumMap;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
inline const Map<const BasicBlock*, const Map<const BasicBlock*, const u32_t>>& getBBSuccessorPosMap()
|
|
257
|
+
{
|
|
258
|
+
return bbSuccessorPosMap;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
inline const Map<const BasicBlock*, const Map<const BasicBlock*, const u32_t>>& getBBPredecessorPosMap()
|
|
262
|
+
{
|
|
263
|
+
return bbPredecessorPosMap;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
inline const Map<const PointerType*, const Type*>& getPtrElementTypeMap()
|
|
267
|
+
{
|
|
268
|
+
return ptrElementTypeMap;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
inline void addBBSuccessorNum(const BasicBlock *bb, const u32_t num)
|
|
272
|
+
{
|
|
273
|
+
bbSuccessorNumMap.insert({bb,num});
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
inline void addBBSuccessorPos(const BasicBlock *bb, const BasicBlock* succ,const u32_t pos)
|
|
277
|
+
{
|
|
278
|
+
Map<const BasicBlock*, const Map<const BasicBlock*, const u32_t>>::iterator bbSuccessorPosMapIter = bbSuccessorPosMap.find(bb);
|
|
279
|
+
if(bbSuccessorPosMapIter != bbSuccessorPosMap.end())
|
|
280
|
+
{
|
|
281
|
+
Map<const BasicBlock*, const u32_t> foundValue = bbSuccessorPosMapIter->second;
|
|
282
|
+
foundValue.insert({succ,pos});
|
|
283
|
+
bbSuccessorPosMap.insert({bb,foundValue});
|
|
284
|
+
}
|
|
285
|
+
else
|
|
286
|
+
{
|
|
287
|
+
Map<const BasicBlock*, const u32_t> valueMap;
|
|
288
|
+
valueMap.insert({succ,pos});
|
|
289
|
+
bbSuccessorPosMap.insert({bb,valueMap});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
inline void addBBPredecessorPos(const BasicBlock *bb, const BasicBlock* Pred,const u32_t pos)
|
|
294
|
+
{
|
|
295
|
+
Map<const BasicBlock*, const Map<const BasicBlock*, const u32_t>>::iterator bbPredecessorPosMapIter = bbPredecessorPosMap.find(bb);
|
|
296
|
+
if(bbPredecessorPosMapIter != bbPredecessorPosMap.end())
|
|
297
|
+
{
|
|
298
|
+
Map<const BasicBlock*, const u32_t> foundValue = bbPredecessorPosMapIter->second;
|
|
299
|
+
foundValue.insert({Pred,pos});
|
|
300
|
+
bbPredecessorPosMap.insert({bb,foundValue});
|
|
301
|
+
}
|
|
302
|
+
else
|
|
303
|
+
{
|
|
304
|
+
Map<const BasicBlock*, const u32_t> valueMap;
|
|
305
|
+
valueMap.insert({Pred,pos});
|
|
306
|
+
bbPredecessorPosMap.insert({bb,valueMap});
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
inline void addptrElementType(const PointerType* ptrType, const Type* type)
|
|
311
|
+
{
|
|
312
|
+
ptrElementTypeMap.insert({ptrType, type});
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
inline void addPtrInUncalledFunction (const Value * value)
|
|
316
|
+
{
|
|
317
|
+
ptrsInUncalledFunctions.insert(value);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
inline void addNullPtrSyms(const Value *val)
|
|
321
|
+
{
|
|
322
|
+
nullPtrSyms.insert(val);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
inline void addBlackholeSyms(const Value *val)
|
|
326
|
+
{
|
|
327
|
+
blackholeSyms.insert(val);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
inline void addArgsOfUncalledFunction(const Value *val)
|
|
331
|
+
{
|
|
332
|
+
argsOfUncalledFunction.insert(val);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
inline void addReturn(const Instruction* inst)
|
|
336
|
+
{
|
|
337
|
+
returnInsts.insert(inst);
|
|
338
|
+
}
|
|
339
|
+
|
|
212
340
|
};
|
|
213
341
|
|
|
214
342
|
} // End namespace SVF
|