svf-tools 1.0.677 → 1.0.679
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-doxygen/wiki/cpu2017-wllvm.cfg +999 -0
- package/package.json +1 -1
- package/svf/include/Graphs/CHG.h +27 -14
- package/svf/include/Graphs/GenericGraph.h +10 -4
- package/svf/include/Graphs/ICFG.h +6 -1
- package/svf/include/Graphs/ICFGEdge.h +41 -31
- package/svf/include/Graphs/ICFGNode.h +14 -2
- package/svf/include/Graphs/IRGraph.h +22 -14
- package/svf/include/MemoryModel/LocationSet.h +10 -8
- package/svf/include/MemoryModel/SVFLoop.h +2 -0
- package/svf/include/SVFIR/SVFIR.h +42 -23
- package/svf/include/SVFIR/SVFIRRW.h +624 -0
- package/svf/include/SVFIR/SVFModule.h +1 -0
- package/svf/include/SVFIR/SVFModuleRW.h +3 -6
- package/svf/include/SVFIR/SVFStatements.h +247 -185
- package/svf/include/SVFIR/SVFType.h +4 -0
- package/svf/include/SVFIR/SVFValue.h +28 -9
- package/svf/include/SVFIR/SVFVariables.h +75 -78
- package/svf/include/SVFIR/SymbolTableInfo.h +19 -11
- package/svf/include/Util/CommandLine.h +1 -1
- package/svf/include/Util/Options.h +1 -0
- package/svf/include/Util/SparseBitVector.h +6 -0
- package/svf/include/Util/ThreadAPI.h +15 -15
- package/svf/lib/AbstractExecution/SVFIR2ItvExeState.cpp +61 -17
- package/svf/lib/Graphs/ICFG.cpp +2 -3
- package/svf/lib/SVFIR/SVFIRRW.cpp +1118 -0
- package/svf/lib/SVFIR/SymbolTableInfo.cpp +1 -1
- package/svf/lib/Util/Options.cpp +6 -0
- package/svf-llvm/include/SVF-LLVM/DCHG.h +36 -35
- package/svf-llvm/lib/LLVMModule.cpp +0 -5
- package/svf-llvm/lib/SVFIRBuilder.cpp +10 -2
- package/svf-llvm/tools/WPA/wpa.cpp +4 -0
package/svf/lib/Util/Options.cpp
CHANGED
|
@@ -316,6 +316,12 @@ const Option<bool> Options::DumpICFG(
|
|
|
316
316
|
false
|
|
317
317
|
);
|
|
318
318
|
|
|
319
|
+
const Option<std::string> Options::DumpJson(
|
|
320
|
+
"dump-json",
|
|
321
|
+
"Dump the SVFIR in JSON format",
|
|
322
|
+
""
|
|
323
|
+
);
|
|
324
|
+
|
|
319
325
|
const Option<bool> Options::CallGraphDotGraph(
|
|
320
326
|
"dump-callgraph",
|
|
321
327
|
"Dump dot graph of Call Graph",
|
|
@@ -74,7 +74,7 @@ public:
|
|
|
74
74
|
|
|
75
75
|
typedef std::vector<const Function*> FuncVector;
|
|
76
76
|
|
|
77
|
-
DCHNode(const DIType
|
|
77
|
+
DCHNode(const DIType* diType, NodeID i = 0, GNodeK k = 0)
|
|
78
78
|
: GenericNode<DCHNode, DCHEdge>(i, k), vtable(nullptr), flags(0)
|
|
79
79
|
{
|
|
80
80
|
this->diType = diType;
|
|
@@ -210,10 +210,10 @@ class DCHGraph : public CommonCHGraph, public GenericGraph<DCHNode, DCHEdge>
|
|
|
210
210
|
{
|
|
211
211
|
public:
|
|
212
212
|
/// Returns the DIType beneath the qualifiers. Does not strip away "DW_TAG_members".
|
|
213
|
-
static const DIType
|
|
213
|
+
static const DIType* stripQualifiers(const DIType*);
|
|
214
214
|
|
|
215
215
|
/// Returns the DIType beneath all qualifiers and arrays.
|
|
216
|
-
static const DIType
|
|
216
|
+
static const DIType* stripArray(const DIType*);
|
|
217
217
|
|
|
218
218
|
/// Returns true if t1 and t2 are equivalent, ignoring qualifiers.
|
|
219
219
|
/// For equality...
|
|
@@ -222,13 +222,13 @@ public:
|
|
|
222
222
|
/// DIDerivedType: base types (teq).
|
|
223
223
|
/// DICompositeType: shallow pointer equality.
|
|
224
224
|
/// DISubroutineType: shallow pointer equality.
|
|
225
|
-
static bool teq(const DIType
|
|
225
|
+
static bool teq(const DIType* t1, const DIType* t2);
|
|
226
226
|
|
|
227
227
|
/// Returns a human-readable version of the DIType.
|
|
228
228
|
static std::string diTypeToStr(const DIType *);
|
|
229
229
|
|
|
230
230
|
// Returns whether t is an array, a struct, a class, a union, or neither.
|
|
231
|
-
static bool isAgg(const DIType
|
|
231
|
+
static bool isAgg(const DIType* t);
|
|
232
232
|
|
|
233
233
|
public:
|
|
234
234
|
DCHGraph(const SVFModule *svfMod)
|
|
@@ -293,7 +293,7 @@ public:
|
|
|
293
293
|
/// Returns the type representing all qualifier-variations of t.
|
|
294
294
|
/// This should only matter in the case of DerivedTypes where
|
|
295
295
|
/// qualifiers and have qualified base types cause a mess.
|
|
296
|
-
const DIType
|
|
296
|
+
const DIType* getCanonicalType(const DIType* t);
|
|
297
297
|
|
|
298
298
|
/// Returns the type of field number idx (flattened) in base.
|
|
299
299
|
const DIType *getFieldType(const DIType *base, unsigned idx)
|
|
@@ -314,13 +314,14 @@ public:
|
|
|
314
314
|
|
|
315
315
|
if (base->getTag() == dwarf::DW_TAG_array_type)
|
|
316
316
|
{
|
|
317
|
-
const DICompositeType
|
|
317
|
+
const DICompositeType* cbase =
|
|
318
|
+
SVFUtil::dyn_cast<DICompositeType>(base);
|
|
318
319
|
assert(cbase && "DCHG: bad DIComposite case");
|
|
319
320
|
return cbase->getBaseType();
|
|
320
321
|
}
|
|
321
322
|
|
|
322
|
-
if (!(base->getTag() == dwarf::DW_TAG_class_type
|
|
323
|
-
|
|
323
|
+
if (!(base->getTag() == dwarf::DW_TAG_class_type ||
|
|
324
|
+
base->getTag() == dwarf::DW_TAG_structure_type))
|
|
324
325
|
{
|
|
325
326
|
return nullptr;
|
|
326
327
|
}
|
|
@@ -355,64 +356,64 @@ public:
|
|
|
355
356
|
return containingAggs[base];
|
|
356
357
|
}
|
|
357
358
|
|
|
358
|
-
bool isFirstField(const DIType
|
|
359
|
+
bool isFirstField(const DIType* f, const DIType* b);
|
|
359
360
|
|
|
360
361
|
protected:
|
|
361
362
|
/// SVF Module this CHG is built from.
|
|
362
|
-
const SVFModule
|
|
363
|
+
const SVFModule* svfModule;
|
|
363
364
|
/// Whether this CHG is an extended CHG (first-field). Set by buildCHG.
|
|
364
365
|
bool extended = false;
|
|
365
366
|
/// Maps DITypes to their nodes.
|
|
366
|
-
Map<const DIType
|
|
367
|
+
Map<const DIType*, DCHNode*> diTypeToNodeMap;
|
|
367
368
|
/// Maps VTables to the DIType associated with them.
|
|
368
|
-
Map<const SVFGlobalValue
|
|
369
|
+
Map<const SVFGlobalValue*, const DIType*> vtblToTypeMap;
|
|
369
370
|
/// Maps types to all children (i.e. CHA).
|
|
370
|
-
Map<const DIType
|
|
371
|
+
Map<const DIType*, NodeBS> chaMap;
|
|
371
372
|
/// Maps types to all children but also considering first field.
|
|
372
|
-
Map<const DIType
|
|
373
|
+
Map<const DIType*, NodeBS> chaFFMap;
|
|
373
374
|
/// Maps types to a set with their vtable and all their children's.
|
|
374
|
-
Map<const DIType
|
|
375
|
+
Map<const DIType*, VTableSet> vtblCHAMap;
|
|
375
376
|
/// Maps callsites to a set of potential virtual functions based on CHA.
|
|
376
377
|
Map<CallSite, VFunSet> csCHAMap;
|
|
377
378
|
/// Maps types to their canonical type (many-to-one).
|
|
378
|
-
Map<const DIType
|
|
379
|
+
Map<const DIType*, const DIType*> canonicalTypeMap;
|
|
379
380
|
/// Set of all possible canonical types (i.e. values of canonicalTypeMap).
|
|
380
|
-
Set<const DIType
|
|
381
|
+
Set<const DIType*> canonicalTypes;
|
|
381
382
|
/// Maps types to their flattened fields' types.
|
|
382
|
-
Map<const DIType
|
|
383
|
+
Map<const DIType*, std::vector<const DIType*>> fieldTypes;
|
|
383
384
|
/// Maps aggregate types to all the aggregate types it transitively contains.
|
|
384
|
-
Map<const DIType
|
|
385
|
+
Map<const DIType*, Set<const DIType*>> containingAggs;
|
|
385
386
|
|
|
386
387
|
private:
|
|
387
388
|
/// Construction helper to process DIBasicTypes.
|
|
388
|
-
void handleDIBasicType(const DIBasicType
|
|
389
|
+
void handleDIBasicType(const DIBasicType* basicType);
|
|
389
390
|
/// Construction helper to process DICompositeTypes.
|
|
390
|
-
void handleDICompositeType(const DICompositeType
|
|
391
|
+
void handleDICompositeType(const DICompositeType* compositeType);
|
|
391
392
|
/// Construction helper to process DIDerivedTypes.
|
|
392
|
-
void handleDIDerivedType(const DIDerivedType
|
|
393
|
+
void handleDIDerivedType(const DIDerivedType* derivedType);
|
|
393
394
|
/// Construction helper to process DISubroutineTypes.
|
|
394
|
-
void handleDISubroutineType(const DISubroutineType
|
|
395
|
+
void handleDISubroutineType(const DISubroutineType* subroutineType);
|
|
395
396
|
|
|
396
397
|
/// Finds all defined virtual functions and attaches them to nodes.
|
|
397
|
-
void buildVTables(const SVFModule
|
|
398
|
+
void buildVTables(const SVFModule& module);
|
|
398
399
|
|
|
399
400
|
/// Returns a set of all children of type (CHA). Also gradually builds chaMap.
|
|
400
|
-
const NodeBS
|
|
401
|
+
const NodeBS& cha(const DIType* type, bool firstField);
|
|
401
402
|
|
|
402
403
|
/// Attaches the typedef(s) to the base node.
|
|
403
|
-
void handleTypedef(const DIType
|
|
404
|
+
void handleTypedef(const DIType* typedefType);
|
|
404
405
|
|
|
405
406
|
/// Populates fieldTypes for type and all its elements.
|
|
406
|
-
void flatten(const DICompositeType
|
|
407
|
+
void flatten(const DICompositeType* type);
|
|
407
408
|
|
|
408
409
|
/// Populates containingAggs for type and all its elements.
|
|
409
|
-
void gatherAggs(const DICompositeType
|
|
410
|
+
void gatherAggs(const DICompositeType* type);
|
|
410
411
|
|
|
411
412
|
/// Creates a node from type, or returns it if it exists.
|
|
412
|
-
DCHNode
|
|
413
|
+
DCHNode* getOrCreateNode(const DIType* type);
|
|
413
414
|
|
|
414
415
|
/// Retrieves the metadata associated with a *virtual* callsite.
|
|
415
|
-
const DIType
|
|
416
|
+
const DIType* getCSStaticType(CallBase* cs) const
|
|
416
417
|
{
|
|
417
418
|
MDNode *md = cs->getMetadata(cppUtil::ctir::derefMDName);
|
|
418
419
|
assert(md != nullptr && "Missing type metadata at virtual callsite");
|
|
@@ -428,14 +429,14 @@ private:
|
|
|
428
429
|
}
|
|
429
430
|
|
|
430
431
|
/// Checks if a node exists for type.
|
|
431
|
-
bool hasNode(const DIType
|
|
432
|
+
bool hasNode(const DIType* type)
|
|
432
433
|
{
|
|
433
434
|
type = getCanonicalType(type);
|
|
434
435
|
return diTypeToNodeMap.find(type) != diTypeToNodeMap.end();
|
|
435
436
|
}
|
|
436
437
|
|
|
437
438
|
/// Returns the node for type (nullptr if it doesn't exist).
|
|
438
|
-
DCHNode
|
|
439
|
+
DCHNode* getNode(const DIType* type)
|
|
439
440
|
{
|
|
440
441
|
type = getCanonicalType(type);
|
|
441
442
|
if (hasNode(type))
|
|
@@ -448,9 +449,9 @@ private:
|
|
|
448
449
|
|
|
449
450
|
|
|
450
451
|
/// Creates an edge between from t1 to t2.
|
|
451
|
-
DCHEdge
|
|
452
|
+
DCHEdge* addEdge(const DIType* t1, const DIType* t2, DCHEdge::GEdgeKind et);
|
|
452
453
|
/// Returns the edge between t1 and t2 if it exists, returns nullptr otherwise.
|
|
453
|
-
DCHEdge
|
|
454
|
+
DCHEdge* hasEdge(const DIType* t1, const DIType* t2, DCHEdge::GEdgeKind et);
|
|
454
455
|
|
|
455
456
|
/// Number of types (nodes) in the graph.
|
|
456
457
|
NodeID numTypes;
|
|
@@ -69,9 +69,6 @@ using namespace SVF;
|
|
|
69
69
|
#define SVF_GLOBAL_CTORS "llvm.global_ctors"
|
|
70
70
|
#define SVF_GLOBAL_DTORS "llvm.global_dtors"
|
|
71
71
|
|
|
72
|
-
static Option<std::string> dumpJson("dump-json",
|
|
73
|
-
"Dump the SVFModule to JSON file", "");
|
|
74
|
-
|
|
75
72
|
LLVMModuleSet *LLVMModuleSet::llvmModuleSet = nullptr;
|
|
76
73
|
std::string SVFModule::pagReadFromTxt = "";
|
|
77
74
|
|
|
@@ -123,8 +120,6 @@ SVFModule* LLVMModuleSet::buildSVFModule(const std::vector<std::string> &moduleN
|
|
|
123
120
|
|
|
124
121
|
build_symbol_table();
|
|
125
122
|
|
|
126
|
-
svfModule->writeToJson(dumpJson());
|
|
127
|
-
|
|
128
123
|
return svfModule.get();
|
|
129
124
|
}
|
|
130
125
|
|
|
@@ -38,8 +38,10 @@
|
|
|
38
38
|
#include "SVF-LLVM/LLVMLoopAnalysis.h"
|
|
39
39
|
#include "Util/Options.h"
|
|
40
40
|
#include "SVF-LLVM/CHGBuilder.h"
|
|
41
|
+
#include "SVFIR/SVFIRRW.h"
|
|
41
42
|
#include "SVF-LLVM/SymbolTableBuilder.h"
|
|
42
43
|
|
|
44
|
+
|
|
43
45
|
using namespace std;
|
|
44
46
|
using namespace SVF;
|
|
45
47
|
using namespace SVFUtil;
|
|
@@ -64,7 +66,7 @@ SVFIR* SVFIRBuilder::build()
|
|
|
64
66
|
icfgbuilder.build(svfModule);
|
|
65
67
|
pag->setICFG(icfg);
|
|
66
68
|
|
|
67
|
-
CHGraph
|
|
69
|
+
CHGraph* chg = new CHGraph(pag->getModule());
|
|
68
70
|
CHGBuilder chgbuilder(chg);
|
|
69
71
|
chgbuilder.buildCHG();
|
|
70
72
|
pag->setCHG(chg);
|
|
@@ -162,8 +164,14 @@ SVFIR* SVFIRBuilder::build()
|
|
|
162
164
|
loopAnalysis.build(pag->getICFG());
|
|
163
165
|
}
|
|
164
166
|
|
|
167
|
+
// dump SVFIR as JSON
|
|
168
|
+
if (!Options::DumpJson().empty())
|
|
169
|
+
{
|
|
170
|
+
SVFIRWriter::writeJsonToPath(pag, Options::DumpJson());
|
|
171
|
+
}
|
|
172
|
+
|
|
165
173
|
double endTime = SVFStat::getClk(true);
|
|
166
|
-
SVFStat::timeOfBuildingSVFIR = (endTime - startTime)/TIMEINTERVAL;
|
|
174
|
+
SVFStat::timeOfBuildingSVFIR = (endTime - startTime) / TIMEINTERVAL;
|
|
167
175
|
|
|
168
176
|
return pag;
|
|
169
177
|
}
|