svf-tools 1.0.1034 → 1.0.1035
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/AbsExtAPI.h +0 -7
- package/svf/include/CFL/CFLAlias.h +0 -8
- package/svf/include/DDA/DDAPass.h +4 -1
- package/svf/include/Graphs/ConsG.h +0 -5
- package/svf/include/Graphs/IRGraph.h +0 -24
- package/svf/include/MSSA/MemRegion.h +1 -1
- package/svf/include/MemoryModel/PointerAnalysis.h +2 -2
- package/svf/include/MemoryModel/PointerAnalysisImpl.h +7 -4
- package/svf/include/SVFIR/SVFIR.h +3 -3
- package/svf/include/SVFIR/SVFVariables.h +3 -3
- package/svf/include/Util/SVFUtil.h +0 -16
- package/svf/include/WPA/WPAPass.h +0 -7
- package/svf/lib/AE/Svfexe/AbsExtAPI.cpp +0 -6
- package/svf/lib/DDA/DDAPass.cpp +0 -27
- package/svf/lib/MSSA/MemRegion.cpp +12 -15
- package/svf/lib/MemoryModel/PointerAnalysisImpl.cpp +0 -8
- package/svf/lib/SVFIR/SVFIR.cpp +4 -4
- package/svf/lib/SVFIR/SVFVariables.cpp +1 -1
- package/svf/lib/WPA/WPAPass.cpp +0 -62
- package/svf-llvm/lib/SVFIRBuilder.cpp +2 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svf-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1035",
|
|
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": {
|
|
@@ -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
|
|
|
@@ -757,10 +757,4 @@ IntervalValue AbsExtAPI::getRangeLimitFromType(const SVFType* type)
|
|
|
757
757
|
return IntervalValue::top();
|
|
758
758
|
// other types, return top interval
|
|
759
759
|
}
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
const SVFVar* AbsExtAPI::getSVFVar(const SVF::SVFValue* val)
|
|
763
|
-
{
|
|
764
|
-
assert(svfir->hasGNode(svfir->getValueNode(val)));
|
|
765
|
-
return svfir->getGNode(svfir->getValueNode(val));
|
|
766
760
|
}
|
package/svf/lib/DDA/DDAPass.cpp
CHANGED
|
@@ -290,34 +290,7 @@ AliasResult DDAPass::alias(NodeID node1, NodeID node2)
|
|
|
290
290
|
|
|
291
291
|
return _pta->alias(node1,node2);
|
|
292
292
|
}
|
|
293
|
-
/*!
|
|
294
|
-
* Return alias results based on our points-to/alias analysis
|
|
295
|
-
* TODO: Need to handle PartialAlias and MustAlias here.
|
|
296
|
-
*/
|
|
297
|
-
AliasResult DDAPass::alias(const SVFValue* V1, const SVFValue* V2)
|
|
298
|
-
{
|
|
299
|
-
SVFIR* pag = _pta->getPAG();
|
|
300
|
-
|
|
301
|
-
/// TODO: When this method is invoked during compiler optimizations, the IR
|
|
302
|
-
/// used for pointer analysis may been changed, so some Values may not
|
|
303
|
-
/// find corresponding SVFIR node. In this case, we only check alias
|
|
304
|
-
/// between two Values if they both have SVFIR nodes. Otherwise, MayAlias
|
|
305
|
-
/// will be returned.
|
|
306
|
-
if (pag->hasValueNode(V1) && pag->hasValueNode(V2))
|
|
307
|
-
{
|
|
308
|
-
PAGNode* node1 = pag->getGNode(pag->getValueNode(V1));
|
|
309
|
-
if(pag->isValidTopLevelPtr(node1))
|
|
310
|
-
_pta->computeDDAPts(node1->getId());
|
|
311
|
-
|
|
312
|
-
PAGNode* node2 = pag->getGNode(pag->getValueNode(V2));
|
|
313
|
-
if(pag->isValidTopLevelPtr(node2))
|
|
314
|
-
_pta->computeDDAPts(node2->getId());
|
|
315
293
|
|
|
316
|
-
return _pta->alias(V1,V2);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
return AliasResult::MayAlias;
|
|
320
|
-
}
|
|
321
294
|
|
|
322
295
|
/*!
|
|
323
296
|
* Print queries' pts
|
|
@@ -737,26 +737,23 @@ ModRefInfo MRGenerator::getModRefInfo(const CallICFGNode* cs)
|
|
|
737
737
|
* Determine whether a const CallICFGNode* instruction can mod or ref
|
|
738
738
|
* a specific memory location pointed by V
|
|
739
739
|
*/
|
|
740
|
-
ModRefInfo MRGenerator::getModRefInfo(const CallICFGNode* cs, const
|
|
740
|
+
ModRefInfo MRGenerator::getModRefInfo(const CallICFGNode* cs, const SVFVar* V)
|
|
741
741
|
{
|
|
742
742
|
bool ref = false;
|
|
743
743
|
bool mod = false;
|
|
744
744
|
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
pta->expandFIObjs(csRef, csRefExpanded);
|
|
753
|
-
pta->expandFIObjs(csMod, csModExpanded);
|
|
745
|
+
const NodeBS pts(pta->getPts(V->getId()).toNodeBS());
|
|
746
|
+
const NodeBS csRef = getRefInfoForCall(cs);
|
|
747
|
+
const NodeBS csMod = getModInfoForCall(cs);
|
|
748
|
+
NodeBS ptsExpanded, csRefExpanded, csModExpanded;
|
|
749
|
+
pta->expandFIObjs(pts, ptsExpanded);
|
|
750
|
+
pta->expandFIObjs(csRef, csRefExpanded);
|
|
751
|
+
pta->expandFIObjs(csMod, csModExpanded);
|
|
754
752
|
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
}
|
|
753
|
+
if (csRefExpanded.intersects(ptsExpanded))
|
|
754
|
+
ref = true;
|
|
755
|
+
if (csModExpanded.intersects(ptsExpanded))
|
|
756
|
+
mod = true;
|
|
760
757
|
|
|
761
758
|
if (mod && ref)
|
|
762
759
|
return ModRefInfo::ModRef;
|
|
@@ -612,14 +612,6 @@ void BVDataPTAImpl::normalizePointsTo()
|
|
|
612
612
|
}
|
|
613
613
|
}
|
|
614
614
|
|
|
615
|
-
/*!
|
|
616
|
-
* Return alias results based on our points-to/alias analysis
|
|
617
|
-
*/
|
|
618
|
-
AliasResult BVDataPTAImpl::alias(const SVFValue* V1,
|
|
619
|
-
const SVFValue* V2)
|
|
620
|
-
{
|
|
621
|
-
return alias(pag->getValueNode(V1),pag->getValueNode(V2));
|
|
622
|
-
}
|
|
623
615
|
|
|
624
616
|
/*!
|
|
625
617
|
* Return alias results based on our points-to/alias analysis
|
package/svf/lib/SVFIR/SVFIR.cpp
CHANGED
|
@@ -384,14 +384,14 @@ GepStmt* SVFIR::addVariantGepStmt(NodeID src, NodeID dst, const AccessPath& ap)
|
|
|
384
384
|
* Add a temp field value node, this method can only invoked by getGepValVar
|
|
385
385
|
* due to constraint expression, curInst is used to distinguish different instructions (e.g., memorycpy) when creating GepValVar.
|
|
386
386
|
*/
|
|
387
|
-
NodeID SVFIR::addGepValNode(
|
|
387
|
+
NodeID SVFIR::addGepValNode(NodeID curInst,const ValVar* baseVar, const AccessPath& ap, NodeID i, const SVFType* type, const ICFGNode* icn)
|
|
388
388
|
{
|
|
389
|
-
NodeID base =
|
|
389
|
+
NodeID base = baseVar->getId();
|
|
390
390
|
//assert(findPAGNode(i) == false && "this node should not be created before");
|
|
391
391
|
assert(0==GepValObjMap[curInst].count(std::make_pair(base, ap))
|
|
392
392
|
&& "this node should not be created before");
|
|
393
393
|
GepValObjMap[curInst][std::make_pair(base, ap)] = i;
|
|
394
|
-
GepValVar *node = new GepValVar(
|
|
394
|
+
GepValVar *node = new GepValVar(baseVar, i, ap, type, icn);
|
|
395
395
|
return addValNode(node);
|
|
396
396
|
}
|
|
397
397
|
|
|
@@ -503,7 +503,7 @@ NodeBS SVFIR::getFieldsAfterCollapse(NodeID id)
|
|
|
503
503
|
/*!
|
|
504
504
|
* It is used to create a dummy GepValVar during global initialization.
|
|
505
505
|
*/
|
|
506
|
-
NodeID SVFIR::getGepValVar(
|
|
506
|
+
NodeID SVFIR::getGepValVar(NodeID curInst, NodeID base, const AccessPath& ap) const
|
|
507
507
|
{
|
|
508
508
|
GepValueVarMap::const_iterator iter = GepValObjMap.find(curInst);
|
|
509
509
|
if(iter==GepValObjMap.end())
|
|
@@ -137,7 +137,7 @@ const std::string ArgValVar::toString() const
|
|
|
137
137
|
return rawstr.str();
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
GepValVar::GepValVar(ValVar* baseNode, NodeID i,
|
|
140
|
+
GepValVar::GepValVar(const ValVar* baseNode, NodeID i,
|
|
141
141
|
const AccessPath& ap, const SVFType* ty, const ICFGNode* node)
|
|
142
142
|
: ValVar(i, ty, node, GepValNode), ap(ap), base(baseNode), gepValType(ty)
|
|
143
143
|
{
|
package/svf/lib/WPA/WPAPass.cpp
CHANGED
|
@@ -154,12 +154,6 @@ void WPAPass::PrintAliasPairs(PointerAnalysis* pta)
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
const PointsTo& WPAPass::getPts(const SVFValue* value)
|
|
158
|
-
{
|
|
159
|
-
assert(_pta && "initialize a pointer analysis first");
|
|
160
|
-
SVFIR* pag = _pta->getPAG();
|
|
161
|
-
return getPts(pag->getValueNode(value));
|
|
162
|
-
}
|
|
163
157
|
|
|
164
158
|
const PointsTo& WPAPass::getPts(NodeID var)
|
|
165
159
|
{
|
|
@@ -167,54 +161,6 @@ const PointsTo& WPAPass::getPts(NodeID var)
|
|
|
167
161
|
return _pta->getPts(var);
|
|
168
162
|
}
|
|
169
163
|
|
|
170
|
-
/*!
|
|
171
|
-
* Return alias results based on our points-to/alias analysis
|
|
172
|
-
* TODO: Need to handle PartialAlias and MustAlias here.
|
|
173
|
-
*/
|
|
174
|
-
AliasResult WPAPass::alias(const SVFValue* V1, const SVFValue* V2)
|
|
175
|
-
{
|
|
176
|
-
|
|
177
|
-
AliasResult result = AliasResult::MayAlias;
|
|
178
|
-
|
|
179
|
-
SVFIR* pag = _pta->getPAG();
|
|
180
|
-
|
|
181
|
-
/// TODO: When this method is invoked during compiler optimizations, the IR
|
|
182
|
-
/// used for pointer analysis may been changed, so some Values may not
|
|
183
|
-
/// find corresponding SVFIR node. In this case, we only check alias
|
|
184
|
-
/// between two Values if they both have SVFIR nodes. Otherwise, MayAlias
|
|
185
|
-
/// will be returned.
|
|
186
|
-
if (pag->hasValueNode(V1) && pag->hasValueNode(V2))
|
|
187
|
-
{
|
|
188
|
-
/// Veto is used by default
|
|
189
|
-
if (Options::AliasRule.nothingSet() || Options::AliasRule(Veto))
|
|
190
|
-
{
|
|
191
|
-
/// Return NoAlias if any PTA gives NoAlias result
|
|
192
|
-
result = AliasResult::MayAlias;
|
|
193
|
-
|
|
194
|
-
for (PTAVector::const_iterator it = ptaVector.begin(), eit = ptaVector.end();
|
|
195
|
-
it != eit; ++it)
|
|
196
|
-
{
|
|
197
|
-
if ((*it)->alias(V1, V2) == AliasResult::NoAlias)
|
|
198
|
-
result = AliasResult::NoAlias;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
else if (Options::AliasRule(Conservative))
|
|
202
|
-
{
|
|
203
|
-
/// Return MayAlias if any PTA gives MayAlias result
|
|
204
|
-
result = AliasResult::NoAlias;
|
|
205
|
-
|
|
206
|
-
for (PTAVector::const_iterator it = ptaVector.begin(), eit = ptaVector.end();
|
|
207
|
-
it != eit; ++it)
|
|
208
|
-
{
|
|
209
|
-
if ((*it)->alias(V1, V2) == AliasResult::MayAlias)
|
|
210
|
-
result = AliasResult::MayAlias;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return result;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
164
|
/*!
|
|
219
165
|
* Return mod-ref result of a Callsite
|
|
220
166
|
*/
|
|
@@ -224,14 +170,6 @@ ModRefInfo WPAPass::getModRefInfo(const CallICFGNode* callInst)
|
|
|
224
170
|
return _svfg->getMSSA()->getMRGenerator()->getModRefInfo(callInst);
|
|
225
171
|
}
|
|
226
172
|
|
|
227
|
-
/*!
|
|
228
|
-
* Return mod-ref results of a Callsite to a specific memory location
|
|
229
|
-
*/
|
|
230
|
-
ModRefInfo WPAPass::getModRefInfo(const CallICFGNode* callInst, const SVFValue* V)
|
|
231
|
-
{
|
|
232
|
-
assert(Options::PASelected(PointerAnalysis::AndersenWaveDiff_WPA) && Options::AnderSVFG() && "mod-ref query is only support with -ander and -svfg turned on");
|
|
233
|
-
return _svfg->getMSSA()->getMRGenerator()->getModRefInfo(callInst, V);
|
|
234
|
-
}
|
|
235
173
|
|
|
236
174
|
/*!
|
|
237
175
|
* Return mod-ref result between two CallInsts
|
|
@@ -1386,7 +1386,7 @@ void SVFIRBuilder::sanityCheck()
|
|
|
1386
1386
|
NodeID SVFIRBuilder::getGepValVar(const Value* val, const AccessPath& ap, const SVFType* elementType)
|
|
1387
1387
|
{
|
|
1388
1388
|
NodeID base = getValueNode(val);
|
|
1389
|
-
NodeID gepval = pag->getGepValVar(curVal, base, ap);
|
|
1389
|
+
NodeID gepval = pag->getGepValVar(pag->getValueNode(curVal), base, ap);
|
|
1390
1390
|
if (gepval==UINT_MAX)
|
|
1391
1391
|
{
|
|
1392
1392
|
assert(((int) UINT_MAX)==-1 && "maximum limit of unsigned int is not -1?");
|
|
@@ -1412,7 +1412,7 @@ NodeID SVFIRBuilder::getGepValVar(const Value* val, const AccessPath& ap, const
|
|
|
1412
1412
|
{
|
|
1413
1413
|
node = llvmmodule->getICFGNode(inst);
|
|
1414
1414
|
}
|
|
1415
|
-
NodeID gepNode = pag->addGepValNode(curVal,
|
|
1415
|
+
NodeID gepNode = pag->addGepValNode(pag->getValueNode(curVal), cast<ValVar>(pag->getGNode(getValueNode(val))), ap,
|
|
1416
1416
|
NodeIDAllocator::get()->allocateValueId(),
|
|
1417
1417
|
llvmmodule->getSVFType(PointerType::getUnqual(llvmmodule->getContext())), node);
|
|
1418
1418
|
addGepEdge(base, gepNode, ap, true);
|
|
@@ -1445,8 +1445,6 @@ void SVFIRBuilder::setCurrentBBAndValueForPAGEdge(PAGEdge* edge)
|
|
|
1445
1445
|
assert(curVal && "current Val is nullptr?");
|
|
1446
1446
|
edge->setBB(curBB!=nullptr ? curBB : nullptr);
|
|
1447
1447
|
edge->setValue(pag->getGNode(pag->getValueNode(curVal)));
|
|
1448
|
-
// backmap in valuToEdgeMap
|
|
1449
|
-
pag->mapValueToEdge(curVal, edge);
|
|
1450
1448
|
ICFGNode* icfgNode = pag->getICFG()->getGlobalICFGNode();
|
|
1451
1449
|
LLVMModuleSet* llvmMS = llvmModuleSet();
|
|
1452
1450
|
if (const SVFInstruction* curInst = SVFUtil::dyn_cast<SVFInstruction>(curVal))
|