svf-lib 1.0.732 → 1.0.736
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/ContextDDA.h +1 -1
- package/SVF-linux/include/DDA/DDAClient.h +8 -8
- package/SVF-linux/include/DDA/DDAVFSolver.h +5 -5
- package/SVF-linux/include/DDA/FlowDDA.h +1 -1
- package/SVF-linux/include/Graphs/ConsG.h +6 -6
- package/SVF-linux/include/Graphs/ConsGEdge.h +2 -2
- package/SVF-linux/include/Graphs/ConsGNode.h +1 -1
- package/SVF-linux/include/Graphs/ExternalPAG.h +14 -14
- package/SVF-linux/include/Graphs/GenericGraph.h +1 -1
- package/SVF-linux/include/Graphs/ICFGNode.h +14 -14
- package/SVF-linux/include/Graphs/IRGraph.h +236 -0
- package/SVF-linux/include/Graphs/OfflineConsG.h +1 -1
- package/SVF-linux/include/Graphs/SVFG.h +1 -1
- package/SVF-linux/include/Graphs/SVFGOPT.h +3 -3
- package/SVF-linux/include/Graphs/VFG.h +37 -52
- package/SVF-linux/include/Graphs/VFGNode.h +2 -3
- package/SVF-linux/include/MSSA/MemRegion.h +11 -11
- package/SVF-linux/include/MSSA/MemSSA.h +4 -4
- package/SVF-linux/include/MTA/FSMPTA.h +1 -1
- package/SVF-linux/include/MemoryModel/PAGBuilderFromFile.h +8 -8
- package/SVF-linux/include/MemoryModel/PTAStat.h +31 -31
- package/SVF-linux/include/MemoryModel/PointerAnalysis.h +9 -9
- package/SVF-linux/include/MemoryModel/PointerAnalysisImpl.h +3 -3
- package/SVF-linux/include/MemoryModel/SVFIR.h +526 -235
- package/SVF-linux/include/MemoryModel/SVFStatements.h +872 -0
- package/SVF-linux/include/MemoryModel/SVFVariables.h +842 -0
- package/SVF-linux/include/MemoryModel/SymbolTableInfo.h +346 -55
- package/SVF-linux/include/SABER/SaberSVFGBuilder.h +0 -2
- package/SVF-linux/include/SABER/SrcSnkDDA.h +3 -3
- package/SVF-linux/include/SVF-FE/Graph2Json.h +1 -3
- package/SVF-linux/include/SVF-FE/SVFIRBuilder.h +398 -0
- package/SVF-linux/include/SVF-FE/SymbolTableBuilder.h +0 -1
- package/SVF-linux/include/Util/CFLSolver.h +1 -1
- package/SVF-linux/include/Util/ExtAPI.h +1 -1
- package/SVF-linux/include/Util/IRAnnotator.h +6 -6
- package/SVF-linux/include/Util/Options.h +1 -1
- package/SVF-linux/include/Util/TypeBasedHeapCloning.h +11 -11
- package/SVF-linux/include/WPA/Andersen.h +11 -11
- package/SVF-linux/include/WPA/AndersenSFR.h +4 -4
- package/SVF-linux/include/WPA/FlowSensitive.h +2 -2
- package/SVF-linux/include/WPA/FlowSensitiveTBHC.h +1 -1
- package/SVF-linux/include/WPA/Steensgaard.h +2 -2
- package/SVF-linux/include/WPA/TypeAnalysis.h +1 -1
- package/SVF-linux/include/WPA/VersionedFlowSensitive.h +2 -2
- package/SVF-linux/include/WPA/WPAStat.h +1 -2
- 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 +5 -5
- 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/GenericGraph.h +1 -1
- package/SVF-osx/include/Graphs/ICFGNode.h +14 -14
- package/SVF-osx/include/Graphs/IRGraph.h +236 -0
- package/SVF-osx/include/Graphs/OfflineConsG.h +1 -1
- 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 +37 -52
- 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/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 +526 -235
- package/SVF-osx/include/MemoryModel/SVFStatements.h +872 -0
- package/SVF-osx/include/MemoryModel/SVFVariables.h +842 -0
- package/SVF-osx/include/MemoryModel/SymbolTableInfo.h +346 -55
- 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 +398 -0
- package/SVF-osx/include/SVF-FE/SymbolTableBuilder.h +0 -1
- 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/TypeBasedHeapCloning.h +11 -11
- package/SVF-osx/include/WPA/Andersen.h +11 -11
- 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
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
//===- SVFIR.h -- SVF IR Graph or PAG (Program Assignment Graph)--------------------------------------//
|
|
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
|
+
* IRGraph.h
|
|
25
|
+
*
|
|
26
|
+
* Created on: Nov 1, 2013
|
|
27
|
+
* Author: Yulei Sui
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
#ifndef IRGRAPH_H_
|
|
32
|
+
#define IRGRAPH_H_
|
|
33
|
+
|
|
34
|
+
#include "MemoryModel/SVFStatements.h"
|
|
35
|
+
#include "MemoryModel/SVFVariables.h"
|
|
36
|
+
#include "Util/NodeIDAllocator.h"
|
|
37
|
+
#include "Util/SVFUtil.h"
|
|
38
|
+
#include "Graphs/ICFG.h"
|
|
39
|
+
|
|
40
|
+
namespace SVF
|
|
41
|
+
{
|
|
42
|
+
typedef SVFVar PAGNode;
|
|
43
|
+
typedef SVFStmt PAGEdge;
|
|
44
|
+
|
|
45
|
+
/*
|
|
46
|
+
* Graph representation of SVF IR. It can be seen as a program assignment graph (PAG)
|
|
47
|
+
*/
|
|
48
|
+
class IRGraph : public GenericGraph<SVFVar,SVFStmt>
|
|
49
|
+
{
|
|
50
|
+
public:
|
|
51
|
+
typedef Set<const SVFStmt*> PAGEdgeSet;
|
|
52
|
+
typedef Map<const Value*,PAGEdgeSet> ValueToEdgeMap;
|
|
53
|
+
|
|
54
|
+
protected:
|
|
55
|
+
SVFStmt::PAGKindToEdgeSetMapTy PAGEdgeKindToSetMap; // < SVFIR edge map containing all PAGEdges
|
|
56
|
+
SVFStmt::PAGKindToEdgeSetMapTy PTAPAGEdgeKindToSetMap; // < SVFIR edge map containing only pointer-related edges, i.e, both RHS and RHS are of pointer type
|
|
57
|
+
bool fromFile; ///< Whether the SVFIR is built according to user specified data from a txt file
|
|
58
|
+
NodeID nodeNumAfterPAGBuild; // initial node number after building SVFIR, excluding later added nodes, e.g., gepobj nodes
|
|
59
|
+
u32_t totalPTAPAGEdge;
|
|
60
|
+
ValueToEdgeMap valueToEdgeMap; ///< Map llvm::Values to all corresponding PAGEdges
|
|
61
|
+
SymbolTableInfo* symInfo;
|
|
62
|
+
|
|
63
|
+
/// Add a node into the graph
|
|
64
|
+
inline NodeID addNode(SVFVar* node, NodeID i)
|
|
65
|
+
{
|
|
66
|
+
addGNode(i,node);
|
|
67
|
+
return i;
|
|
68
|
+
}
|
|
69
|
+
/// Add an edge into the graph
|
|
70
|
+
bool addEdge(SVFVar* src, SVFVar* dst, SVFStmt* edge);
|
|
71
|
+
|
|
72
|
+
//// Return true if this edge exits
|
|
73
|
+
SVFStmt* hasNonlabeledEdge(SVFVar* src, SVFVar* dst, SVFStmt::PEDGEK kind);
|
|
74
|
+
/// Return true if this labeled edge exits, including store, call and load
|
|
75
|
+
/// two store edge can have same dst and src but located in different basic blocks, thus flags are needed to distinguish them
|
|
76
|
+
SVFStmt* hasLabeledEdge(SVFVar* src, SVFVar* dst, SVFStmt::PEDGEK kind, const ICFGNode* cs);
|
|
77
|
+
/// Return MultiOpndStmt since it has more than one operands (we use operand 2 here to make the flag)
|
|
78
|
+
SVFStmt* hasLabeledEdge(SVFVar* src, SVFVar* op1, SVFStmt::PEDGEK kind, const SVFVar* op2);
|
|
79
|
+
|
|
80
|
+
/// Map a value to a set of edges
|
|
81
|
+
inline void mapValueToEdge(const Value *V, SVFStmt *edge)
|
|
82
|
+
{
|
|
83
|
+
auto inserted = valueToEdgeMap.emplace(V, PAGEdgeSet{edge});
|
|
84
|
+
if (!inserted.second) {
|
|
85
|
+
inserted.first->second.emplace(edge);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/// get MemObj according to LLVM value
|
|
89
|
+
inline const MemObj* getMemObj(const Value* val) const{
|
|
90
|
+
return symInfo->getObj(symInfo->getObjSym(val));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public:
|
|
94
|
+
IRGraph(bool buildFromFile): fromFile(buildFromFile), nodeNumAfterPAGBuild(0), totalPTAPAGEdge(0){
|
|
95
|
+
symInfo = SymbolTableInfo::SymbolInfo();
|
|
96
|
+
// insert dummy value if a correct value cannot be found
|
|
97
|
+
valueToEdgeMap[nullptr] = PAGEdgeSet();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
virtual ~IRGraph();
|
|
101
|
+
|
|
102
|
+
/// Whether this SVFIR built from a txt file
|
|
103
|
+
inline bool isBuiltFromFile()
|
|
104
|
+
{
|
|
105
|
+
return fromFile;
|
|
106
|
+
}
|
|
107
|
+
/// Get all SVFIR Edges that corresponds to an LLVM value
|
|
108
|
+
inline const PAGEdgeSet& getValueEdges(const Value *V)
|
|
109
|
+
{
|
|
110
|
+
auto it = valueToEdgeMap.find(V);
|
|
111
|
+
if (it == valueToEdgeMap.end()) {
|
|
112
|
+
//special empty set
|
|
113
|
+
return valueToEdgeMap.at(nullptr);
|
|
114
|
+
}
|
|
115
|
+
return it->second;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/// Get SVFIR Node according to LLVM value
|
|
119
|
+
///getNode - Return the node corresponding to the specified pointer.
|
|
120
|
+
inline NodeID getValueNode(const Value *V)
|
|
121
|
+
{
|
|
122
|
+
return symInfo->getValSym(V);
|
|
123
|
+
}
|
|
124
|
+
inline bool hasValueNode(const Value* V)
|
|
125
|
+
{
|
|
126
|
+
return symInfo->hasValSym(V);
|
|
127
|
+
}
|
|
128
|
+
/// getObject - Return the obj node id refer to the memory object for the
|
|
129
|
+
/// specified global, heap or alloca instruction according to llvm value.
|
|
130
|
+
inline NodeID getObjectNode(const Value *V)
|
|
131
|
+
{
|
|
132
|
+
return symInfo->getObjSym(V);
|
|
133
|
+
}
|
|
134
|
+
/// GetReturnNode - Return the unique node representing the return value of a function
|
|
135
|
+
inline NodeID getReturnNode(const SVFFunction* func) const
|
|
136
|
+
{
|
|
137
|
+
return symInfo->getRetSym(func->getLLVMFun());
|
|
138
|
+
}
|
|
139
|
+
/// getVarargNode - Return the unique node representing the variadic argument of a variadic function.
|
|
140
|
+
inline NodeID getVarargNode(const SVFFunction* func) const
|
|
141
|
+
{
|
|
142
|
+
return symInfo->getVarargSym(func->getLLVMFun());
|
|
143
|
+
}
|
|
144
|
+
inline NodeID getBlackHoleNode() const
|
|
145
|
+
{
|
|
146
|
+
return symInfo->blackholeSymID();
|
|
147
|
+
}
|
|
148
|
+
inline NodeID getConstantNode() const
|
|
149
|
+
{
|
|
150
|
+
return symInfo->constantSymID();
|
|
151
|
+
}
|
|
152
|
+
inline NodeID getBlkPtr() const
|
|
153
|
+
{
|
|
154
|
+
return symInfo->blkPtrSymID();
|
|
155
|
+
}
|
|
156
|
+
inline NodeID getNullPtr() const
|
|
157
|
+
{
|
|
158
|
+
return symInfo->nullPtrSymID();
|
|
159
|
+
}
|
|
160
|
+
inline const MemObj* getBlackHoleObj() const
|
|
161
|
+
{
|
|
162
|
+
return symInfo->getBlkObj();
|
|
163
|
+
}
|
|
164
|
+
inline const MemObj* getConstantObj() const
|
|
165
|
+
{
|
|
166
|
+
return symInfo->getConstantObj();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
inline Size_t getValueNodeNum() const
|
|
170
|
+
{
|
|
171
|
+
return symInfo->valSyms().size();
|
|
172
|
+
}
|
|
173
|
+
inline Size_t getObjectNodeNum() const
|
|
174
|
+
{
|
|
175
|
+
return symInfo->idToObjMap().size();
|
|
176
|
+
}
|
|
177
|
+
inline u32_t getNodeNumAfterPAGBuild() const
|
|
178
|
+
{
|
|
179
|
+
return nodeNumAfterPAGBuild;
|
|
180
|
+
}
|
|
181
|
+
inline void setNodeNumAfterPAGBuild(u32_t num)
|
|
182
|
+
{
|
|
183
|
+
nodeNumAfterPAGBuild = num;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
inline Size_t getPAGNodeNum() const
|
|
187
|
+
{
|
|
188
|
+
return nodeNum;
|
|
189
|
+
}
|
|
190
|
+
inline Size_t getPAGEdgeNum() const
|
|
191
|
+
{
|
|
192
|
+
return edgeNum;
|
|
193
|
+
}
|
|
194
|
+
inline Size_t getPTAPAGEdgeNum() const
|
|
195
|
+
{
|
|
196
|
+
return totalPTAPAGEdge;
|
|
197
|
+
}
|
|
198
|
+
/// Return graph name
|
|
199
|
+
inline std::string getGraphName() const
|
|
200
|
+
{
|
|
201
|
+
return "SVFIR";
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/// Dump SVFIR
|
|
205
|
+
void dump(std::string name);
|
|
206
|
+
|
|
207
|
+
/// View graph from the debugger
|
|
208
|
+
void view();
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
namespace llvm
|
|
215
|
+
{
|
|
216
|
+
|
|
217
|
+
/* !
|
|
218
|
+
* GraphTraits specializations of SVFIR to be used for the generic graph algorithms.
|
|
219
|
+
* Provide graph traits for tranversing from a SVFIR node using standard graph traversals.
|
|
220
|
+
*/
|
|
221
|
+
template<> struct GraphTraits<SVF::SVFVar*> : public GraphTraits<SVF::GenericNode<SVF::SVFVar,SVF::SVFStmt>* >
|
|
222
|
+
{
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
/// Inverse GraphTraits specializations for SVFIR node, it is used for inverse traversal.
|
|
226
|
+
template<> struct GraphTraits<Inverse<SVF::SVFVar *> > : public GraphTraits<Inverse<SVF::GenericNode<SVF::SVFVar,SVF::SVFStmt>* > >
|
|
227
|
+
{
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
template<> struct GraphTraits<SVF::IRGraph*> : public GraphTraits<SVF::GenericGraph<SVF::SVFVar,SVF::SVFStmt>* >
|
|
231
|
+
{
|
|
232
|
+
typedef SVF::SVFVar *NodeRef;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
} // End namespace llvm
|
|
236
|
+
#endif /* IRGRAPH_H_ */
|
|
@@ -55,7 +55,7 @@ protected:
|
|
|
55
55
|
NodeToRepMap norToRepMap; // for each *a construct a --> rep, i.e., mapping a node of to a rep node for online constraint solving
|
|
56
56
|
|
|
57
57
|
public:
|
|
58
|
-
OfflineConsG(
|
|
58
|
+
OfflineConsG(SVFIR *p) : ConstraintGraph(p),
|
|
59
59
|
nodeToRefMap( {}), norToRepMap({})
|
|
60
60
|
{
|
|
61
61
|
buildOfflineCG();
|
|
@@ -369,7 +369,7 @@ protected:
|
|
|
369
369
|
}
|
|
370
370
|
else
|
|
371
371
|
{
|
|
372
|
-
assert((it->second == node->getId()) && "a
|
|
372
|
+
assert((it->second == node->getId()) && "a SVFIR node can only have unique definition ");
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
375
|
inline NodeID getDef(const MRVer* mvar) const
|
|
@@ -259,7 +259,7 @@ private:
|
|
|
259
259
|
inline void resetDef(const PAGNode* pagNode, const SVFGNode* node)
|
|
260
260
|
{
|
|
261
261
|
PAGNodeToDefMapTy::iterator it = PAGNodeToDefMap.find(pagNode);
|
|
262
|
-
assert(it != PAGNodeToDefMap.end() && "a
|
|
262
|
+
assert(it != PAGNodeToDefMap.end() && "a SVFIR node doesn't have definition before");
|
|
263
263
|
PAGNodeToDefMap[pagNode] = node->getId();
|
|
264
264
|
}
|
|
265
265
|
|
|
@@ -290,11 +290,11 @@ private:
|
|
|
290
290
|
//@{
|
|
291
291
|
inline bool actualInOfIndCS(const ActualINSVFGNode* ai) const
|
|
292
292
|
{
|
|
293
|
-
return (
|
|
293
|
+
return (SVFIR::getPAG()->isIndirectCallSites(ai->getCallSite()));
|
|
294
294
|
}
|
|
295
295
|
inline bool actualOutOfIndCS(const ActualOUTSVFGNode* ao) const
|
|
296
296
|
{
|
|
297
|
-
return (
|
|
297
|
+
return (SVFIR::getPAG()->isIndirectCallSites(ao->getCallSite()));
|
|
298
298
|
}
|
|
299
299
|
//@}
|
|
300
300
|
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
#define INCLUDE_UTIL_VFG_H_
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
#include "
|
|
34
|
+
#include "MemoryModel/SVFIR.h"
|
|
35
35
|
#include "Graphs/PTACallGraph.h"
|
|
36
36
|
#include "Graphs/VFGNode.h"
|
|
37
37
|
#include "Graphs/VFGEdge.h"
|
|
@@ -78,7 +78,7 @@ public:
|
|
|
78
78
|
typedef VFGEdge::VFGEdgeSetTy::iterator VFGNodeIter;
|
|
79
79
|
typedef VFGNodeIDToNodeMapTy::iterator iterator;
|
|
80
80
|
typedef VFGNodeIDToNodeMapTy::const_iterator const_iterator;
|
|
81
|
-
typedef
|
|
81
|
+
typedef SVFIR::PAGEdgeSet PAGEdgeSet;
|
|
82
82
|
typedef Set<const VFGNode*> GlobalVFGNodeSet;
|
|
83
83
|
typedef Set<const PAGNode*> PAGNodeSet;
|
|
84
84
|
|
|
@@ -99,7 +99,7 @@ protected:
|
|
|
99
99
|
|
|
100
100
|
GlobalVFGNodeSet globalVFGNodes; ///< set of global store VFG nodes
|
|
101
101
|
PTACallGraph* callgraph;
|
|
102
|
-
|
|
102
|
+
SVFIR* pag;
|
|
103
103
|
VFGK kind;
|
|
104
104
|
|
|
105
105
|
/// Clean up memory
|
|
@@ -127,8 +127,8 @@ public:
|
|
|
127
127
|
return (kind == PTRONLYSVFG) || (kind == PTRONLYSVFG_OPT);
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
/// Return
|
|
131
|
-
inline
|
|
130
|
+
/// Return SVFIR
|
|
131
|
+
inline SVFIR* getPAG() const
|
|
132
132
|
{
|
|
133
133
|
return pag;
|
|
134
134
|
}
|
|
@@ -261,12 +261,12 @@ public:
|
|
|
261
261
|
const VFGNode* defNode = getVFGNode(getDef(pagNode));
|
|
262
262
|
if (const AddrVFGNode* addr = SVFUtil::dyn_cast<AddrVFGNode>(defNode))
|
|
263
263
|
{
|
|
264
|
-
if (
|
|
264
|
+
if (SVFIR::getPAG()->isBlkObjOrConstantObj(addr->getPAGEdge()->getSrcID()))
|
|
265
265
|
return true;
|
|
266
266
|
}
|
|
267
267
|
else if(const CopyVFGNode* copy = SVFUtil::dyn_cast<CopyVFGNode>(defNode))
|
|
268
268
|
{
|
|
269
|
-
if (
|
|
269
|
+
if (SVFIR::getPAG()->isNullPtr(copy->getPAGEdge()->getSrcID()))
|
|
270
270
|
return true;
|
|
271
271
|
}
|
|
272
272
|
}
|
|
@@ -400,13 +400,13 @@ protected:
|
|
|
400
400
|
}
|
|
401
401
|
else
|
|
402
402
|
{
|
|
403
|
-
assert((it->second == node->getId()) && "a
|
|
403
|
+
assert((it->second == node->getId()) && "a SVFIR node can only have unique definition ");
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
406
|
inline NodeID getDef(const PAGNode* pagNode) const
|
|
407
407
|
{
|
|
408
408
|
PAGNodeToDefMapTy::const_iterator it = PAGNodeToDefMap.find(pagNode);
|
|
409
|
-
assert(it!=PAGNodeToDefMap.end() && "
|
|
409
|
+
assert(it!=PAGNodeToDefMap.end() && "SVFIR node does not have a definition??");
|
|
410
410
|
return it->second;
|
|
411
411
|
}
|
|
412
412
|
inline bool hasDef(const PAGNode* pagNode) const
|
|
@@ -503,7 +503,7 @@ protected:
|
|
|
503
503
|
setDef(load->getDstNode(),sNode);
|
|
504
504
|
}
|
|
505
505
|
/// Add a Store VFG node,
|
|
506
|
-
/// To be noted store does not create a new pointer, we do not set def for any
|
|
506
|
+
/// To be noted store does not create a new pointer, we do not set def for any SVFIR node
|
|
507
507
|
void addStoreVFGNode(const StorePE* store)
|
|
508
508
|
{
|
|
509
509
|
StoreVFGNode* sNode = new StoreVFGNode(totalVFGNode++,store);
|
|
@@ -545,7 +545,7 @@ protected:
|
|
|
545
545
|
PAGNodeToFormalRetMap[uniqueFunRet] = sNode;
|
|
546
546
|
/// if this uniqueFunRet is a phi node, which means it will receive values from multiple return instructions of fun
|
|
547
547
|
/// we will set this phi node's def later
|
|
548
|
-
/// Ideally, every function uniqueFunRet should be a PhiNode (
|
|
548
|
+
/// Ideally, every function uniqueFunRet should be a PhiNode (SVFIRBuilder.cpp), unless it does not have ret instruction
|
|
549
549
|
if (!pag->isPhiNode(uniqueFunRet)){
|
|
550
550
|
std::string warn = fun->getName().str();
|
|
551
551
|
SVFUtil::writeWrnMsg(warn + " does not have any ret instruction!");
|
|
@@ -561,70 +561,55 @@ protected:
|
|
|
561
561
|
PAGNodeToActualRetMap[ret] = sNode;
|
|
562
562
|
}
|
|
563
563
|
/// Add an llvm PHI VFG node
|
|
564
|
-
inline void addIntraPHIVFGNode(const
|
|
564
|
+
inline void addIntraPHIVFGNode(const PhiPE* edge)
|
|
565
565
|
{
|
|
566
|
-
IntraPHIVFGNode* sNode = new IntraPHIVFGNode(totalVFGNode++,
|
|
566
|
+
IntraPHIVFGNode* sNode = new IntraPHIVFGNode(totalVFGNode++,edge->getRes());
|
|
567
567
|
u32_t pos = 0;
|
|
568
|
-
|
|
569
|
-
for(PAG::CopyPEList::const_iterator it = oplist.begin(), eit=oplist.end(); it!=eit; ++it,++pos)
|
|
568
|
+
for(auto var : edge->getOpndVars())
|
|
570
569
|
{
|
|
571
|
-
|
|
572
|
-
|
|
570
|
+
sNode->setOpVerAndBB(pos, var, edge->getICFGNode());
|
|
571
|
+
pos++;
|
|
573
572
|
}
|
|
574
|
-
assert(edge && "edge not found?");
|
|
575
573
|
addVFGNode(sNode,edge->getICFGNode());
|
|
576
|
-
setDef(
|
|
577
|
-
PAGNodeToIntraPHIVFGNodeMap[
|
|
574
|
+
setDef(edge->getRes(),sNode);
|
|
575
|
+
PAGNodeToIntraPHIVFGNodeMap[edge->getRes()] = sNode;
|
|
578
576
|
}
|
|
579
577
|
/// Add a Compare VFG node
|
|
580
|
-
inline void addCmpVFGNode(const
|
|
578
|
+
inline void addCmpVFGNode(const CmpPE* edge)
|
|
581
579
|
{
|
|
582
|
-
CmpVFGNode* sNode = new CmpVFGNode(totalVFGNode++,
|
|
580
|
+
CmpVFGNode* sNode = new CmpVFGNode(totalVFGNode++, edge->getRes());
|
|
583
581
|
u32_t pos = 0;
|
|
584
|
-
|
|
585
|
-
for(PAG::CmpPEList::const_iterator it = oplist.begin(), eit=oplist.end(); it!=eit; ++it,++pos)
|
|
582
|
+
for(auto var : edge->getOpndVars())
|
|
586
583
|
{
|
|
587
|
-
|
|
588
|
-
|
|
584
|
+
sNode->setOpVer(pos, var);
|
|
585
|
+
pos++;
|
|
589
586
|
}
|
|
590
|
-
assert(edge && "edge not found?");
|
|
591
587
|
addVFGNode(sNode,edge->getICFGNode());
|
|
592
|
-
setDef(
|
|
593
|
-
PAGNodeToCmpVFGNodeMap[
|
|
588
|
+
setDef(edge->getRes(),sNode);
|
|
589
|
+
PAGNodeToCmpVFGNodeMap[edge->getRes()] = sNode;
|
|
594
590
|
}
|
|
595
591
|
/// Add a BinaryOperator VFG node
|
|
596
|
-
inline void addBinaryOPVFGNode(const
|
|
592
|
+
inline void addBinaryOPVFGNode(const BinaryOPPE* edge)
|
|
597
593
|
{
|
|
598
|
-
BinaryOPVFGNode* sNode = new BinaryOPVFGNode(totalVFGNode++,
|
|
594
|
+
BinaryOPVFGNode* sNode = new BinaryOPVFGNode(totalVFGNode++, edge->getRes());
|
|
599
595
|
u32_t pos = 0;
|
|
600
|
-
|
|
601
|
-
for(PAG::BinaryOPList::const_iterator it = oplist.begin(), eit=oplist.end(); it!=eit; ++it,++pos)
|
|
596
|
+
for(auto var : edge->getOpndVars())
|
|
602
597
|
{
|
|
603
|
-
|
|
604
|
-
|
|
598
|
+
sNode->setOpVer(pos, var);
|
|
599
|
+
pos++;
|
|
605
600
|
}
|
|
606
|
-
|
|
607
|
-
assert(edge && "edge not found?");
|
|
608
601
|
addVFGNode(sNode,edge->getICFGNode());
|
|
609
|
-
setDef(
|
|
610
|
-
PAGNodeToBinaryOPVFGNodeMap[
|
|
602
|
+
setDef(edge->getRes(),sNode);
|
|
603
|
+
PAGNodeToBinaryOPVFGNodeMap[edge->getRes()] = sNode;
|
|
611
604
|
}
|
|
612
605
|
/// Add a UnaryOperator VFG node
|
|
613
|
-
inline void addUnaryOPVFGNode(const
|
|
606
|
+
inline void addUnaryOPVFGNode(const UnaryOPPE* edge)
|
|
614
607
|
{
|
|
615
|
-
UnaryOPVFGNode* sNode = new UnaryOPVFGNode(totalVFGNode++,
|
|
616
|
-
|
|
617
|
-
const PAGEdge* edge = nullptr;
|
|
618
|
-
for(PAG::UnaryOPList::const_iterator it = oplist.begin(), eit=oplist.end(); it!=eit; ++it,++pos)
|
|
619
|
-
{
|
|
620
|
-
edge = *it;
|
|
621
|
-
sNode->setOpVer(pos, (*it)->getSrcNode());
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
assert(edge && "edge not found?");
|
|
608
|
+
UnaryOPVFGNode* sNode = new UnaryOPVFGNode(totalVFGNode++, edge->getDstNode());
|
|
609
|
+
sNode->setOpVer(0, edge->getSrcNode());
|
|
625
610
|
addVFGNode(sNode,edge->getICFGNode());
|
|
626
|
-
setDef(
|
|
627
|
-
PAGNodeToUnaryOPVFGNodeMap[
|
|
611
|
+
setDef(edge->getDstNode(),sNode);
|
|
612
|
+
PAGNodeToUnaryOPVFGNodeMap[edge->getDstNode()] = sNode;
|
|
628
613
|
}
|
|
629
614
|
};
|
|
630
615
|
|
|
@@ -33,8 +33,7 @@
|
|
|
33
33
|
#include "Graphs/GenericGraph.h"
|
|
34
34
|
#include "Graphs/VFGEdge.h"
|
|
35
35
|
#include "Graphs/ICFGNode.h"
|
|
36
|
-
#include "
|
|
37
|
-
#include "Graphs/PAGEdge.h"
|
|
36
|
+
#include "MemoryModel/SVFIR.h"
|
|
38
37
|
|
|
39
38
|
namespace SVF
|
|
40
39
|
{
|
|
@@ -331,7 +330,7 @@ public:
|
|
|
331
330
|
CmpVFGNode(NodeID id,const PAGNode* r): VFGNode(id,Cmp), res(r)
|
|
332
331
|
{
|
|
333
332
|
const CmpInst* cmp = SVFUtil::dyn_cast<CmpInst>(r->getValue());
|
|
334
|
-
assert(cmp && "not a
|
|
333
|
+
assert(cmp && "not a compare operator?");
|
|
335
334
|
}
|
|
336
335
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
337
336
|
//@{
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
#ifndef MEMORYREGION_H_
|
|
31
31
|
#define MEMORYREGION_H_
|
|
32
32
|
|
|
33
|
-
#include "
|
|
33
|
+
#include "MemoryModel/SVFIR.h"
|
|
34
34
|
#include "Graphs/PTACallGraph.h"
|
|
35
35
|
#include "Util/SCC.h"
|
|
36
36
|
#include "Util/WorkList.h"
|
|
@@ -168,8 +168,8 @@ public:
|
|
|
168
168
|
|
|
169
169
|
typedef Map<NodeID, NodeBS> NodeToPTSSMap;
|
|
170
170
|
|
|
171
|
-
///
|
|
172
|
-
typedef
|
|
171
|
+
/// SVFIR edge list
|
|
172
|
+
typedef SVFIR::PAGEdgeList PAGEdgeList;
|
|
173
173
|
/// Call Graph SCC
|
|
174
174
|
typedef SCCDetection<PTACallGraph*> SCC;
|
|
175
175
|
|
|
@@ -197,17 +197,17 @@ private:
|
|
|
197
197
|
|
|
198
198
|
/// Map a function to all its memory regions
|
|
199
199
|
FunToMRsMap funToMRsMap;
|
|
200
|
-
/// Map a load
|
|
200
|
+
/// Map a load SVFIR Edge to its memory regions sets in order for inserting mus in Memory SSA
|
|
201
201
|
LoadsToMRsMap loadsToMRsMap;
|
|
202
|
-
/// Map a store
|
|
202
|
+
/// Map a store SVFIR Edge to its memory regions sets in order for inserting chis in Memory SSA
|
|
203
203
|
StoresToMRsMap storesToMRsMap;
|
|
204
204
|
/// Map a callsite to its refs regions
|
|
205
205
|
CallSiteToMRsMap callsiteToRefMRsMap;
|
|
206
206
|
/// Map a callsite to its mods regions
|
|
207
207
|
CallSiteToMRsMap callsiteToModMRsMap;
|
|
208
|
-
/// Map a load
|
|
208
|
+
/// Map a load SVFIR Edge to its CPts set map
|
|
209
209
|
LoadsToPointsToMap loadsToPointsToMap;
|
|
210
|
-
/// Map a store
|
|
210
|
+
/// Map a store SVFIR Edge to its CPts set map
|
|
211
211
|
StoresToPointsToMap storesToPointsToMap;
|
|
212
212
|
/// Map a callsite to it refs cpts set
|
|
213
213
|
CallSiteToPointsToMap callsiteToRefPointsToMap;
|
|
@@ -235,7 +235,7 @@ private:
|
|
|
235
235
|
/// Map a pointer to its cached points-to chain;
|
|
236
236
|
NodeToPTSSMap cachedPtsChainMap;
|
|
237
237
|
|
|
238
|
-
/// All global variable
|
|
238
|
+
/// All global variable SVFIR node ids
|
|
239
239
|
NodeBS allGlobals;
|
|
240
240
|
|
|
241
241
|
/// Clean up memory
|
|
@@ -427,11 +427,11 @@ public:
|
|
|
427
427
|
/// Start generating memory regions
|
|
428
428
|
virtual void generateMRs();
|
|
429
429
|
|
|
430
|
-
/// Get the function which
|
|
430
|
+
/// Get the function which SVFIR Edge located
|
|
431
431
|
const SVFFunction* getFunction(const PAGEdge* pagEdge) const
|
|
432
432
|
{
|
|
433
433
|
PAGEdgeToFunMap::const_iterator it = pagEdgeToFunMap.find(pagEdge);
|
|
434
|
-
assert(it!=pagEdgeToFunMap.end() && "can not find its function, it is a global
|
|
434
|
+
assert(it!=pagEdgeToFunMap.end() && "can not find its function, it is a global SVFIR edge");
|
|
435
435
|
return it->second;
|
|
436
436
|
}
|
|
437
437
|
/// Get Memory Region set
|
|
@@ -465,7 +465,7 @@ public:
|
|
|
465
465
|
return callsiteToModMRsMap[cs];
|
|
466
466
|
}
|
|
467
467
|
//@}
|
|
468
|
-
/// Whether this instruction has
|
|
468
|
+
/// Whether this instruction has SVFIR Edge
|
|
469
469
|
bool hasPAGEdgeList(const Instruction* inst);
|
|
470
470
|
/// Given an instruction, get all its the PAGEdge (statement) in sequence
|
|
471
471
|
PAGEdgeList& getPAGEdgesFromInst(const Instruction* inst);
|
|
@@ -93,8 +93,8 @@ public:
|
|
|
93
93
|
typedef Map<const MemRegion*, std::vector<MRVer*> > MemRegToVerStackMap;
|
|
94
94
|
typedef Map<const MemRegion*, MRVERSION> MemRegToCounterMap;
|
|
95
95
|
|
|
96
|
-
///
|
|
97
|
-
typedef
|
|
96
|
+
/// SVFIR edge list
|
|
97
|
+
typedef SVFIR::PAGEdgeList PAGEdgeList;
|
|
98
98
|
|
|
99
99
|
/// Statistics
|
|
100
100
|
//@{
|
|
@@ -309,8 +309,8 @@ public:
|
|
|
309
309
|
{
|
|
310
310
|
destroy();
|
|
311
311
|
}
|
|
312
|
-
/// Return
|
|
313
|
-
inline
|
|
312
|
+
/// Return SVFIR
|
|
313
|
+
inline SVFIR* getPAG();
|
|
314
314
|
/// Return PTA
|
|
315
315
|
inline BVDataPTAImpl* getPTA() const
|
|
316
316
|
{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//===- PAGBuilderFromFile.h -- Building
|
|
1
|
+
//===- PAGBuilderFromFile.h -- Building SVFIR from File--------------------------------//
|
|
2
2
|
//
|
|
3
3
|
// SVF: Static Value-Flow Analysis
|
|
4
4
|
//
|
|
@@ -30,24 +30,24 @@
|
|
|
30
30
|
#ifndef INCLUDE_MEMORYMODEL_PAGBUILDERFROMFILE_H_
|
|
31
31
|
#define INCLUDE_MEMORYMODEL_PAGBUILDERFROMFILE_H_
|
|
32
32
|
|
|
33
|
-
#include "
|
|
33
|
+
#include "MemoryModel/SVFIR.h"
|
|
34
34
|
|
|
35
35
|
namespace SVF
|
|
36
36
|
{
|
|
37
37
|
|
|
38
38
|
/*!
|
|
39
|
-
* Build
|
|
39
|
+
* Build SVFIR from a user specified file (for debugging purpose)
|
|
40
40
|
*/
|
|
41
41
|
class PAGBuilderFromFile
|
|
42
42
|
{
|
|
43
43
|
|
|
44
44
|
private:
|
|
45
|
-
|
|
45
|
+
SVFIR* pag;
|
|
46
46
|
std::string file;
|
|
47
47
|
public:
|
|
48
48
|
/// Constructor
|
|
49
49
|
PAGBuilderFromFile(std::string f) :
|
|
50
|
-
pag(
|
|
50
|
+
pag(SVFIR::getPAG(true)), file(f)
|
|
51
51
|
{
|
|
52
52
|
}
|
|
53
53
|
/// Destructor
|
|
@@ -55,8 +55,8 @@ public:
|
|
|
55
55
|
{
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
/// Return
|
|
59
|
-
|
|
58
|
+
/// Return SVFIR
|
|
59
|
+
SVFIR* getPAG() const
|
|
60
60
|
{
|
|
61
61
|
return pag;
|
|
62
62
|
}
|
|
@@ -68,7 +68,7 @@ public:
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
/// Start building
|
|
71
|
-
|
|
71
|
+
SVFIR* build();
|
|
72
72
|
|
|
73
73
|
// Add edges
|
|
74
74
|
void addEdge(NodeID nodeSrc, NodeID nodeDst, Size_t offset,
|