svf-tools 1.0.1039 → 1.0.1041
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/AE/Svfexe/AbstractInterpretation.h +2 -2
- package/svf/include/Graphs/PTACallGraph.h +9 -1
- package/svf/include/Graphs/SCC.h +7 -2
- package/svf/include/Graphs/ThreadCallGraph.h +1 -1
- package/svf/include/MSSA/MemRegion.h +0 -2
- package/svf/include/SVFIR/SVFIR.h +11 -12
- package/svf/include/SVFIR/SVFValue.h +0 -10
- package/svf/include/SVFIR/SVFVariables.h +13 -13
- package/svf/include/Util/CallGraphBuilder.h +1 -1
- package/svf/include/WPA/WPAFSSolver.h +2 -2
- package/svf/lib/AE/Svfexe/AbstractInterpretation.cpp +10 -10
- package/svf/lib/DDA/ContextDDA.cpp +1 -1
- package/svf/lib/Graphs/PTACallGraph.cpp +46 -4
- package/svf/lib/Graphs/ThreadCallGraph.cpp +5 -7
- package/svf/lib/MSSA/MemRegion.cpp +5 -19
- package/svf/lib/MSSA/MemSSA.cpp +2 -2
- package/svf/lib/MSSA/SVFGBuilder.cpp +2 -2
- package/svf/lib/MTA/MTAStat.cpp +1 -1
- package/svf/lib/MTA/TCT.cpp +2 -2
- package/svf/lib/MemoryModel/PointerAnalysis.cpp +1 -1
- package/svf/lib/MemoryModel/PointerAnalysisImpl.cpp +1 -1
- package/svf/lib/SABER/SaberCondAllocator.cpp +2 -2
- package/svf/lib/SVFIR/SVFIR.cpp +1 -1
- package/svf/lib/SVFIR/SVFVariables.cpp +11 -11
- package/svf/lib/Util/CDGBuilder.cpp +2 -2
- package/svf/lib/Util/CallGraphBuilder.cpp +5 -5
- package/svf/lib/Util/SVFStat.cpp +2 -2
- package/svf/lib/Util/SVFUtil.cpp +5 -5
- package/svf/lib/Util/ThreadAPI.cpp +2 -2
- package/svf/lib/WPA/Andersen.cpp +5 -5
- package/svf-llvm/include/SVF-LLVM/LLVMModule.h +1 -12
- package/svf-llvm/lib/LLVMModule.cpp +1 -19
- package/svf-llvm/lib/SVFIRBuilder.cpp +7 -7
- package/svf-llvm/lib/SVFIRExtAPI.cpp +2 -3
- package/svf/include/Graphs/CallGraph.h +0 -266
- package/svf/lib/Graphs/CallGraph.cpp +0 -221
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svf-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1041",
|
|
4
4
|
"description": "* <b>[TypeClone](https://github.com/SVF-tools/SVF/wiki/TypeClone) published in our [ECOOP paper](https://yuleisui.github.io/publications/ecoop20.pdf) is now available in SVF </b> * <b>SVF now uses a single script for its build. Just type [`source ./build.sh`](https://github.com/SVF-tools/SVF/blob/master/build.sh) in your terminal, that's it!</b> * <b>SVF now supports LLVM-10.0.0! </b> * <b>We thank [bsauce](https://github.com/bsauce) for writing a user manual of SVF ([link1](https://www.jianshu.com/p/068a08ec749c) and [link2](https://www.jianshu.com/p/777c30d4240e)) in Chinese </b> * <b>SVF now supports LLVM-9.0.0 (Thank [Byoungyoung Lee](https://github.com/SVF-tools/SVF/issues/142) for his help!). </b> * <b>SVF now supports a set of [field-sensitive pointer analyses](https://yuleisui.github.io/publications/sas2019a.pdf). </b> * <b>[Use SVF as an external lib](https://github.com/SVF-tools/SVF/wiki/Using-SVF-as-a-lib-in-your-own-tool) for your own project (Contributed by [Hongxu Chen](https://github.com/HongxuChen)). </b> * <b>SVF now supports LLVM-7.0.0. </b> * <b>SVF now supports Docker. [Try SVF in Docker](https://github.com/SVF-tools/SVF/wiki/Try-SVF-in-Docker)! </b> * <b>SVF now supports [LLVM-6.0.0](https://github.com/svf-tools/SVF/pull/38) (Contributed by [Jack Anthony](https://github.com/jackanth)). </b> * <b>SVF now supports [LLVM-4.0.0](https://github.com/svf-tools/SVF/pull/23) (Contributed by Jared Carlson. Thank [Jared](https://github.com/jcarlson23) and [Will](https://github.com/dtzWill) for their in-depth [discussions](https://github.com/svf-tools/SVF/pull/18) about updating SVF!) </b> * <b>SVF now supports analysis for C++ programs.</b> <br />",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -251,8 +251,8 @@ private:
|
|
|
251
251
|
AEStat* stat;
|
|
252
252
|
|
|
253
253
|
std::vector<const CallICFGNode*> callSiteStack;
|
|
254
|
-
Map<const
|
|
255
|
-
Set<const
|
|
254
|
+
Map<const SVFFunction*, ICFGWTO*> funcToWTO;
|
|
255
|
+
Set<const SVFFunction*> recursiveFuns;
|
|
256
256
|
|
|
257
257
|
|
|
258
258
|
AbstractState& getAbsStateFromTrace(const ICFGNode* node)
|
|
@@ -302,7 +302,7 @@ public:
|
|
|
302
302
|
PTACallGraph(CGEK k = NormCallGraph);
|
|
303
303
|
|
|
304
304
|
/// Copy constructor
|
|
305
|
-
PTACallGraph(const
|
|
305
|
+
PTACallGraph(const PTACallGraph& other);
|
|
306
306
|
|
|
307
307
|
/// Destructor
|
|
308
308
|
virtual ~PTACallGraph()
|
|
@@ -351,8 +351,16 @@ public:
|
|
|
351
351
|
/// Issue a warning if the function which has indirect call sites can not be reached from program entry.
|
|
352
352
|
void verifyCallGraph();
|
|
353
353
|
|
|
354
|
+
/// Add direct call edges
|
|
355
|
+
void addDirectCallGraphEdge(const CallICFGNode* call, const SVFFunction* callerFun, const SVFFunction* calleeFun);
|
|
356
|
+
|
|
357
|
+
void addCallGraphNode(const SVFFunction* fun);
|
|
358
|
+
|
|
354
359
|
/// Get call graph node
|
|
355
360
|
//@{
|
|
361
|
+
|
|
362
|
+
const PTACallGraphNode* getCallGraphNode(const std::string& name);
|
|
363
|
+
|
|
356
364
|
inline PTACallGraphNode* getCallGraphNode(NodeID id) const
|
|
357
365
|
{
|
|
358
366
|
return getGNode(id);
|
package/svf/include/Graphs/SCC.h
CHANGED
|
@@ -130,12 +130,17 @@ public:
|
|
|
130
130
|
return _T;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
inline const GNodeStack& topoNodeStack() const
|
|
134
|
+
{
|
|
135
|
+
return _T;
|
|
136
|
+
}
|
|
137
|
+
|
|
133
138
|
/// Return a handle to the stack of nodes in reverse topological
|
|
134
139
|
/// order. This will be used to seed the initial solution
|
|
135
140
|
/// and improve efficiency.
|
|
136
|
-
inline
|
|
141
|
+
inline FIFOWorkList<NodeID> revTopoNodeStack() const
|
|
137
142
|
{
|
|
138
|
-
|
|
143
|
+
FIFOWorkList<NodeID> revTopoOrder;
|
|
139
144
|
GNodeStack topoOrder = topoNodeStack();
|
|
140
145
|
while(!topoOrder.empty())
|
|
141
146
|
{
|
|
@@ -172,7 +172,7 @@ public:
|
|
|
172
172
|
typedef Map<const CallICFGNode*, ParForEdgeSet> CallInstToParForEdgesMap;
|
|
173
173
|
|
|
174
174
|
/// Constructor
|
|
175
|
-
ThreadCallGraph(const
|
|
175
|
+
ThreadCallGraph(const PTACallGraph& cg);
|
|
176
176
|
|
|
177
177
|
ThreadCallGraph(ThreadCallGraph& cg) = delete;
|
|
178
178
|
|
|
@@ -268,8 +268,6 @@ private:
|
|
|
268
268
|
/// Get all the objects in callee's modref escaped via global objects (the chain pts of globals)
|
|
269
269
|
void getEscapObjviaGlobals(NodeBS& globs, const NodeBS& pts);
|
|
270
270
|
|
|
271
|
-
/// Get reverse topo call graph scc
|
|
272
|
-
void getCallGraphSCCRevTopoOrder(WorkList& worklist);
|
|
273
271
|
|
|
274
272
|
protected:
|
|
275
273
|
MRGenerator(BVDataPTAImpl* p, bool ptrOnly);
|
|
@@ -35,7 +35,6 @@
|
|
|
35
35
|
namespace SVF
|
|
36
36
|
{
|
|
37
37
|
class CommonCHGraph;
|
|
38
|
-
class CallGraph;
|
|
39
38
|
/*!
|
|
40
39
|
* SVF Intermediate representation, representing variables and statements as a Program Assignment Graph (PAG)
|
|
41
40
|
* Variables as nodes and statements as edges.
|
|
@@ -62,7 +61,7 @@ public:
|
|
|
62
61
|
typedef Map<const CallICFGNode*,SVFVarList> CSToArgsListMap;
|
|
63
62
|
typedef Map<const RetICFGNode*,const SVFVar*> CSToRetMap;
|
|
64
63
|
typedef Map<const SVFFunction*,const SVFVar*> FunToRetMap;
|
|
65
|
-
typedef Map<const
|
|
64
|
+
typedef Map<const SVFFunction*,const FunObjVar *> FunToFunObjVarMap;
|
|
66
65
|
typedef Map<const SVFFunction*,SVFStmtSet> FunToPAGEdgeSetMap;
|
|
67
66
|
typedef Map<const ICFGNode*,SVFStmtList> ICFGNode2SVFStmtsMap;
|
|
68
67
|
typedef Map<NodeID, NodeID> NodeToNodeMap;
|
|
@@ -100,7 +99,7 @@ private:
|
|
|
100
99
|
ICFG* icfg; // ICFG
|
|
101
100
|
CommonCHGraph* chgraph; // class hierarchy graph
|
|
102
101
|
CallSiteSet callSiteSet; /// all the callsites of a program
|
|
103
|
-
|
|
102
|
+
PTACallGraph* callGraph; /// call graph
|
|
104
103
|
|
|
105
104
|
static std::unique_ptr<SVFIR> pag; ///< Singleton pattern here to enable instance of SVFIR can only be created once.
|
|
106
105
|
|
|
@@ -187,11 +186,11 @@ public:
|
|
|
187
186
|
}
|
|
188
187
|
|
|
189
188
|
/// Set/Get CG
|
|
190
|
-
inline void setCallGraph(
|
|
189
|
+
inline void setCallGraph(PTACallGraph* c)
|
|
191
190
|
{
|
|
192
191
|
callGraph = c;
|
|
193
192
|
}
|
|
194
|
-
inline
|
|
193
|
+
inline PTACallGraph* getCallGraph()
|
|
195
194
|
{
|
|
196
195
|
assert(callGraph && "empty CallGraph! Build SVF IR first!");
|
|
197
196
|
return callGraph;
|
|
@@ -331,7 +330,7 @@ public:
|
|
|
331
330
|
}
|
|
332
331
|
//@}
|
|
333
332
|
|
|
334
|
-
inline const FunObjVar* getFunObjVar(const
|
|
333
|
+
inline const FunObjVar* getFunObjVar(const SVFFunction* node) const
|
|
335
334
|
{
|
|
336
335
|
FunToFunObjVarMap::const_iterator it = funToFunObjvarMap.find(node);
|
|
337
336
|
assert(it != funToFunObjvarMap.end() && "this function doesn't have funobjvar");
|
|
@@ -547,13 +546,13 @@ private:
|
|
|
547
546
|
return addValNode(node);
|
|
548
547
|
}
|
|
549
548
|
|
|
550
|
-
NodeID addFunValNode(NodeID i, const ICFGNode* icfgNode, const
|
|
549
|
+
NodeID addFunValNode(NodeID i, const ICFGNode* icfgNode, const SVFFunction* callGraphNode, const SVFType* type)
|
|
551
550
|
{
|
|
552
551
|
FunValVar* node = new FunValVar(i, icfgNode, callGraphNode, type);
|
|
553
552
|
return addValNode(node);
|
|
554
553
|
}
|
|
555
554
|
|
|
556
|
-
NodeID addArgValNode(NodeID i, u32_t argNo, const ICFGNode* icfgNode, const
|
|
555
|
+
NodeID addArgValNode(NodeID i, u32_t argNo, const ICFGNode* icfgNode, const SVFFunction* callGraphNode, const SVFType* type)
|
|
557
556
|
{
|
|
558
557
|
ArgValVar* node =
|
|
559
558
|
new ArgValVar(i, argNo, icfgNode, callGraphNode, type);
|
|
@@ -625,7 +624,7 @@ private:
|
|
|
625
624
|
return addObjNode(stackObj);
|
|
626
625
|
}
|
|
627
626
|
|
|
628
|
-
NodeID addFunObjNode(NodeID id, ObjTypeInfo* ti, const
|
|
627
|
+
NodeID addFunObjNode(NodeID id, ObjTypeInfo* ti, const SVFFunction* callGraphNode, const SVFType* type, const ICFGNode* node)
|
|
629
628
|
{
|
|
630
629
|
memToFieldsMap[id].set(id);
|
|
631
630
|
FunObjVar* funObj = new FunObjVar(id, ti, callGraphNode, type, node);
|
|
@@ -678,13 +677,13 @@ private:
|
|
|
678
677
|
}
|
|
679
678
|
|
|
680
679
|
/// Add a unique return node for a procedure
|
|
681
|
-
inline NodeID addRetNode(NodeID i, const
|
|
680
|
+
inline NodeID addRetNode(NodeID i, const SVFFunction* callGraphNode, const SVFType* type, const ICFGNode* icn)
|
|
682
681
|
{
|
|
683
682
|
SVFVar *node = new RetValPN(i, callGraphNode, type, icn);
|
|
684
683
|
return addRetNode(callGraphNode, node);
|
|
685
684
|
}
|
|
686
685
|
/// Add a unique vararg node for a procedure
|
|
687
|
-
inline NodeID addVarargNode(NodeID i, const
|
|
686
|
+
inline NodeID addVarargNode(NodeID i, const SVFFunction* val, const SVFType* type, const ICFGNode* n)
|
|
688
687
|
{
|
|
689
688
|
SVFVar *node = new VarArgValPN(i, val, type, n);
|
|
690
689
|
return addNode(node);
|
|
@@ -758,7 +757,7 @@ private:
|
|
|
758
757
|
return addNode(node);
|
|
759
758
|
}
|
|
760
759
|
/// Add a unique return node for a procedure
|
|
761
|
-
inline NodeID addRetNode(const
|
|
760
|
+
inline NodeID addRetNode(const SVFFunction*, SVFVar *node)
|
|
762
761
|
{
|
|
763
762
|
return addNode(node);
|
|
764
763
|
}
|
|
@@ -320,14 +320,9 @@ private:
|
|
|
320
320
|
const SVFFunction* realDefFun; /// the definition of a function across multiple modules
|
|
321
321
|
std::vector<const ArgValVar*> allArgs; /// all formal arguments of this function
|
|
322
322
|
SVFBasicBlock *exitBlock; /// a 'single' basic block having no successors and containing return instruction in a function
|
|
323
|
-
const CallGraphNode *callGraphNode; /// call graph node for this function
|
|
324
323
|
BasicBlockGraph* bbGraph; /// the basic block graph of this function
|
|
325
324
|
|
|
326
325
|
protected:
|
|
327
|
-
inline void setCallGraphNode(CallGraphNode *cgn)
|
|
328
|
-
{
|
|
329
|
-
callGraphNode = cgn;
|
|
330
|
-
}
|
|
331
326
|
|
|
332
327
|
inline void addArgument(const ArgValVar* arg)
|
|
333
328
|
{
|
|
@@ -355,11 +350,6 @@ public:
|
|
|
355
350
|
SVFFunction(void) = delete;
|
|
356
351
|
virtual ~SVFFunction();
|
|
357
352
|
|
|
358
|
-
inline const CallGraphNode* getCallGraphNode() const
|
|
359
|
-
{
|
|
360
|
-
return callGraphNode;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
353
|
static inline bool classof(const SVFValue *node)
|
|
364
354
|
{
|
|
365
355
|
return node->getKind() == SVFFunc;
|
|
@@ -366,7 +366,7 @@ class ArgValVar: public ValVar
|
|
|
366
366
|
friend class SVFIRReader;
|
|
367
367
|
|
|
368
368
|
private:
|
|
369
|
-
const
|
|
369
|
+
const SVFFunction* cgNode;
|
|
370
370
|
u32_t argNo;
|
|
371
371
|
|
|
372
372
|
protected:
|
|
@@ -399,7 +399,7 @@ public:
|
|
|
399
399
|
//@}
|
|
400
400
|
|
|
401
401
|
/// Constructor
|
|
402
|
-
ArgValVar(NodeID i, u32_t argNo, const ICFGNode* icn, const
|
|
402
|
+
ArgValVar(NodeID i, u32_t argNo, const ICFGNode* icn, const SVFFunction* callGraphNode,
|
|
403
403
|
const SVFType* svfType);
|
|
404
404
|
|
|
405
405
|
/// Return name of a LLVM value
|
|
@@ -968,7 +968,7 @@ class FunValVar : public ValVar
|
|
|
968
968
|
friend class SVFIRWriter;
|
|
969
969
|
friend class SVFIRReader;
|
|
970
970
|
private:
|
|
971
|
-
const
|
|
971
|
+
const SVFFunction* callGraphNode;
|
|
972
972
|
|
|
973
973
|
public:
|
|
974
974
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
@@ -995,13 +995,13 @@ public:
|
|
|
995
995
|
}
|
|
996
996
|
//@}
|
|
997
997
|
|
|
998
|
-
inline const
|
|
998
|
+
inline virtual const SVFFunction* getFunction() const
|
|
999
999
|
{
|
|
1000
1000
|
return callGraphNode;
|
|
1001
1001
|
}
|
|
1002
1002
|
|
|
1003
1003
|
/// Constructor
|
|
1004
|
-
FunValVar(NodeID i, const ICFGNode* icn, const
|
|
1004
|
+
FunValVar(NodeID i, const ICFGNode* icn, const SVFFunction* cgn, const SVFType* svfType);
|
|
1005
1005
|
|
|
1006
1006
|
|
|
1007
1007
|
virtual bool isPointer() const
|
|
@@ -1018,7 +1018,7 @@ class FunObjVar : public BaseObjVar
|
|
|
1018
1018
|
friend class SVFIRReader;
|
|
1019
1019
|
|
|
1020
1020
|
private:
|
|
1021
|
-
const
|
|
1021
|
+
const SVFFunction* callGraphNode;
|
|
1022
1022
|
|
|
1023
1023
|
private:
|
|
1024
1024
|
/// Constructor to create empty ObjVar (for SVFIRReader/deserialization)
|
|
@@ -1054,9 +1054,9 @@ public:
|
|
|
1054
1054
|
//@}
|
|
1055
1055
|
|
|
1056
1056
|
/// Constructor
|
|
1057
|
-
FunObjVar(NodeID i, ObjTypeInfo* ti, const
|
|
1057
|
+
FunObjVar(NodeID i, ObjTypeInfo* ti, const SVFFunction* cgNode, const SVFType* svfType, const ICFGNode* node);
|
|
1058
1058
|
|
|
1059
|
-
inline const
|
|
1059
|
+
inline const SVFFunction* getCallGraphNode() const
|
|
1060
1060
|
{
|
|
1061
1061
|
return callGraphNode;
|
|
1062
1062
|
}
|
|
@@ -1782,7 +1782,7 @@ class RetValPN : public ValVar
|
|
|
1782
1782
|
friend class SVFIRReader;
|
|
1783
1783
|
|
|
1784
1784
|
private:
|
|
1785
|
-
const
|
|
1785
|
+
const SVFFunction* callGraphNode;
|
|
1786
1786
|
private:
|
|
1787
1787
|
/// Constructor to create empty RetValPN (for SVFIRReader/deserialization)
|
|
1788
1788
|
RetValPN(NodeID i) : ValVar(i, RetValNode) {}
|
|
@@ -1813,9 +1813,9 @@ public:
|
|
|
1813
1813
|
|
|
1814
1814
|
|
|
1815
1815
|
/// Constructor
|
|
1816
|
-
RetValPN(NodeID i, const
|
|
1816
|
+
RetValPN(NodeID i, const SVFFunction* node, const SVFType* svfType, const ICFGNode* icn);
|
|
1817
1817
|
|
|
1818
|
-
inline const
|
|
1818
|
+
inline const SVFFunction* getCallGraphNode() const
|
|
1819
1819
|
{
|
|
1820
1820
|
return callGraphNode;
|
|
1821
1821
|
}
|
|
@@ -1838,7 +1838,7 @@ class VarArgValPN : public ValVar
|
|
|
1838
1838
|
friend class SVFIRWriter;
|
|
1839
1839
|
friend class SVFIRReader;
|
|
1840
1840
|
private:
|
|
1841
|
-
const
|
|
1841
|
+
const SVFFunction* callGraphNode;
|
|
1842
1842
|
|
|
1843
1843
|
private:
|
|
1844
1844
|
/// Constructor to create empty VarArgValPN (for SVFIRReader/deserialization)
|
|
@@ -1869,7 +1869,7 @@ public:
|
|
|
1869
1869
|
//@}
|
|
1870
1870
|
|
|
1871
1871
|
/// Constructor
|
|
1872
|
-
VarArgValPN(NodeID i, const
|
|
1872
|
+
VarArgValPN(NodeID i, const SVFFunction* node, const SVFType* svfType, const ICFGNode* icn)
|
|
1873
1873
|
: ValVar(i, svfType, icn, VarargValNode), callGraphNode(node)
|
|
1874
1874
|
{
|
|
1875
1875
|
}
|
|
@@ -73,10 +73,10 @@ protected:
|
|
|
73
73
|
|
|
74
74
|
/// Both rep and sub nodes need to be processed later.
|
|
75
75
|
/// Collect sub nodes from SCCDetector.
|
|
76
|
-
|
|
76
|
+
FIFOWorkList<NodeID> revTopoStack = this->getSCCDetector()->revTopoNodeStack();
|
|
77
77
|
while (!revTopoStack.empty())
|
|
78
78
|
{
|
|
79
|
-
NodeID nodeId = revTopoStack.
|
|
79
|
+
NodeID nodeId = revTopoStack.front();
|
|
80
80
|
revTopoStack.pop();
|
|
81
81
|
const NodeBS& subNodes = this->getSCCDetector()->subNodes(nodeId);
|
|
82
82
|
for (NodeBS::iterator it = subNodes.begin(), eit = subNodes.end(); it != eit; ++it)
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
#include "SVFIR/SVFIR.h"
|
|
31
31
|
#include "Util/Options.h"
|
|
32
32
|
#include "Util/WorkList.h"
|
|
33
|
-
#include "Graphs/
|
|
33
|
+
#include "Graphs/PTACallGraph.h"
|
|
34
34
|
#include <cmath>
|
|
35
35
|
|
|
36
36
|
using namespace SVF;
|
|
@@ -84,19 +84,19 @@ void AbstractInterpretation::initWTO()
|
|
|
84
84
|
// Detect if the call graph has cycles by finding its strongly connected components (SCC)
|
|
85
85
|
Andersen::CallGraphSCC* callGraphScc = ander->getCallGraphSCC();
|
|
86
86
|
callGraphScc->find();
|
|
87
|
-
|
|
87
|
+
PTACallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph();
|
|
88
88
|
|
|
89
89
|
// Iterate through the call graph
|
|
90
90
|
for (auto it = svfirCallGraph->begin(); it != svfirCallGraph->end(); it++)
|
|
91
91
|
{
|
|
92
92
|
// Check if the current function is part of a cycle
|
|
93
93
|
if (callGraphScc->isInCycle(it->second->getId()))
|
|
94
|
-
recursiveFuns.insert(it->second); // Mark the function as recursive
|
|
94
|
+
recursiveFuns.insert(it->second->getFunction()); // Mark the function as recursive
|
|
95
95
|
if (it->second->getFunction()->isDeclaration())
|
|
96
96
|
continue;
|
|
97
97
|
auto* wto = new ICFGWTO(icfg, icfg->getFunEntryICFGNode(it->second->getFunction()));
|
|
98
98
|
wto->init();
|
|
99
|
-
funcToWTO[it->second] = wto;
|
|
99
|
+
funcToWTO[it->second->getFunction()] = wto;
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
/// Program entry
|
|
@@ -107,9 +107,9 @@ void AbstractInterpretation::analyse()
|
|
|
107
107
|
handleGlobalNode();
|
|
108
108
|
getAbsStateFromTrace(
|
|
109
109
|
icfg->getGlobalICFGNode())[PAG::getPAG()->getBlkPtr()] = IntervalValue::top();
|
|
110
|
-
if (const
|
|
110
|
+
if (const PTACallGraphNode* cgn = svfir->getCallGraph()->getCallGraphNode("main"))
|
|
111
111
|
{
|
|
112
|
-
ICFGWTO* wto = funcToWTO[cgn];
|
|
112
|
+
ICFGWTO* wto = funcToWTO[cgn->getFunction()];
|
|
113
113
|
handleWTOComponents(wto->getWTOComponents());
|
|
114
114
|
}
|
|
115
115
|
}
|
|
@@ -585,7 +585,7 @@ bool AbstractInterpretation::isRecursiveCall(const SVF::CallICFGNode *callNode)
|
|
|
585
585
|
if (!callfun)
|
|
586
586
|
return false;
|
|
587
587
|
else
|
|
588
|
-
return recursiveFuns.find(callfun
|
|
588
|
+
return recursiveFuns.find(callfun) != recursiveFuns.end();
|
|
589
589
|
}
|
|
590
590
|
|
|
591
591
|
void AbstractInterpretation::recursiveCallPass(const SVF::CallICFGNode *callNode)
|
|
@@ -613,7 +613,7 @@ bool AbstractInterpretation::isDirectCall(const SVF::CallICFGNode *callNode)
|
|
|
613
613
|
if (!callfun)
|
|
614
614
|
return false;
|
|
615
615
|
else
|
|
616
|
-
return funcToWTO.find(callfun
|
|
616
|
+
return funcToWTO.find(callfun) != funcToWTO.end();
|
|
617
617
|
}
|
|
618
618
|
void AbstractInterpretation::directCallFunPass(const SVF::CallICFGNode *callNode)
|
|
619
619
|
{
|
|
@@ -623,7 +623,7 @@ void AbstractInterpretation::directCallFunPass(const SVF::CallICFGNode *callNode
|
|
|
623
623
|
abstractTrace[callNode] = as;
|
|
624
624
|
|
|
625
625
|
const SVFFunction *callfun =callNode->getCalledFunction();
|
|
626
|
-
ICFGWTO* wto = funcToWTO[callfun
|
|
626
|
+
ICFGWTO* wto = funcToWTO[callfun];
|
|
627
627
|
handleWTOComponents(wto->getWTOComponents());
|
|
628
628
|
|
|
629
629
|
callSiteStack.pop_back();
|
|
@@ -653,7 +653,7 @@ void AbstractInterpretation::indirectCallFunPass(const SVF::CallICFGNode *callNo
|
|
|
653
653
|
SVFVar *func_var = svfir->getGNode(AbstractState::getInternalID(addr));
|
|
654
654
|
if(const FunObjVar*funObjVar = SVFUtil::dyn_cast<FunObjVar>(func_var))
|
|
655
655
|
{
|
|
656
|
-
const
|
|
656
|
+
const SVFFunction* callfun = funObjVar->getFunction();
|
|
657
657
|
callSiteStack.push_back(callNode);
|
|
658
658
|
abstractTrace[callNode] = as;
|
|
659
659
|
|
|
@@ -195,7 +195,7 @@ bool ContextDDA::testIndCallReachability(CxtLocDPItem& dpm, const SVFFunction* c
|
|
|
195
195
|
CxtVar funptrVar(dpm.getCondVar().get_cond(), id);
|
|
196
196
|
CxtLocDPItem funptrDpm = getDPIm(funptrVar,getDefSVFGNode(node));
|
|
197
197
|
PointsTo pts = getBVPointsTo(findPT(funptrDpm));
|
|
198
|
-
if(pts.test(getPAG()->getFunObjVar(callee
|
|
198
|
+
if(pts.test(getPAG()->getFunObjVar(callee)->getId()))
|
|
199
199
|
return true;
|
|
200
200
|
else
|
|
201
201
|
return false;
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
31
|
#include "Graphs/PTACallGraph.h"
|
|
32
|
-
#include "Graphs/
|
|
32
|
+
#include "Graphs/PTACallGraph.h"
|
|
33
33
|
#include "SVFIR/SVFIR.h"
|
|
34
34
|
#include "SVFIR/SVFModule.h"
|
|
35
35
|
#include "Util/SVFUtil.h"
|
|
@@ -114,7 +114,7 @@ PTACallGraph::PTACallGraph(CGEK k): kind(k)
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
/// Copy constructor
|
|
117
|
-
PTACallGraph::PTACallGraph(const
|
|
117
|
+
PTACallGraph::PTACallGraph(const PTACallGraph& other)
|
|
118
118
|
{
|
|
119
119
|
callGraphNodeNum = other.getTotalNodeNum();
|
|
120
120
|
numOfResolvedIndCallEdge = 0;
|
|
@@ -123,7 +123,7 @@ PTACallGraph::PTACallGraph(const CallGraph& other)
|
|
|
123
123
|
/// copy call graph nodes
|
|
124
124
|
for (const auto& item : other)
|
|
125
125
|
{
|
|
126
|
-
const
|
|
126
|
+
const PTACallGraphNode* cgn = item.second;
|
|
127
127
|
PTACallGraphNode* callGraphNode = new PTACallGraphNode(cgn->getId(), cgn->getFunction());
|
|
128
128
|
addGNode(cgn->getId(),callGraphNode);
|
|
129
129
|
funToCallGraphNodeMap[cgn->getFunction()] = callGraphNode;
|
|
@@ -133,7 +133,7 @@ PTACallGraph::PTACallGraph(const CallGraph& other)
|
|
|
133
133
|
for (const auto& item : other.callinstToCallGraphEdgesMap)
|
|
134
134
|
{
|
|
135
135
|
const CallICFGNode* cs = item.first;
|
|
136
|
-
for (const
|
|
136
|
+
for (const PTACallGraphEdge* edge : item.second)
|
|
137
137
|
{
|
|
138
138
|
PTACallGraphNode* src = getCallGraphNode(edge->getSrcID());
|
|
139
139
|
PTACallGraphNode* dst = getCallGraphNode(edge->getDstID());
|
|
@@ -334,6 +334,48 @@ void PTACallGraph::view()
|
|
|
334
334
|
SVF::ViewGraph(this, "Call Graph");
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
+
|
|
338
|
+
/*!
|
|
339
|
+
* Add call graph node
|
|
340
|
+
*/
|
|
341
|
+
void PTACallGraph::addCallGraphNode(const SVFFunction* fun)
|
|
342
|
+
{
|
|
343
|
+
NodeID id = callGraphNodeNum;
|
|
344
|
+
PTACallGraphNode*callGraphNode = new PTACallGraphNode(id, fun);
|
|
345
|
+
addGNode(id, callGraphNode);
|
|
346
|
+
funToCallGraphNodeMap[callGraphNode->getFunction()] = callGraphNode;
|
|
347
|
+
callGraphNodeNum++;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const PTACallGraphNode* PTACallGraph::getCallGraphNode(const std::string& name)
|
|
351
|
+
{
|
|
352
|
+
for (const auto& item : *this)
|
|
353
|
+
{
|
|
354
|
+
if (item.second->getName() == name)
|
|
355
|
+
return item.second;
|
|
356
|
+
}
|
|
357
|
+
return nullptr;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/*!
|
|
361
|
+
* Add direct call edges
|
|
362
|
+
*/
|
|
363
|
+
void PTACallGraph::addDirectCallGraphEdge(const CallICFGNode* cs,const SVFFunction* callerFun, const SVFFunction* calleeFun)
|
|
364
|
+
{
|
|
365
|
+
|
|
366
|
+
PTACallGraphNode* caller = getCallGraphNode(callerFun);
|
|
367
|
+
PTACallGraphNode* callee = getCallGraphNode(calleeFun);
|
|
368
|
+
CallSiteID csId = addCallSite(cs, calleeFun);
|
|
369
|
+
|
|
370
|
+
if(!hasGraphEdge(caller,callee, PTACallGraphEdge::CallRetEdge, csId))
|
|
371
|
+
{
|
|
372
|
+
PTACallGraphEdge* edge = new PTACallGraphEdge(caller,callee, PTACallGraphEdge::CallRetEdge, csId);
|
|
373
|
+
edge->addDirectCallSite(cs);
|
|
374
|
+
addEdge(edge);
|
|
375
|
+
callinstToCallGraphEdgesMap[cs].insert(edge);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
337
379
|
namespace SVF
|
|
338
380
|
{
|
|
339
381
|
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
#include "Util/ThreadAPI.h"
|
|
33
33
|
#include "SVFIR/SVFIR.h"
|
|
34
34
|
#include "MemoryModel/PointerAnalysisImpl.h"
|
|
35
|
-
#include "Graphs/
|
|
35
|
+
#include "Graphs/PTACallGraph.h"
|
|
36
36
|
|
|
37
37
|
using namespace SVF;
|
|
38
38
|
using namespace SVFUtil;
|
|
@@ -40,7 +40,7 @@ using namespace SVFUtil;
|
|
|
40
40
|
/*!
|
|
41
41
|
* Constructor
|
|
42
42
|
*/
|
|
43
|
-
ThreadCallGraph::ThreadCallGraph(const
|
|
43
|
+
ThreadCallGraph::ThreadCallGraph(const PTACallGraph& cg) :
|
|
44
44
|
PTACallGraph(cg), tdAPI(ThreadAPI::getThreadAPI())
|
|
45
45
|
{
|
|
46
46
|
kind = ThdCallGraph;
|
|
@@ -127,8 +127,8 @@ bool ThreadCallGraph::addDirectForkEdge(const CallICFGNode* cs)
|
|
|
127
127
|
{
|
|
128
128
|
|
|
129
129
|
PTACallGraphNode* caller = getCallGraphNode(cs->getCaller());
|
|
130
|
-
const
|
|
131
|
-
|
|
130
|
+
const FunValVar* funValvar = SVFUtil::dyn_cast<FunValVar>(tdAPI->getForkedFun(cs));
|
|
131
|
+
const SVFFunction* forkee = funValvar->getFunction();
|
|
132
132
|
assert(forkee && "callee does not exist");
|
|
133
133
|
PTACallGraphNode* callee = getCallGraphNode(forkee->getDefFunForMultipleModule());
|
|
134
134
|
CallSiteID csId = addCallSite(cs, callee->getFunction());
|
|
@@ -188,9 +188,7 @@ void ThreadCallGraph::addDirectJoinEdge(const CallICFGNode* cs,const CallSiteSet
|
|
|
188
188
|
{
|
|
189
189
|
|
|
190
190
|
const SVFFunction* threadRoutineFun =
|
|
191
|
-
SVFUtil::dyn_cast<FunValVar>(tdAPI->getForkedFun(*it))
|
|
192
|
-
->getCallGraphNode()
|
|
193
|
-
->getFunction();
|
|
191
|
+
SVFUtil::dyn_cast<FunValVar>(tdAPI->getForkedFun(*it))->getFunction();
|
|
194
192
|
assert(threadRoutineFun && "thread routine function does not exist");
|
|
195
193
|
PTACallGraphNode* threadRoutineFunNode = getCallGraphNode(threadRoutineFun);
|
|
196
194
|
CallSiteID csId = addCallSite(cs, threadRoutineFun);
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
#include "SVFIR/SVFModule.h"
|
|
32
32
|
#include "MSSA/MemRegion.h"
|
|
33
33
|
#include "MSSA/MSSAMuChi.h"
|
|
34
|
-
#include "Graphs/
|
|
34
|
+
#include "Graphs/PTACallGraph.h"
|
|
35
35
|
|
|
36
36
|
using namespace SVF;
|
|
37
37
|
using namespace SVFUtil;
|
|
@@ -174,7 +174,7 @@ SVFIR::SVFStmtList& MRGenerator::getPAGEdgesFromInst(const ICFGNode* node)
|
|
|
174
174
|
void MRGenerator::collectModRefForLoadStore()
|
|
175
175
|
{
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
PTACallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph();
|
|
178
178
|
for (const auto& item: *svfirCallGraph)
|
|
179
179
|
{
|
|
180
180
|
const SVFFunction& fun = *item.second->getFunction();
|
|
@@ -238,12 +238,12 @@ void MRGenerator::collectModRefForCall()
|
|
|
238
238
|
|
|
239
239
|
DBOUT(DGENERAL, outs() << pasMsg("\t\tPerform Callsite Mod-Ref \n"));
|
|
240
240
|
|
|
241
|
-
WorkList worklist;
|
|
242
|
-
getCallGraphSCCRevTopoOrder(worklist);
|
|
241
|
+
WorkList worklist = callGraphSCC->revTopoNodeStack();
|
|
243
242
|
|
|
244
243
|
while(!worklist.empty())
|
|
245
244
|
{
|
|
246
|
-
NodeID callGraphNodeID = worklist.
|
|
245
|
+
NodeID callGraphNodeID = worklist.front();
|
|
246
|
+
worklist.pop();
|
|
247
247
|
/// handle all sub scc nodes of this rep node
|
|
248
248
|
const NodeBS& subNodes = callGraphSCC->subNodes(callGraphNodeID);
|
|
249
249
|
for(NodeBS::iterator it = subNodes.begin(), eit = subNodes.end(); it!=eit; ++it)
|
|
@@ -456,20 +456,6 @@ bool MRGenerator::addModSideEffectOfCallSite(const CallICFGNode* cs, const NodeB
|
|
|
456
456
|
}
|
|
457
457
|
|
|
458
458
|
|
|
459
|
-
/*!
|
|
460
|
-
* Get the reverse topo order of scc call graph
|
|
461
|
-
*/
|
|
462
|
-
void MRGenerator::getCallGraphSCCRevTopoOrder(WorkList& worklist)
|
|
463
|
-
{
|
|
464
|
-
NodeStack revTopoNodeStack = callGraphSCC->revTopoNodeStack();
|
|
465
|
-
while(!revTopoNodeStack.empty())
|
|
466
|
-
{
|
|
467
|
-
NodeID callgraphNodeID = revTopoNodeStack.top();
|
|
468
|
-
revTopoNodeStack.pop();
|
|
469
|
-
worklist.push(callgraphNodeID);
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
|
|
473
459
|
/*!
|
|
474
460
|
* Get all objects might pass into and pass out of callee(s) from a callsite
|
|
475
461
|
*/
|
package/svf/lib/MSSA/MemSSA.cpp
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
#include "MSSA/MemPartition.h"
|
|
32
32
|
#include "MSSA/MemSSA.h"
|
|
33
33
|
#include "Graphs/SVFGStat.h"
|
|
34
|
-
#include "Graphs/
|
|
34
|
+
#include "Graphs/PTACallGraph.h"
|
|
35
35
|
|
|
36
36
|
using namespace SVF;
|
|
37
37
|
using namespace SVFUtil;
|
|
@@ -576,7 +576,7 @@ u32_t MemSSA::getBBPhiNum() const
|
|
|
576
576
|
void MemSSA::dumpMSSA(OutStream& Out)
|
|
577
577
|
{
|
|
578
578
|
|
|
579
|
-
|
|
579
|
+
PTACallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph();
|
|
580
580
|
for (const auto& item: *svfirCallGraph)
|
|
581
581
|
{
|
|
582
582
|
const SVFFunction* fun = item.second->getFunction();
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
#include "Graphs/SVFG.h"
|
|
34
34
|
#include "MSSA/SVFGBuilder.h"
|
|
35
35
|
#include "WPA/Andersen.h"
|
|
36
|
-
#include "Graphs/
|
|
36
|
+
#include "Graphs/PTACallGraph.h"
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
using namespace SVF;
|
|
@@ -103,7 +103,7 @@ std::unique_ptr<MemSSA> SVFGBuilder::buildMSSA(BVDataPTAImpl* pta, bool ptrOnlyM
|
|
|
103
103
|
|
|
104
104
|
auto mssa = std::make_unique<MemSSA>(pta, ptrOnlyMSSA);
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
PTACallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph();
|
|
107
107
|
for (const auto& item: *svfirCallGraph)
|
|
108
108
|
{
|
|
109
109
|
|