svf-tools 1.0.330 → 1.0.331
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-doxygen/html/html/AndersenSFR_8cpp_source.html +4 -4
- package/SVF-doxygen/html/html/Andersen_8cpp_source.html +4 -4
- package/SVF-doxygen/html/html/CSC_8cpp_source.html +2 -3
- package/SVF-doxygen/html/html/ConsGEdge_8h_source.html +3 -3
- package/SVF-doxygen/html/html/ConsGNode_8h_source.html +5 -5
- package/SVF-doxygen/html/html/ConsG_8cpp_source.html +2 -2
- package/SVF-doxygen/html/html/ConsG_8h_source.html +4 -4
- package/SVF-doxygen/html/html/ContextDDA_8cpp_source.html +5 -5
- package/SVF-doxygen/html/html/DDAVFSolver_8h_source.html +6 -6
- package/SVF-doxygen/html/html/FlowDDA_8cpp_source.html +2 -2
- package/SVF-doxygen/html/html/FlowSensitiveStat_8cpp_source.html +3 -3
- package/SVF-doxygen/html/html/FlowSensitiveTBHC_8cpp_source.html +2 -2
- package/SVF-doxygen/html/html/IRAnnotator_8h_source.html +6 -7
- package/SVF-doxygen/html/html/IRGraph_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/IRGraph_8h_source.html +1 -1
- package/SVF-doxygen/html/html/LocationSet_8cpp.html +1 -0
- package/SVF-doxygen/html/html/LocationSet_8cpp_source.html +12 -15
- package/SVF-doxygen/html/html/LocationSet_8h.html +1 -1
- package/SVF-doxygen/html/html/LocationSet_8h_source.html +26 -40
- package/SVF-doxygen/html/html/MemRegion_8cpp_source.html +5 -5
- package/SVF-doxygen/html/html/OfflineConsG_8cpp_source.html +1 -1
- package/SVF-doxygen/html/html/PAGBuilderFromFile_8cpp_source.html +2 -2
- package/SVF-doxygen/html/html/PTAStat_8cpp_source.html +14 -14
- package/SVF-doxygen/html/html/PointerAnalysisImpl_8cpp_source.html +6 -6
- package/SVF-doxygen/html/html/PointerAnalysis_8cpp_source.html +5 -5
- package/SVF-doxygen/html/html/PointerAnalysis_8h_source.html +6 -6
- package/SVF-doxygen/html/html/SVFIRBuilder_8cpp_source.html +6 -7
- package/SVF-doxygen/html/html/SVFIRBuilder_8h_source.html +32 -32
- package/SVF-doxygen/html/html/SVFIR_8cpp_source.html +12 -12
- package/SVF-doxygen/html/html/SVFIR_8h_source.html +12 -12
- package/SVF-doxygen/html/html/SVFStatements_8h_source.html +3 -3
- package/SVF-doxygen/html/html/SVFVariables_8cpp_source.html +2 -2
- package/SVF-doxygen/html/html/SVFVariables_8h.html +1 -1
- package/SVF-doxygen/html/html/SVFVariables_8h_source.html +69 -69
- package/SVF-doxygen/html/html/SaberSVFGBuilder_8cpp_source.html +3 -3
- package/SVF-doxygen/html/html/SymbolTableBuilder_8cpp_source.html +21 -21
- package/SVF-doxygen/html/html/SymbolTableBuilder_8h_source.html +1 -1
- package/SVF-doxygen/html/html/SymbolTableInfo_8cpp_source.html +52 -53
- package/SVF-doxygen/html/html/SymbolTableInfo_8h_source.html +72 -75
- package/SVF-doxygen/html/html/ThreadCallGraph_8cpp_source.html +3 -3
- package/SVF-doxygen/html/html/TypeBasedHeapCloning_8cpp_source.html +13 -13
- package/SVF-doxygen/html/html/TypeBasedHeapCloning_8h_source.html +2 -2
- package/SVF-doxygen/html/html/VersionedFlowSensitiveStat_8cpp_source.html +3 -3
- package/SVF-doxygen/html/html/annotated.html +6 -6
- package/SVF-doxygen/html/html/classSVF_1_1AndersenBase.html +4 -4
- package/SVF-doxygen/html/html/classSVF_1_1AndersenSFR.html +5 -5
- package/SVF-doxygen/html/html/classSVF_1_1BVDataPTAImpl.html +9 -9
- package/SVF-doxygen/html/html/classSVF_1_1CSC.html +2 -3
- package/SVF-doxygen/html/html/classSVF_1_1CloneDummyObjVar.html +11 -11
- package/SVF-doxygen/html/html/classSVF_1_1CloneFIObjVar.html +11 -11
- package/SVF-doxygen/html/html/classSVF_1_1CloneGepObjVar-members.html +56 -55
- package/SVF-doxygen/html/html/classSVF_1_1CloneGepObjVar.html +44 -41
- package/SVF-doxygen/html/html/classSVF_1_1CloneGepObjVar.png +0 -0
- package/SVF-doxygen/html/html/classSVF_1_1ConstraintGraph.html +3 -3
- package/SVF-doxygen/html/html/classSVF_1_1ConstraintNode-members.html +26 -26
- package/SVF-doxygen/html/html/classSVF_1_1ConstraintNode.html +43 -43
- package/SVF-doxygen/html/html/classSVF_1_1ContextDDA.html +4 -4
- package/SVF-doxygen/html/html/classSVF_1_1DDAVFSolver.html +1 -1
- package/SVF-doxygen/html/html/classSVF_1_1DummyObjVar.html +11 -11
- package/SVF-doxygen/html/html/classSVF_1_1DummyValVar.html +11 -11
- package/SVF-doxygen/html/html/classSVF_1_1FIObjVar.html +13 -13
- package/SVF-doxygen/html/html/classSVF_1_1FlattenedFieldInfo-members.html +85 -0
- package/SVF-doxygen/html/html/classSVF_1_1FlattenedFieldInfo.html +254 -0
- package/SVF-doxygen/html/html/classSVF_1_1FlowDDA.html +2 -2
- package/SVF-doxygen/html/html/classSVF_1_1FlowSensitive.html +1 -1
- package/SVF-doxygen/html/html/classSVF_1_1FlowSensitiveStat.html +3 -3
- package/SVF-doxygen/html/html/classSVF_1_1FlowSensitiveTBHC.html +6 -6
- package/SVF-doxygen/html/html/classSVF_1_1GenericNode.html +22 -23
- package/SVF-doxygen/html/html/classSVF_1_1GenericNode.png +0 -0
- package/SVF-doxygen/html/html/classSVF_1_1GepObjVar-members.html +173 -0
- package/SVF-doxygen/html/html/classSVF_1_1GepObjVar.html +813 -0
- package/SVF-doxygen/html/html/classSVF_1_1GepObjVar.png +0 -0
- package/SVF-doxygen/html/html/classSVF_1_1GepValVar.html +2 -2
- package/SVF-doxygen/html/html/classSVF_1_1IRAnnotator-members.html +1 -1
- package/SVF-doxygen/html/html/classSVF_1_1IRAnnotator.html +8 -8
- package/SVF-doxygen/html/html/classSVF_1_1LocationSet-members.html +17 -21
- package/SVF-doxygen/html/html/classSVF_1_1LocationSet.html +150 -326
- package/SVF-doxygen/html/html/classSVF_1_1MRGenerator.html +6 -6
- package/SVF-doxygen/html/html/classSVF_1_1MemObj.html +84 -84
- package/SVF-doxygen/html/html/classSVF_1_1NormalGepCGEdge.html +2 -2
- package/SVF-doxygen/html/html/classSVF_1_1NormalGepStmt.html +2 -2
- package/SVF-doxygen/html/html/classSVF_1_1ObjTypeInfo.html +96 -96
- package/SVF-doxygen/html/html/classSVF_1_1ObjVar.html +5 -5
- package/SVF-doxygen/html/html/classSVF_1_1ObjVar.png +0 -0
- package/SVF-doxygen/html/html/classSVF_1_1PAGBuilderFromFile.html +2 -2
- package/SVF-doxygen/html/html/classSVF_1_1PTAStat.html +14 -14
- package/SVF-doxygen/html/html/classSVF_1_1PointerAnalysis.html +8 -8
- package/SVF-doxygen/html/html/classSVF_1_1RetPN.html +11 -11
- package/SVF-doxygen/html/html/classSVF_1_1SVFIR.html +26 -26
- package/SVF-doxygen/html/html/classSVF_1_1SVFIRBuilder.html +114 -115
- package/SVF-doxygen/html/html/classSVF_1_1SVFVar.html +4 -4
- package/SVF-doxygen/html/html/classSVF_1_1SVFVar.png +0 -0
- package/SVF-doxygen/html/html/classSVF_1_1SaberSVFGBuilder.html +3 -3
- package/SVF-doxygen/html/html/classSVF_1_1StInfo-members.html +11 -14
- package/SVF-doxygen/html/html/classSVF_1_1StInfo.html +70 -168
- package/SVF-doxygen/html/html/classSVF_1_1SymbolTableBuilder.html +30 -30
- package/SVF-doxygen/html/html/classSVF_1_1SymbolTableInfo-members.html +59 -60
- package/SVF-doxygen/html/html/classSVF_1_1SymbolTableInfo.html +118 -146
- package/SVF-doxygen/html/html/classSVF_1_1ThreadCallGraph.html +3 -3
- package/SVF-doxygen/html/html/classSVF_1_1TypeBasedHeapCloning.html +18 -18
- package/SVF-doxygen/html/html/classSVF_1_1VarArgPN.html +11 -11
- package/SVF-doxygen/html/html/classSVF_1_1VersionedFlowSensitiveStat.html +3 -3
- package/SVF-doxygen/html/html/classes.html +6 -6
- package/SVF-doxygen/html/html/functions_a.html +13 -10
- package/SVF-doxygen/html/html/functions_b.html +1 -5
- package/SVF-doxygen/html/html/functions_c.html +6 -8
- package/SVF-doxygen/html/html/functions_d.html +1 -1
- package/SVF-doxygen/html/html/functions_e.html +0 -16
- package/SVF-doxygen/html/html/functions_f.html +21 -19
- package/SVF-doxygen/html/html/functions_func.html +15 -12
- package/SVF-doxygen/html/html/functions_func_c.html +2 -2
- package/SVF-doxygen/html/html/functions_func_d.html +1 -1
- package/SVF-doxygen/html/html/functions_func_e.html +2 -8
- package/SVF-doxygen/html/html/functions_func_f.html +4 -4
- package/SVF-doxygen/html/html/functions_func_g.html +39 -60
- package/SVF-doxygen/html/html/functions_func_i.html +11 -14
- package/SVF-doxygen/html/html/functions_func_s.html +6 -9
- package/SVF-doxygen/html/html/functions_func_t.html +1 -1
- package/SVF-doxygen/html/html/functions_func_w.html +1 -1
- package/SVF-doxygen/html/html/functions_g.html +38 -59
- package/SVF-doxygen/html/html/functions_i.html +6 -9
- package/SVF-doxygen/html/html/functions_l.html +1 -1
- package/SVF-doxygen/html/html/functions_n.html +4 -7
- package/SVF-doxygen/html/html/functions_o.html +21 -16
- package/SVF-doxygen/html/html/functions_p.html +16 -14
- package/SVF-doxygen/html/html/functions_s.html +15 -18
- package/SVF-doxygen/html/html/functions_t.html +4 -4
- package/SVF-doxygen/html/html/functions_type_e.html +0 -4
- package/SVF-doxygen/html/html/functions_type_o.html +3 -0
- package/SVF-doxygen/html/html/functions_v.html +3 -3
- package/SVF-doxygen/html/html/functions_vars_b.html +1 -5
- package/SVF-doxygen/html/html/functions_vars_e.html +0 -6
- package/SVF-doxygen/html/html/functions_vars_f.html +9 -7
- package/SVF-doxygen/html/html/functions_vars_l.html +1 -1
- package/SVF-doxygen/html/html/functions_vars_n.html +0 -3
- package/SVF-doxygen/html/html/functions_vars_o.html +2 -2
- package/SVF-doxygen/html/html/functions_w.html +1 -1
- package/SVF-doxygen/html/html/hierarchy.html +64 -64
- package/SVF-doxygen/html/html/namespaceSVF.html +3 -3
- package/SVF-doxygen/html/html/search/all_1.js +3 -2
- package/SVF-doxygen/html/html/search/all_10.js +8 -8
- package/SVF-doxygen/html/html/search/all_12.js +1 -1
- package/SVF-doxygen/html/html/search/all_13.js +9 -10
- package/SVF-doxygen/html/html/search/all_14.js +7 -7
- package/SVF-doxygen/html/html/search/all_15.js +1 -1
- package/SVF-doxygen/html/html/search/all_16.js +2 -2
- package/SVF-doxygen/html/html/search/all_17.js +1 -1
- package/SVF-doxygen/html/html/search/all_2.js +2 -3
- package/SVF-doxygen/html/html/search/all_3.js +3 -3
- package/SVF-doxygen/html/html/search/all_4.js +1 -1
- package/SVF-doxygen/html/html/search/all_5.js +0 -5
- package/SVF-doxygen/html/html/search/all_6.js +6 -5
- package/SVF-doxygen/html/html/search/all_7.js +13 -21
- package/SVF-doxygen/html/html/search/all_9.js +1 -2
- package/SVF-doxygen/html/html/search/all_c.js +2 -2
- package/SVF-doxygen/html/html/search/all_d.js +1 -1
- package/SVF-doxygen/html/html/search/all_e.js +1 -2
- package/SVF-doxygen/html/html/search/all_f.js +4 -3
- package/SVF-doxygen/html/html/search/classes_5.js +1 -1
- package/SVF-doxygen/html/html/search/classes_6.js +1 -1
- package/SVF-doxygen/html/html/search/functions_0.js +3 -2
- package/SVF-doxygen/html/html/search/functions_10.js +2 -3
- package/SVF-doxygen/html/html/search/functions_11.js +1 -1
- package/SVF-doxygen/html/html/search/functions_14.js +1 -1
- package/SVF-doxygen/html/html/search/functions_2.js +2 -2
- package/SVF-doxygen/html/html/search/functions_3.js +1 -1
- package/SVF-doxygen/html/html/search/functions_4.js +0 -2
- package/SVF-doxygen/html/html/search/functions_5.js +1 -1
- package/SVF-doxygen/html/html/search/functions_6.js +13 -21
- package/SVF-doxygen/html/html/search/functions_8.js +1 -2
- package/SVF-doxygen/html/html/search/functions_a.js +1 -1
- package/SVF-doxygen/html/html/search/functions_e.js +1 -1
- package/SVF-doxygen/html/html/search/typedefs_4.js +0 -1
- package/SVF-doxygen/html/html/search/typedefs_e.js +1 -0
- package/SVF-doxygen/html/html/search/variables_14.js +3 -3
- package/SVF-doxygen/html/html/search/variables_15.js +1 -1
- package/SVF-doxygen/html/html/search/variables_2.js +2 -3
- package/SVF-doxygen/html/html/search/variables_5.js +0 -2
- package/SVF-doxygen/html/html/search/variables_6.js +5 -4
- package/SVF-doxygen/html/html/search/variables_c.js +1 -1
- package/SVF-doxygen/html/html/search/variables_e.js +0 -1
- package/SVF-doxygen/html/html/search/variables_f.js +1 -1
- package/SVF-doxygen/html/html/structllvm_1_1DOTGraphTraits_3_01ConstraintGraph_01_5_01_4.html +1 -1
- package/SVF-doxygen/html/html/structllvm_1_1DOTGraphTraits_3_01IRGraph_01_5_01_4.html +1 -1
- package/SVF-doxygen/html/html/structllvm_1_1DOTGraphTraits_3_01OfflineConsG_01_5_01_4.html +1 -1
- package/SVF-doxygen/html/html/structstd_1_1hash_3_01SVF_1_1LocationSet_01_4.html +5 -5
- package/include/Graphs/ConsG.h +1 -1
- package/include/Graphs/ConsGEdge.h +1 -1
- package/include/MemoryModel/LocationSet.h +39 -126
- package/include/MemoryModel/SVFIR.h +1 -1
- package/include/MemoryModel/SVFStatements.h +1 -1
- package/include/MemoryModel/SVFVariables.h +17 -11
- package/include/MemoryModel/SymbolTableInfo.h +27 -25
- package/include/Util/IRAnnotator.h +3 -3
- package/lib/DDA/ContextDDA.cpp +1 -1
- package/lib/Graphs/ConsG.cpp +1 -1
- package/lib/Graphs/IRGraph.cpp +1 -1
- package/lib/Graphs/OfflineConsG.cpp +1 -1
- package/lib/MemoryModel/LocationSet.cpp +53 -95
- package/lib/MemoryModel/PointerAnalysisImpl.cpp +4 -4
- package/lib/MemoryModel/SVFIR.cpp +4 -4
- package/lib/MemoryModel/SVFVariables.cpp +2 -2
- package/lib/MemoryModel/SymbolTableInfo.cpp +36 -63
- package/lib/SABER/SaberSVFGBuilder.cpp +1 -1
- package/lib/SVF-FE/SVFIRBuilder.cpp +9 -10
- package/lib/SVF-FE/SymbolTableBuilder.cpp +4 -4
- package/lib/Util/TypeBasedHeapCloning.cpp +10 -10
- package/lib/WPA/Andersen.cpp +1 -1
- package/lib/WPA/AndersenSFR.cpp +2 -2
- package/lib/WPA/CSC.cpp +1 -1
- package/lib/WPA/FlowSensitiveTBHC.cpp +6 -6
- package/package.json +1 -1
|
@@ -31,122 +31,80 @@
|
|
|
31
31
|
|
|
32
32
|
#include "Util/Options.h"
|
|
33
33
|
#include "MemoryModel/LocationSet.h"
|
|
34
|
+
#include "Util/SVFUtil.h"
|
|
34
35
|
|
|
35
36
|
using namespace SVF;
|
|
36
|
-
|
|
37
|
+
using namespace SVFUtil;
|
|
37
38
|
|
|
38
39
|
/*!
|
|
39
|
-
* Add
|
|
40
|
+
* Add offset value to vector offsetValues
|
|
40
41
|
*/
|
|
41
|
-
|
|
42
|
+
bool LocationSet::addOffsetValue(const Value* offsetVal)
|
|
42
43
|
{
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return;
|
|
47
|
-
|
|
48
|
-
if (Options::SingleStride)
|
|
49
|
-
{
|
|
50
|
-
if (numStridePair.empty())
|
|
51
|
-
numStridePair.push_back(std::make_pair(StInfo::getMaxFieldLimit(),pair.second));
|
|
52
|
-
else
|
|
53
|
-
{
|
|
54
|
-
/// Find the GCD stride
|
|
55
|
-
NodeID existStride = (*numStridePair.begin()).second;
|
|
56
|
-
NodeID newStride = gcd(pair.second, existStride);
|
|
57
|
-
if (newStride != existStride)
|
|
58
|
-
{
|
|
59
|
-
numStridePair.pop_back();
|
|
60
|
-
numStridePair.push_back(std::make_pair(StInfo::getMaxFieldLimit(),newStride));
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
else
|
|
65
|
-
{
|
|
66
|
-
numStridePair.push_back(pair);
|
|
44
|
+
for(const Value* val : offsetValues){
|
|
45
|
+
if(val==offsetVal)
|
|
46
|
+
return false;
|
|
67
47
|
}
|
|
48
|
+
offsetValues.push_back(offsetVal);
|
|
49
|
+
return true;
|
|
68
50
|
}
|
|
69
51
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
* Return TRUE if it successfully increases any index by 1
|
|
73
|
-
*/
|
|
74
|
-
bool LocationSet::increaseIfNotReachUpperBound(std::vector<NodeID>& indices,
|
|
75
|
-
const ElemNumStridePairVec& pairVec) const
|
|
52
|
+
/// Return TRUE if all offset values are constants
|
|
53
|
+
bool LocationSet::isConstantOffset() const
|
|
76
54
|
{
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
bool reachUpperBound = true;
|
|
81
|
-
for (u32_t i = 0; i < indices.size(); i++)
|
|
82
|
-
{
|
|
83
|
-
assert(pairVec[i].first > 0 && "number must be greater than 0");
|
|
84
|
-
if (indices[i] < (pairVec[i].first - 1))
|
|
85
|
-
reachUpperBound = false;
|
|
55
|
+
for(const Value* val : offsetValues){
|
|
56
|
+
if(SVFUtil::isa<ConstantInt>(val) == false)
|
|
57
|
+
return false;
|
|
86
58
|
}
|
|
87
|
-
|
|
88
|
-
/// Increase index if not reach upper bound
|
|
89
|
-
bool increased = false;
|
|
90
|
-
if (reachUpperBound == false)
|
|
91
|
-
{
|
|
92
|
-
u32_t i = 0;
|
|
93
|
-
while (increased == false)
|
|
94
|
-
{
|
|
95
|
-
if (indices[i] < (pairVec[i].first - 1))
|
|
96
|
-
{
|
|
97
|
-
indices[i] += 1;
|
|
98
|
-
increased = true;
|
|
99
|
-
}
|
|
100
|
-
else
|
|
101
|
-
{
|
|
102
|
-
indices[i] = 0;
|
|
103
|
-
i++;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return increased;
|
|
59
|
+
return true;
|
|
109
60
|
}
|
|
110
61
|
|
|
111
|
-
|
|
112
62
|
/*!
|
|
113
63
|
* Compute all possible locations according to offset and number-stride pairs.
|
|
114
64
|
*/
|
|
115
65
|
NodeBS LocationSet::computeAllLocations() const
|
|
116
66
|
{
|
|
117
|
-
|
|
118
67
|
NodeBS result;
|
|
119
|
-
result.set(
|
|
68
|
+
result.set(accumulateConstantOffset());
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
120
71
|
|
|
121
|
-
|
|
72
|
+
SVF::LocationSet::LSRelation LocationSet::checkRelation(const LocationSet& LHS, const LocationSet& RHS)
|
|
73
|
+
{
|
|
74
|
+
NodeBS lhsLocations = LHS.computeAllLocations();
|
|
75
|
+
NodeBS rhsLocations = RHS.computeAllLocations();
|
|
76
|
+
if (lhsLocations.intersects(rhsLocations))
|
|
122
77
|
{
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
NodeID ofst = getOffset();
|
|
136
|
-
while (i < lhsVec.size())
|
|
137
|
-
{
|
|
138
|
-
ofst += (lhsVec[i].second * indices[i]);
|
|
139
|
-
i++;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
result.set(ofst);
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
while (increaseIfNotReachUpperBound(indices, lhsVec));
|
|
78
|
+
if (lhsLocations == rhsLocations)
|
|
79
|
+
return Same;
|
|
80
|
+
else if (lhsLocations.contains(rhsLocations))
|
|
81
|
+
return Superset;
|
|
82
|
+
else if (rhsLocations.contains(lhsLocations))
|
|
83
|
+
return Subset;
|
|
84
|
+
else
|
|
85
|
+
return Overlap;
|
|
86
|
+
}
|
|
87
|
+
else
|
|
88
|
+
{
|
|
89
|
+
return NonOverlap;
|
|
146
90
|
}
|
|
147
|
-
|
|
148
|
-
return result;
|
|
149
91
|
}
|
|
150
92
|
|
|
151
|
-
|
|
152
|
-
|
|
93
|
+
/// Dump location set
|
|
94
|
+
std::string LocationSet::dump() const
|
|
95
|
+
{
|
|
96
|
+
std::string str;
|
|
97
|
+
raw_string_ostream rawstr(str);
|
|
98
|
+
|
|
99
|
+
rawstr << "LocationSet\tField_Index: " << accumulateConstantOffset();
|
|
100
|
+
rawstr << ",\tNum-Stride: {";
|
|
101
|
+
const OffsetValueVec& vec = getOffsetValueVec();
|
|
102
|
+
OffsetValueVec::const_iterator it = vec.begin();
|
|
103
|
+
OffsetValueVec::const_iterator eit = vec.end();
|
|
104
|
+
for (; it != eit; ++it)
|
|
105
|
+
{
|
|
106
|
+
rawstr << " (" << value2String(*it) << ")";
|
|
107
|
+
}
|
|
108
|
+
rawstr << " }\n";
|
|
109
|
+
return rawstr.str();
|
|
110
|
+
}
|
|
@@ -150,11 +150,11 @@ void BVDataPTAImpl::writeToFile(const string& filename)
|
|
|
150
150
|
for (auto it = pag->begin(), ie = pag->end(); it != ie; ++it)
|
|
151
151
|
{
|
|
152
152
|
PAGNode* pagNode = it->second;
|
|
153
|
-
if (
|
|
153
|
+
if (GepObjVar *gepObjPN = SVFUtil::dyn_cast<GepObjVar>(pagNode))
|
|
154
154
|
{
|
|
155
155
|
F.os() << it->first << " ";
|
|
156
156
|
F.os() << pag->getBaseObjVar(it->first) << " ";
|
|
157
|
-
F.os() << gepObjPN->
|
|
157
|
+
F.os() << gepObjPN->getOffset() << "\n";
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
|
|
@@ -411,7 +411,7 @@ void BVDataPTAImpl::normalizePointsTo() {
|
|
|
411
411
|
assert(memObj && "Invalid memobj in memToFieldsMap");
|
|
412
412
|
if (memObj->isFieldInsensitive()) {
|
|
413
413
|
for (NodeID id : t.second) {
|
|
414
|
-
if (SVFUtil::isa<
|
|
414
|
+
if (SVFUtil::isa<GepObjVar>(pag->getGNode(id))) {
|
|
415
415
|
dropNodes.set(id);
|
|
416
416
|
} else
|
|
417
417
|
assert(id == base && "Not a GepObj Node or a baseObj Node?");
|
|
@@ -437,7 +437,7 @@ void BVDataPTAImpl::normalizePointsTo() {
|
|
|
437
437
|
// and remove those nodes from pag
|
|
438
438
|
for (NodeID n: dropNodes) {
|
|
439
439
|
NodeID base = pag->getBaseObjVar(n);
|
|
440
|
-
|
|
440
|
+
GepObjVar *gepNode = SVFUtil::dyn_cast<GepObjVar>(pag->getGNode(n));
|
|
441
441
|
const LocationSet ls = gepNode->getLocationSet();
|
|
442
442
|
GepObjVarMap.erase(std::make_pair(base, ls));
|
|
443
443
|
memToFieldsMap[base].reset(n);
|
|
@@ -383,7 +383,7 @@ NodeID SVFIR::addGepValNode(const Value* curInst,const Value* gepVal, const Loca
|
|
|
383
383
|
NodeID SVFIR::getGepObjVar(NodeID id, const LocationSet& ls)
|
|
384
384
|
{
|
|
385
385
|
SVFVar* node = pag->getGNode(id);
|
|
386
|
-
if (
|
|
386
|
+
if (GepObjVar* gepNode = SVFUtil::dyn_cast<GepObjVar>(node))
|
|
387
387
|
return getGepObjVar(gepNode->getMemObj(), gepNode->getLocationSet() + ls);
|
|
388
388
|
else if (FIObjVar* baseNode = SVFUtil::dyn_cast<FIObjVar>(node))
|
|
389
389
|
return getGepObjVar(baseNode->getMemObj(), ls);
|
|
@@ -413,7 +413,7 @@ NodeID SVFIR::getGepObjVar(const MemObj* obj, const LocationSet& ls)
|
|
|
413
413
|
LocationSet newLS = SymbolTableInfo::SymbolInfo()->getModulusOffset(obj,ls);
|
|
414
414
|
|
|
415
415
|
// Base and first field are the same memory location.
|
|
416
|
-
if (Options::FirstFieldEqBase && newLS.
|
|
416
|
+
if (Options::FirstFieldEqBase && newLS.accumulateConstantOffset() == 0) return base;
|
|
417
417
|
|
|
418
418
|
NodeLocationSetMap::iterator iter = GepObjVarMap.find(std::make_pair(base, newLS));
|
|
419
419
|
if (iter == GepObjVarMap.end())
|
|
@@ -433,9 +433,9 @@ NodeID SVFIR::addGepObjNode(const MemObj* obj, const LocationSet& ls)
|
|
|
433
433
|
assert(0==GepObjVarMap.count(std::make_pair(base, ls))
|
|
434
434
|
&& "this node should not be created before");
|
|
435
435
|
|
|
436
|
-
NodeID gepId = NodeIDAllocator::get()->allocateGepObjectId(base, ls.
|
|
436
|
+
NodeID gepId = NodeIDAllocator::get()->allocateGepObjectId(base, ls.accumulateConstantOffset(), StInfo::getMaxFieldLimit());
|
|
437
437
|
GepObjVarMap[std::make_pair(base, ls)] = gepId;
|
|
438
|
-
|
|
438
|
+
GepObjVar *node = new GepObjVar(obj, gepId, ls);
|
|
439
439
|
memToFieldsMap[base].set(gepId);
|
|
440
440
|
return addObjNode(obj->getValue(), node, gepId);
|
|
441
441
|
}
|
|
@@ -141,10 +141,10 @@ const std::string GepValVar::toString() const {
|
|
|
141
141
|
return rawstr.str();
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
const std::string
|
|
144
|
+
const std::string GepObjVar::toString() const {
|
|
145
145
|
std::string str;
|
|
146
146
|
raw_string_ostream rawstr(str);
|
|
147
|
-
rawstr << "
|
|
147
|
+
rawstr << "GepObjVar ID: " << getId() << " with offset_" + llvm::itostr(ls.accumulateConstantOffset());
|
|
148
148
|
if (Options::PAGDotGraphShorter) {
|
|
149
149
|
rawstr << "\n";
|
|
150
150
|
}
|
|
@@ -101,22 +101,18 @@ void SymbolTableInfo::collectArrayInfo(const ArrayType* ty)
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
/// Array itself only has one field which is the inner most element
|
|
104
|
-
stinfo->addFldWithType(0,
|
|
104
|
+
stinfo->addFldWithType(0,elemTy);
|
|
105
105
|
|
|
106
106
|
/// Array's flatten field infor is the same as its element's
|
|
107
107
|
/// flatten infor.
|
|
108
108
|
StInfo* elemStInfo = getStructInfo(elemTy);
|
|
109
|
-
u32_t nfE = elemStInfo->
|
|
109
|
+
u32_t nfE = elemStInfo->getFlattenedFieldInfoVec().size();
|
|
110
110
|
for (u32_t j = 0; j < nfE; j++)
|
|
111
111
|
{
|
|
112
|
-
u32_t idx = elemStInfo->
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
/// append the additional number
|
|
117
|
-
pair.push_back(std::make_pair(out_num, out_stride));
|
|
118
|
-
FieldInfo field(idx, off, fieldTy, pair);
|
|
119
|
-
stinfo->getFlattenFieldInfoVec().push_back(field);
|
|
112
|
+
u32_t idx = elemStInfo->getFlattenedFieldInfoVec()[j].getFlattenFldIdx();
|
|
113
|
+
const Type* fieldTy = elemStInfo->getFlattenedFieldInfoVec()[j].getFlattenElemTy();
|
|
114
|
+
FlattenedFieldInfo field(idx, fieldTy);
|
|
115
|
+
stinfo->getFlattenedFieldInfoVec().push_back(field);
|
|
120
116
|
}
|
|
121
117
|
}
|
|
122
118
|
|
|
@@ -139,36 +135,27 @@ void SymbolTableInfo::collectStructInfo(const StructType *sty)
|
|
|
139
135
|
sty->element_end(); it != ie; ++it, ++field_idx)
|
|
140
136
|
{
|
|
141
137
|
const Type *et = *it;
|
|
142
|
-
// This offset is computed after alignment with the current struct
|
|
143
|
-
u64_t eOffsetInBytes = getTypeSizeInBytes(sty, field_idx);
|
|
144
|
-
//The offset is where this element will be placed in the exp. struct.
|
|
145
|
-
/// FIXME: As the layout size is uint_64, here we assume
|
|
146
138
|
/// offset with uint_32 (Size_t) is large enough and will not cause overflow
|
|
147
|
-
stinfo->addFldWithType(nf,
|
|
139
|
+
stinfo->addFldWithType(nf, et);
|
|
148
140
|
|
|
149
141
|
if (SVFUtil::isa<StructType>(et) || SVFUtil::isa<ArrayType>(et))
|
|
150
142
|
{
|
|
151
143
|
StInfo * subStinfo = getStructInfo(et);
|
|
152
|
-
u32_t nfE = subStinfo->
|
|
144
|
+
u32_t nfE = subStinfo->getFlattenedFieldInfoVec().size();
|
|
153
145
|
//Copy ST's info, whose element 0 is the size of ST itself.
|
|
154
146
|
for (u32_t j = 0; j < nfE; j++)
|
|
155
147
|
{
|
|
156
|
-
u32_t fldIdx = nf + subStinfo->
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
pair.push_back(std::make_pair(1, 0));
|
|
161
|
-
FieldInfo field(fldIdx, off,elemTy,pair);
|
|
162
|
-
stinfo->getFlattenFieldInfoVec().push_back(field);
|
|
148
|
+
u32_t fldIdx = nf + subStinfo->getFlattenedFieldInfoVec()[j].getFlattenFldIdx();
|
|
149
|
+
const Type* elemTy = subStinfo->getFlattenedFieldInfoVec()[j].getFlattenElemTy();
|
|
150
|
+
FlattenedFieldInfo field(fldIdx, elemTy);
|
|
151
|
+
stinfo->getFlattenedFieldInfoVec().push_back(field);
|
|
163
152
|
}
|
|
164
153
|
nf += nfE;
|
|
165
154
|
}
|
|
166
155
|
else //simple type
|
|
167
156
|
{
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
FieldInfo field(nf, eOffsetInBytes, et,pair);
|
|
171
|
-
stinfo->getFlattenFieldInfoVec().push_back(field);
|
|
157
|
+
FlattenedFieldInfo field(nf, et);
|
|
158
|
+
stinfo->getFlattenedFieldInfoVec().push_back(field);
|
|
172
159
|
++nf;
|
|
173
160
|
}
|
|
174
161
|
}
|
|
@@ -191,12 +178,10 @@ void SymbolTableInfo::collectSimpleTypeInfo(const Type* ty)
|
|
|
191
178
|
typeToFieldInfo[ty] = stinfo;
|
|
192
179
|
|
|
193
180
|
/// Only one field
|
|
194
|
-
stinfo->addFldWithType(0,
|
|
181
|
+
stinfo->addFldWithType(0, ty);
|
|
195
182
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
FieldInfo field(0, 0, ty, pair);
|
|
199
|
-
stinfo->getFlattenFieldInfoVec().push_back(field);
|
|
183
|
+
FlattenedFieldInfo field(0, ty);
|
|
184
|
+
stinfo->getFlattenedFieldInfoVec().push_back(field);
|
|
200
185
|
}
|
|
201
186
|
|
|
202
187
|
|
|
@@ -210,7 +195,7 @@ LocationSet SymbolTableInfo::getModulusOffset(const MemObj* obj, const LocationS
|
|
|
210
195
|
/// of current struct. Make the offset positive so we can still get a node within current
|
|
211
196
|
/// struct to represent this obj.
|
|
212
197
|
|
|
213
|
-
Size_t offset = ls.
|
|
198
|
+
Size_t offset = ls.accumulateConstantOffset();
|
|
214
199
|
if(offset < 0)
|
|
215
200
|
{
|
|
216
201
|
writeWrnMsg("try to create a gep node with negative offset.");
|
|
@@ -294,10 +279,10 @@ bool SymbolTableInfo::isConstantObjSym(const Value *val)
|
|
|
294
279
|
else
|
|
295
280
|
{
|
|
296
281
|
StInfo *stInfo = getStructInfo(v->getInitializer()->getType());
|
|
297
|
-
const std::vector<
|
|
298
|
-
for (std::vector<
|
|
282
|
+
const std::vector<FlattenedFieldInfo> &fields = stInfo->getFlattenedFieldInfoVec();
|
|
283
|
+
for (std::vector<FlattenedFieldInfo>::const_iterator it = fields.begin(), eit = fields.end(); it != eit; ++it)
|
|
299
284
|
{
|
|
300
|
-
const
|
|
285
|
+
const FlattenedFieldInfo &field = *it;
|
|
301
286
|
const Type *elemTy = field.getFlattenElemTy();
|
|
302
287
|
assert(!SVFUtil::isa<FunctionType>(elemTy) && "Initializer of a global is a function?");
|
|
303
288
|
if (SVFUtil::isa<PointerType>(elemTy))
|
|
@@ -337,29 +322,23 @@ const MemObj* SymbolTableInfo::createDummyObj(SymID symId, const Type* type)
|
|
|
337
322
|
return memObj;
|
|
338
323
|
}
|
|
339
324
|
|
|
340
|
-
const std::vector<u32_t>& SymbolTableInfo::
|
|
325
|
+
const std::vector<u32_t>& SymbolTableInfo::getFlattenedFieldIdxVec(const Type *T)
|
|
341
326
|
{
|
|
342
|
-
return getStructInfoIter(T)->second->
|
|
327
|
+
return getStructInfoIter(T)->second->getFlattenedFieldIdxVec();
|
|
343
328
|
}
|
|
344
329
|
|
|
345
|
-
const std::vector<
|
|
330
|
+
const std::vector<FlattenedFieldInfo>& SymbolTableInfo::getFlattenedFieldInfoVec(const Type *T)
|
|
346
331
|
{
|
|
347
|
-
return getStructInfoIter(T)->second->
|
|
332
|
+
return getStructInfoIter(T)->second->getFlattenedFieldInfoVec();
|
|
348
333
|
}
|
|
349
334
|
|
|
350
|
-
const
|
|
335
|
+
const Type* SymbolTableInfo::getOriginalFieldType(const Type* baseType, u32_t field_idx)
|
|
351
336
|
{
|
|
352
|
-
return getStructInfoIter(
|
|
337
|
+
return getStructInfoIter(baseType)->second->getOriginalFieldType(field_idx);
|
|
353
338
|
}
|
|
354
339
|
|
|
355
|
-
const Type* SymbolTableInfo::
|
|
356
|
-
|
|
357
|
-
return getStructInfoIter(baseType)->second->getFieldTypeWithFldIdx(field_idx);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
const Type* SymbolTableInfo::getOrigSubTypeWithByteOffset(const Type* baseType, u32_t byteOffset)
|
|
361
|
-
{
|
|
362
|
-
return getStructInfoIter(baseType)->second->getFieldTypeWithByteOffset(byteOffset);
|
|
340
|
+
const Type* SymbolTableInfo::getFlatternedFieldType(const Type* baseType, u32_t field_idx){
|
|
341
|
+
return getStructInfoIter(baseType)->second->getFlatternedFieldType(field_idx);
|
|
363
342
|
}
|
|
364
343
|
|
|
365
344
|
/*
|
|
@@ -383,21 +362,15 @@ void SymbolTableInfo::printFlattenFields(const Type* type)
|
|
|
383
362
|
outs() <<" {Type: ";
|
|
384
363
|
st->print(outs());
|
|
385
364
|
outs() << "}\n";
|
|
386
|
-
std::vector<
|
|
365
|
+
std::vector<FlattenedFieldInfo>& finfo = getStructInfo(st)->getFlattenedFieldInfoVec();
|
|
387
366
|
int field_idx = 0;
|
|
388
|
-
for(std::vector<
|
|
367
|
+
for(std::vector<FlattenedFieldInfo>::iterator it = finfo.begin(), eit = finfo.end();
|
|
389
368
|
it!=eit; ++it, field_idx++)
|
|
390
369
|
{
|
|
391
|
-
outs() << " \tField_idx = " << (*it).getFlattenFldIdx()
|
|
370
|
+
outs() << " \tField_idx = " << (*it).getFlattenFldIdx();
|
|
392
371
|
outs() << ", field type: ";
|
|
393
372
|
(*it).getFlattenElemTy()->print(outs());
|
|
394
373
|
outs() << ", field size: " << getTypeSizeInBytes((*it).getFlattenElemTy());
|
|
395
|
-
outs() << ", field stride pair: ";
|
|
396
|
-
for(FieldInfo::ElemNumStridePairVec::const_iterator pit = (*it).elemStridePairBegin(),
|
|
397
|
-
peit = (*it).elemStridePairEnd(); pit!=peit; ++pit)
|
|
398
|
-
{
|
|
399
|
-
outs() << "[ " << pit->first << ", " << pit->second << " ] ";
|
|
400
|
-
}
|
|
401
374
|
outs() << "\n";
|
|
402
375
|
}
|
|
403
376
|
outs() << "\n";
|
|
@@ -576,12 +549,12 @@ bool ObjTypeInfo::isNonPtrFieldObj(const LocationSet& ls)
|
|
|
576
549
|
if (SVFUtil::isa<StructType>(ety) || SVFUtil::isa<ArrayType>(ety))
|
|
577
550
|
{
|
|
578
551
|
bool hasIntersection = false;
|
|
579
|
-
const vector<
|
|
580
|
-
vector<
|
|
581
|
-
vector<
|
|
552
|
+
const vector<FlattenedFieldInfo> &infovec = SymbolTableInfo::SymbolInfo()->getFlattenedFieldInfoVec(ety);
|
|
553
|
+
vector<FlattenedFieldInfo>::const_iterator it = infovec.begin();
|
|
554
|
+
vector<FlattenedFieldInfo>::const_iterator eit = infovec.end();
|
|
582
555
|
for (; it != eit; ++it)
|
|
583
556
|
{
|
|
584
|
-
const
|
|
557
|
+
const FlattenedFieldInfo& fieldLS = *it;
|
|
585
558
|
if (ls.intersects(LocationSet(fieldLS)))
|
|
586
559
|
{
|
|
587
560
|
hasIntersection = true;
|
|
@@ -73,7 +73,7 @@ void SaberSVFGBuilder::collectGlobals(BVDataPTAImpl* pta)
|
|
|
73
73
|
if(SVFUtil::isa<DummyValVar>(pagNode) || SVFUtil::isa<DummyObjVar>(pagNode))
|
|
74
74
|
continue;
|
|
75
75
|
|
|
76
|
-
if(
|
|
76
|
+
if(GepObjVar* gepobj = SVFUtil::dyn_cast<GepObjVar>(pagNode)) {
|
|
77
77
|
if(SVFUtil::isa<DummyObjVar>(pag->getGNode(gepobj->getBaseNode())))
|
|
78
78
|
continue;
|
|
79
79
|
}
|
|
@@ -212,13 +212,12 @@ bool SVFIRBuilder::computeGepOffset(const User *V, LocationSet& ls)
|
|
|
212
212
|
if(gepOp && dataLayout && gepOp->accumulateConstantOffset(*dataLayout,byteOffset))
|
|
213
213
|
{
|
|
214
214
|
Size_t bo = byteOffset.getSExtValue();
|
|
215
|
-
ls.setByteOffset(bo + ls.getByteOffset());
|
|
216
215
|
}
|
|
217
216
|
|
|
218
217
|
for (bridge_gep_iterator gi = bridge_gep_begin(*V), ge = bridge_gep_end(*V);
|
|
219
218
|
gi != ge; ++gi)
|
|
220
219
|
{
|
|
221
|
-
|
|
220
|
+
ls.addOffsetValue(gi.getOperand());
|
|
222
221
|
// Handling array types, skipe array handling here
|
|
223
222
|
// We treat whole array as one, then we can distinguish different field of an array of struct
|
|
224
223
|
// e.g. s[1].f1 is differet from s[0].f2
|
|
@@ -257,14 +256,14 @@ bool SVFIRBuilder::computeGepOffset(const User *V, LocationSet& ls)
|
|
|
257
256
|
if (const StructType *ST = SVFUtil::dyn_cast<StructType>(*gi) )
|
|
258
257
|
{
|
|
259
258
|
assert(op && "non-const struct index in GEP");
|
|
260
|
-
const vector<u32_t> &so = SymbolTableInfo::SymbolInfo()->
|
|
259
|
+
const vector<u32_t> &so = SymbolTableInfo::SymbolInfo()->getFlattenedFieldIdxVec(ST);
|
|
261
260
|
if ((unsigned)idx >= so.size())
|
|
262
261
|
{
|
|
263
262
|
outs() << "!! Struct index out of bounds" << idx << "\n";
|
|
264
263
|
assert(0);
|
|
265
264
|
}
|
|
266
265
|
//add the translated offset
|
|
267
|
-
ls.setFldIdx(ls.
|
|
266
|
+
ls.setFldIdx(ls.accumulateConstantOffset() + so[idx]);
|
|
268
267
|
}
|
|
269
268
|
}
|
|
270
269
|
return true;
|
|
@@ -483,7 +482,7 @@ void SVFIRBuilder::InitialGlobal(const GlobalVariable *gvar, Constant *C,
|
|
|
483
482
|
{
|
|
484
483
|
const StructType *sty = SVFUtil::cast<StructType>(C->getType());
|
|
485
484
|
const std::vector<u32_t>& offsetvect =
|
|
486
|
-
SymbolTableInfo::SymbolInfo()->
|
|
485
|
+
SymbolTableInfo::SymbolInfo()->getFlattenedFieldIdxVec(sty);
|
|
487
486
|
for (u32_t i = 0, e = C->getNumOperands(); i != e; i++)
|
|
488
487
|
{
|
|
489
488
|
u32_t off = offsetvect[i];
|
|
@@ -1290,7 +1289,7 @@ void SVFIRBuilder::handleExtCall(CallSite cs, const SVFFunction *callee)
|
|
|
1290
1289
|
// We have vArg3 points to the entry of _Rb_tree_node_base { color; parent; left; right; }.
|
|
1291
1290
|
// Now we calculate the offset from base to vArg3
|
|
1292
1291
|
NodeID vnArg3 = pag->getValueNode(vArg3);
|
|
1293
|
-
Size_t offset = pag->getLocationSetFromBaseNode(vnArg3).
|
|
1292
|
+
Size_t offset = pag->getLocationSetFromBaseNode(vnArg3).accumulateConstantOffset();
|
|
1294
1293
|
|
|
1295
1294
|
// We get all flattened fields of base
|
|
1296
1295
|
vector<LocationSet> fields;
|
|
@@ -1314,7 +1313,7 @@ void SVFIRBuilder::handleExtCall(CallSite cs, const SVFFunction *callee)
|
|
|
1314
1313
|
|
|
1315
1314
|
Value *vArg = cs.getArgument(0);
|
|
1316
1315
|
NodeID vnArg = pag->getValueNode(vArg);
|
|
1317
|
-
Size_t offset = pag->getLocationSetFromBaseNode(vnArg).
|
|
1316
|
+
Size_t offset = pag->getLocationSetFromBaseNode(vnArg).accumulateConstantOffset();
|
|
1318
1317
|
|
|
1319
1318
|
// We get all fields
|
|
1320
1319
|
vector<LocationSet> fields;
|
|
@@ -1523,7 +1522,7 @@ NodeID SVFIRBuilder::getGepValVar(const Value* val, const LocationSet& ls, const
|
|
|
1523
1522
|
* 2. GlobalVariable
|
|
1524
1523
|
*/
|
|
1525
1524
|
assert((SVFUtil::isa<Instruction>(curVal) || SVFUtil::isa<GlobalVariable>(curVal)) && "curVal not an instruction or a globalvariable?");
|
|
1526
|
-
const std::vector<
|
|
1525
|
+
const std::vector<FlattenedFieldInfo> &fieldinfo = SymbolTableInfo::SymbolInfo()->getFlattenedFieldInfoVec(baseType);
|
|
1527
1526
|
const Type *type = fieldinfo[fieldidx].getFlattenElemTy();
|
|
1528
1527
|
|
|
1529
1528
|
// We assume every GepValNode and its GepEdge to the baseNode are unique across the whole program
|
|
@@ -1627,13 +1626,13 @@ u32_t SVFIRBuilder::getFields(std::vector<LocationSet>& fields, const Type* T, u
|
|
|
1627
1626
|
return 0;
|
|
1628
1627
|
|
|
1629
1628
|
T = T->getContainedType(0);
|
|
1630
|
-
const std::vector<
|
|
1629
|
+
const std::vector<FlattenedFieldInfo>& stVec = SymbolTableInfo::SymbolInfo()->getFlattenedFieldInfoVec(T);
|
|
1631
1630
|
u32_t sz = stVec.size();
|
|
1632
1631
|
if (msz < sz)
|
|
1633
1632
|
{
|
|
1634
1633
|
/// Replace fields with T's flatten fields.
|
|
1635
1634
|
fields.clear();
|
|
1636
|
-
for(std::vector<
|
|
1635
|
+
for(std::vector<FlattenedFieldInfo>::const_iterator it = stVec.begin(), eit = stVec.end(); it!=eit; ++it)
|
|
1637
1636
|
fields.push_back(LocationSet(*it));
|
|
1638
1637
|
}
|
|
1639
1638
|
|
|
@@ -444,7 +444,7 @@ void SymbolTableBuilder::handleGlobalInitializerCE(const Constant *C,
|
|
|
444
444
|
{
|
|
445
445
|
const StructType *sty = SVFUtil::cast<StructType>(C->getType());
|
|
446
446
|
const std::vector<u32_t>& offsetvect =
|
|
447
|
-
SymbolTableInfo::SymbolInfo()->
|
|
447
|
+
SymbolTableInfo::SymbolInfo()->getFlattenedFieldIdxVec(sty);
|
|
448
448
|
for (u32_t i = 0, e = C->getNumOperands(); i != e; i++)
|
|
449
449
|
{
|
|
450
450
|
u32_t off = offsetvect[i];
|
|
@@ -515,8 +515,8 @@ void SymbolTableBuilder::analyzeGlobalStackObjType(ObjTypeInfo* typeinfo, const
|
|
|
515
515
|
}
|
|
516
516
|
if (const StructType *ST= SVFUtil::dyn_cast<StructType>(elemTy))
|
|
517
517
|
{
|
|
518
|
-
const std::vector<
|
|
519
|
-
for(std::vector<
|
|
518
|
+
const std::vector<FlattenedFieldInfo>& flattenFields = SymbolTableInfo::SymbolInfo()->getFlattenedFieldInfoVec(ST);
|
|
519
|
+
for(std::vector<FlattenedFieldInfo>::const_iterator it = flattenFields.begin(), eit = flattenFields.end();
|
|
520
520
|
it!=eit; ++it)
|
|
521
521
|
{
|
|
522
522
|
if((*it).getFlattenElemTy()->isPointerTy())
|
|
@@ -600,7 +600,7 @@ u32_t SymbolTableBuilder::getObjSize(const Value* val)
|
|
|
600
600
|
u32_t numOfFields = 1;
|
|
601
601
|
if (SVFUtil::isa<StructType>(ety) || SVFUtil::isa<ArrayType>(ety))
|
|
602
602
|
{
|
|
603
|
-
numOfFields = SymbolTableInfo::SymbolInfo()->
|
|
603
|
+
numOfFields = SymbolTableInfo::SymbolInfo()->getFlattenedFieldInfoVec(ety).size();
|
|
604
604
|
}
|
|
605
605
|
return numOfFields;
|
|
606
606
|
}
|
|
@@ -153,9 +153,9 @@ const NodeBS TypeBasedHeapCloning::getGepObjClones(NodeID base, unsigned offset)
|
|
|
153
153
|
// totalOffset is the offset from the real base (i.e. base of base),
|
|
154
154
|
// offset is the offset into base, whether it is a field itself or not.
|
|
155
155
|
unsigned totalOffset = offset;
|
|
156
|
-
if (const
|
|
156
|
+
if (const GepObjVar *baseGep = SVFUtil::dyn_cast<GepObjVar>(baseNode))
|
|
157
157
|
{
|
|
158
|
-
totalOffset += baseGep->
|
|
158
|
+
totalOffset += baseGep->getOffset();
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
const DIType *baseType = getType(base);
|
|
@@ -184,12 +184,12 @@ const NodeBS TypeBasedHeapCloning::getGepObjClones(NodeID base, unsigned offset)
|
|
|
184
184
|
{
|
|
185
185
|
PAGNode *node = ppag->getGNode(gep);
|
|
186
186
|
assert(node && "TBHC: expected gep node doesn't exist.");
|
|
187
|
-
assert((SVFUtil::isa<
|
|
187
|
+
assert((SVFUtil::isa<GepObjVar>(node) || SVFUtil::isa<FIObjVar>(node))
|
|
188
188
|
&& "TBHC: expected a GEP or FI object.");
|
|
189
189
|
|
|
190
|
-
if (
|
|
190
|
+
if (GepObjVar *gepNode = SVFUtil::dyn_cast<GepObjVar>(node))
|
|
191
191
|
{
|
|
192
|
-
if (gepNode->
|
|
192
|
+
if (gepNode->getOffset() == totalOffset)
|
|
193
193
|
{
|
|
194
194
|
geps.set(gep);
|
|
195
195
|
}
|
|
@@ -225,7 +225,7 @@ const NodeBS TypeBasedHeapCloning::getGepObjClones(NodeID base, unsigned offset)
|
|
|
225
225
|
newGep = ppag->getGepObjVar(base, newLS);
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
if (
|
|
228
|
+
if (GepObjVar *gep = SVFUtil::dyn_cast<GepObjVar>(ppag->getGNode(newGep)))
|
|
229
229
|
{
|
|
230
230
|
gep->setBaseNode(base);
|
|
231
231
|
}
|
|
@@ -412,9 +412,9 @@ NodeID TypeBasedHeapCloning::cloneObject(NodeID o, const DIType *type, bool)
|
|
|
412
412
|
{
|
|
413
413
|
NodeID clone;
|
|
414
414
|
const PAGNode *obj = ppag->getGNode(o);
|
|
415
|
-
if (const
|
|
415
|
+
if (const GepObjVar *gepObj = SVFUtil::dyn_cast<GepObjVar>(obj))
|
|
416
416
|
{
|
|
417
|
-
const NodeBS &clones = getGepObjClones(gepObj->getBaseNode(), gepObj->
|
|
417
|
+
const NodeBS &clones = getGepObjClones(gepObj->getBaseNode(), gepObj->getOffset());
|
|
418
418
|
// TODO: a bit of repetition.
|
|
419
419
|
for (NodeID clone : clones)
|
|
420
420
|
{
|
|
@@ -427,7 +427,7 @@ NodeID TypeBasedHeapCloning::cloneObject(NodeID o, const DIType *type, bool)
|
|
|
427
427
|
clone = addCloneGepObjNode(gepObj->getMemObj(), gepObj->getLocationSet());
|
|
428
428
|
|
|
429
429
|
// The base needs to know about the new clone.
|
|
430
|
-
addGepToObj(clone, gepObj->getBaseNode(), gepObj->
|
|
430
|
+
addGepToObj(clone, gepObj->getBaseNode(), gepObj->getOffset());
|
|
431
431
|
|
|
432
432
|
addClone(o, clone);
|
|
433
433
|
addClone(getOriginalObj(o), clone);
|
|
@@ -539,7 +539,7 @@ const DIType *TypeBasedHeapCloning::getTypeFromCTirMetadata(const Value *v)
|
|
|
539
539
|
bool TypeBasedHeapCloning::isGep(const PAGNode *n) const
|
|
540
540
|
{
|
|
541
541
|
assert(n != nullptr && "TBHC: testing if null is a GEP object!");
|
|
542
|
-
return SVFUtil::isa<
|
|
542
|
+
return SVFUtil::isa<GepObjVar>(n);
|
|
543
543
|
}
|
|
544
544
|
|
|
545
545
|
/// Returns true if the function name matches MAYALIAS, NOALIAS, etc.
|
package/lib/WPA/Andersen.cpp
CHANGED
|
@@ -166,7 +166,7 @@ void AndersenBase::normalizePointsTo()
|
|
|
166
166
|
// for redundant gepnodes and remove those nodes from pag
|
|
167
167
|
for (NodeID n: redundantGepNodes) {
|
|
168
168
|
NodeID base = pag->getBaseObjVar(n);
|
|
169
|
-
|
|
169
|
+
GepObjVar *gepNode = SVFUtil::dyn_cast<GepObjVar>(pag->getGNode(n));
|
|
170
170
|
assert(gepNode && "Not a gep node in redundantGepNodes set");
|
|
171
171
|
const LocationSet ls = gepNode->getLocationSet();
|
|
172
172
|
GepObjVarMap.erase(std::make_pair(base, ls));
|
package/lib/WPA/AndersenSFR.cpp
CHANGED
|
@@ -133,8 +133,8 @@ void AndersenSFR::fieldExpand(NodeSet& initials, Size_t offset, NodeBS& strides,
|
|
|
133
133
|
const MemObj* obj = pag->getBaseObj(init);
|
|
134
134
|
const Size_t maxLimit = obj->getMaxFieldOffsetLimit();
|
|
135
135
|
Size_t initOffset;
|
|
136
|
-
if (
|
|
137
|
-
initOffset = gepNode->
|
|
136
|
+
if (GepObjVar *gepNode = SVFUtil::dyn_cast<GepObjVar>(initPN))
|
|
137
|
+
initOffset = gepNode->getOffset();
|
|
138
138
|
else if (SVFUtil::isa<FIObjVar>(initPN) || SVFUtil::isa<DummyObjVar>(initPN))
|
|
139
139
|
initOffset = 0;
|
|
140
140
|
else
|