svf-lib 1.0.2195 → 1.0.2197
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/bin/ae +0 -0
- package/SVF-linux/Release-build/bin/cfl +0 -0
- package/SVF-linux/Release-build/bin/dvf +0 -0
- package/SVF-linux/Release-build/bin/llvm2svf +0 -0
- package/SVF-linux/Release-build/bin/mta +0 -0
- package/SVF-linux/Release-build/bin/saber +0 -0
- package/SVF-linux/Release-build/bin/svf-ex +0 -0
- package/SVF-linux/Release-build/bin/wpa +0 -0
- package/SVF-linux/Release-build/include/AE/Svfexe/AbsExtAPI.h +0 -7
- package/SVF-linux/Release-build/include/CFL/CFLAlias.h +0 -8
- package/SVF-linux/Release-build/include/DDA/DDAPass.h +4 -1
- package/SVF-linux/Release-build/include/Graphs/ConsG.h +0 -5
- package/SVF-linux/Release-build/include/Graphs/IRGraph.h +0 -24
- package/SVF-linux/Release-build/include/MSSA/MemRegion.h +1 -1
- package/SVF-linux/Release-build/include/MemoryModel/PointerAnalysis.h +2 -2
- package/SVF-linux/Release-build/include/MemoryModel/PointerAnalysisImpl.h +7 -4
- package/SVF-linux/Release-build/include/SVFIR/SVFIR.h +3 -3
- package/SVF-linux/Release-build/include/SVFIR/SVFVariables.h +3 -3
- package/SVF-linux/Release-build/include/Util/SVFUtil.h +0 -16
- package/SVF-linux/Release-build/include/WPA/WPAPass.h +0 -7
- package/SVF-linux/Release-build/lib/libSvfCore.a +0 -0
- package/SVF-linux/Release-build/lib/libSvfLLVM.a +0 -0
- package/SVF-osx/Release-build/bin/ae +0 -0
- package/SVF-osx/Release-build/bin/cfl +0 -0
- package/SVF-osx/Release-build/bin/dvf +0 -0
- package/SVF-osx/Release-build/bin/llvm2svf +0 -0
- package/SVF-osx/Release-build/bin/mta +0 -0
- package/SVF-osx/Release-build/bin/saber +0 -0
- package/SVF-osx/Release-build/bin/svf-ex +0 -0
- package/SVF-osx/Release-build/bin/wpa +0 -0
- package/SVF-osx/Release-build/include/Graphs/IRGraph.h +238 -29
- package/SVF-osx/Release-build/include/MemoryModel/AccessPath.h +0 -1
- package/SVF-osx/Release-build/include/SVF-LLVM/LLVMModule.h +1 -1
- package/SVF-osx/Release-build/include/SVF-LLVM/SymbolTableBuilder.h +3 -3
- package/SVF-osx/Release-build/include/SVFIR/ObjTypeInfo.h +225 -0
- package/SVF-osx/Release-build/include/SVFIR/SVFIR.h +9 -19
- package/SVF-osx/Release-build/include/SVFIR/SVFVariables.h +4 -9
- package/SVF-osx/Release-build/lib/libSvfCore.a +0 -0
- package/SVF-osx/Release-build/lib/libSvfLLVM.a +0 -0
- package/package.json +1 -1
- package/SVF-osx/Release-build/include/SVFIR/SymbolTableInfo.h +0 -545
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -130,13 +130,6 @@ public:
|
|
|
130
130
|
*/
|
|
131
131
|
AbstractState& getAbsStateFromTrace(const ICFGNode* node);
|
|
132
132
|
|
|
133
|
-
/**
|
|
134
|
-
* @brief Retrieves the SVF variable from a given SVF value.
|
|
135
|
-
* @param val Pointer to the SVF value.
|
|
136
|
-
* @return Pointer to the corresponding SVF variable.
|
|
137
|
-
*/
|
|
138
|
-
const SVFVar* getSVFVar(const SVFValue* val);
|
|
139
|
-
|
|
140
133
|
protected:
|
|
141
134
|
SVFIR* svfir; ///< Pointer to the SVF intermediate representation.
|
|
142
135
|
ICFG* icfg; ///< Pointer to the interprocedural control flow graph.
|
|
@@ -61,14 +61,6 @@ public:
|
|
|
61
61
|
/// Solving CFL Reachability
|
|
62
62
|
virtual void solve();
|
|
63
63
|
|
|
64
|
-
/// Interface exposed to users of our Alias analysis, given Value infos
|
|
65
|
-
virtual AliasResult alias(const SVFValue* v1, const SVFValue* v2)
|
|
66
|
-
{
|
|
67
|
-
NodeID n1 = svfir->getValueNode(v1);
|
|
68
|
-
NodeID n2 = svfir->getValueNode(v2);
|
|
69
|
-
return alias(n1,n2);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
64
|
/// Interface exposed to users of our Alias analysis, given PAGNodeID
|
|
73
65
|
virtual AliasResult alias(NodeID node1, NodeID node2)
|
|
74
66
|
{
|
|
@@ -57,7 +57,10 @@ public:
|
|
|
57
57
|
~DDAPass();
|
|
58
58
|
|
|
59
59
|
/// Interface expose to users of our pointer analysis, given Value infos
|
|
60
|
-
virtual AliasResult alias(const
|
|
60
|
+
virtual AliasResult alias(const SVFVar* V1, const SVFVar* V2)
|
|
61
|
+
{
|
|
62
|
+
return alias(V1->getId(), V2->getId());
|
|
63
|
+
}
|
|
61
64
|
|
|
62
65
|
/// Interface expose to users of our pointer analysis, given PAGNodes
|
|
63
66
|
virtual AliasResult alias(NodeID V1, NodeID V2);
|
|
@@ -76,11 +76,6 @@ protected:
|
|
|
76
76
|
|
|
77
77
|
/// Wrappers used internally, not expose to Andersen Pass
|
|
78
78
|
//@{
|
|
79
|
-
inline NodeID getValueNode(const SVFValue* value) const
|
|
80
|
-
{
|
|
81
|
-
return sccRepNode(pag->getValueNode(value));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
79
|
inline NodeID getReturnNode(const SVFFunction* value) const
|
|
85
80
|
{
|
|
86
81
|
return pag->getReturnNode(value);
|
|
@@ -53,7 +53,6 @@ class IRGraph : public GenericGraph<SVFVar, SVFStmt>
|
|
|
53
53
|
|
|
54
54
|
public:
|
|
55
55
|
typedef Set<const SVFStmt*> SVFStmtSet;
|
|
56
|
-
typedef Map<const SVFValue*,SVFStmtSet> ValueToEdgeMap;
|
|
57
56
|
|
|
58
57
|
protected:
|
|
59
58
|
SVFStmt::KindToSVFStmtMapTy KindToSVFStmtSetMap; ///< SVFIR edge map containing all PAGEdges
|
|
@@ -61,7 +60,6 @@ protected:
|
|
|
61
60
|
bool fromFile; ///< Whether the SVFIR is built according to user specified data from a txt file
|
|
62
61
|
NodeID nodeNumAfterPAGBuild; ///< initial node number after building SVFIR, excluding later added nodes, e.g., gepobj nodes
|
|
63
62
|
u32_t totalPTAPAGEdge;
|
|
64
|
-
ValueToEdgeMap valueToEdgeMap; ///< Map SVFValues (e.g., ICFGNodes) to all corresponding PAGEdges
|
|
65
63
|
SymbolTableInfo* symInfo;
|
|
66
64
|
|
|
67
65
|
/// Add a node into the graph
|
|
@@ -86,22 +84,11 @@ protected:
|
|
|
86
84
|
SVFStmt* hasLabeledEdge(SVFVar* src, SVFVar* op1, SVFStmt::PEDGEK kind,
|
|
87
85
|
const SVFVar* op2);
|
|
88
86
|
|
|
89
|
-
/// Map a value to a set of edges
|
|
90
|
-
inline void mapValueToEdge(const SVFValue* V, SVFStmt *edge)
|
|
91
|
-
{
|
|
92
|
-
auto inserted = valueToEdgeMap.emplace(V, SVFStmtSet{edge});
|
|
93
|
-
if (!inserted.second)
|
|
94
|
-
{
|
|
95
|
-
inserted.first->second.emplace(edge);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
87
|
public:
|
|
99
88
|
IRGraph(bool buildFromFile)
|
|
100
89
|
: fromFile(buildFromFile), nodeNumAfterPAGBuild(0), totalPTAPAGEdge(0)
|
|
101
90
|
{
|
|
102
91
|
symInfo = SymbolTableInfo::SymbolInfo();
|
|
103
|
-
// insert dummy value if a correct value cannot be found
|
|
104
|
-
valueToEdgeMap[nullptr] = SVFStmtSet();
|
|
105
92
|
}
|
|
106
93
|
|
|
107
94
|
virtual ~IRGraph();
|
|
@@ -115,17 +102,6 @@ public:
|
|
|
115
102
|
{
|
|
116
103
|
return fromFile;
|
|
117
104
|
}
|
|
118
|
-
/// Get all SVFIR Edges that corresponds to an LLVM value
|
|
119
|
-
inline const SVFStmtSet& getValueEdges(const SVFValue* V)
|
|
120
|
-
{
|
|
121
|
-
auto it = valueToEdgeMap.find(V);
|
|
122
|
-
if (it == valueToEdgeMap.end())
|
|
123
|
-
{
|
|
124
|
-
//special empty set
|
|
125
|
-
return valueToEdgeMap.at(nullptr);
|
|
126
|
-
}
|
|
127
|
-
return it->second;
|
|
128
|
-
}
|
|
129
105
|
|
|
130
106
|
/// Get SVFIR Node according to LLVM value
|
|
131
107
|
///getNode - Return the node corresponding to the specified pointer.
|
|
@@ -480,7 +480,7 @@ public:
|
|
|
480
480
|
NodeBS getModInfoForCall(const CallICFGNode* cs);
|
|
481
481
|
NodeBS getRefInfoForCall(const CallICFGNode* cs);
|
|
482
482
|
ModRefInfo getModRefInfo(const CallICFGNode* cs);
|
|
483
|
-
ModRefInfo getModRefInfo(const CallICFGNode* cs, const
|
|
483
|
+
ModRefInfo getModRefInfo(const CallICFGNode* cs, const SVFVar* V);
|
|
484
484
|
ModRefInfo getModRefInfo(const CallICFGNode* cs1, const CallICFGNode* cs2);
|
|
485
485
|
//@}
|
|
486
486
|
|
|
@@ -233,8 +233,8 @@ public:
|
|
|
233
233
|
virtual void computeDDAPts(NodeID) {}
|
|
234
234
|
|
|
235
235
|
/// Interface exposed to users of our pointer analysis, given Value infos
|
|
236
|
-
virtual AliasResult alias(const
|
|
237
|
-
const
|
|
236
|
+
virtual AliasResult alias(const SVFVar* V1,
|
|
237
|
+
const SVFVar* V2) = 0;
|
|
238
238
|
|
|
239
239
|
/// Interface exposed to users of our pointer analysis, given PAGNodeID
|
|
240
240
|
virtual AliasResult alias(NodeID node1, NodeID node2) = 0;
|
|
@@ -215,8 +215,11 @@ private:
|
|
|
215
215
|
|
|
216
216
|
public:
|
|
217
217
|
/// Interface expose to users of our pointer analysis, given Value infos
|
|
218
|
-
AliasResult alias(const
|
|
219
|
-
const
|
|
218
|
+
AliasResult alias(const SVFVar* V1,
|
|
219
|
+
const SVFVar* V2) override
|
|
220
|
+
{
|
|
221
|
+
return alias(V1->getId(), V2->getId());
|
|
222
|
+
}
|
|
220
223
|
|
|
221
224
|
/// Interface expose to users of our pointer analysis, given PAGNodeID
|
|
222
225
|
AliasResult alias(NodeID node1, NodeID node2) override;
|
|
@@ -501,9 +504,9 @@ public:
|
|
|
501
504
|
}
|
|
502
505
|
|
|
503
506
|
/// Interface expose to users of our pointer analysis, given Value infos
|
|
504
|
-
virtual inline AliasResult alias(const
|
|
507
|
+
virtual inline AliasResult alias(const SVFVar* V1, const SVFVar* V2)
|
|
505
508
|
{
|
|
506
|
-
return alias(
|
|
509
|
+
return alias(V1->getId(), V2->getId());
|
|
507
510
|
}
|
|
508
511
|
/// Interface expose to users of our pointer analysis, given two pointers
|
|
509
512
|
virtual inline AliasResult alias(NodeID node1, NodeID node2)
|
|
@@ -70,7 +70,7 @@ public:
|
|
|
70
70
|
typedef std::pair<NodeID, AccessPath> NodeAccessPath;
|
|
71
71
|
typedef Map<NodeOffset,NodeID> NodeOffsetMap;
|
|
72
72
|
typedef Map<NodeAccessPath,NodeID> NodeAccessPathMap;
|
|
73
|
-
typedef Map<
|
|
73
|
+
typedef Map<NodeID, NodeAccessPathMap> GepValueVarMap;
|
|
74
74
|
typedef std::pair<const SVFType*, std::vector<AccessPath>> SVFTypeLocSetsPair;
|
|
75
75
|
typedef Map<NodeID, SVFTypeLocSetsPair> TypeLocSetsMap;
|
|
76
76
|
typedef Map<NodePair,NodeID> NodePairSetMap;
|
|
@@ -343,7 +343,7 @@ public:
|
|
|
343
343
|
//@}
|
|
344
344
|
|
|
345
345
|
/// Due to constraint expression, curInst is used to distinguish different instructions (e.g., memorycpy) when creating GepValVar.
|
|
346
|
-
NodeID getGepValVar(
|
|
346
|
+
NodeID getGepValVar(NodeID curInst, NodeID base,
|
|
347
347
|
const AccessPath& ap) const;
|
|
348
348
|
|
|
349
349
|
/// Add/get indirect callsites
|
|
@@ -693,7 +693,7 @@ private:
|
|
|
693
693
|
}
|
|
694
694
|
|
|
695
695
|
/// Add a temp field value node, this method can only invoked by getGepValVar
|
|
696
|
-
NodeID addGepValNode(
|
|
696
|
+
NodeID addGepValNode(NodeID curInst, const ValVar* base, const AccessPath& ap, NodeID i, const SVFType* type, const ICFGNode* node);
|
|
697
697
|
/// Add a field obj node, this method can only invoked by getGepObjVar
|
|
698
698
|
NodeID addGepObjNode(const BaseObjVar* baseObj, const APOffset& apOffset, const NodeID gepId);
|
|
699
699
|
/// Add a field-insensitive node, this method can only invoked by getFIGepObjNode
|
|
@@ -443,7 +443,7 @@ class GepValVar: public ValVar
|
|
|
443
443
|
|
|
444
444
|
private:
|
|
445
445
|
AccessPath ap; // AccessPath
|
|
446
|
-
ValVar* base; // base node
|
|
446
|
+
const ValVar* base; // base node
|
|
447
447
|
const SVFType* gepValType;
|
|
448
448
|
|
|
449
449
|
/// Constructor to create empty GeValVar (for SVFIRReader/deserialization)
|
|
@@ -475,7 +475,7 @@ public:
|
|
|
475
475
|
//@}
|
|
476
476
|
|
|
477
477
|
/// Constructor
|
|
478
|
-
GepValVar(ValVar* baseNode, NodeID i, const AccessPath& ap,
|
|
478
|
+
GepValVar(const ValVar* baseNode, NodeID i, const AccessPath& ap,
|
|
479
479
|
const SVFType* ty, const ICFGNode* node);
|
|
480
480
|
|
|
481
481
|
/// offset of the base value variable
|
|
@@ -485,7 +485,7 @@ public:
|
|
|
485
485
|
}
|
|
486
486
|
|
|
487
487
|
/// Return the base object from which this GEP node came from.
|
|
488
|
-
inline ValVar* getBaseNode(void) const
|
|
488
|
+
inline const ValVar* getBaseNode(void) const
|
|
489
489
|
{
|
|
490
490
|
return base;
|
|
491
491
|
}
|
|
@@ -171,14 +171,6 @@ bool isIntrinsicInst(const SVFInstruction* inst);
|
|
|
171
171
|
bool isIntrinsicInst(const ICFGNode* inst);
|
|
172
172
|
//@}
|
|
173
173
|
|
|
174
|
-
/// Whether an instruction is a call or invoke instruction
|
|
175
|
-
inline bool isCallSite(const SVFValue* val)
|
|
176
|
-
{
|
|
177
|
-
if(SVFUtil::isa<SVFCallInst>(val))
|
|
178
|
-
return true;
|
|
179
|
-
else
|
|
180
|
-
return false;
|
|
181
|
-
}
|
|
182
174
|
|
|
183
175
|
bool isCallSite(const ICFGNode* inst);
|
|
184
176
|
|
|
@@ -342,14 +334,6 @@ inline bool isProgExitFunction (const SVFFunction * fun)
|
|
|
342
334
|
fun->getName() == "__assert_fail" );
|
|
343
335
|
}
|
|
344
336
|
|
|
345
|
-
/// Return true if this argument belongs to an uncalled function
|
|
346
|
-
inline bool isArgOfUncalledFunction(const SVFValue* svfval)
|
|
347
|
-
{
|
|
348
|
-
if(const SVFArgument* arg = SVFUtil::dyn_cast<SVFArgument>(svfval))
|
|
349
|
-
return arg->isArgOfUncalledFunction();
|
|
350
|
-
else
|
|
351
|
-
return false;
|
|
352
|
-
}
|
|
353
337
|
|
|
354
338
|
bool isArgOfUncalledFunction(const SVFVar* svfvar);
|
|
355
339
|
|
|
@@ -75,11 +75,7 @@ public:
|
|
|
75
75
|
/// Destructor
|
|
76
76
|
virtual ~WPAPass();
|
|
77
77
|
|
|
78
|
-
/// Interface expose to users of our pointer analysis, given Value infos
|
|
79
|
-
virtual AliasResult alias(const SVFValue* V1, const SVFValue* V2);
|
|
80
|
-
|
|
81
78
|
/// Retrieve points-to set information
|
|
82
|
-
virtual const PointsTo& getPts(const SVFValue* value);
|
|
83
79
|
virtual const PointsTo& getPts(NodeID var);
|
|
84
80
|
|
|
85
81
|
/// Print all alias pairs
|
|
@@ -94,9 +90,6 @@ public:
|
|
|
94
90
|
// return getModRefInfo(callInst, Loc.Ptr);
|
|
95
91
|
// }
|
|
96
92
|
|
|
97
|
-
/// Interface of mod-ref analysis to determine whether a CallSite instruction can mod or ref a specific memory location, given Value infos
|
|
98
|
-
virtual ModRefInfo getModRefInfo(const CallICFGNode* callInst, const SVFValue* V);
|
|
99
|
-
|
|
100
93
|
/// Interface of mod-ref analysis between two CallSite instructions
|
|
101
94
|
virtual ModRefInfo getModRefInfo(const CallICFGNode* callInst1, const CallICFGNode* callInst2);
|
|
102
95
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -42,6 +42,8 @@ namespace SVF
|
|
|
42
42
|
typedef SVFVar PAGNode;
|
|
43
43
|
typedef SVFStmt PAGEdge;
|
|
44
44
|
|
|
45
|
+
class ObjTypeInfo;
|
|
46
|
+
|
|
45
47
|
/*
|
|
46
48
|
* Graph representation of SVF IR.
|
|
47
49
|
* It can be seen as a program assignment graph (PAG).
|
|
@@ -50,6 +52,58 @@ class IRGraph : public GenericGraph<SVFVar, SVFStmt>
|
|
|
50
52
|
{
|
|
51
53
|
friend class SVFIRWriter;
|
|
52
54
|
friend class SVFIRReader;
|
|
55
|
+
friend class SymbolTableBuilder;
|
|
56
|
+
|
|
57
|
+
public:
|
|
58
|
+
|
|
59
|
+
/// Symbol types
|
|
60
|
+
enum SYMTYPE
|
|
61
|
+
{
|
|
62
|
+
NullPtr,
|
|
63
|
+
BlkPtr,
|
|
64
|
+
BlackHole,
|
|
65
|
+
ConstantObj,
|
|
66
|
+
ValSymbol,
|
|
67
|
+
ObjSymbol,
|
|
68
|
+
RetSymbol,
|
|
69
|
+
VarargSymbol
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/// various maps defined
|
|
73
|
+
//{@
|
|
74
|
+
/// llvm value to sym id map
|
|
75
|
+
/// local (%) and global (@) identifiers are pointer types which have a value node id.
|
|
76
|
+
typedef OrderedMap<const SVFValue*, NodeID> ValueToIDMapTy;
|
|
77
|
+
/// sym id to obj type info map
|
|
78
|
+
typedef OrderedMap<NodeID, ObjTypeInfo*> IDToTypeInfoMapTy;
|
|
79
|
+
|
|
80
|
+
/// function to sym id map
|
|
81
|
+
typedef OrderedMap<const SVFFunction*, NodeID> FunToIDMapTy;
|
|
82
|
+
/// struct type to struct info map
|
|
83
|
+
typedef Set<const SVFType*> SVFTypeSet;
|
|
84
|
+
//@}
|
|
85
|
+
|
|
86
|
+
private:
|
|
87
|
+
ValueToIDMapTy valSymMap; ///< map a value to its sym id
|
|
88
|
+
ValueToIDMapTy objSymMap; ///< map a obj reference to its sym id
|
|
89
|
+
FunToIDMapTy returnSymMap; ///< return map
|
|
90
|
+
FunToIDMapTy varargSymMap; ///< vararg map
|
|
91
|
+
IDToTypeInfoMapTy objTypeInfoMap; ///< map a memory sym id to its obj
|
|
92
|
+
|
|
93
|
+
/// (owned) All SVF Types
|
|
94
|
+
/// Every type T is mapped to StInfo
|
|
95
|
+
/// which contains size (fsize) , offset(foffset)
|
|
96
|
+
/// fsize[i] is the number of fields in the largest such struct, else fsize[i] = 1.
|
|
97
|
+
/// fsize[0] is always the size of the expanded struct.
|
|
98
|
+
SVFTypeSet svfTypes;
|
|
99
|
+
|
|
100
|
+
/// @brief (owned) All StInfo
|
|
101
|
+
Set<const StInfo*> stInfos;
|
|
102
|
+
|
|
103
|
+
/// total number of symbols
|
|
104
|
+
NodeID totalSymNum;
|
|
105
|
+
|
|
106
|
+
void destorySymTable();
|
|
53
107
|
|
|
54
108
|
public:
|
|
55
109
|
typedef Set<const SVFStmt*> SVFStmtSet;
|
|
@@ -60,7 +114,6 @@ protected:
|
|
|
60
114
|
bool fromFile; ///< Whether the SVFIR is built according to user specified data from a txt file
|
|
61
115
|
NodeID nodeNumAfterPAGBuild; ///< initial node number after building SVFIR, excluding later added nodes, e.g., gepobj nodes
|
|
62
116
|
u32_t totalPTAPAGEdge;
|
|
63
|
-
SymbolTableInfo* symInfo;
|
|
64
117
|
|
|
65
118
|
/// Add a node into the graph
|
|
66
119
|
inline NodeID addNode(SVFVar* node)
|
|
@@ -86,74 +139,203 @@ protected:
|
|
|
86
139
|
|
|
87
140
|
public:
|
|
88
141
|
IRGraph(bool buildFromFile)
|
|
89
|
-
: fromFile(buildFromFile), nodeNumAfterPAGBuild(0), totalPTAPAGEdge(0)
|
|
142
|
+
: totalSymNum(0), fromFile(buildFromFile), nodeNumAfterPAGBuild(0), totalPTAPAGEdge(0),
|
|
143
|
+
maxStruct(nullptr), maxStSize(0)
|
|
90
144
|
{
|
|
91
|
-
symInfo = SymbolTableInfo::SymbolInfo();
|
|
92
145
|
}
|
|
93
146
|
|
|
94
147
|
virtual ~IRGraph();
|
|
95
148
|
|
|
96
|
-
|
|
97
|
-
{
|
|
98
|
-
return symInfo;
|
|
99
|
-
}
|
|
149
|
+
|
|
100
150
|
/// Whether this SVFIR built from a txt file
|
|
101
151
|
inline bool isBuiltFromFile()
|
|
102
152
|
{
|
|
103
153
|
return fromFile;
|
|
104
154
|
}
|
|
105
155
|
|
|
106
|
-
///
|
|
107
|
-
|
|
108
|
-
inline
|
|
156
|
+
/// special value
|
|
157
|
+
// @{
|
|
158
|
+
static inline bool isBlkPtr(NodeID id)
|
|
109
159
|
{
|
|
110
|
-
return
|
|
160
|
+
return (id == BlkPtr);
|
|
111
161
|
}
|
|
112
|
-
inline bool
|
|
162
|
+
static inline bool isNullPtr(NodeID id)
|
|
113
163
|
{
|
|
114
|
-
return
|
|
164
|
+
return (id == NullPtr);
|
|
115
165
|
}
|
|
116
|
-
|
|
117
|
-
/// specified global, heap or alloca instruction according to llvm value.
|
|
118
|
-
inline NodeID getObjectNode(const SVFValue* V)
|
|
166
|
+
static inline bool isBlkObj(NodeID id)
|
|
119
167
|
{
|
|
120
|
-
return
|
|
168
|
+
return (id == BlackHole);
|
|
121
169
|
}
|
|
122
|
-
|
|
123
|
-
inline NodeID getReturnNode(const SVFFunction* func) const
|
|
170
|
+
static inline bool isConstantSym(NodeID id)
|
|
124
171
|
{
|
|
125
|
-
return
|
|
172
|
+
return (id == ConstantObj);
|
|
126
173
|
}
|
|
127
|
-
|
|
128
|
-
|
|
174
|
+
static inline bool isBlkObjOrConstantObj(NodeID id)
|
|
175
|
+
{
|
|
176
|
+
return (isBlkObj(id) || isConstantSym(id));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
inline NodeID blkPtrSymID() const
|
|
180
|
+
{
|
|
181
|
+
return BlkPtr;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
inline NodeID nullPtrSymID() const
|
|
185
|
+
{
|
|
186
|
+
return NullPtr;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
inline NodeID constantSymID() const
|
|
190
|
+
{
|
|
191
|
+
return ConstantObj;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
inline NodeID blackholeSymID() const
|
|
195
|
+
{
|
|
196
|
+
return BlackHole;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/// Statistics
|
|
200
|
+
//@{
|
|
201
|
+
inline u32_t getTotalSymNum() const
|
|
202
|
+
{
|
|
203
|
+
return totalSymNum;
|
|
204
|
+
}
|
|
205
|
+
inline u32_t getMaxStructSize() const
|
|
206
|
+
{
|
|
207
|
+
return maxStSize;
|
|
208
|
+
}
|
|
209
|
+
//@}
|
|
210
|
+
|
|
211
|
+
/// Get different kinds of syms maps
|
|
212
|
+
//@{
|
|
213
|
+
inline ValueToIDMapTy& valSyms()
|
|
214
|
+
{
|
|
215
|
+
return valSymMap;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
inline ValueToIDMapTy& objSyms()
|
|
219
|
+
{
|
|
220
|
+
return objSymMap;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
inline IDToTypeInfoMapTy& idToObjTypeInfoMap()
|
|
224
|
+
{
|
|
225
|
+
return objTypeInfoMap;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
inline const IDToTypeInfoMapTy& idToObjTypeInfoMap() const
|
|
129
229
|
{
|
|
130
|
-
return
|
|
230
|
+
return objTypeInfoMap;
|
|
131
231
|
}
|
|
232
|
+
|
|
233
|
+
inline FunToIDMapTy& retSyms()
|
|
234
|
+
{
|
|
235
|
+
return returnSymMap;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
inline FunToIDMapTy& varargSyms()
|
|
239
|
+
{
|
|
240
|
+
return varargSymMap;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
//@}
|
|
244
|
+
|
|
245
|
+
/// Get SVFIR Node according to LLVM value
|
|
246
|
+
///getNode - Return the node corresponding to the specified pointer.
|
|
247
|
+
NodeID getValueNode(const SVFValue* V);
|
|
248
|
+
|
|
249
|
+
bool hasValueNode(const SVFValue* V);
|
|
250
|
+
|
|
251
|
+
/// getObject - Return the obj node id refer to the memory object for the
|
|
252
|
+
/// specified global, heap or alloca instruction according to llvm value.
|
|
253
|
+
NodeID getObjectNode(const SVFValue* V);
|
|
254
|
+
|
|
255
|
+
inline ObjTypeInfo* getObjTypeInfo(NodeID id) const
|
|
256
|
+
{
|
|
257
|
+
IDToTypeInfoMapTy::const_iterator iter = objTypeInfoMap.find(id);
|
|
258
|
+
assert(iter!=objTypeInfoMap.end() && "obj type info not found");
|
|
259
|
+
return iter->second;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/// GetReturnNode - Return the unique node representing the return value of a function
|
|
263
|
+
NodeID getReturnNode(const SVFFunction* func) const;
|
|
264
|
+
|
|
265
|
+
/// getVarargNode - Return the unique node representing the variadic argument of a variadic function.
|
|
266
|
+
NodeID getVarargNode(const SVFFunction* func) const;
|
|
267
|
+
|
|
132
268
|
inline NodeID getBlackHoleNode() const
|
|
133
269
|
{
|
|
134
|
-
return
|
|
270
|
+
return blackholeSymID();
|
|
135
271
|
}
|
|
136
272
|
inline NodeID getConstantNode() const
|
|
137
273
|
{
|
|
138
|
-
return
|
|
274
|
+
return constantSymID();
|
|
139
275
|
}
|
|
140
276
|
inline NodeID getBlkPtr() const
|
|
141
277
|
{
|
|
142
|
-
return
|
|
278
|
+
return blkPtrSymID();
|
|
143
279
|
}
|
|
144
280
|
inline NodeID getNullPtr() const
|
|
145
281
|
{
|
|
146
|
-
return
|
|
282
|
+
return nullPtrSymID();
|
|
147
283
|
}
|
|
148
284
|
|
|
149
285
|
inline u32_t getValueNodeNum() const
|
|
150
286
|
{
|
|
151
|
-
return
|
|
287
|
+
return valSymMap.size();
|
|
152
288
|
}
|
|
153
289
|
inline u32_t getObjectNodeNum() const
|
|
154
290
|
{
|
|
155
|
-
return
|
|
291
|
+
return objTypeInfoMap.size();
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/// Constant reader that won't change the state of the symbol table
|
|
295
|
+
//@{
|
|
296
|
+
inline const SVFTypeSet& getSVFTypes() const
|
|
297
|
+
{
|
|
298
|
+
return svfTypes;
|
|
156
299
|
}
|
|
300
|
+
|
|
301
|
+
inline const Set<const StInfo*>& getStInfos() const
|
|
302
|
+
{
|
|
303
|
+
return stInfos;
|
|
304
|
+
}
|
|
305
|
+
//@}
|
|
306
|
+
/// Given an offset from a Gep Instruction, return it modulus offset by considering memory layout
|
|
307
|
+
virtual APOffset getModulusOffset(const BaseObjVar* baseObj, const APOffset& apOffset);
|
|
308
|
+
/// Get struct info
|
|
309
|
+
//@{
|
|
310
|
+
///Get a reference to StructInfo.
|
|
311
|
+
const StInfo* getTypeInfo(const SVFType* T) const;
|
|
312
|
+
inline bool hasSVFTypeInfo(const SVFType* T)
|
|
313
|
+
{
|
|
314
|
+
return svfTypes.find(T) != svfTypes.end();
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/// Create an objectInfo based on LLVM type (value is null, and type could be null, representing a dummy object)
|
|
318
|
+
ObjTypeInfo* createObjTypeInfo(const SVFType* type);
|
|
319
|
+
|
|
320
|
+
const ObjTypeInfo* createDummyObjTypeInfo(NodeID symId, const SVFType* type);
|
|
321
|
+
|
|
322
|
+
///Get a reference to the components of struct_info.
|
|
323
|
+
/// Number of flattened elements of an array or struct
|
|
324
|
+
u32_t getNumOfFlattenElements(const SVFType* T);
|
|
325
|
+
/// Flattened element idx of an array or struct by considering stride
|
|
326
|
+
u32_t getFlattenedElemIdx(const SVFType* T, u32_t origId);
|
|
327
|
+
/// Return the type of a flattened element given a flattened index
|
|
328
|
+
const SVFType* getFlatternedElemType(const SVFType* baseType, u32_t flatten_idx);
|
|
329
|
+
/// struct A { int id; int salary; }; struct B { char name[20]; struct A a;} B b;
|
|
330
|
+
/// OriginalElemType of b with field_idx 1 : Struct A
|
|
331
|
+
/// FlatternedElemType of b with field_idx 1 : int
|
|
332
|
+
const SVFType* getOriginalElemType(const SVFType* baseType, u32_t origId) const;
|
|
333
|
+
//@}
|
|
334
|
+
|
|
335
|
+
/// Debug method
|
|
336
|
+
void printFlattenFields(const SVFType* type);
|
|
337
|
+
|
|
338
|
+
|
|
157
339
|
inline u32_t getNodeNumAfterPAGBuild() const
|
|
158
340
|
{
|
|
159
341
|
return nodeNumAfterPAGBuild;
|
|
@@ -181,11 +363,38 @@ public:
|
|
|
181
363
|
return "SVFIR";
|
|
182
364
|
}
|
|
183
365
|
|
|
366
|
+
void dumpSymTable();
|
|
367
|
+
|
|
184
368
|
/// Dump SVFIR
|
|
185
369
|
void dump(std::string name);
|
|
186
370
|
|
|
187
371
|
/// View graph from the debugger
|
|
188
372
|
void view();
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
///The struct type with the most fields
|
|
377
|
+
const SVFType* maxStruct;
|
|
378
|
+
|
|
379
|
+
///The number of fields in max_struct
|
|
380
|
+
u32_t maxStSize;
|
|
381
|
+
|
|
382
|
+
inline void addTypeInfo(const SVFType* ty)
|
|
383
|
+
{
|
|
384
|
+
bool inserted = svfTypes.insert(ty).second;
|
|
385
|
+
if(!inserted)
|
|
386
|
+
assert(false && "this type info has been added before");
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
inline void addStInfo(StInfo* stInfo)
|
|
390
|
+
{
|
|
391
|
+
stInfos.insert(stInfo);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
protected:
|
|
395
|
+
|
|
396
|
+
/// Return the flattened field type for struct type only
|
|
397
|
+
const std::vector<const SVFType*>& getFlattenFieldTypes(const SVFStructType *T);
|
|
189
398
|
};
|
|
190
399
|
|
|
191
400
|
}
|