svf-lib 1.0.729 → 1.0.733
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/DDA/DDAVFSolver.h +1 -1
- package/SVF-linux/include/Graphs/PAG.h +4 -4
- package/SVF-linux/include/Graphs/PAGNode.h +3 -3
- package/SVF-linux/include/MemoryModel/SVFIR.h +1 -1
- package/SVF-linux/include/MemoryModel/SVFSymbols.h +648 -0
- package/SVF-linux/include/MemoryModel/SymbolTableInfo.h +26 -14
- package/SVF-linux/include/SVF-FE/SymbolTableBuilder.h +1 -1
- 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/DDA/ContextDDA.h +1 -1
- package/SVF-osx/include/DDA/DDAClient.h +8 -8
- package/SVF-osx/include/DDA/DDAVFSolver.h +6 -6
- package/SVF-osx/include/DDA/FlowDDA.h +1 -1
- package/SVF-osx/include/Graphs/ConsG.h +6 -6
- package/SVF-osx/include/Graphs/ConsGEdge.h +2 -2
- package/SVF-osx/include/Graphs/ConsGNode.h +1 -1
- package/SVF-osx/include/Graphs/ExternalPAG.h +14 -14
- package/SVF-osx/include/Graphs/ICFGNode.h +14 -14
- package/SVF-osx/include/Graphs/IRGraph.h +245 -0
- package/SVF-osx/include/Graphs/OfflineConsG.h +1 -1
- package/SVF-osx/include/Graphs/PAG.h +4 -4
- package/SVF-osx/include/Graphs/PAGNode.h +4 -4
- package/SVF-osx/include/Graphs/SVFG.h +1 -1
- package/SVF-osx/include/Graphs/SVFGOPT.h +3 -3
- package/SVF-osx/include/Graphs/VFG.h +19 -19
- package/SVF-osx/include/Graphs/VFGNode.h +2 -3
- package/SVF-osx/include/MSSA/MemRegion.h +11 -11
- package/SVF-osx/include/MSSA/MemSSA.h +4 -4
- package/SVF-osx/include/MTA/FSMPTA.h +1 -1
- package/SVF-osx/include/MemoryModel/LocationSet.h +0 -1
- package/SVF-osx/include/MemoryModel/PAGBuilderFromFile.h +8 -8
- package/SVF-osx/include/MemoryModel/PTAStat.h +31 -31
- package/SVF-osx/include/MemoryModel/PointerAnalysis.h +9 -9
- package/SVF-osx/include/MemoryModel/PointerAnalysisImpl.h +3 -3
- package/SVF-osx/include/MemoryModel/SVFIR.h +738 -0
- package/SVF-osx/include/MemoryModel/SVFStatements.h +738 -0
- package/SVF-osx/include/MemoryModel/SVFSymbols.h +648 -0
- package/SVF-osx/include/MemoryModel/SVFVariables.h +842 -0
- package/SVF-osx/include/MemoryModel/SymbolTableInfo.h +731 -0
- package/SVF-osx/include/SABER/SaberSVFGBuilder.h +0 -2
- package/SVF-osx/include/SABER/SrcSnkDDA.h +3 -3
- package/SVF-osx/include/SVF-FE/Graph2Json.h +1 -3
- package/SVF-osx/include/SVF-FE/SVFIRBuilder.h +392 -0
- package/SVF-osx/include/SVF-FE/SymbolTableBuilder.h +89 -0
- package/SVF-osx/include/Util/BasicTypes.h +0 -10
- package/SVF-osx/include/Util/CFLSolver.h +1 -1
- package/SVF-osx/include/Util/ExtAPI.h +1 -1
- package/SVF-osx/include/Util/IRAnnotator.h +6 -6
- package/SVF-osx/include/Util/Options.h +1 -1
- package/SVF-osx/include/Util/SVFUtil.h +11 -0
- package/SVF-osx/include/Util/TypeBasedHeapCloning.h +11 -11
- package/SVF-osx/include/WPA/Andersen.h +11 -100
- package/SVF-osx/include/WPA/AndersenSFR.h +4 -4
- package/SVF-osx/include/WPA/FlowSensitive.h +2 -2
- package/SVF-osx/include/WPA/FlowSensitiveTBHC.h +1 -1
- package/SVF-osx/include/WPA/Steensgaard.h +2 -2
- package/SVF-osx/include/WPA/TypeAnalysis.h +1 -1
- package/SVF-osx/include/WPA/VersionedFlowSensitive.h +2 -2
- package/SVF-osx/include/WPA/WPAStat.h +1 -2
- package/package.json +1 -1
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
#ifndef INCLUDE_SVF_FE_GRAPH2JSON_H_
|
|
2
2
|
#define INCLUDE_SVF_FE_GRAPH2JSON_H_
|
|
3
3
|
|
|
4
|
-
#include "
|
|
5
|
-
#include "Graphs/PAGEdge.h"
|
|
6
|
-
#include "Graphs/PAGNode.h"
|
|
4
|
+
#include "MemoryModel/SVFIR.h"
|
|
7
5
|
#include "Graphs/ICFG.h"
|
|
8
6
|
#include "Graphs/ICFGNode.h"
|
|
9
7
|
#include "Graphs/ICFGEdge.h"
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
//===- SVFIRBuilder.h -- Building SVFIR-------------------------------------------//
|
|
2
|
+
//
|
|
3
|
+
// SVF: Static Value-Flow Analysis
|
|
4
|
+
//
|
|
5
|
+
// Copyright (C) <2013-2017> <Yulei Sui>
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
// This program is free software: you can redistribute it and/or modify
|
|
9
|
+
// it under the terms of the GNU General Public License as published by
|
|
10
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
// (at your option) any later version.
|
|
12
|
+
|
|
13
|
+
// This program is distributed in the hope that it will be useful,
|
|
14
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
// GNU General Public License for more details.
|
|
17
|
+
|
|
18
|
+
// You should have received a copy of the GNU General Public License
|
|
19
|
+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
//
|
|
21
|
+
//===----------------------------------------------------------------------===//
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
* SVFIRBuilder.h
|
|
25
|
+
*
|
|
26
|
+
* Created on: Nov 1, 2013
|
|
27
|
+
* Author: Yulei Sui
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
#ifndef PAGBUILDER_H_
|
|
31
|
+
#define PAGBUILDER_H_
|
|
32
|
+
|
|
33
|
+
#include "MemoryModel/SVFIR.h"
|
|
34
|
+
#include "Util/ExtAPI.h"
|
|
35
|
+
#include "SVF-FE/ICFGBuilder.h"
|
|
36
|
+
|
|
37
|
+
namespace SVF
|
|
38
|
+
{
|
|
39
|
+
|
|
40
|
+
class SVFModule;
|
|
41
|
+
/*!
|
|
42
|
+
* SVFIR Builder to create SVF variables and statements and PAG
|
|
43
|
+
*/
|
|
44
|
+
class SVFIRBuilder: public llvm::InstVisitor<SVFIRBuilder>
|
|
45
|
+
{
|
|
46
|
+
|
|
47
|
+
private:
|
|
48
|
+
SVFIR* pag;
|
|
49
|
+
SVFModule* svfMod;
|
|
50
|
+
const BasicBlock* curBB; ///< Current basic block during SVFIR construction when visiting the module
|
|
51
|
+
const Value* curVal; ///< Current Value during SVFIR construction when visiting the module
|
|
52
|
+
|
|
53
|
+
public:
|
|
54
|
+
/// Constructor
|
|
55
|
+
SVFIRBuilder(): pag(SVFIR::getPAG()), svfMod(nullptr), curBB(nullptr),curVal(nullptr)
|
|
56
|
+
{
|
|
57
|
+
}
|
|
58
|
+
/// Destructor
|
|
59
|
+
virtual ~SVFIRBuilder()
|
|
60
|
+
{
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/// Start building SVFIR here
|
|
64
|
+
virtual SVFIR* build(SVFModule* svfModule);
|
|
65
|
+
|
|
66
|
+
/// Return SVFIR
|
|
67
|
+
SVFIR* getPAG() const
|
|
68
|
+
{
|
|
69
|
+
return pag;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/// Initialize nodes and edges
|
|
73
|
+
//@{
|
|
74
|
+
void initialiseNodes();
|
|
75
|
+
void addEdge(NodeID src, NodeID dst, PAGEdge::PEDGEK kind,
|
|
76
|
+
Size_t offset = 0, Instruction* cs = nullptr);
|
|
77
|
+
// @}
|
|
78
|
+
|
|
79
|
+
/// Sanity check for SVFIR
|
|
80
|
+
void sanityCheck();
|
|
81
|
+
|
|
82
|
+
/// Get different kinds of node
|
|
83
|
+
//@{
|
|
84
|
+
// GetValNode - Return the value node according to a LLVM Value.
|
|
85
|
+
NodeID getValueNode(const Value *V)
|
|
86
|
+
{
|
|
87
|
+
// first handle gep edge if val if a constant expression
|
|
88
|
+
processCE(V);
|
|
89
|
+
|
|
90
|
+
// strip off the constant cast and return the value node
|
|
91
|
+
return pag->getValueNode(V);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/// GetObject - Return the object node (stack/global/heap/function) according to a LLVM Value
|
|
95
|
+
inline NodeID getObjectNode(const Value *V)
|
|
96
|
+
{
|
|
97
|
+
return pag->getObjectNode(V);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/// getReturnNode - Return the node representing the unique return value of a function.
|
|
101
|
+
inline NodeID getReturnNode(const SVFFunction *func)
|
|
102
|
+
{
|
|
103
|
+
return pag->getReturnNode(func);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/// getVarargNode - Return the node representing the unique variadic argument of a function.
|
|
107
|
+
inline NodeID getVarargNode(const SVFFunction *func)
|
|
108
|
+
{
|
|
109
|
+
return pag->getVarargNode(func);
|
|
110
|
+
}
|
|
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
|
+
/// Compute offset of a gep instruction or gep constant expression
|
|
125
|
+
bool computeGepOffset(const User *V, LocationSet& ls);
|
|
126
|
+
|
|
127
|
+
/// Handle direct call
|
|
128
|
+
void handleDirectCall(CallSite cs, const SVFFunction *F);
|
|
129
|
+
|
|
130
|
+
/// Handle indirect call
|
|
131
|
+
void handleIndCall(CallSite cs);
|
|
132
|
+
|
|
133
|
+
/// Handle external call
|
|
134
|
+
//@{
|
|
135
|
+
virtual void handleExtCall(CallSite cs, const SVFFunction *F);
|
|
136
|
+
const Type *getBaseTypeAndFlattenedFields(Value* v, std::vector<LocationSet> &fields);
|
|
137
|
+
void addComplexConsForExt(Value *D, Value *S,u32_t sz = 0);
|
|
138
|
+
//@}
|
|
139
|
+
|
|
140
|
+
/// Our visit overrides.
|
|
141
|
+
//@{
|
|
142
|
+
// Instructions that cannot be folded away.
|
|
143
|
+
virtual void visitAllocaInst(AllocaInst &AI);
|
|
144
|
+
void visitPHINode(PHINode &I);
|
|
145
|
+
void visitStoreInst(StoreInst &I);
|
|
146
|
+
void visitLoadInst(LoadInst &I);
|
|
147
|
+
void visitGetElementPtrInst(GetElementPtrInst &I);
|
|
148
|
+
void visitCallInst(CallInst &I)
|
|
149
|
+
{
|
|
150
|
+
visitCallSite(&I);
|
|
151
|
+
}
|
|
152
|
+
void visitInvokeInst(InvokeInst &II)
|
|
153
|
+
{
|
|
154
|
+
visitCallSite(&II);
|
|
155
|
+
}
|
|
156
|
+
void visitCallBrInst(CallBrInst &I) {
|
|
157
|
+
return visitCallSite(&I);
|
|
158
|
+
}
|
|
159
|
+
void visitCallSite(CallSite cs);
|
|
160
|
+
void visitReturnInst(ReturnInst &I);
|
|
161
|
+
void visitCastInst(CastInst &I);
|
|
162
|
+
void visitSelectInst(SelectInst &I);
|
|
163
|
+
void visitExtractValueInst(ExtractValueInst &EVI);
|
|
164
|
+
void visitBranchInst(BranchInst &I);
|
|
165
|
+
void visitSwitchInst(SwitchInst &I);
|
|
166
|
+
void visitInsertValueInst(InsertValueInst &I)
|
|
167
|
+
{
|
|
168
|
+
addBlackHoleAddrEdge(getValueNode(&I));
|
|
169
|
+
}
|
|
170
|
+
// TerminatorInst and UnwindInst have been removed since llvm-8.0.0
|
|
171
|
+
// void visitTerminatorInst(TerminatorInst &TI) {}
|
|
172
|
+
// void visitUnwindInst(UnwindInst &I) { /*returns void*/}
|
|
173
|
+
|
|
174
|
+
void visitBinaryOperator(BinaryOperator &I);
|
|
175
|
+
void visitUnaryOperator(UnaryOperator &I);
|
|
176
|
+
void visitCmpInst(CmpInst &I);
|
|
177
|
+
|
|
178
|
+
/// TODO: var arguments need to be handled.
|
|
179
|
+
/// https://llvm.org/docs/LangRef.html#id1911
|
|
180
|
+
void visitVAArgInst(VAArgInst&);
|
|
181
|
+
void visitVACopyInst(VACopyInst&){}
|
|
182
|
+
void visitVAEndInst(VAEndInst&){}
|
|
183
|
+
void visitVAStartInst(VAStartInst&){}
|
|
184
|
+
|
|
185
|
+
/// <result> = freeze ty <val>
|
|
186
|
+
/// If <val> is undef or poison, ‘freeze’ returns an arbitrary, but fixed value of type `ty`
|
|
187
|
+
/// Otherwise, this instruction is a no-op and returns the input <val>
|
|
188
|
+
void visitFreezeInst(FreezeInst& I);
|
|
189
|
+
|
|
190
|
+
void visitExtractElementInst(ExtractElementInst &I);
|
|
191
|
+
|
|
192
|
+
void visitInsertElementInst(InsertElementInst &I)
|
|
193
|
+
{
|
|
194
|
+
addBlackHoleAddrEdge(getValueNode(&I));
|
|
195
|
+
}
|
|
196
|
+
void visitShuffleVectorInst(ShuffleVectorInst &I)
|
|
197
|
+
{
|
|
198
|
+
addBlackHoleAddrEdge(getValueNode(&I));
|
|
199
|
+
}
|
|
200
|
+
void visitLandingPadInst(LandingPadInst &I)
|
|
201
|
+
{
|
|
202
|
+
addBlackHoleAddrEdge(getValueNode(&I));
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/// Instruction not that often
|
|
206
|
+
void visitResumeInst(ResumeInst&) /*returns void*/
|
|
207
|
+
{
|
|
208
|
+
}
|
|
209
|
+
void visitUnreachableInst(UnreachableInst&) /*returns void*/
|
|
210
|
+
{
|
|
211
|
+
}
|
|
212
|
+
void visitFenceInst(FenceInst &I) /*returns void*/
|
|
213
|
+
{
|
|
214
|
+
addBlackHoleAddrEdge(getValueNode(&I));
|
|
215
|
+
}
|
|
216
|
+
void visitAtomicCmpXchgInst(AtomicCmpXchgInst &I)
|
|
217
|
+
{
|
|
218
|
+
addBlackHoleAddrEdge(getValueNode(&I));
|
|
219
|
+
}
|
|
220
|
+
void visitAtomicRMWInst(AtomicRMWInst &I)
|
|
221
|
+
{
|
|
222
|
+
addBlackHoleAddrEdge(getValueNode(&I));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/// Provide base case for our instruction visit.
|
|
226
|
+
inline void visitInstruction(Instruction&)
|
|
227
|
+
{
|
|
228
|
+
// If a new instruction is added to LLVM that we don't handle.
|
|
229
|
+
// TODO: ignore here:
|
|
230
|
+
}
|
|
231
|
+
//}@
|
|
232
|
+
|
|
233
|
+
/// Set current basic block in order to keep track of control flow information
|
|
234
|
+
inline void setCurrentLocation(const Value* val, const BasicBlock* bb)
|
|
235
|
+
{
|
|
236
|
+
curBB = bb;
|
|
237
|
+
curVal = val;
|
|
238
|
+
}
|
|
239
|
+
inline const Value *getCurrentValue() const
|
|
240
|
+
{
|
|
241
|
+
return curVal;
|
|
242
|
+
}
|
|
243
|
+
inline const BasicBlock *getCurrentBB() const
|
|
244
|
+
{
|
|
245
|
+
return curBB;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/// Add global black hole Address edge
|
|
249
|
+
void addGlobalBlackHoleAddrEdge(NodeID node, const ConstantExpr *int2Ptrce)
|
|
250
|
+
{
|
|
251
|
+
const Value* cval = getCurrentValue();
|
|
252
|
+
const BasicBlock* cbb = getCurrentBB();
|
|
253
|
+
setCurrentLocation(int2Ptrce,nullptr);
|
|
254
|
+
addBlackHoleAddrEdge(node);
|
|
255
|
+
setCurrentLocation(cval,cbb);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/// Add NullPtr PAGNode
|
|
259
|
+
inline NodeID addNullPtrNode()
|
|
260
|
+
{
|
|
261
|
+
NodeID nullPtr = pag->addDummyValNode(pag->getNullPtr());
|
|
262
|
+
/// let all undef value or non-determined pointers points-to black hole
|
|
263
|
+
LLVMContext &cxt = LLVMModuleSet::getLLVMModuleSet()->getContext();
|
|
264
|
+
ConstantPointerNull *constNull = ConstantPointerNull::get(Type::getInt8PtrTy(cxt));
|
|
265
|
+
setCurrentLocation(constNull, nullptr);
|
|
266
|
+
addBlackHoleAddrEdge(pag->getBlkPtr());
|
|
267
|
+
return nullPtr;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
NodeID getGepValNode(const Value* val, const LocationSet& ls, const Type *baseType, u32_t fieldidx);
|
|
271
|
+
|
|
272
|
+
void setCurrentBBAndValueForPAGEdge(PAGEdge* edge);
|
|
273
|
+
|
|
274
|
+
inline PAGEdge* addBlackHoleAddrEdge(NodeID node)
|
|
275
|
+
{
|
|
276
|
+
PAGEdge *edge = pag->addBlackHoleAddrPE(node);
|
|
277
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
278
|
+
return edge;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/// Add Address edge
|
|
282
|
+
inline AddrPE* addAddrEdge(NodeID src, NodeID dst)
|
|
283
|
+
{
|
|
284
|
+
AddrPE *edge = pag->addAddrPE(src, dst);
|
|
285
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
286
|
+
return edge;
|
|
287
|
+
}
|
|
288
|
+
/// Add Copy edge
|
|
289
|
+
inline CopyPE* addCopyEdge(NodeID src, NodeID dst)
|
|
290
|
+
{
|
|
291
|
+
CopyPE *edge = pag->addCopyPE(src, dst);
|
|
292
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
293
|
+
return edge;
|
|
294
|
+
}
|
|
295
|
+
/// Add Copy edge
|
|
296
|
+
inline CmpPE* addCmpEdge(NodeID src, NodeID dst)
|
|
297
|
+
{
|
|
298
|
+
CmpPE *edge = pag->addCmpPE(src, dst);
|
|
299
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
300
|
+
return edge;
|
|
301
|
+
}
|
|
302
|
+
/// Add Copy edge
|
|
303
|
+
inline BinaryOPPE* addBinaryOPEdge(NodeID src, NodeID dst)
|
|
304
|
+
{
|
|
305
|
+
BinaryOPPE *edge = pag->addBinaryOPPE(src, dst);
|
|
306
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
307
|
+
return edge;
|
|
308
|
+
}
|
|
309
|
+
/// Add Unary edge
|
|
310
|
+
inline UnaryOPPE* addUnaryOPEdge(NodeID src, NodeID dst)
|
|
311
|
+
{
|
|
312
|
+
UnaryOPPE *edge = pag->addUnaryOPPE(src, dst);
|
|
313
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
314
|
+
return edge;
|
|
315
|
+
}
|
|
316
|
+
/// Add Load edge
|
|
317
|
+
inline LoadPE* addLoadEdge(NodeID src, NodeID dst)
|
|
318
|
+
{
|
|
319
|
+
LoadPE *edge = pag->addLoadPE(src, dst);
|
|
320
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
321
|
+
return edge;
|
|
322
|
+
}
|
|
323
|
+
/// Add Store edge
|
|
324
|
+
inline StorePE* addStoreEdge(NodeID src, NodeID dst)
|
|
325
|
+
{
|
|
326
|
+
IntraBlockNode* node;
|
|
327
|
+
if(const Instruction* inst = SVFUtil::dyn_cast<Instruction>(curVal))
|
|
328
|
+
node = pag->getICFG()->getIntraBlockNode(inst);
|
|
329
|
+
else
|
|
330
|
+
node = nullptr;
|
|
331
|
+
StorePE *edge = pag->addStorePE(src, dst, node);
|
|
332
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
333
|
+
return edge;
|
|
334
|
+
}
|
|
335
|
+
/// Add Call edge
|
|
336
|
+
inline CallPE* addCallEdge(NodeID src, NodeID dst, const CallBlockNode* cs)
|
|
337
|
+
{
|
|
338
|
+
CallPE *edge = pag->addCallPE(src, dst, cs);
|
|
339
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
340
|
+
return edge;
|
|
341
|
+
}
|
|
342
|
+
/// Add Return edge
|
|
343
|
+
inline RetPE* addRetEdge(NodeID src, NodeID dst, const CallBlockNode* cs)
|
|
344
|
+
{
|
|
345
|
+
RetPE *edge = pag->addRetPE(src, dst, cs);
|
|
346
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
347
|
+
return edge;
|
|
348
|
+
}
|
|
349
|
+
/// Add Gep edge
|
|
350
|
+
inline GepPE* addGepEdge(NodeID src, NodeID dst, const LocationSet& ls, bool constGep)
|
|
351
|
+
{
|
|
352
|
+
GepPE *edge = pag->addGepPE(src, dst, ls, constGep);
|
|
353
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
354
|
+
return edge;
|
|
355
|
+
}
|
|
356
|
+
/// Add Offset(Gep) edge
|
|
357
|
+
inline NormalGepPE* addNormalGepEdge(NodeID src, NodeID dst, const LocationSet& ls)
|
|
358
|
+
{
|
|
359
|
+
NormalGepPE *edge = pag->addNormalGepPE(src, dst, ls);
|
|
360
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
361
|
+
return edge;
|
|
362
|
+
}
|
|
363
|
+
/// Add Variant(Gep) edge
|
|
364
|
+
inline VariantGepPE* addVariantGepEdge(NodeID src, NodeID dst)
|
|
365
|
+
{
|
|
366
|
+
VariantGepPE *edge = pag->addVariantGepPE(src, dst);
|
|
367
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
368
|
+
return edge;
|
|
369
|
+
}
|
|
370
|
+
/// Add Thread fork edge for parameter passing
|
|
371
|
+
inline TDForkPE* addThreadForkEdge(NodeID src, NodeID dst, const CallBlockNode* cs)
|
|
372
|
+
{
|
|
373
|
+
TDForkPE *edge = pag->addThreadForkPE(src, dst, cs);
|
|
374
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
375
|
+
return edge;
|
|
376
|
+
}
|
|
377
|
+
/// Add Thread join edge for parameter passing
|
|
378
|
+
inline TDJoinPE* addThreadJoinEdge(NodeID src, NodeID dst, const CallBlockNode* cs)
|
|
379
|
+
{
|
|
380
|
+
TDJoinPE *edge = pag->addThreadJoinPE(src, dst, cs);
|
|
381
|
+
setCurrentBBAndValueForPAGEdge(edge);
|
|
382
|
+
return edge;
|
|
383
|
+
}
|
|
384
|
+
//@}
|
|
385
|
+
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
typedef SVFIRBuilder PAGBuilder;
|
|
389
|
+
|
|
390
|
+
} // End namespace SVF
|
|
391
|
+
|
|
392
|
+
#endif /* PAGBUILDER_H_ */
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
//===- SymbolTableBuilder.h -- Symbol Table builder-----------------------//
|
|
2
|
+
//
|
|
3
|
+
// SVF: Static Value-Flow Analysis
|
|
4
|
+
//
|
|
5
|
+
// Copyright (C) <2013-> <Yulei Sui>
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
// This program is free software: you can redistribute it and/or modify
|
|
9
|
+
// it under the terms of the GNU General Public License as published by
|
|
10
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
// (at your option) any later version.
|
|
12
|
+
|
|
13
|
+
// This program is distributed in the hope that it will be useful,
|
|
14
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
// GNU General Public License for more details.
|
|
17
|
+
|
|
18
|
+
// You should have received a copy of the GNU General Public License
|
|
19
|
+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
//
|
|
21
|
+
//===----------------------------------------------------------------------===//
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
* SymbolTableBuilder.h
|
|
25
|
+
*
|
|
26
|
+
* Created on: Apr 28, 2014
|
|
27
|
+
* Author: Yulei
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
#ifndef SymbolTableBuilder_H_
|
|
31
|
+
#define SymbolTableBuilder_H_
|
|
32
|
+
|
|
33
|
+
#include "SVF-FE/LLVMModule.h"
|
|
34
|
+
#include "MemoryModel/SymbolTableInfo.h"
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
* This class is to build SymbolTableInfo, MemObjs and ObjTypeInfo
|
|
38
|
+
*/
|
|
39
|
+
namespace SVF
|
|
40
|
+
{
|
|
41
|
+
|
|
42
|
+
class SymbolTableBuilder
|
|
43
|
+
{
|
|
44
|
+
|
|
45
|
+
private:
|
|
46
|
+
SymbolTableInfo* symInfo;
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
/// Constructor
|
|
50
|
+
SymbolTableBuilder(SymbolTableInfo* si): symInfo(si){
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/// Start building memory model
|
|
54
|
+
void buildMemModel(SVFModule* svfModule);
|
|
55
|
+
|
|
56
|
+
/// collect the syms
|
|
57
|
+
//@{
|
|
58
|
+
void collectSym(const Value *val);
|
|
59
|
+
|
|
60
|
+
void collectVal(const Value *val);
|
|
61
|
+
|
|
62
|
+
void collectObj(const Value *val);
|
|
63
|
+
|
|
64
|
+
void collectRet(const Function *val);
|
|
65
|
+
|
|
66
|
+
void collectVararg(const Function *val);
|
|
67
|
+
//@}
|
|
68
|
+
|
|
69
|
+
/// Handle constant expression
|
|
70
|
+
// @{
|
|
71
|
+
void handleGlobalCE(const GlobalVariable *G);
|
|
72
|
+
void handleGlobalInitializerCE(const Constant *C, u32_t offset);
|
|
73
|
+
void handleCE(const Value *val);
|
|
74
|
+
// @}
|
|
75
|
+
|
|
76
|
+
/// Create an objectInfo based on LLVM value
|
|
77
|
+
ObjTypeInfo* createObjTypeInfo(const Value *val);
|
|
78
|
+
|
|
79
|
+
/// Initialize TypeInfo based on LLVM Value
|
|
80
|
+
void initTypeInfo(ObjTypeInfo* typeinfo, const Value* value);
|
|
81
|
+
/// Analyse types of all flattened fields of this object
|
|
82
|
+
void analyzeGlobalStackObjType(ObjTypeInfo* typeinfo, const Value* val);
|
|
83
|
+
/// Return size of this object based on LLVM value
|
|
84
|
+
u32_t getObjSize(const Value* val);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
#endif /* SymbolTableBuilder_H_ */
|
|
@@ -300,16 +300,6 @@ public:
|
|
|
300
300
|
|
|
301
301
|
};
|
|
302
302
|
|
|
303
|
-
class SVFInstruction : public SVFValue
|
|
304
|
-
{
|
|
305
|
-
|
|
306
|
-
public:
|
|
307
|
-
SVFInstruction(const std::string& val): SVFValue(val,SVFValue::SVFInst)
|
|
308
|
-
{
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
};
|
|
312
|
-
|
|
313
303
|
class CallSite {
|
|
314
304
|
private:
|
|
315
305
|
CallBase *CB;
|
|
@@ -37,7 +37,7 @@ namespace SVF
|
|
|
37
37
|
{
|
|
38
38
|
|
|
39
39
|
/*
|
|
40
|
-
* Generic CFL solver for demand-driven analysis based on different graphs (e.g.
|
|
40
|
+
* Generic CFL solver for demand-driven analysis based on different graphs (e.g. SVFIR, VFG, ThreadVFG)
|
|
41
41
|
* Extend this class for sophisticated CFL-reachability resolution (e.g. field, flow, path)
|
|
42
42
|
*/
|
|
43
43
|
template<class GraphType, class DPIm = DPItem>
|
|
@@ -105,7 +105,7 @@ private:
|
|
|
105
105
|
isext_cache.clear();
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
// Singleton pattern here to enable instance of
|
|
108
|
+
// Singleton pattern here to enable instance of SVFIR can only be created once.
|
|
109
109
|
static ExtAPI* extAPI;
|
|
110
110
|
|
|
111
111
|
public:
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
#ifndef IRANNOTATOR_H_
|
|
9
9
|
#define IRANNOTATOR_H_
|
|
10
10
|
|
|
11
|
-
#include "
|
|
11
|
+
#include "MemoryModel/SVFIR.h"
|
|
12
12
|
#include "MemoryModel/PointerAnalysisImpl.h"
|
|
13
13
|
#include "Util/SVFUtil.h"
|
|
14
14
|
#include "llvm/IR/Metadata.h"
|
|
@@ -28,7 +28,7 @@ public:
|
|
|
28
28
|
{}
|
|
29
29
|
~IRAnnotator() {}
|
|
30
30
|
|
|
31
|
-
void processAndersenResults(
|
|
31
|
+
void processAndersenResults(SVFIR *pag, BVDataPTAImpl *ptsTo, bool writeFlag)
|
|
32
32
|
{
|
|
33
33
|
this->ptsTo = ptsTo;
|
|
34
34
|
mainModule = LLVMModuleSet::getLLVMModuleSet()->getMainLLVMModule();
|
|
@@ -36,7 +36,7 @@ public:
|
|
|
36
36
|
// Add a named metadata node used to check whether or not
|
|
37
37
|
// this IR has been annotated with Andersen information
|
|
38
38
|
if (writeFlag)
|
|
39
|
-
mainModule->getOrInsertNamedMetadata("
|
|
39
|
+
mainModule->getOrInsertNamedMetadata("SVFIR-Annotated");
|
|
40
40
|
|
|
41
41
|
for (auto it = pag->begin(); it != pag->end(); ++it)
|
|
42
42
|
{
|
|
@@ -59,7 +59,7 @@ public:
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
private:
|
|
62
|
-
// Write the PAGgepNode to the IR such that metadata name is the
|
|
62
|
+
// Write the PAGgepNode to the IR such that metadata name is the SVFIR node id and the operands
|
|
63
63
|
// are its base node's id and location offset
|
|
64
64
|
void writePAGgepNode(SVF::NodeID nodeId, GepObjPN* gepNode)
|
|
65
65
|
{
|
|
@@ -77,9 +77,9 @@ private:
|
|
|
77
77
|
mainModule->getOrInsertNamedMetadata(label)->addOperand(metadata);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
// Reads the PAGGepNodes in the annotated IR and creates a new
|
|
80
|
+
// Reads the PAGGepNodes in the annotated IR and creates a new SVFIR Node based on the
|
|
81
81
|
// data contained in the operands of the metadata node
|
|
82
|
-
void readPAGgepNodes(
|
|
82
|
+
void readPAGgepNodes(SVFIR *pag)
|
|
83
83
|
{
|
|
84
84
|
for (auto it = mainModule->named_metadata_begin(); it != mainModule->named_metadata_end(); ++it)
|
|
85
85
|
{
|
|
@@ -108,7 +108,7 @@ public:
|
|
|
108
108
|
// Offline constraint graph (OfflineConsG.cpp)
|
|
109
109
|
static const llvm::cl::opt<bool> OCGDotGraph;
|
|
110
110
|
|
|
111
|
-
// Program Assignment Graph for pointer analysis (
|
|
111
|
+
// Program Assignment Graph for pointer analysis (SVFIR.cpp)
|
|
112
112
|
static llvm::cl::opt<bool> HandBlackHole;
|
|
113
113
|
static const llvm::cl::opt<bool> FirstFieldEqBase;
|
|
114
114
|
|
|
@@ -241,6 +241,17 @@ inline const SVFFunction* getFunction(StringRef name)
|
|
|
241
241
|
return nullptr;
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
+
/// find the unique defined global across multiple modules
|
|
245
|
+
inline const Value* getGlobalRep(const Value* val)
|
|
246
|
+
{
|
|
247
|
+
if(const GlobalVariable* gvar = SVFUtil::dyn_cast<GlobalVariable>(val))
|
|
248
|
+
{
|
|
249
|
+
if (LLVMModuleSet::getLLVMModuleSet()->hasGlobalRep(gvar))
|
|
250
|
+
val = LLVMModuleSet::getLLVMModuleSet()->getGlobalRep(gvar);
|
|
251
|
+
}
|
|
252
|
+
return val;
|
|
253
|
+
}
|
|
254
|
+
|
|
244
255
|
/// Get the definition of a function across multiple modules
|
|
245
256
|
inline const SVFFunction* getDefFunForMultipleModule(const Function* fun)
|
|
246
257
|
{
|