svf-lib 1.0.1234 → 1.0.1235
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/MSSA/MemSSA.h +1 -16
- package/SVF-osx/include/MSSA/SVFGBuilder.h +0 -17
- package/SVF-osx/include/SABER/SaberCondAllocator.h +14 -6
- package/SVF-osx/include/SVF-FE/BasicTypes.h +9 -0
- package/SVF-osx/include/SVF-FE/LLVMModule.h +6 -28
- package/SVF-osx/include/Util/BasicTypes.h +100 -7
- package/SVF-osx/include/Util/SVFUtil.h +1 -1
- package/package.json +1 -1
|
Binary file
|
|
@@ -120,8 +120,6 @@ public:
|
|
|
120
120
|
protected:
|
|
121
121
|
BVDataPTAImpl* pta;
|
|
122
122
|
MRGenerator* mrGen;
|
|
123
|
-
DominanceFrontier* df;
|
|
124
|
-
DominatorTree* dt;
|
|
125
123
|
MemSSAStat* stat;
|
|
126
124
|
|
|
127
125
|
/// Create mu chi for candidate regions in a function
|
|
@@ -291,19 +289,6 @@ private:
|
|
|
291
289
|
phi->setOpVer(getTopStackVer(phi->getMR()), pos);
|
|
292
290
|
}
|
|
293
291
|
}
|
|
294
|
-
|
|
295
|
-
//@}
|
|
296
|
-
/// Get/set methods for dominace frontier/tree
|
|
297
|
-
//@{
|
|
298
|
-
DominanceFrontier* getDF(const SVFFunction&)
|
|
299
|
-
{
|
|
300
|
-
return df;
|
|
301
|
-
}
|
|
302
|
-
DominatorTree* getDT(const SVFFunction&)
|
|
303
|
-
{
|
|
304
|
-
return dt;
|
|
305
|
-
}
|
|
306
|
-
void setCurrentDFDT(DominanceFrontier* f, DominatorTree* t);
|
|
307
292
|
//@}
|
|
308
293
|
|
|
309
294
|
public:
|
|
@@ -328,7 +313,7 @@ public:
|
|
|
328
313
|
return mrGen;
|
|
329
314
|
}
|
|
330
315
|
/// We start from here
|
|
331
|
-
virtual void buildMemSSA(const SVFFunction& fun
|
|
316
|
+
virtual void buildMemSSA(const SVFFunction& fun);
|
|
332
317
|
|
|
333
318
|
/// Perform statistics
|
|
334
319
|
void performStat();
|
|
@@ -36,23 +36,6 @@
|
|
|
36
36
|
namespace SVF
|
|
37
37
|
{
|
|
38
38
|
|
|
39
|
-
/*!
|
|
40
|
-
* Dominator frontier used in MSSA
|
|
41
|
-
*/
|
|
42
|
-
class MemSSADF : public DominanceFrontier
|
|
43
|
-
{
|
|
44
|
-
public:
|
|
45
|
-
MemSSADF() : DominanceFrontier()
|
|
46
|
-
{}
|
|
47
|
-
|
|
48
|
-
bool runOnDT(DominatorTree& dt)
|
|
49
|
-
{
|
|
50
|
-
releaseMemory();
|
|
51
|
-
analyze(dt);
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
39
|
/*!
|
|
57
40
|
* SVFG Builder
|
|
58
41
|
*/
|
|
@@ -144,16 +144,24 @@ public:
|
|
|
144
144
|
return negConds.test(id);
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
|
|
148
|
-
inline DominatorTree* getDT(const Function* fun)
|
|
147
|
+
inline bool postDominate(const BasicBlock* bbKey, const BasicBlock* bbValue) const
|
|
149
148
|
{
|
|
150
|
-
|
|
149
|
+
const SVFFunction* keyFunc = LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(bbKey->getParent());
|
|
150
|
+
const SVFFunction* valueFunc = LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(bbValue->getParent());
|
|
151
|
+
assert((keyFunc == valueFunc) && "two basicblocks should be in the same function!");
|
|
152
|
+
|
|
153
|
+
return keyFunc->postDominate(bbKey,bbValue);
|
|
151
154
|
}
|
|
152
|
-
|
|
153
|
-
inline
|
|
155
|
+
|
|
156
|
+
inline bool dominate(const BasicBlock* bbKey, const BasicBlock* bbValue) const
|
|
154
157
|
{
|
|
155
|
-
|
|
158
|
+
const SVFFunction* keyFunc = LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(bbKey->getParent());
|
|
159
|
+
const SVFFunction* valueFunc = LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(bbValue->getParent());
|
|
160
|
+
assert((keyFunc == valueFunc) && "two basicblocks should be in the same function!");
|
|
161
|
+
|
|
162
|
+
return keyFunc->dominate(bbKey,bbValue);
|
|
156
163
|
}
|
|
164
|
+
|
|
157
165
|
/// Get LoopInfo
|
|
158
166
|
inline LoopInfo* getLoopInfo(const Function* f)
|
|
159
167
|
{
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
#include <llvm/IR/DerivedTypes.h>
|
|
18
18
|
|
|
19
19
|
#include <llvm/Analysis/MemoryLocation.h>
|
|
20
|
+
#include <llvm/Analysis/DominanceFrontier.h>
|
|
21
|
+
#include <llvm/Analysis/PostDominators.h>
|
|
20
22
|
#include <llvm/Analysis/ScalarEvolution.h>
|
|
21
23
|
#include <llvm/Analysis/ScalarEvolutionExpressions.h>
|
|
22
24
|
|
|
@@ -64,6 +66,13 @@ typedef llvm::ConstantData ConstantData;
|
|
|
64
66
|
typedef llvm::ConstantArray ConstantArray;
|
|
65
67
|
typedef llvm::Constant Constant;
|
|
66
68
|
|
|
69
|
+
/// LLVM Dominators
|
|
70
|
+
typedef llvm::DominatorTree DominatorTree;
|
|
71
|
+
typedef llvm::DomTreeNode DomTreeNode;
|
|
72
|
+
typedef llvm::DominanceFrontier DominanceFrontier;
|
|
73
|
+
typedef llvm::PostDominatorTree PostDominatorTree;
|
|
74
|
+
typedef llvm::DominanceFrontierBase<llvm::BasicBlock, false> DominanceFrontierBase;
|
|
75
|
+
|
|
67
76
|
// LLVM Instructions
|
|
68
77
|
typedef llvm::AllocaInst AllocaInst;
|
|
69
78
|
typedef llvm::AtomicCmpXchgInst AtomicCmpXchgInst;
|
|
@@ -42,9 +42,9 @@ class LLVMModuleSet
|
|
|
42
42
|
{
|
|
43
43
|
public:
|
|
44
44
|
|
|
45
|
-
typedef std::vector<const
|
|
46
|
-
typedef Map<const
|
|
47
|
-
typedef Map<const
|
|
45
|
+
typedef std::vector<const Function*> FunctionSetType;
|
|
46
|
+
typedef Map<const Function*, const Function*> FunDeclToDefMapTy;
|
|
47
|
+
typedef Map<const Function*, FunctionSetType> FunDefToDeclsMapTy;
|
|
48
48
|
typedef Map<const GlobalVariable*, GlobalVariable*> GlobalDefToRepMapTy;
|
|
49
49
|
|
|
50
50
|
private:
|
|
@@ -133,25 +133,14 @@ public:
|
|
|
133
133
|
return nullptr;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
/// Fun decl --> def
|
|
137
136
|
bool hasDefinition(const Function *fun) const
|
|
138
|
-
{
|
|
139
|
-
return hasDefinition(svfModule->getSVFFunction(fun));
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
bool hasDefinition(const SVFFunction *fun) const
|
|
143
137
|
{
|
|
144
138
|
assert(fun->isDeclaration() && "not a function declaration?");
|
|
145
139
|
FunDeclToDefMapTy::const_iterator it = FunDeclToDefMap.find(fun);
|
|
146
140
|
return it != FunDeclToDefMap.end();
|
|
147
141
|
}
|
|
148
142
|
|
|
149
|
-
const
|
|
150
|
-
{
|
|
151
|
-
return getDefinition(svfModule->getSVFFunction(fun));
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const SVFFunction *getDefinition(const SVFFunction *fun) const
|
|
143
|
+
const Function *getDefinition(const Function *fun) const
|
|
155
144
|
{
|
|
156
145
|
assert(fun->isDeclaration() && "not a function declaration?");
|
|
157
146
|
FunDeclToDefMapTy::const_iterator it = FunDeclToDefMap.find(fun);
|
|
@@ -159,18 +148,12 @@ public:
|
|
|
159
148
|
return it->second;
|
|
160
149
|
}
|
|
161
150
|
|
|
162
|
-
/// Fun def --> decl
|
|
163
151
|
bool hasDeclaration(const Function *fun) const
|
|
164
|
-
{
|
|
165
|
-
return hasDeclaration(svfModule->getSVFFunction(fun));
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
bool hasDeclaration(const SVFFunction *fun) const
|
|
169
152
|
{
|
|
170
153
|
if(fun->isDeclaration() && !hasDefinition(fun))
|
|
171
154
|
return false;
|
|
172
155
|
|
|
173
|
-
const
|
|
156
|
+
const Function* funDef = fun;
|
|
174
157
|
if(fun->isDeclaration() && hasDefinition(fun))
|
|
175
158
|
funDef = getDefinition(fun);
|
|
176
159
|
|
|
@@ -180,12 +163,7 @@ public:
|
|
|
180
163
|
|
|
181
164
|
const FunctionSetType& getDeclaration(const Function *fun) const
|
|
182
165
|
{
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const FunctionSetType& getDeclaration(const SVFFunction *fun) const
|
|
187
|
-
{
|
|
188
|
-
const SVFFunction* funDef = fun;
|
|
166
|
+
const Function* funDef = fun;
|
|
189
167
|
if(fun->isDeclaration() && hasDefinition(fun))
|
|
190
168
|
funDef = getDefinition(fun);
|
|
191
169
|
|
|
@@ -103,12 +103,6 @@ typedef llvm::CallInst CallInst;
|
|
|
103
103
|
typedef llvm::StoreInst StoreInst;
|
|
104
104
|
typedef llvm::LoadInst LoadInst;
|
|
105
105
|
|
|
106
|
-
/// LLVM Dominators
|
|
107
|
-
typedef llvm::DominanceFrontier DominanceFrontier;
|
|
108
|
-
typedef llvm::DominatorTree DominatorTree;
|
|
109
|
-
typedef llvm::PostDominatorTree PostDominatorTree;
|
|
110
|
-
typedef llvm::DomTreeNode DomTreeNode;
|
|
111
|
-
typedef llvm::DominanceFrontierBase<BasicBlock, false> DominanceFrontierBase;
|
|
112
106
|
|
|
113
107
|
/// LLVM Iterators
|
|
114
108
|
#if LLVM_VERSION_MAJOR >= 11
|
|
@@ -132,6 +126,9 @@ private:
|
|
|
132
126
|
std::vector<const BasicBlock*> reachableBBs;
|
|
133
127
|
bool isUncalled;
|
|
134
128
|
bool isNotRet;
|
|
129
|
+
Map<const BasicBlock*,Set<const BasicBlock*>> dtBBsMap;
|
|
130
|
+
Map<const BasicBlock*,Set<const BasicBlock*>> dfBBsMap;
|
|
131
|
+
Map<const BasicBlock*,Set<const BasicBlock*>> pdtBBsMap;
|
|
135
132
|
public:
|
|
136
133
|
SVFFunction(const std::string& val): SVFValue(val,SVFValue::SVFFunc),
|
|
137
134
|
isDecl(false), isIntri(false), fun(nullptr), exitBB(nullptr), isUncalled(false), isNotRet(false)
|
|
@@ -209,7 +206,42 @@ public:
|
|
|
209
206
|
this->reachableBBs = reachableBBs;
|
|
210
207
|
}
|
|
211
208
|
|
|
212
|
-
inline const
|
|
209
|
+
inline const Map<const BasicBlock*,Set<const BasicBlock*>>& getDomFrontierMap() const
|
|
210
|
+
{
|
|
211
|
+
return dfBBsMap;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
inline Map<const BasicBlock*,Set<const BasicBlock*>>& getDomFrontierMap()
|
|
215
|
+
{
|
|
216
|
+
return dfBBsMap;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
inline const Map<const BasicBlock*,Set<const BasicBlock*>>& getPostDomTreeMap() const
|
|
220
|
+
{
|
|
221
|
+
return pdtBBsMap;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
inline Map<const BasicBlock*,Set<const BasicBlock*>>& getPostDomTreeMap()
|
|
225
|
+
{
|
|
226
|
+
return pdtBBsMap;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
inline Map<const BasicBlock*,Set<const BasicBlock*>>& getDomTreeMap()
|
|
230
|
+
{
|
|
231
|
+
return dtBBsMap;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
inline const Map<const BasicBlock*,Set<const BasicBlock*>>& getDomTreeMap() const
|
|
235
|
+
{
|
|
236
|
+
return dtBBsMap;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
inline bool isUnreachable(const BasicBlock* bb) const
|
|
240
|
+
{
|
|
241
|
+
return std::find(reachableBBs.begin(), reachableBBs.end(), bb)==reachableBBs.end();
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
inline bool isNotRetFunction() const
|
|
213
245
|
{
|
|
214
246
|
return isNotRet;
|
|
215
247
|
}
|
|
@@ -219,6 +251,67 @@ public:
|
|
|
219
251
|
return this->exitBB;
|
|
220
252
|
}
|
|
221
253
|
|
|
254
|
+
bool dominate(const BasicBlock* bbKey, const BasicBlock* bbValue) const
|
|
255
|
+
{
|
|
256
|
+
if (bbKey == bbValue)
|
|
257
|
+
return true;
|
|
258
|
+
|
|
259
|
+
// An unreachable node is dominated by anything.
|
|
260
|
+
if (isUnreachable(bbValue))
|
|
261
|
+
{
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// And dominates nothing.
|
|
266
|
+
if (isUnreachable(bbKey))
|
|
267
|
+
{
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
const Map<const BasicBlock*,Set<const BasicBlock*>>& dtBBsMap = getDomTreeMap();
|
|
272
|
+
Map<const BasicBlock*,Set<const BasicBlock*>>::const_iterator mapIter = dtBBsMap.find(bbKey);
|
|
273
|
+
if (mapIter != dtBBsMap.end())
|
|
274
|
+
{
|
|
275
|
+
const Set<const BasicBlock*> & dtBBs = mapIter->second;
|
|
276
|
+
if (dtBBs.find(bbValue) != dtBBs.end())
|
|
277
|
+
{
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
bool postDominate(const BasicBlock* bbKey, const BasicBlock* bbValue) const
|
|
286
|
+
{
|
|
287
|
+
if (bbKey == bbValue)
|
|
288
|
+
return true;
|
|
289
|
+
|
|
290
|
+
// An unreachable node is dominated by anything.
|
|
291
|
+
if (isUnreachable(bbValue))
|
|
292
|
+
{
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// And dominates nothing.
|
|
297
|
+
if (isUnreachable(bbKey))
|
|
298
|
+
{
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const Map<const BasicBlock*,Set<const BasicBlock*>>& dtBBsMap = getPostDomTreeMap();
|
|
303
|
+
Map<const BasicBlock*,Set<const BasicBlock*>>::const_iterator mapIter = dtBBsMap.find(bbKey);
|
|
304
|
+
if (mapIter != dtBBsMap.end())
|
|
305
|
+
{
|
|
306
|
+
const Set<const BasicBlock*> & dtBBs = mapIter->second;
|
|
307
|
+
if (dtBBs.find(bbValue) != dtBBs.end())
|
|
308
|
+
{
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
|
|
222
315
|
// Dump Control Flow Graph of llvm function, with instructions
|
|
223
316
|
void viewCFG();
|
|
224
317
|
|
|
@@ -260,7 +260,7 @@ inline const SVFFunction* getDefFunForMultipleModule(const Function* fun)
|
|
|
260
260
|
LLVMModuleSet* llvmModuleset = LLVMModuleSet::getLLVMModuleSet();
|
|
261
261
|
const SVFFunction* svfFun = llvmModuleset->getSVFFunction(fun);
|
|
262
262
|
if (fun->isDeclaration() && llvmModuleset->hasDefinition(fun))
|
|
263
|
-
svfFun = LLVMModuleSet::getLLVMModuleSet()->getDefinition(fun);
|
|
263
|
+
svfFun = llvmModuleset->getSVFFunction(LLVMModuleSet::getLLVMModuleSet()->getDefinition(fun));
|
|
264
264
|
return svfFun;
|
|
265
265
|
}
|
|
266
266
|
|