svf-tools 1.0.673 → 1.0.675
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/svf/include/Graphs/ConsGEdge.h +1 -1
- package/svf/include/MemoryModel/LocationSet.h +13 -12
- package/svf/include/SVFIR/SVFStatements.h +4 -4
- package/svf/include/SVFIR/SVFVariables.h +5 -5
- package/svf/lib/AbstractExecution/SVFIR2ItvExeState.cpp +4 -4
- package/svf/lib/Graphs/VFG.cpp +3 -3
- package/svf/lib/MemoryModel/LocationSet.cpp +29 -29
- package/svf/lib/SVFIR/SVFIR.cpp +2 -2
- package/svf/lib/SVFIR/SVFVariables.cpp +1 -1
- package/svf/lib/SVFIR/SymbolTableInfo.cpp +3 -3
- package/svf-llvm/lib/SVFIRBuilder.cpp +20 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svf-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.675",
|
|
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": {
|
|
@@ -58,7 +58,8 @@ public:
|
|
|
58
58
|
NonOverlap, Overlap, Subset, Superset, Same
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
typedef std::
|
|
61
|
+
typedef std::pair<const SVFVar*, const SVFType*> VarAndGepTypePair;
|
|
62
|
+
typedef std::vector<VarAndGepTypePair> OffsetVarAndGepTypePairs;
|
|
62
63
|
|
|
63
64
|
/// Constructor
|
|
64
65
|
LocationSet(s32_t o = 0) : fldIdx(o)
|
|
@@ -66,7 +67,7 @@ public:
|
|
|
66
67
|
|
|
67
68
|
/// Copy Constructor
|
|
68
69
|
LocationSet(const LocationSet& ls)
|
|
69
|
-
: fldIdx(ls.fldIdx),
|
|
70
|
+
: fldIdx(ls.fldIdx), offsetVarAndGepTypePairs(ls.getOffsetVarAndGepTypePairVec())
|
|
70
71
|
{
|
|
71
72
|
}
|
|
72
73
|
|
|
@@ -79,19 +80,19 @@ public:
|
|
|
79
80
|
inline const LocationSet& operator= (const LocationSet& rhs)
|
|
80
81
|
{
|
|
81
82
|
fldIdx = rhs.fldIdx;
|
|
82
|
-
|
|
83
|
+
offsetVarAndGepTypePairs = rhs.getOffsetVarAndGepTypePairVec();
|
|
83
84
|
return *this;
|
|
84
85
|
}
|
|
85
86
|
inline bool operator==(const LocationSet& rhs) const
|
|
86
87
|
{
|
|
87
88
|
return this->fldIdx == rhs.fldIdx
|
|
88
|
-
&& this->
|
|
89
|
+
&& this->offsetVarAndGepTypePairs == rhs.offsetVarAndGepTypePairs;
|
|
89
90
|
}
|
|
90
91
|
//@}
|
|
91
92
|
|
|
92
93
|
/// Get methods
|
|
93
94
|
//@{
|
|
94
|
-
inline s32_t
|
|
95
|
+
inline s32_t getConstantFieldIdx() const
|
|
95
96
|
{
|
|
96
97
|
return fldIdx;
|
|
97
98
|
}
|
|
@@ -99,20 +100,20 @@ public:
|
|
|
99
100
|
{
|
|
100
101
|
fldIdx = idx;
|
|
101
102
|
}
|
|
102
|
-
inline const
|
|
103
|
+
inline const OffsetVarAndGepTypePairs& getOffsetVarAndGepTypePairVec() const
|
|
103
104
|
{
|
|
104
|
-
return
|
|
105
|
+
return offsetVarAndGepTypePairs;
|
|
105
106
|
}
|
|
106
107
|
//@}
|
|
107
108
|
|
|
108
109
|
/// Return accumulated constant offset given OffsetVarVec
|
|
109
|
-
s32_t
|
|
110
|
+
s32_t computeConstantOffset() const;
|
|
110
111
|
|
|
111
112
|
/// Return element number of a type.
|
|
112
113
|
u32_t getElementNum(const SVFType* type) const;
|
|
113
114
|
|
|
114
115
|
|
|
115
|
-
bool
|
|
116
|
+
bool addOffsetVarAndGepTypePair(const SVFVar* var, const SVFType* gepIterType);
|
|
116
117
|
|
|
117
118
|
/// Return TRUE if this is a constant location set.
|
|
118
119
|
bool isConstantOffset() const;
|
|
@@ -135,7 +136,7 @@ private:
|
|
|
135
136
|
NodeBS computeAllLocations() const;
|
|
136
137
|
|
|
137
138
|
s32_t fldIdx; ///< Accumulated Constant Offsets
|
|
138
|
-
|
|
139
|
+
OffsetVarAndGepTypePairs offsetVarAndGepTypePairs; ///< a vector of actual offset in the form of <SVF Var, iterator type>s
|
|
139
140
|
};
|
|
140
141
|
|
|
141
142
|
} // End namespace SVF
|
|
@@ -145,8 +146,8 @@ template <> struct std::hash<SVF::LocationSet>
|
|
|
145
146
|
size_t operator()(const SVF::LocationSet &ls) const
|
|
146
147
|
{
|
|
147
148
|
SVF::Hash<std::pair<SVF::NodeID, SVF::NodeID>> h;
|
|
148
|
-
std::hash<SVF::LocationSet::
|
|
149
|
-
return h(std::make_pair(ls.
|
|
149
|
+
std::hash<SVF::LocationSet::OffsetVarAndGepTypePairs> v;
|
|
150
|
+
return h(std::make_pair(ls.getConstantFieldIdx(), v(ls.getOffsetVarAndGepTypePairVec())));
|
|
150
151
|
}
|
|
151
152
|
};
|
|
152
153
|
|
|
@@ -444,9 +444,9 @@ public:
|
|
|
444
444
|
{
|
|
445
445
|
return ls;
|
|
446
446
|
}
|
|
447
|
-
inline const LocationSet::
|
|
447
|
+
inline const LocationSet::OffsetVarAndGepTypePairs getOffsetVarAndGepTypePairVec() const
|
|
448
448
|
{
|
|
449
|
-
return getLocationSet().
|
|
449
|
+
return getLocationSet().getOffsetVarAndGepTypePairVec();
|
|
450
450
|
}
|
|
451
451
|
/// Return TRUE if this is a constant location set.
|
|
452
452
|
inline bool isConstantOffset() const
|
|
@@ -456,13 +456,13 @@ public:
|
|
|
456
456
|
/// Return accumulated constant offset (when accessing array or struct) if this offset is a constant.
|
|
457
457
|
inline s32_t accumulateConstantOffset() const
|
|
458
458
|
{
|
|
459
|
-
return getLocationSet().
|
|
459
|
+
return getLocationSet().computeConstantOffset();
|
|
460
460
|
}
|
|
461
461
|
/// Field index of the gep statement if it access the field of a struct
|
|
462
462
|
inline s32_t getConstantFieldIdx() const
|
|
463
463
|
{
|
|
464
464
|
assert(isVariantFieldGep()==false && "Can't retrieve the LocationSet if using a variable field index (pointer arithmetic) for struct field access ");
|
|
465
|
-
return getLocationSet().
|
|
465
|
+
return getLocationSet().getConstantFieldIdx();
|
|
466
466
|
}
|
|
467
467
|
/// Gep statement with a variant field index (pointer arithmetic) for struct field access
|
|
468
468
|
inline bool isVariantFieldGep() const
|
|
@@ -399,7 +399,7 @@ public:
|
|
|
399
399
|
/// offset of the base value variable
|
|
400
400
|
inline s32_t getConstantFieldIdx() const
|
|
401
401
|
{
|
|
402
|
-
return ls.
|
|
402
|
+
return ls.getConstantFieldIdx();
|
|
403
403
|
}
|
|
404
404
|
|
|
405
405
|
/// Return name of a LLVM value
|
|
@@ -466,7 +466,7 @@ public:
|
|
|
466
466
|
/// offset of the mem object
|
|
467
467
|
inline s32_t getConstantFieldIdx() const
|
|
468
468
|
{
|
|
469
|
-
return ls.
|
|
469
|
+
return ls.getConstantFieldIdx();
|
|
470
470
|
}
|
|
471
471
|
|
|
472
472
|
/// Set the base object from which this GEP node came from.
|
|
@@ -484,15 +484,15 @@ public:
|
|
|
484
484
|
/// Return the type of this gep object
|
|
485
485
|
inline virtual const SVFType* getType() const
|
|
486
486
|
{
|
|
487
|
-
return SymbolTableInfo::SymbolInfo()->getFlatternedElemType(mem->getType(), ls.
|
|
487
|
+
return SymbolTableInfo::SymbolInfo()->getFlatternedElemType(mem->getType(), ls.getConstantFieldIdx());
|
|
488
488
|
}
|
|
489
489
|
|
|
490
490
|
/// Return name of a LLVM value
|
|
491
491
|
inline const std::string getValueName() const
|
|
492
492
|
{
|
|
493
493
|
if (value)
|
|
494
|
-
return value->getName() + "_" + std::to_string(ls.
|
|
495
|
-
return "offset_" + std::to_string(ls.
|
|
494
|
+
return value->getName() + "_" + std::to_string(ls.getConstantFieldIdx());
|
|
495
|
+
return "offset_" + std::to_string(ls.getConstantFieldIdx());
|
|
496
496
|
}
|
|
497
497
|
|
|
498
498
|
virtual const std::string toString() const;
|
|
@@ -104,15 +104,15 @@ SVFIR2ItvExeState::VAddrs SVFIR2ItvExeState::getGepObjAddress(u32_t pointer, u32
|
|
|
104
104
|
|
|
105
105
|
std::pair<s32_t, s32_t> SVFIR2ItvExeState::getGepOffset(const GepStmt *gep)
|
|
106
106
|
{
|
|
107
|
-
if (gep->
|
|
107
|
+
if (gep->getOffsetVarAndGepTypePairVec().empty())
|
|
108
108
|
return std::make_pair(gep->getConstantFieldIdx(), gep->getConstantFieldIdx());
|
|
109
109
|
|
|
110
110
|
s32_t totalOffsetLb = 0;
|
|
111
111
|
s32_t totalOffsetUb = 0;
|
|
112
|
-
for (int i = gep->
|
|
112
|
+
for (int i = gep->getOffsetVarAndGepTypePairVec().size() - 1; i >= 0; i--)
|
|
113
113
|
{
|
|
114
|
-
const SVFValue *value = gep->
|
|
115
|
-
const SVFType *type = gep->
|
|
114
|
+
const SVFValue *value = gep->getOffsetVarAndGepTypePairVec()[i].first->getValue();
|
|
115
|
+
const SVFType *type = gep->getOffsetVarAndGepTypePairVec()[i].second;
|
|
116
116
|
const SVFConstantInt *op = SVFUtil::dyn_cast<SVFConstantInt>(value);
|
|
117
117
|
s32_t offsetLb = 0;
|
|
118
118
|
s32_t offsetUb = 0;
|
package/svf/lib/Graphs/VFG.cpp
CHANGED
|
@@ -757,11 +757,11 @@ void VFG::connectDirectVFGEdges()
|
|
|
757
757
|
addIntraDirectVFEdge(getDef(stmtNode->getPAGSrcNode()), nodeId);
|
|
758
758
|
if (const GepStmt* gepStmt = SVFUtil::dyn_cast<GepStmt>(stmtNode->getPAGEdge()))
|
|
759
759
|
{
|
|
760
|
-
for (const auto &
|
|
760
|
+
for (const auto &varType: gepStmt->getOffsetVarAndGepTypePairVec())
|
|
761
761
|
{
|
|
762
|
-
if(
|
|
762
|
+
if(varType.first->isConstDataOrAggDataButNotNullPtr() || isInterestedPAGNode(varType.first) == false)
|
|
763
763
|
continue;
|
|
764
|
-
addIntraDirectVFEdge(getDef(
|
|
764
|
+
addIntraDirectVFEdge(getDef(varType.first), nodeId);
|
|
765
765
|
}
|
|
766
766
|
}
|
|
767
767
|
/// for store, connect the RHS/LHS pointer to its def
|
|
@@ -37,20 +37,20 @@ using namespace SVF;
|
|
|
37
37
|
using namespace SVFUtil;
|
|
38
38
|
|
|
39
39
|
/*!
|
|
40
|
-
* Add offset value to vector
|
|
40
|
+
* Add offset value to vector offsetVarAndGepTypePairs
|
|
41
41
|
*/
|
|
42
|
-
bool LocationSet::
|
|
42
|
+
bool LocationSet::addOffsetVarAndGepTypePair(const SVFVar* var, const SVFType* gepIterType)
|
|
43
43
|
{
|
|
44
|
-
|
|
44
|
+
offsetVarAndGepTypePairs.emplace_back(var, gepIterType);
|
|
45
45
|
return true;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/// Return true if all offset values are constants
|
|
49
49
|
bool LocationSet::isConstantOffset() const
|
|
50
50
|
{
|
|
51
|
-
for(auto it :
|
|
51
|
+
for(auto it : offsetVarAndGepTypePairs)
|
|
52
52
|
{
|
|
53
|
-
if(SVFUtil::isa<SVFConstantInt>(it->getValue()) == false)
|
|
53
|
+
if(SVFUtil::isa<SVFConstantInt>(it.first->getValue()) == false)
|
|
54
54
|
return false;
|
|
55
55
|
}
|
|
56
56
|
return true;
|
|
@@ -102,32 +102,32 @@ u32_t LocationSet::getElementNum(const SVFType* type) const
|
|
|
102
102
|
|
|
103
103
|
/// %5 = getelementptr inbounds %struct.Student, %struct.Student* %4, i64 1
|
|
104
104
|
/// value1: i64 1 type1: %struct.Student*
|
|
105
|
-
///
|
|
105
|
+
/// computeConstantOffset = 32
|
|
106
106
|
/// %6 = getelementptr inbounds %struct.Student, %struct.Student* %5, i32 0, i32 1
|
|
107
107
|
/// value1: i32 0 type1: %struct.Student*
|
|
108
108
|
/// value2: i32 1 type2: %struct.Student = type { %struct.inner, [10 x [3 x i8]] }
|
|
109
|
-
///
|
|
109
|
+
/// computeConstantOffset = 2
|
|
110
110
|
/// %7 = getelementptr inbounds [10 x [3 x i8]], [10 x [3 x i8]]* %6, i64 0, i64 3
|
|
111
111
|
/// value1: i64 0 type1: [10 x [3 x i8]]*
|
|
112
112
|
/// value2: i64 3 type2: [10 x [3 x i8]]
|
|
113
|
-
///
|
|
113
|
+
/// computeConstantOffset = 9
|
|
114
114
|
/// %8 = getelementptr inbounds [3 x i8], [3 x i8]* %7, i64 0, i64 2
|
|
115
115
|
/// value1: i64 0 type1: [3 x i8]*
|
|
116
116
|
/// value2: i64 2 type2: [3 x i8]
|
|
117
|
-
///
|
|
118
|
-
s32_t LocationSet::
|
|
117
|
+
/// computeConstantOffset = 2
|
|
118
|
+
s32_t LocationSet::computeConstantOffset() const
|
|
119
119
|
{
|
|
120
120
|
|
|
121
121
|
assert(isConstantOffset() && "not a constant offset");
|
|
122
122
|
|
|
123
|
-
if(
|
|
124
|
-
return
|
|
123
|
+
if(offsetVarAndGepTypePairs.empty())
|
|
124
|
+
return getConstantFieldIdx();
|
|
125
125
|
|
|
126
126
|
s32_t totalConstOffset = 0;
|
|
127
|
-
for(int i =
|
|
127
|
+
for(int i = offsetVarAndGepTypePairs.size() - 1; i >= 0; i--)
|
|
128
128
|
{
|
|
129
|
-
const SVFValue* value =
|
|
130
|
-
const SVFType* type =
|
|
129
|
+
const SVFValue* value = offsetVarAndGepTypePairs[i].first->getValue();
|
|
130
|
+
const SVFType* type = offsetVarAndGepTypePairs[i].second;
|
|
131
131
|
const SVFConstantInt* op = SVFUtil::dyn_cast<SVFConstantInt>(value);
|
|
132
132
|
assert(op && "not a constant offset?");
|
|
133
133
|
if(type==nullptr)
|
|
@@ -153,18 +153,18 @@ s32_t LocationSet::accumulateConstantOffset() const
|
|
|
153
153
|
NodeBS LocationSet::computeAllLocations() const
|
|
154
154
|
{
|
|
155
155
|
NodeBS result;
|
|
156
|
-
result.set(
|
|
156
|
+
result.set(getConstantFieldIdx());
|
|
157
157
|
return result;
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
LocationSet LocationSet::operator+ (const LocationSet& rhs) const
|
|
161
161
|
{
|
|
162
162
|
LocationSet ls(rhs);
|
|
163
|
-
ls.fldIdx +=
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
ls.fldIdx += getConstantFieldIdx();
|
|
164
|
+
OffsetVarAndGepTypePairs::const_iterator it = getOffsetVarAndGepTypePairVec().begin();
|
|
165
|
+
OffsetVarAndGepTypePairs::const_iterator eit = getOffsetVarAndGepTypePairVec().end();
|
|
166
166
|
for (; it != eit; ++it)
|
|
167
|
-
ls.
|
|
167
|
+
ls.addOffsetVarAndGepTypePair(it->first, it->second);
|
|
168
168
|
|
|
169
169
|
return ls;
|
|
170
170
|
}
|
|
@@ -176,14 +176,14 @@ bool LocationSet::operator< (const LocationSet& rhs) const
|
|
|
176
176
|
return (fldIdx < rhs.fldIdx);
|
|
177
177
|
else
|
|
178
178
|
{
|
|
179
|
-
const
|
|
180
|
-
const
|
|
179
|
+
const OffsetVarAndGepTypePairs& pairVec = getOffsetVarAndGepTypePairVec();
|
|
180
|
+
const OffsetVarAndGepTypePairs& rhsPairVec = rhs.getOffsetVarAndGepTypePairVec();
|
|
181
181
|
if (pairVec.size() != rhsPairVec.size())
|
|
182
182
|
return (pairVec.size() < rhsPairVec.size());
|
|
183
183
|
else
|
|
184
184
|
{
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
OffsetVarAndGepTypePairs::const_iterator it = pairVec.begin();
|
|
186
|
+
OffsetVarAndGepTypePairs::const_iterator rhsIt = rhsPairVec.begin();
|
|
187
187
|
for (; it != pairVec.end() && rhsIt != rhsPairVec.end(); ++it, ++rhsIt)
|
|
188
188
|
{
|
|
189
189
|
return (*it) < (*rhsIt);
|
|
@@ -221,14 +221,14 @@ std::string LocationSet::dump() const
|
|
|
221
221
|
std::string str;
|
|
222
222
|
std::stringstream rawstr(str);
|
|
223
223
|
|
|
224
|
-
rawstr << "LocationSet\tField_Index: " <<
|
|
224
|
+
rawstr << "LocationSet\tField_Index: " << getConstantFieldIdx();
|
|
225
225
|
rawstr << ",\tNum-Stride: {";
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
|
|
226
|
+
const OffsetVarAndGepTypePairs& vec = getOffsetVarAndGepTypePairVec();
|
|
227
|
+
OffsetVarAndGepTypePairs::const_iterator it = vec.begin();
|
|
228
|
+
OffsetVarAndGepTypePairs::const_iterator eit = vec.end();
|
|
229
229
|
for (; it != eit; ++it)
|
|
230
230
|
{
|
|
231
|
-
rawstr << " (var: " << (
|
|
231
|
+
rawstr << " (Svf var: " << it->first->toString() << ", Iter type: " << it->second->toString() << ")";
|
|
232
232
|
}
|
|
233
233
|
rawstr << " }\n";
|
|
234
234
|
return rawstr.str();
|
package/svf/lib/SVFIR/SVFIR.cpp
CHANGED
|
@@ -430,7 +430,7 @@ NodeID SVFIR::getGepObjVar(const MemObj* obj, const LocationSet& ls)
|
|
|
430
430
|
LocationSet newLS = pag->getSymbolInfo()->getModulusOffset(obj,ls);
|
|
431
431
|
|
|
432
432
|
// Base and first field are the same memory location.
|
|
433
|
-
if (Options::FirstFieldEqBase() && newLS.
|
|
433
|
+
if (Options::FirstFieldEqBase() && newLS.getConstantFieldIdx() == 0) return base;
|
|
434
434
|
|
|
435
435
|
NodeLocationSetMap::iterator iter = GepObjVarMap.find(std::make_pair(base, newLS));
|
|
436
436
|
if (iter == GepObjVarMap.end())
|
|
@@ -450,7 +450,7 @@ NodeID SVFIR::addGepObjNode(const MemObj* obj, const LocationSet& ls)
|
|
|
450
450
|
assert(0==GepObjVarMap.count(std::make_pair(base, ls))
|
|
451
451
|
&& "this node should not be created before");
|
|
452
452
|
|
|
453
|
-
NodeID gepId = NodeIDAllocator::get()->allocateGepObjectId(base, ls.
|
|
453
|
+
NodeID gepId = NodeIDAllocator::get()->allocateGepObjectId(base, ls.getConstantFieldIdx(), Options::MaxFieldLimit());
|
|
454
454
|
GepObjVarMap[std::make_pair(base, ls)] = gepId;
|
|
455
455
|
GepObjVar *node = new GepObjVar(obj, gepId, ls);
|
|
456
456
|
memToFieldsMap[base].set(gepId);
|
|
@@ -145,7 +145,7 @@ const std::string GepObjVar::toString() const
|
|
|
145
145
|
{
|
|
146
146
|
std::string str;
|
|
147
147
|
std::stringstream rawstr(str);
|
|
148
|
-
rawstr << "GepObjVar ID: " << getId() << " with offset_" + std::to_string(ls.
|
|
148
|
+
rawstr << "GepObjVar ID: " << getId() << " with offset_" + std::to_string(ls.getConstantFieldIdx());
|
|
149
149
|
if (Options::ShowSVFIRValue())
|
|
150
150
|
{
|
|
151
151
|
rawstr << "\n";
|
|
@@ -98,7 +98,7 @@ LocationSet SymbolTableInfo::getModulusOffset(const MemObj* obj, const LocationS
|
|
|
98
98
|
/// of current struct. Make the offset positive so we can still get a node within current
|
|
99
99
|
/// struct to represent this obj.
|
|
100
100
|
|
|
101
|
-
s32_t offset = ls.
|
|
101
|
+
s32_t offset = ls.getConstantFieldIdx();
|
|
102
102
|
if(offset < 0)
|
|
103
103
|
{
|
|
104
104
|
writeWrnMsg("try to create a gep node with negative offset.");
|
|
@@ -392,13 +392,13 @@ bool ObjTypeInfo::isNonPtrFieldObj(const LocationSet& ls)
|
|
|
392
392
|
else
|
|
393
393
|
sz = SymbolTableInfo::SymbolInfo()->getTypeInfo(ety)->getFlattenFieldTypes().size();
|
|
394
394
|
|
|
395
|
-
if(sz <= (u32_t)ls.
|
|
395
|
+
if(sz <= (u32_t) ls.getConstantFieldIdx())
|
|
396
396
|
{
|
|
397
397
|
writeWrnMsg("out of bound error when accessing the struct/array");
|
|
398
398
|
return false;
|
|
399
399
|
}
|
|
400
400
|
|
|
401
|
-
const SVFType* elemTy = SymbolTableInfo::SymbolInfo()->getFlatternedElemType(ety, ls.
|
|
401
|
+
const SVFType* elemTy = SymbolTableInfo::SymbolInfo()->getFlatternedElemType(ety, ls.getConstantFieldIdx());
|
|
402
402
|
return (elemTy->isPointerTy() == false);
|
|
403
403
|
}
|
|
404
404
|
else
|
|
@@ -272,13 +272,17 @@ bool SVFIRBuilder::computeGepOffset(const User *V, LocationSet& ls)
|
|
|
272
272
|
//s32_t bo = byteOffset.getSExtValue();
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
+
bool isConst = true;
|
|
276
|
+
|
|
275
277
|
for (bridge_gep_iterator gi = bridge_gep_begin(*V), ge = bridge_gep_end(*V);
|
|
276
278
|
gi != ge; ++gi)
|
|
277
279
|
{
|
|
278
280
|
const Type* gepTy = *gi;
|
|
281
|
+
const SVFType* svfGepTy = LLVMModuleSet::getLLVMModuleSet()->getSVFType(gepTy);
|
|
279
282
|
const Value* offsetVal = gi.getOperand();
|
|
280
283
|
const SVFValue* offsetSvfVal = LLVMModuleSet::getLLVMModuleSet()->getSVFValue(offsetVal);
|
|
281
|
-
|
|
284
|
+
assert(gepTy != offsetVal->getType() && "iteration and operand have the same type?");
|
|
285
|
+
ls.addOffsetVarAndGepTypePair(getPAG()->getGNode(getPAG()->getValueNode(offsetSvfVal)), svfGepTy);
|
|
282
286
|
|
|
283
287
|
//The int value of the current index operand
|
|
284
288
|
const ConstantInt* op = SVFUtil::dyn_cast<ConstantInt>(offsetVal);
|
|
@@ -291,7 +295,7 @@ bool SVFIRBuilder::computeGepOffset(const User *V, LocationSet& ls)
|
|
|
291
295
|
continue;
|
|
292
296
|
s32_t idx = op->getSExtValue();
|
|
293
297
|
u32_t offset = pag->getSymbolInfo()->getFlattenedElemIdx(LLVMModuleSet::getLLVMModuleSet()->getSVFType(arrTy), idx);
|
|
294
|
-
ls.setFldIdx(ls.
|
|
298
|
+
ls.setFldIdx(ls.getConstantFieldIdx() + offset);
|
|
295
299
|
}
|
|
296
300
|
else if (const StructType *ST = SVFUtil::dyn_cast<StructType>(gepTy))
|
|
297
301
|
{
|
|
@@ -299,7 +303,7 @@ bool SVFIRBuilder::computeGepOffset(const User *V, LocationSet& ls)
|
|
|
299
303
|
//The actual index
|
|
300
304
|
s32_t idx = op->getSExtValue();
|
|
301
305
|
u32_t offset = pag->getSymbolInfo()->getFlattenedElemIdx(LLVMModuleSet::getLLVMModuleSet()->getSVFType(ST), idx);
|
|
302
|
-
ls.setFldIdx(ls.
|
|
306
|
+
ls.setFldIdx(ls.getConstantFieldIdx() + offset);
|
|
303
307
|
}
|
|
304
308
|
else if (gepTy->isSingleValueType())
|
|
305
309
|
{
|
|
@@ -307,17 +311,17 @@ bool SVFIRBuilder::computeGepOffset(const User *V, LocationSet& ls)
|
|
|
307
311
|
// If its point-to target is struct or array, it's likely an array accessing (%result = gep %struct.A* %a, i32 %non-const-index)
|
|
308
312
|
// If its point-to target is single value (pointer arithmetic), then it's a variant gep (%result = gep i8* %p, i32 %non-const-index)
|
|
309
313
|
if(!op && gepTy->isPointerTy() && getPtrElementType(SVFUtil::dyn_cast<PointerType>(gepTy))->isSingleValueType())
|
|
310
|
-
|
|
314
|
+
isConst = false;
|
|
311
315
|
|
|
312
316
|
// The actual index
|
|
313
317
|
//s32_t idx = op->getSExtValue();
|
|
314
318
|
|
|
315
319
|
// For pointer arithmetic we ignore the byte offset
|
|
316
320
|
// consider using inferFieldIdxFromByteOffset(geopOp,dataLayout,ls,idx)?
|
|
317
|
-
// ls.setFldIdx(ls.
|
|
321
|
+
// ls.setFldIdx(ls.getConstantFieldIdx() + inferFieldIdxFromByteOffset(geopOp,idx));
|
|
318
322
|
}
|
|
319
323
|
}
|
|
320
|
-
return
|
|
324
|
+
return isConst;
|
|
321
325
|
}
|
|
322
326
|
|
|
323
327
|
/*!
|
|
@@ -1132,7 +1136,7 @@ const Type* SVFIRBuilder::getBaseTypeAndFlattenedFields(const Value* V, std::vec
|
|
|
1132
1136
|
builder.collectSym(offset);
|
|
1133
1137
|
pag->addValNode(svfOffset, pag->getSymbolInfo()->getValSym(svfOffset));
|
|
1134
1138
|
}
|
|
1135
|
-
ls.
|
|
1139
|
+
ls.addOffsetVarAndGepTypePair(getPAG()->getGNode(getPAG()->getValueNode(svfOffset)), nullptr);
|
|
1136
1140
|
fields.push_back(ls);
|
|
1137
1141
|
}
|
|
1138
1142
|
return T;
|
|
@@ -1176,8 +1180,10 @@ void SVFIRBuilder::addComplexConsForExt(const Value* D, const Value* S, const Va
|
|
|
1176
1180
|
for (u32_t index = 0; index < sz; index++)
|
|
1177
1181
|
{
|
|
1178
1182
|
LLVMModuleSet* llvmmodule = LLVMModuleSet::getLLVMModuleSet();
|
|
1179
|
-
const SVFType* dElementType = pag->getSymbolInfo()->getFlatternedElemType(llvmmodule->getSVFType(dtype),
|
|
1180
|
-
|
|
1183
|
+
const SVFType* dElementType = pag->getSymbolInfo()->getFlatternedElemType(llvmmodule->getSVFType(dtype),
|
|
1184
|
+
fields[index].getConstantFieldIdx());
|
|
1185
|
+
const SVFType* sElementType = pag->getSymbolInfo()->getFlatternedElemType(llvmmodule->getSVFType(stype),
|
|
1186
|
+
fields[index].getConstantFieldIdx());
|
|
1181
1187
|
NodeID dField = getGepValVar(D,fields[index],dElementType);
|
|
1182
1188
|
NodeID sField = getGepValVar(S,fields[index],sElementType);
|
|
1183
1189
|
NodeID dummy = pag->addDummyValNode();
|
|
@@ -1385,7 +1391,8 @@ void SVFIRBuilder::handleExtCall(CallBase* cs, const Function *callee)
|
|
|
1385
1391
|
//For each field (i), add store edge *(arg0 + i) = arg1
|
|
1386
1392
|
for (u32_t index = 0; index < sz; index++)
|
|
1387
1393
|
{
|
|
1388
|
-
const SVFType* dElementType = pag->getSymbolInfo()->getFlatternedElemType(LLVMModuleSet::getLLVMModuleSet()->getSVFType(dtype),
|
|
1394
|
+
const SVFType* dElementType = pag->getSymbolInfo()->getFlatternedElemType(LLVMModuleSet::getLLVMModuleSet()->getSVFType(dtype),
|
|
1395
|
+
dstFields[index].getConstantFieldIdx());
|
|
1389
1396
|
NodeID dField = getGepValVar(cs->getArgOperand(op.getOperands()[0]), dstFields[index], dElementType);
|
|
1390
1397
|
addStoreEdge(getValueNode(cs->getArgOperand(op.getOperands()[1])),dField);
|
|
1391
1398
|
}
|
|
@@ -1428,7 +1435,7 @@ void SVFIRBuilder::handleExtCall(CallBase* cs, const Function *callee)
|
|
|
1428
1435
|
// We have vArg3 points to the entry of _Rb_tree_node_base { color; parent; left; right; }.
|
|
1429
1436
|
// Now we calculate the offset from base to vArg3
|
|
1430
1437
|
NodeID vnArg3 = pag->getValueNode(LLVMModuleSet::getLLVMModuleSet()->getSVFValue(vArg3));
|
|
1431
|
-
s32_t offset = getLocationSetFromBaseNode(vnArg3).
|
|
1438
|
+
s32_t offset = getLocationSetFromBaseNode(vnArg3).getConstantFieldIdx();
|
|
1432
1439
|
|
|
1433
1440
|
// We get all flattened fields of base
|
|
1434
1441
|
vector<LocationSet> fields;
|
|
@@ -1440,7 +1447,8 @@ void SVFIRBuilder::handleExtCall(CallBase* cs, const Function *callee)
|
|
|
1440
1447
|
{
|
|
1441
1448
|
if((u32_t)i >= fields.size())
|
|
1442
1449
|
break;
|
|
1443
|
-
const SVFType* elementType = pag->getSymbolInfo()->getFlatternedElemType(LLVMModuleSet::getLLVMModuleSet()->getSVFType(type),
|
|
1450
|
+
const SVFType* elementType = pag->getSymbolInfo()->getFlatternedElemType(LLVMModuleSet::getLLVMModuleSet()->getSVFType(type),
|
|
1451
|
+
fields[i].getConstantFieldIdx());
|
|
1444
1452
|
NodeID vnD = getGepValVar(vArg3, fields[i], elementType);
|
|
1445
1453
|
NodeID vnS = getValueNode(vArg1);
|
|
1446
1454
|
if(vnD && vnS)
|