svf-tools 1.0.678 → 1.0.680
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/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/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 +11 -3
- package/svf-llvm/tools/WPA/wpa.cpp +4 -0
|
@@ -42,11 +42,11 @@ class CommonCHGraph;
|
|
|
42
42
|
*/
|
|
43
43
|
class SVFIR : public IRGraph
|
|
44
44
|
{
|
|
45
|
-
|
|
46
45
|
friend class SVFIRBuilder;
|
|
47
46
|
friend class ExternalPAG;
|
|
48
47
|
friend class PAGBuilderFromFile;
|
|
49
48
|
friend class TypeBasedHeapCloning;
|
|
49
|
+
friend class SVFIRWriter;
|
|
50
50
|
|
|
51
51
|
public:
|
|
52
52
|
typedef Set<const CallICFGNode*> CallSiteSet;
|
|
@@ -84,7 +84,6 @@ private:
|
|
|
84
84
|
CSToArgsListMap callSiteArgsListMap; ///< Map a callsite to a list of all its actual parameters
|
|
85
85
|
CSToRetMap callSiteRetMap; ///< Map a callsite to its callsite returns PAGNodes
|
|
86
86
|
FunToRetMap funRetMap; ///< Map a function to its unique function return PAGNodes
|
|
87
|
-
static std::unique_ptr<SVFIR> pag; ///< Singleton pattern here to enable instance of SVFIR can only be created once.
|
|
88
87
|
CallSiteToFunPtrMap indCallSiteToFunPtrMap; ///< Map an indirect callsite to its function pointer
|
|
89
88
|
FunPtrToCallSitesMap funPtrToCallSitesMap; ///< Map a function pointer to the callsites where it is used
|
|
90
89
|
/// Valid pointers for pointer analysis resolution connected by SVFIR edges (constraints)
|
|
@@ -94,6 +93,9 @@ private:
|
|
|
94
93
|
ICFG* icfg; // ICFG
|
|
95
94
|
CommonCHGraph* chgraph; // class hierarchy graph
|
|
96
95
|
CallSiteSet callSiteSet; /// all the callsites of a program
|
|
96
|
+
|
|
97
|
+
static std::unique_ptr<SVFIR> pag; ///< Singleton pattern here to enable instance of SVFIR can only be created once.
|
|
98
|
+
|
|
97
99
|
/// Constructor
|
|
98
100
|
SVFIR(bool buildFromFile);
|
|
99
101
|
|
|
@@ -160,7 +162,7 @@ public:
|
|
|
160
162
|
{
|
|
161
163
|
icfg = i;
|
|
162
164
|
}
|
|
163
|
-
inline ICFG* getICFG()
|
|
165
|
+
inline ICFG* getICFG() const
|
|
164
166
|
{
|
|
165
167
|
assert(icfg->totalICFGNode>0 && "empty ICFG! Build SVF IR first!");
|
|
166
168
|
return icfg;
|
|
@@ -190,11 +192,12 @@ public:
|
|
|
190
192
|
/// Whether this instruction has SVFIR Edge
|
|
191
193
|
inline bool hasSVFStmtList(const ICFGNode* inst) const
|
|
192
194
|
{
|
|
193
|
-
return icfgNode2SVFStmtsMap.find(inst)!=icfgNode2SVFStmtsMap.end();
|
|
195
|
+
return icfgNode2SVFStmtsMap.find(inst) != icfgNode2SVFStmtsMap.end();
|
|
194
196
|
}
|
|
195
197
|
inline bool hasPTASVFStmtList(const ICFGNode* inst) const
|
|
196
198
|
{
|
|
197
|
-
return icfgNode2PTASVFStmtsMap.find(inst)!=
|
|
199
|
+
return icfgNode2PTASVFStmtsMap.find(inst) !=
|
|
200
|
+
icfgNode2PTASVFStmtsMap.end();
|
|
198
201
|
}
|
|
199
202
|
/// Given an instruction, get all its PAGEdges
|
|
200
203
|
inline SVFStmtList& getSVFStmtList(const ICFGNode* inst)
|
|
@@ -348,7 +351,7 @@ public:
|
|
|
348
351
|
}
|
|
349
352
|
inline SVFStmt* getIntraPAGEdge(SVFVar* src, SVFVar* dst, SVFStmt::PEDGEK kind)
|
|
350
353
|
{
|
|
351
|
-
SVFStmt edge(src,dst,kind, false);
|
|
354
|
+
SVFStmt edge(src, dst, kind, false);
|
|
352
355
|
const SVFStmt::SVFStmtSetTy& edgeSet = getSVFStmtSet(kind);
|
|
353
356
|
SVFStmt::SVFStmtSetTy::const_iterator it = edgeSet.find(&edge);
|
|
354
357
|
assert(it != edgeSet.end() && "can not find pag edge");
|
|
@@ -360,10 +363,10 @@ public:
|
|
|
360
363
|
/// return whole allocated memory object if this node is a gep obj node
|
|
361
364
|
/// return nullptr is this node is not a ObjVar type
|
|
362
365
|
//@{
|
|
363
|
-
inline const MemObj*getObject(NodeID id) const
|
|
366
|
+
inline const MemObj* getObject(NodeID id) const
|
|
364
367
|
{
|
|
365
368
|
const SVFVar* node = getGNode(id);
|
|
366
|
-
if(const ObjVar* objPN = SVFUtil::dyn_cast<ObjVar>(node))
|
|
369
|
+
if (const ObjVar* objPN = SVFUtil::dyn_cast<ObjVar>(node))
|
|
367
370
|
return getObject(objPN);
|
|
368
371
|
else
|
|
369
372
|
return nullptr;
|
|
@@ -412,7 +415,8 @@ public:
|
|
|
412
415
|
{
|
|
413
416
|
const MemObj* obj = getObject(id);
|
|
414
417
|
assert(obj && "not an object node?");
|
|
415
|
-
return SymbolTableInfo::isConstantObj(id) ||
|
|
418
|
+
return SymbolTableInfo::isConstantObj(id) ||
|
|
419
|
+
obj->isConstDataOrConstGlobal();
|
|
416
420
|
}
|
|
417
421
|
/// Whether an object can point to any other object or any of its fields is a pointer type.
|
|
418
422
|
bool isNonPointerObj(NodeID id) const;
|
|
@@ -522,7 +526,7 @@ private:
|
|
|
522
526
|
inline NodeID addObjNode(const SVFValue* val, NodeID i)
|
|
523
527
|
{
|
|
524
528
|
const MemObj* mem = getMemObj(val);
|
|
525
|
-
assert(
|
|
529
|
+
assert(mem->getId() == i && "not same object id?");
|
|
526
530
|
return addFIObjNode(mem);
|
|
527
531
|
}
|
|
528
532
|
/// Add a unique return node for a procedure
|
|
@@ -563,11 +567,15 @@ private:
|
|
|
563
567
|
}
|
|
564
568
|
inline NodeID addBlackholeObjNode()
|
|
565
569
|
{
|
|
566
|
-
return addObjNode(
|
|
570
|
+
return addObjNode(
|
|
571
|
+
nullptr, new DummyObjVar(getBlackHoleNode(), getBlackHoleObj()),
|
|
572
|
+
getBlackHoleNode());
|
|
567
573
|
}
|
|
568
574
|
inline NodeID addConstantObjNode()
|
|
569
575
|
{
|
|
570
|
-
return addObjNode(nullptr,
|
|
576
|
+
return addObjNode(nullptr,
|
|
577
|
+
new DummyObjVar(getConstantNode(), getConstantObj()),
|
|
578
|
+
getConstantNode());
|
|
571
579
|
}
|
|
572
580
|
inline NodeID addBlackholePtrNode()
|
|
573
581
|
{
|
|
@@ -578,14 +586,18 @@ private:
|
|
|
578
586
|
/// Add a value (pointer) node
|
|
579
587
|
inline NodeID addValNode(const SVFValue*, SVFVar *node, NodeID i)
|
|
580
588
|
{
|
|
581
|
-
assert(hasGNode(i) == false &&
|
|
582
|
-
|
|
589
|
+
assert(hasGNode(i) == false &&
|
|
590
|
+
"This NodeID clashes here. Please check NodeIDAllocator. Switch "
|
|
591
|
+
"Strategy::DBUG to SEQ or DENSE");
|
|
592
|
+
return addNode(node, i);
|
|
583
593
|
}
|
|
584
594
|
/// Add a memory obj node
|
|
585
595
|
inline NodeID addObjNode(const SVFValue*, SVFVar *node, NodeID i)
|
|
586
596
|
{
|
|
587
|
-
assert(hasGNode(i) == false &&
|
|
588
|
-
|
|
597
|
+
assert(hasGNode(i) == false &&
|
|
598
|
+
"This NodeID clashes here. Please check NodeIDAllocator. Switch "
|
|
599
|
+
"Strategy::DBUG to SEQ or DENSE");
|
|
600
|
+
return addNode(node, i);
|
|
589
601
|
}
|
|
590
602
|
/// Add a unique return node for a procedure
|
|
591
603
|
inline NodeID addRetNode(const SVFFunction*, SVFVar *node, NodeID i)
|
|
@@ -621,29 +633,36 @@ private:
|
|
|
621
633
|
/// Add Copy edge
|
|
622
634
|
CmpStmt* addCmpStmt(NodeID op1, NodeID op2, NodeID dst, u32_t predict);
|
|
623
635
|
/// Add Copy edge
|
|
624
|
-
BinaryOPStmt* addBinaryOPStmt(NodeID op1, NodeID op2, NodeID dst,
|
|
636
|
+
BinaryOPStmt* addBinaryOPStmt(NodeID op1, NodeID op2, NodeID dst,
|
|
637
|
+
u32_t opcode);
|
|
625
638
|
/// Add Unary edge
|
|
626
639
|
UnaryOPStmt* addUnaryOPStmt(NodeID src, NodeID dst, u32_t opcode);
|
|
627
640
|
/// Add BranchStmt
|
|
628
|
-
BranchStmt* addBranchStmt(NodeID br, NodeID cond,
|
|
641
|
+
BranchStmt* addBranchStmt(NodeID br, NodeID cond,
|
|
642
|
+
const BranchStmt::SuccAndCondPairVec& succs);
|
|
629
643
|
/// Add Load edge
|
|
630
644
|
LoadStmt* addLoadStmt(NodeID src, NodeID dst);
|
|
631
645
|
/// Add Store edge
|
|
632
646
|
StoreStmt* addStoreStmt(NodeID src, NodeID dst, const IntraICFGNode* val);
|
|
633
647
|
/// Add Call edge
|
|
634
|
-
CallPE* addCallPE(NodeID src, NodeID dst, const CallICFGNode* cs,
|
|
648
|
+
CallPE* addCallPE(NodeID src, NodeID dst, const CallICFGNode* cs,
|
|
649
|
+
const FunEntryICFGNode* entry);
|
|
635
650
|
/// Add Return edge
|
|
636
|
-
RetPE* addRetPE(NodeID src, NodeID dst, const CallICFGNode* cs,
|
|
651
|
+
RetPE* addRetPE(NodeID src, NodeID dst, const CallICFGNode* cs,
|
|
652
|
+
const FunExitICFGNode* exit);
|
|
637
653
|
/// Add Gep edge
|
|
638
|
-
GepStmt* addGepStmt(NodeID src, NodeID dst, const LocationSet& ls,
|
|
654
|
+
GepStmt* addGepStmt(NodeID src, NodeID dst, const LocationSet& ls,
|
|
655
|
+
bool constGep);
|
|
639
656
|
/// Add Offset(Gep) edge
|
|
640
657
|
GepStmt* addNormalGepStmt(NodeID src, NodeID dst, const LocationSet& ls);
|
|
641
658
|
/// Add Variant(Gep) edge
|
|
642
659
|
GepStmt* addVariantGepStmt(NodeID src, NodeID dst, const LocationSet& ls);
|
|
643
660
|
/// Add Thread fork edge for parameter passing
|
|
644
|
-
TDForkPE* addThreadForkPE(NodeID src, NodeID dst, const CallICFGNode* cs,
|
|
661
|
+
TDForkPE* addThreadForkPE(NodeID src, NodeID dst, const CallICFGNode* cs,
|
|
662
|
+
const FunEntryICFGNode* entry);
|
|
645
663
|
/// Add Thread join edge for parameter passing
|
|
646
|
-
TDJoinPE* addThreadJoinPE(NodeID src, NodeID dst, const CallICFGNode* cs,
|
|
664
|
+
TDJoinPE* addThreadJoinPE(NodeID src, NodeID dst, const CallICFGNode* cs,
|
|
665
|
+
const FunExitICFGNode* exit);
|
|
647
666
|
//@}
|
|
648
667
|
|
|
649
668
|
/// Set a pointer points-to black hole (e.g. int2ptr)
|