svf-lib 1.0.1375 → 1.0.1376

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.
Files changed (147) hide show
  1. package/SVF-osx/Release-build/svf-llvm/libSvfLLVM.a +0 -0
  2. package/SVF-osx/svf/include/include/AbstractExecution/AbstractValue.h +79 -0
  3. package/SVF-osx/svf/include/include/AbstractExecution/AddressValue.h +210 -0
  4. package/SVF-osx/svf/include/include/AbstractExecution/ExeState.h +223 -0
  5. package/SVF-osx/svf/include/include/AbstractExecution/IntervalExeState.h +425 -0
  6. package/SVF-osx/svf/include/include/AbstractExecution/IntervalValue.h +868 -0
  7. package/SVF-osx/svf/include/include/AbstractExecution/NumericLiteral.h +406 -0
  8. package/SVF-osx/svf/include/include/AbstractExecution/RelExeState.h +225 -0
  9. package/SVF-osx/svf/include/include/AbstractExecution/RelationSolver.h +68 -0
  10. package/SVF-osx/svf/include/include/AbstractExecution/SVFIR2ItvExeState.h +186 -0
  11. package/SVF-osx/svf/include/include/AbstractExecution/WTO.h +845 -0
  12. package/SVF-osx/svf/include/include/CFL/CFGNormalizer.h +84 -0
  13. package/SVF-osx/svf/include/include/CFL/CFLAlias.h +176 -0
  14. package/SVF-osx/svf/include/include/CFL/CFLBase.h +115 -0
  15. package/SVF-osx/svf/include/include/CFL/CFLData.h +316 -0
  16. package/SVF-osx/svf/include/include/CFL/CFLDataBuilder.h +91 -0
  17. package/SVF-osx/svf/include/include/CFL/CFLGramGraphChecker.h +74 -0
  18. package/SVF-osx/svf/include/include/CFL/CFLGrammar.h +468 -0
  19. package/SVF-osx/svf/include/include/CFL/CFLGrammar.txt +15 -0
  20. package/SVF-osx/svf/include/include/CFL/CFLGraphBuilder.h +193 -0
  21. package/SVF-osx/svf/include/include/CFL/CFLSolver.h +136 -0
  22. package/SVF-osx/svf/include/include/CFL/CFLStat.h +67 -0
  23. package/SVF-osx/svf/include/include/CFL/CFLVF.h +65 -0
  24. package/SVF-osx/svf/include/include/CFL/GrammarBuilder.h +100 -0
  25. package/SVF-osx/svf/include/include/CFL/PEGGrammar.txt +11 -0
  26. package/SVF-osx/svf/include/include/CFL/VFG.txt +7 -0
  27. package/SVF-osx/svf/include/include/DDA/ContextDDA.h +230 -0
  28. package/SVF-osx/svf/include/include/DDA/DDAClient.h +168 -0
  29. package/SVF-osx/svf/include/include/DDA/DDAPass.h +99 -0
  30. package/SVF-osx/svf/include/include/DDA/DDAStat.h +138 -0
  31. package/SVF-osx/svf/include/include/DDA/DDAVFSolver.h +789 -0
  32. package/SVF-osx/svf/include/include/DDA/FlowDDA.h +178 -0
  33. package/SVF-osx/svf/include/include/FastCluster/LICENSE.TXT +13 -0
  34. package/SVF-osx/svf/include/include/FastCluster/fastcluster.h +80 -0
  35. package/SVF-osx/svf/include/include/Graphs/CFLGraph.h +215 -0
  36. package/SVF-osx/svf/include/include/Graphs/CHG.h +351 -0
  37. package/SVF-osx/svf/include/include/Graphs/ConsG.h +408 -0
  38. package/SVF-osx/svf/include/include/Graphs/ConsGEdge.h +353 -0
  39. package/SVF-osx/svf/include/include/Graphs/ConsGNode.h +391 -0
  40. package/SVF-osx/svf/include/include/Graphs/DOTGraphTraits.h +188 -0
  41. package/SVF-osx/svf/include/include/Graphs/GenericGraph.h +620 -0
  42. package/SVF-osx/svf/include/include/Graphs/GraphPrinter.h +111 -0
  43. package/SVF-osx/svf/include/include/Graphs/GraphTraits.h +150 -0
  44. package/SVF-osx/svf/include/include/Graphs/GraphWriter.h +380 -0
  45. package/SVF-osx/svf/include/include/Graphs/ICFG.h +331 -0
  46. package/SVF-osx/svf/include/include/Graphs/ICFGEdge.h +264 -0
  47. package/SVF-osx/svf/include/include/Graphs/ICFGNode.h +523 -0
  48. package/SVF-osx/svf/include/include/Graphs/ICFGStat.h +164 -0
  49. package/SVF-osx/svf/include/include/Graphs/IRGraph.h +243 -0
  50. package/SVF-osx/svf/include/include/Graphs/PTACallGraph.h +471 -0
  51. package/SVF-osx/svf/include/include/Graphs/SVFG.h +490 -0
  52. package/SVF-osx/svf/include/include/Graphs/SVFGEdge.h +237 -0
  53. package/SVF-osx/svf/include/include/Graphs/SVFGNode.h +513 -0
  54. package/SVF-osx/svf/include/include/Graphs/SVFGOPT.h +362 -0
  55. package/SVF-osx/svf/include/include/Graphs/SVFGStat.h +273 -0
  56. package/SVF-osx/svf/include/include/Graphs/ThreadCallGraph.h +422 -0
  57. package/SVF-osx/svf/include/include/Graphs/VFG.h +664 -0
  58. package/SVF-osx/svf/include/include/Graphs/VFGEdge.h +295 -0
  59. package/SVF-osx/svf/include/include/Graphs/VFGNode.h +1197 -0
  60. package/SVF-osx/svf/include/include/MSSA/MSSAMuChi.h +722 -0
  61. package/SVF-osx/svf/include/include/MSSA/MemPartition.h +169 -0
  62. package/SVF-osx/svf/include/include/MSSA/MemRegion.h +491 -0
  63. package/SVF-osx/svf/include/include/MSSA/MemSSA.h +452 -0
  64. package/SVF-osx/svf/include/include/MSSA/SVFGBuilder.h +98 -0
  65. package/SVF-osx/svf/include/include/MTA/FSMPTA.h +270 -0
  66. package/SVF-osx/svf/include/include/MTA/LockAnalysis.h +517 -0
  67. package/SVF-osx/svf/include/include/MTA/MHP.h +565 -0
  68. package/SVF-osx/svf/include/include/MTA/MTA.h +101 -0
  69. package/SVF-osx/svf/include/include/MTA/MTAResultValidator.h +448 -0
  70. package/SVF-osx/svf/include/include/MTA/MTAStat.h +74 -0
  71. package/SVF-osx/svf/include/include/MTA/PCG.h +229 -0
  72. package/SVF-osx/svf/include/include/MTA/TCT.h +599 -0
  73. package/SVF-osx/svf/include/include/MemoryModel/AbstractPointsToDS.h +316 -0
  74. package/SVF-osx/svf/include/include/MemoryModel/ConditionalPT.h +878 -0
  75. package/SVF-osx/svf/include/include/MemoryModel/LocationSet.h +148 -0
  76. package/SVF-osx/svf/include/include/MemoryModel/MutablePointsToDS.h +1025 -0
  77. package/SVF-osx/svf/include/include/MemoryModel/PersistentPointsToCache.h +463 -0
  78. package/SVF-osx/svf/include/include/MemoryModel/PersistentPointsToDS.h +955 -0
  79. package/SVF-osx/svf/include/include/MemoryModel/PointerAnalysis.h +452 -0
  80. package/SVF-osx/svf/include/include/MemoryModel/PointerAnalysisImpl.h +590 -0
  81. package/SVF-osx/svf/include/include/MemoryModel/PointsTo.h +255 -0
  82. package/SVF-osx/svf/include/include/MemoryModel/SVFLoop.h +164 -0
  83. package/SVF-osx/svf/include/include/SABER/DoubleFreeChecker.h +76 -0
  84. package/SVF-osx/svf/include/include/SABER/FileChecker.h +82 -0
  85. package/SVF-osx/svf/include/include/SABER/LeakChecker.h +124 -0
  86. package/SVF-osx/svf/include/include/SABER/ProgSlice.h +313 -0
  87. package/SVF-osx/svf/include/include/SABER/SaberCheckerAPI.h +166 -0
  88. package/SVF-osx/svf/include/include/SABER/SaberCondAllocator.h +310 -0
  89. package/SVF-osx/svf/include/include/SABER/SaberSVFGBuilder.h +104 -0
  90. package/SVF-osx/svf/include/include/SABER/SrcSnkDDA.h +321 -0
  91. package/SVF-osx/svf/include/include/SABER/SrcSnkSolver.h +186 -0
  92. package/SVF-osx/svf/include/include/SVFIR/PAGBuilderFromFile.h +80 -0
  93. package/SVF-osx/svf/include/include/SVFIR/SVFIR.h +659 -0
  94. package/SVF-osx/svf/include/include/SVFIR/SVFModule.h +233 -0
  95. package/SVF-osx/svf/include/include/SVFIR/SVFStatements.h +1136 -0
  96. package/SVF-osx/svf/include/include/SVFIR/SVFType.h +527 -0
  97. package/SVF-osx/svf/include/include/SVFIR/SVFValue.h +1120 -0
  98. package/SVF-osx/svf/include/include/SVFIR/SVFVariables.h +721 -0
  99. package/SVF-osx/svf/include/include/SVFIR/SymbolTableInfo.h +597 -0
  100. package/SVF-osx/svf/include/include/Util/Annotator.h +180 -0
  101. package/SVF-osx/svf/include/include/Util/BitVector.h +55 -0
  102. package/SVF-osx/svf/include/include/Util/CallGraphBuilder.h +74 -0
  103. package/SVF-osx/svf/include/include/Util/Casting.h +426 -0
  104. package/SVF-osx/svf/include/include/Util/CommandLine.h +530 -0
  105. package/SVF-osx/svf/include/include/Util/CoreBitVector.h +214 -0
  106. package/SVF-osx/svf/include/include/Util/CppUtil.h +81 -0
  107. package/SVF-osx/svf/include/include/Util/CxtStmt.h +501 -0
  108. package/SVF-osx/svf/include/include/Util/DPItem.h +618 -0
  109. package/SVF-osx/svf/include/include/Util/ExtAPI.h +339 -0
  110. package/SVF-osx/svf/include/include/Util/ExtAPI.json +5707 -0
  111. package/SVF-osx/svf/include/include/Util/GraphReachSolver.h +186 -0
  112. package/SVF-osx/svf/include/include/Util/NodeIDAllocator.h +194 -0
  113. package/SVF-osx/svf/include/include/Util/Options.h +266 -0
  114. package/SVF-osx/svf/include/include/Util/PTAStat.h +65 -0
  115. package/SVF-osx/svf/include/include/Util/SCC.h +354 -0
  116. package/SVF-osx/svf/include/include/Util/SVFStat.h +100 -0
  117. package/SVF-osx/svf/include/include/Util/SVFUtil.h +660 -0
  118. package/SVF-osx/svf/include/include/Util/SparseBitVector.h +1202 -0
  119. package/SVF-osx/svf/include/include/Util/ThreadAPI.h +330 -0
  120. package/SVF-osx/svf/include/include/Util/WorkList.h +317 -0
  121. package/SVF-osx/svf/include/include/Util/Z3Expr.h +318 -0
  122. package/SVF-osx/svf/include/include/Util/cJSON.h +300 -0
  123. package/SVF-osx/svf/include/include/Util/iterator.h +407 -0
  124. package/SVF-osx/svf/include/include/Util/iterator_range.h +76 -0
  125. package/SVF-osx/svf/include/include/WPA/Andersen.h +416 -0
  126. package/SVF-osx/svf/include/include/WPA/AndersenPWC.h +160 -0
  127. package/SVF-osx/svf/include/include/WPA/CSC.h +95 -0
  128. package/SVF-osx/svf/include/include/WPA/FlowSensitive.h +317 -0
  129. package/SVF-osx/svf/include/include/WPA/Steensgaard.h +126 -0
  130. package/SVF-osx/svf/include/include/WPA/TypeAnalysis.h +83 -0
  131. package/SVF-osx/svf/include/include/WPA/VersionedFlowSensitive.h +287 -0
  132. package/SVF-osx/svf/include/include/WPA/WPAFSSolver.h +254 -0
  133. package/SVF-osx/svf/include/include/WPA/WPAPass.h +119 -0
  134. package/SVF-osx/svf/include/include/WPA/WPASolver.h +205 -0
  135. package/SVF-osx/svf/include/include/WPA/WPAStat.h +222 -0
  136. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/BasicTypes.h +250 -0
  137. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/BreakConstantExpr.h +94 -0
  138. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/CHGBuilder.h +73 -0
  139. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/DCHG.h +484 -0
  140. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/GEPTypeBridgeIterator.h +183 -0
  141. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/ICFGBuilder.h +106 -0
  142. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/LLVMLoopAnalysis.h +61 -0
  143. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/LLVMModule.h +360 -0
  144. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/LLVMUtil.h +466 -0
  145. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/SVFIRBuilder.h +417 -0
  146. package/SVF-osx/svf-llvm/include/SVF-LLVM/SVF-LLVM/SymbolTableBuilder.h +110 -0
  147. package/package.json +1 -1
@@ -0,0 +1,416 @@
1
+ //===- Andersen.h -- Field-sensitive Andersen's pointer analysis-------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-2017> <Yulei Sui>
6
+ //
7
+
8
+ // This program is free software: you can redistribute it and/or modify
9
+ // it under the terms of the GNU General Public License as published by
10
+ // the Free Software Foundation, either version 3 of the License, or
11
+ // (at your option) any later version.
12
+
13
+ // This program is distributed in the hope that it will be useful,
14
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ // GNU General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU General Public License
19
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ //
21
+ //===----------------------------------------------------------------------===//
22
+
23
+ /*
24
+ * Andersen.h
25
+ *
26
+ * Created on: Nov 12, 2013
27
+ * Author: Yulei Sui
28
+ *
29
+ * The field-sensitive implementation is improved based on
30
+ *
31
+ * Yuxiang Lei and Yulei Sui. "Fast and Precise Handling of Positive Weight Cycles for Field-sensitive Pointer Analysis".
32
+ * 26th International Static Analysis Symposium (SAS'19)
33
+ */
34
+
35
+ #ifndef INCLUDE_WPA_ANDERSEN_H_
36
+ #define INCLUDE_WPA_ANDERSEN_H_
37
+
38
+ #include "MemoryModel/PointerAnalysisImpl.h"
39
+ #include "WPA/WPAStat.h"
40
+ #include "WPA/WPASolver.h"
41
+ #include "SVFIR/SVFIR.h"
42
+ #include "Graphs/ConsG.h"
43
+ #include "Util/Options.h"
44
+
45
+ namespace SVF
46
+ {
47
+
48
+ class SVFModule;
49
+
50
+ /*!
51
+ * Abstract class of inclusion-based Pointer Analysis
52
+ */
53
+ typedef WPASolver<ConstraintGraph*> WPAConstraintSolver;
54
+
55
+ class AndersenBase: public WPAConstraintSolver, public BVDataPTAImpl
56
+ {
57
+ public:
58
+
59
+ /// Constructor
60
+ AndersenBase(SVFIR* _pag, PTATY type = Andersen_BASE, bool alias_check = true)
61
+ : BVDataPTAImpl(_pag, type, alias_check), consCG(nullptr)
62
+ {
63
+ iterationForPrintStat = OnTheFlyIterBudgetForStat;
64
+ }
65
+
66
+ /// Destructor
67
+ ~AndersenBase() override;
68
+
69
+ /// Andersen analysis
70
+ virtual void analyze() override;
71
+
72
+ /// Initialize analysis
73
+ virtual void initialize() override;
74
+
75
+ /// Finalize analysis
76
+ virtual void finalize() override;
77
+
78
+ /// Implement it in child class to update call graph
79
+ virtual inline bool updateCallGraph(const CallSiteToFunPtrMap&) override
80
+ {
81
+ return false;
82
+ }
83
+
84
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
85
+ //@{
86
+ static inline bool classof(const AndersenBase *)
87
+ {
88
+ return true;
89
+ }
90
+ static inline bool classof(const PointerAnalysis *pta)
91
+ {
92
+ return ( pta->getAnalysisTy() == Andersen_BASE
93
+ || pta->getAnalysisTy() == Andersen_WPA
94
+ || pta->getAnalysisTy() == AndersenWaveDiff_WPA
95
+ || pta->getAnalysisTy() == AndersenSCD_WPA
96
+ || pta->getAnalysisTy() == AndersenSFR_WPA
97
+ || pta->getAnalysisTy() == TypeCPP_WPA
98
+ || pta->getAnalysisTy() == Steensgaard_WPA);
99
+ }
100
+ //@}
101
+
102
+ /// Get constraint graph
103
+ ConstraintGraph* getConstraintGraph()
104
+ {
105
+ return consCG;
106
+ }
107
+
108
+ /// dump statistics
109
+ inline void printStat()
110
+ {
111
+ PointerAnalysis::dumpStat();
112
+ }
113
+
114
+ virtual void normalizePointsTo() override;
115
+
116
+ /// remove redundant gepnodes in constraint graph
117
+ void cleanConsCG(NodeID id);
118
+
119
+ NodeBS redundantGepNodes;
120
+
121
+ /// Statistics
122
+ //@{
123
+ static u32_t numOfProcessedAddr; /// Number of processed Addr edge
124
+ static u32_t numOfProcessedCopy; /// Number of processed Copy edge
125
+ static u32_t numOfProcessedGep; /// Number of processed Gep edge
126
+ static u32_t numOfProcessedLoad; /// Number of processed Load edge
127
+ static u32_t numOfProcessedStore; /// Number of processed Store edge
128
+ static u32_t numOfSfrs;
129
+ static u32_t numOfFieldExpand;
130
+
131
+ static u32_t numOfSCCDetection;
132
+ static double timeOfSCCDetection;
133
+ static double timeOfSCCMerges;
134
+ static double timeOfCollapse;
135
+ static u32_t AveragePointsToSetSize;
136
+ static u32_t MaxPointsToSetSize;
137
+ static double timeOfProcessCopyGep;
138
+ static double timeOfProcessLoadStore;
139
+ static double timeOfUpdateCallGraph;
140
+ //@}
141
+
142
+ protected:
143
+ /// Constraint Graph
144
+ ConstraintGraph* consCG;
145
+ };
146
+
147
+ /*!
148
+ * Inclusion-based Pointer Analysis
149
+ */
150
+ class Andersen: public AndersenBase
151
+ {
152
+
153
+
154
+ public:
155
+ typedef SCCDetection<ConstraintGraph*> CGSCC;
156
+ typedef OrderedMap<CallSite, NodeID> CallSite2DummyValPN;
157
+
158
+ /// Constructor
159
+ Andersen(SVFIR* _pag, PTATY type = Andersen_WPA, bool alias_check = true)
160
+ : AndersenBase(_pag, type, alias_check)
161
+ {
162
+ }
163
+
164
+ /// Destructor
165
+ virtual ~Andersen()
166
+ {
167
+
168
+ }
169
+
170
+ /// Initialize analysis
171
+ virtual void initialize();
172
+
173
+ /// Finalize analysis
174
+ virtual void finalize();
175
+
176
+ /// Reset data
177
+ inline void resetData()
178
+ {
179
+ AveragePointsToSetSize = 0;
180
+ MaxPointsToSetSize = 0;
181
+ timeOfProcessCopyGep = 0;
182
+ timeOfProcessLoadStore = 0;
183
+ }
184
+
185
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
186
+ //@{
187
+ static inline bool classof(const Andersen *)
188
+ {
189
+ return true;
190
+ }
191
+ static inline bool classof(const PointerAnalysis *pta)
192
+ {
193
+ return (pta->getAnalysisTy() == Andersen_WPA
194
+ || pta->getAnalysisTy() == AndersenWaveDiff_WPA
195
+ || pta->getAnalysisTy() == AndersenSCD_WPA
196
+ || pta->getAnalysisTy() == AndersenSFR_WPA);
197
+ }
198
+ //@}
199
+
200
+ /// SCC methods
201
+ //@{
202
+ inline NodeID sccRepNode(NodeID id) const
203
+ {
204
+ return consCG->sccRepNode(id);
205
+ }
206
+ inline NodeBS& sccSubNodes(NodeID repId)
207
+ {
208
+ return consCG->sccSubNodes(repId);
209
+ }
210
+ //@}
211
+
212
+ /// Operation of points-to set
213
+ virtual inline const PointsTo& getPts(NodeID id)
214
+ {
215
+ return getPTDataTy()->getPts(sccRepNode(id));
216
+ }
217
+ virtual inline bool unionPts(NodeID id, const PointsTo& target)
218
+ {
219
+ id = sccRepNode(id);
220
+ return getPTDataTy()->unionPts(id, target);
221
+ }
222
+ virtual inline bool unionPts(NodeID id, NodeID ptd)
223
+ {
224
+ id = sccRepNode(id);
225
+ ptd = sccRepNode(ptd);
226
+ return getPTDataTy()->unionPts(id,ptd);
227
+ }
228
+
229
+
230
+ void dumpTopLevelPtsTo();
231
+
232
+ void setDetectPWC(bool flag)
233
+ {
234
+ Options::DetectPWC.setValue(flag);
235
+ }
236
+
237
+ protected:
238
+
239
+ CallSite2DummyValPN callsite2DummyValPN; ///< Map an instruction to a dummy obj which created at an indirect callsite, which invokes a heap allocator
240
+ void heapAllocatorViaIndCall(CallSite cs,NodePairSet &cpySrcNodes);
241
+
242
+ /// Handle diff points-to set.
243
+ virtual inline void computeDiffPts(NodeID id)
244
+ {
245
+ if (Options::DiffPts())
246
+ {
247
+ NodeID rep = sccRepNode(id);
248
+ getDiffPTDataTy()->computeDiffPts(rep, getDiffPTDataTy()->getPts(rep));
249
+ }
250
+ }
251
+ virtual inline const PointsTo& getDiffPts(NodeID id)
252
+ {
253
+ NodeID rep = sccRepNode(id);
254
+ if (Options::DiffPts())
255
+ return getDiffPTDataTy()->getDiffPts(rep);
256
+ else
257
+ return getPTDataTy()->getPts(rep);
258
+ }
259
+
260
+ /// Handle propagated points-to set.
261
+ inline void updatePropaPts(NodeID dstId, NodeID srcId)
262
+ {
263
+ if (!Options::DiffPts())
264
+ return;
265
+ NodeID srcRep = sccRepNode(srcId);
266
+ NodeID dstRep = sccRepNode(dstId);
267
+ getDiffPTDataTy()->updatePropaPtsMap(srcRep, dstRep);
268
+ }
269
+ inline void clearPropaPts(NodeID src)
270
+ {
271
+ if (Options::DiffPts())
272
+ {
273
+ NodeID rep = sccRepNode(src);
274
+ getDiffPTDataTy()->clearPropaPts(rep);
275
+ }
276
+ }
277
+
278
+ virtual void initWorklist() {}
279
+
280
+ /// Override WPASolver function in order to use the default solver
281
+ virtual void processNode(NodeID nodeId);
282
+
283
+ /// handling various constraints
284
+ //@{
285
+ void processAllAddr();
286
+
287
+ virtual bool processLoad(NodeID node, const ConstraintEdge* load);
288
+ virtual bool processStore(NodeID node, const ConstraintEdge* load);
289
+ virtual bool processCopy(NodeID node, const ConstraintEdge* edge);
290
+ virtual bool processGep(NodeID node, const GepCGEdge* edge);
291
+ virtual void handleCopyGep(ConstraintNode* node);
292
+ virtual void handleLoadStore(ConstraintNode* node);
293
+ virtual void processAddr(const AddrCGEdge* addr);
294
+ virtual bool processGepPts(const PointsTo& pts, const GepCGEdge* edge);
295
+ //@}
296
+
297
+ /// Add copy edge on constraint graph
298
+ virtual inline bool addCopyEdge(NodeID src, NodeID dst)
299
+ {
300
+ if (consCG->addCopyCGEdge(src, dst))
301
+ {
302
+ updatePropaPts(src, dst);
303
+ return true;
304
+ }
305
+ return false;
306
+ }
307
+
308
+ /// Update call graph for the input indirect callsites
309
+ virtual bool updateCallGraph(const CallSiteToFunPtrMap& callsites);
310
+
311
+ /// Connect formal and actual parameters for indirect callsites
312
+ void connectCaller2CalleeParams(CallSite cs, const SVFFunction* F, NodePairSet& cpySrcNodes);
313
+
314
+ /// Merge sub node to its rep
315
+ virtual void mergeNodeToRep(NodeID nodeId,NodeID newRepId);
316
+
317
+ virtual bool mergeSrcToTgt(NodeID srcId,NodeID tgtId);
318
+
319
+ /// Merge sub node in a SCC cycle to their rep node
320
+ //@{
321
+ void mergeSccNodes(NodeID repNodeId, const NodeBS& subNodes);
322
+ void mergeSccCycle();
323
+ //@}
324
+ /// Collapse a field object into its base for field insensitive anlaysis
325
+ //@{
326
+ virtual void collapsePWCNode(NodeID nodeId);
327
+ void collapseFields();
328
+ bool collapseNodePts(NodeID nodeId);
329
+ bool collapseField(NodeID nodeId);
330
+ //@}
331
+
332
+ /// Updates subnodes of its rep, and rep node of its subs
333
+ void updateNodeRepAndSubs(NodeID nodeId,NodeID newRepId);
334
+
335
+ /// SCC detection
336
+ virtual NodeStack& SCCDetect();
337
+
338
+
339
+
340
+ /// Sanitize pts for field insensitive objects
341
+ void sanitizePts()
342
+ {
343
+ for(ConstraintGraph::iterator it = consCG->begin(), eit = consCG->end(); it!=eit; ++it)
344
+ {
345
+ const PointsTo& pts = getPts(it->first);
346
+ NodeBS fldInsenObjs;
347
+
348
+ for (NodeID o : pts)
349
+ {
350
+ if(isFieldInsensitive(o))
351
+ fldInsenObjs.set(o);
352
+ }
353
+
354
+ for (NodeID o : fldInsenObjs)
355
+ {
356
+ const NodeBS &allFields = consCG->getAllFieldsObjVars(o);
357
+ for (NodeID f : allFields) addPts(it->first, f);
358
+ }
359
+ }
360
+ }
361
+
362
+ /// Get PTA name
363
+ virtual const std::string PTAName() const
364
+ {
365
+ return "AndersenWPA";
366
+ }
367
+
368
+ /// Runs a Steensgaard analysis and performs clustering based on those
369
+ /// results set the global best mapping.
370
+ virtual void cluster(void) const;
371
+ };
372
+
373
+
374
+
375
+ /**
376
+ * Wave propagation with diff points-to set.
377
+ */
378
+ class AndersenWaveDiff : public Andersen
379
+ {
380
+
381
+ private:
382
+
383
+ static AndersenWaveDiff* diffWave; // static instance
384
+
385
+ public:
386
+ AndersenWaveDiff(SVFIR* _pag, PTATY type = AndersenWaveDiff_WPA, bool alias_check = true): Andersen(_pag, type, alias_check) {}
387
+
388
+ /// Create an singleton instance directly instead of invoking llvm pass manager
389
+ static AndersenWaveDiff* createAndersenWaveDiff(SVFIR* _pag)
390
+ {
391
+ if(diffWave==nullptr)
392
+ {
393
+ diffWave = new AndersenWaveDiff(_pag, AndersenWaveDiff_WPA, false);
394
+ diffWave->analyze();
395
+ return diffWave;
396
+ }
397
+ return diffWave;
398
+ }
399
+ static void releaseAndersenWaveDiff()
400
+ {
401
+ if (diffWave)
402
+ delete diffWave;
403
+ diffWave = nullptr;
404
+ }
405
+
406
+ virtual void initialize();
407
+ virtual void solveWorklist();
408
+ virtual void processNode(NodeID nodeId);
409
+ virtual void postProcessNode(NodeID nodeId);
410
+ virtual bool handleLoad(NodeID id, const ConstraintEdge* load);
411
+ virtual bool handleStore(NodeID id, const ConstraintEdge* store);
412
+ };
413
+
414
+ } // End namespace SVF
415
+
416
+ #endif /* INCLUDE_WPA_ANDERSEN_H_ */
@@ -0,0 +1,160 @@
1
+ //===- AndersenSFR.h -- SFR based field-sensitive Andersen's analysis-------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-2017> <Yulei Sui>
6
+ //
7
+
8
+ // This program is free software: you can redistribute it and/or modify
9
+ // it under the terms of the GNU General Public License as published by
10
+ // the Free Software Foundation, either version 3 of the License, or
11
+ // (at your option) any later version.
12
+
13
+ // This program is distributed in the hope that it will be useful,
14
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ // GNU General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU General Public License
19
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ //
21
+ //===----------------------------------------------------------------------===//
22
+
23
+ /*
24
+ * AndersenSFR.h
25
+ *
26
+ * Created on: 09, Feb, 2019
27
+ * Author: Yuxiang Lei
28
+ */
29
+
30
+ #ifndef PROJECT_ANDERSENSFR_H
31
+ #define PROJECT_ANDERSENSFR_H
32
+
33
+
34
+ #include "WPA/Andersen.h"
35
+ #include "WPA/CSC.h"
36
+ #include "MemoryModel/PointsTo.h"
37
+
38
+ namespace SVF
39
+ {
40
+
41
+ /*!
42
+ * Selective Cycle Detection Based Andersen Analysis
43
+ */
44
+ class AndersenSCD : public Andersen
45
+ {
46
+ public:
47
+ typedef Map<NodeID, NodeID> NodeToNodeMap;
48
+
49
+ protected:
50
+ static AndersenSCD* scdAndersen;
51
+ NodeSet sccCandidates;
52
+ NodeToNodeMap pwcReps;
53
+
54
+ public:
55
+ AndersenSCD(SVFIR* _pag, PTATY type = AndersenSCD_WPA) :
56
+ Andersen(_pag,type)
57
+ {
58
+ }
59
+
60
+ /// Create an singleton instance directly instead of invoking llvm pass manager
61
+ static AndersenSCD *createAndersenSCD(SVFIR* _pag)
62
+ {
63
+ if (scdAndersen == nullptr)
64
+ {
65
+ new AndersenSCD(_pag);
66
+ scdAndersen->analyze();
67
+ return scdAndersen;
68
+ }
69
+ return scdAndersen;
70
+ }
71
+
72
+ static void releaseAndersenSCD()
73
+ {
74
+ if (scdAndersen)
75
+ delete scdAndersen;
76
+ scdAndersen = nullptr;
77
+ }
78
+
79
+ protected:
80
+ inline void addSccCandidate(NodeID nodeId)
81
+ {
82
+ sccCandidates.insert(sccRepNode(nodeId));
83
+ }
84
+
85
+ virtual NodeStack& SCCDetect();
86
+ virtual void PWCDetect();
87
+ virtual void solveWorklist();
88
+ virtual void handleLoadStore(ConstraintNode* node);
89
+ virtual void processAddr(const AddrCGEdge* addr);
90
+ virtual bool addCopyEdge(NodeID src, NodeID dst);
91
+ virtual bool updateCallGraph(const CallSiteToFunPtrMap& callsites);
92
+ virtual void processPWC(ConstraintNode* rep);
93
+ virtual void handleCopyGep(ConstraintNode* node);
94
+
95
+ };
96
+
97
+
98
+
99
+ /*!
100
+ * Selective Cycle Detection with Stride-based Field Representation
101
+ */
102
+ class AndersenSFR : public AndersenSCD
103
+ {
104
+ public:
105
+ typedef Map<NodeID, NodeBS> NodeStrides;
106
+ typedef Map<NodeID, NodeSet> FieldReps;
107
+ typedef Map<NodeID, std::pair<NodeID, NodeSet>> SFRTrait;
108
+
109
+ private:
110
+ static AndersenSFR* sfrAndersen;
111
+
112
+ CSC* csc;
113
+ NodeSet sfrObjNodes;
114
+ FieldReps fieldReps;
115
+
116
+ public:
117
+ AndersenSFR(SVFIR* _pag, PTATY type = AndersenSFR_WPA) :
118
+ AndersenSCD(_pag, type), csc(nullptr)
119
+ {
120
+ }
121
+
122
+ /// Create an singleton instance directly instead of invoking llvm pass manager
123
+ static AndersenSFR *createAndersenSFR(SVFIR* _pag)
124
+ {
125
+ if (sfrAndersen == nullptr)
126
+ {
127
+ new AndersenSFR(_pag);
128
+ sfrAndersen->analyze();
129
+ return sfrAndersen;
130
+ }
131
+ return sfrAndersen;
132
+ }
133
+
134
+ static void releaseAndersenSFR()
135
+ {
136
+ if (sfrAndersen)
137
+ delete sfrAndersen;
138
+ }
139
+
140
+ ~AndersenSFR()
141
+ {
142
+ if (csc != nullptr)
143
+ {
144
+ delete(csc);
145
+ csc = nullptr;
146
+ }
147
+ }
148
+
149
+ protected:
150
+ void initialize();
151
+ void PWCDetect();
152
+ void fieldExpand(NodeSet& initials, s32_t offset, NodeBS& strides, PointsTo& expandPts);
153
+ bool processGepPts(const PointsTo& pts, const GepCGEdge* edge);
154
+ bool mergeSrcToTgt(NodeID nodeId, NodeID newRepId);
155
+
156
+ };
157
+
158
+ } // End namespace SVF
159
+
160
+ #endif //PROJECT_ANDERSENSFR_H
@@ -0,0 +1,95 @@
1
+ //===- CSC.h -- Cycle Stride Calculation algorithm---------------------------------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-2017> <Yulei Sui>
6
+ //
7
+
8
+ // This program is free software: you can redistribute it and/or modify
9
+ // it under the terms of the GNU General Public License as published by
10
+ // the Free Software Foundation, either version 3 of the License, or
11
+ // (at your option) any later version.
12
+
13
+ // This program is distributed in the hope that it will be useful,
14
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ // GNU General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU General Public License
19
+ // along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ //
21
+ //===----------------------------------------------------------------------===//
22
+
23
+ /*
24
+ * CSC.h
25
+ *
26
+ * Created on: 09, Feb, 2019
27
+ * Author: Yuxiang Lei
28
+ */
29
+
30
+ #ifndef PROJECT_CSC_H
31
+ #define PROJECT_CSC_H
32
+
33
+ #include "Util/SCC.h"
34
+ #include "SVFIR/SVFValue.h" // for NodeBS
35
+ #include "Graphs/ConsG.h"
36
+ #include "Util/WorkList.h"
37
+ #include <limits.h>
38
+ #include <stack>
39
+ #include <map>
40
+
41
+ namespace SVF
42
+ {
43
+
44
+ typedef SCCDetection<ConstraintGraph *> CGSCC;
45
+
46
+ /*!
47
+ * class CSC: cycle stride calculation
48
+ */
49
+ class CSC
50
+ {
51
+ public:
52
+ typedef Map<NodeID, NodeID> IdToIdMap;
53
+ typedef FILOWorkList<NodeID> WorkStack;
54
+ typedef typename IdToIdMap::iterator iterator;
55
+
56
+ private:
57
+ ConstraintGraph* _consG;
58
+ CGSCC* _scc;
59
+
60
+ NodeID _I;
61
+ IdToIdMap _D; // the sum of weight of a path relevant to a certain node, while accessing the node via DFS
62
+ NodeStack _S; // a stack holding a DFS branch
63
+ NodeSet _visited; // a set holding visited nodes
64
+ // NodeStrides nodeStrides;
65
+ // IdToIdMap pwcReps;
66
+
67
+ public:
68
+ CSC(ConstraintGraph* g, CGSCC* c)
69
+ : _consG(g), _scc(c), _I(0) {}
70
+
71
+ void find(NodeStack& candidates);
72
+ void visit(NodeID nodeId, s32_t _w);
73
+ void clear();
74
+
75
+ bool isVisited(NodeID nId)
76
+ {
77
+ return _visited.find(nId) != _visited.end();
78
+ }
79
+
80
+ void setVisited(NodeID nId)
81
+ {
82
+ _visited.insert(nId);
83
+ }
84
+ // inline iterator begin() { return pwcReps.begin(); }
85
+ //
86
+ // inline iterator end() { return pwcReps.end(); }
87
+
88
+ // NodeStrides &getNodeStrides() { return nodeStrides; }
89
+
90
+ // const NodeSet& getPWCReps() const { return _pwcReps; }
91
+ };
92
+
93
+ } // End namespace SVF
94
+
95
+ #endif //PROJECT_CSC_H