svf-lib 1.0.2237 → 1.0.2239

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 (165) hide show
  1. package/SVF-linux-aarch64/Release-build/bin/ae +0 -0
  2. package/SVF-linux-aarch64/Release-build/bin/cfl +0 -0
  3. package/SVF-linux-aarch64/Release-build/bin/dvf +0 -0
  4. package/SVF-linux-aarch64/Release-build/bin/llvm2svf +0 -0
  5. package/SVF-linux-aarch64/Release-build/bin/mta +0 -0
  6. package/SVF-linux-aarch64/Release-build/bin/saber +0 -0
  7. package/SVF-linux-aarch64/Release-build/bin/svf-ex +0 -0
  8. package/SVF-linux-aarch64/Release-build/bin/wpa +0 -0
  9. package/SVF-linux-aarch64/Release-build/include/AE/Core/AbstractState.h +406 -0
  10. package/SVF-linux-aarch64/Release-build/include/AE/Core/AbstractValue.h +157 -0
  11. package/SVF-linux-aarch64/Release-build/include/AE/Core/AddressValue.h +232 -0
  12. package/SVF-linux-aarch64/Release-build/include/AE/Core/ICFGWTO.h +82 -0
  13. package/SVF-linux-aarch64/Release-build/include/AE/Core/IntervalValue.h +1055 -0
  14. package/SVF-linux-aarch64/Release-build/include/AE/Core/NumericValue.h +1292 -0
  15. package/SVF-linux-aarch64/Release-build/include/AE/Core/RelExeState.h +226 -0
  16. package/SVF-linux-aarch64/Release-build/include/AE/Core/RelationSolver.h +91 -0
  17. package/SVF-linux-aarch64/Release-build/include/AE/Svfexe/AEDetector.h +323 -0
  18. package/SVF-linux-aarch64/Release-build/include/AE/Svfexe/AbsExtAPI.h +140 -0
  19. package/SVF-linux-aarch64/Release-build/include/AE/Svfexe/AbstractInterpretation.h +350 -0
  20. package/SVF-linux-aarch64/Release-build/include/CFL/CFGNormalizer.h +84 -0
  21. package/SVF-linux-aarch64/Release-build/include/CFL/CFGrammar.h +468 -0
  22. package/SVF-linux-aarch64/Release-build/include/CFL/CFLAlias.h +168 -0
  23. package/SVF-linux-aarch64/Release-build/include/CFL/CFLBase.h +118 -0
  24. package/SVF-linux-aarch64/Release-build/include/CFL/CFLGramGraphChecker.h +74 -0
  25. package/SVF-linux-aarch64/Release-build/include/CFL/CFLGraphBuilder.h +166 -0
  26. package/SVF-linux-aarch64/Release-build/include/CFL/CFLSVFGBuilder.h +58 -0
  27. package/SVF-linux-aarch64/Release-build/include/CFL/CFLSolver.h +374 -0
  28. package/SVF-linux-aarch64/Release-build/include/CFL/CFLStat.h +67 -0
  29. package/SVF-linux-aarch64/Release-build/include/CFL/CFLVF.h +68 -0
  30. package/SVF-linux-aarch64/Release-build/include/CFL/GrammarBuilder.h +100 -0
  31. package/SVF-linux-aarch64/Release-build/include/CFL/grammar/PAGGrammar.txt +15 -0
  32. package/SVF-linux-aarch64/Release-build/include/CFL/grammar/PEGGrammar.txt +11 -0
  33. package/SVF-linux-aarch64/Release-build/include/CFL/grammar/VFGGrammar.txt +7 -0
  34. package/SVF-linux-aarch64/Release-build/include/DDA/ContextDDA.h +230 -0
  35. package/SVF-linux-aarch64/Release-build/include/DDA/DDAClient.h +163 -0
  36. package/SVF-linux-aarch64/Release-build/include/DDA/DDAPass.h +102 -0
  37. package/SVF-linux-aarch64/Release-build/include/DDA/DDAStat.h +121 -0
  38. package/SVF-linux-aarch64/Release-build/include/DDA/DDAVFSolver.h +794 -0
  39. package/SVF-linux-aarch64/Release-build/include/DDA/FlowDDA.h +178 -0
  40. package/SVF-linux-aarch64/Release-build/include/FastCluster/LICENSE.TXT +13 -0
  41. package/SVF-linux-aarch64/Release-build/include/FastCluster/fastcluster.h +80 -0
  42. package/SVF-linux-aarch64/Release-build/include/Graphs/BasicBlockG.h +318 -0
  43. package/SVF-linux-aarch64/Release-build/include/Graphs/CDG.h +482 -0
  44. package/SVF-linux-aarch64/Release-build/include/Graphs/CFLGraph.h +232 -0
  45. package/SVF-linux-aarch64/Release-build/include/Graphs/CHG.h +369 -0
  46. package/SVF-linux-aarch64/Release-build/include/Graphs/CallGraph.h +498 -0
  47. package/SVF-linux-aarch64/Release-build/include/Graphs/ConsG.h +402 -0
  48. package/SVF-linux-aarch64/Release-build/include/Graphs/ConsGEdge.h +355 -0
  49. package/SVF-linux-aarch64/Release-build/include/Graphs/ConsGNode.h +418 -0
  50. package/SVF-linux-aarch64/Release-build/include/Graphs/DOTGraphTraits.h +188 -0
  51. package/SVF-linux-aarch64/Release-build/include/Graphs/GenericGraph.h +628 -0
  52. package/SVF-linux-aarch64/Release-build/include/Graphs/GraphPrinter.h +111 -0
  53. package/SVF-linux-aarch64/Release-build/include/Graphs/GraphTraits.h +150 -0
  54. package/SVF-linux-aarch64/Release-build/include/Graphs/GraphWriter.h +380 -0
  55. package/SVF-linux-aarch64/Release-build/include/Graphs/ICFG.h +331 -0
  56. package/SVF-linux-aarch64/Release-build/include/Graphs/ICFGEdge.h +281 -0
  57. package/SVF-linux-aarch64/Release-build/include/Graphs/ICFGNode.h +669 -0
  58. package/SVF-linux-aarch64/Release-build/include/Graphs/ICFGStat.h +164 -0
  59. package/SVF-linux-aarch64/Release-build/include/Graphs/IRGraph.h +398 -0
  60. package/SVF-linux-aarch64/Release-build/include/Graphs/SCC.h +375 -0
  61. package/SVF-linux-aarch64/Release-build/include/Graphs/SVFG.h +491 -0
  62. package/SVF-linux-aarch64/Release-build/include/Graphs/SVFGEdge.h +237 -0
  63. package/SVF-linux-aarch64/Release-build/include/Graphs/SVFGNode.h +501 -0
  64. package/SVF-linux-aarch64/Release-build/include/Graphs/SVFGOPT.h +363 -0
  65. package/SVF-linux-aarch64/Release-build/include/Graphs/SVFGStat.h +273 -0
  66. package/SVF-linux-aarch64/Release-build/include/Graphs/ThreadCallGraph.h +400 -0
  67. package/SVF-linux-aarch64/Release-build/include/Graphs/VFG.h +664 -0
  68. package/SVF-linux-aarch64/Release-build/include/Graphs/VFGEdge.h +295 -0
  69. package/SVF-linux-aarch64/Release-build/include/Graphs/VFGNode.h +1266 -0
  70. package/SVF-linux-aarch64/Release-build/include/Graphs/WTO.h +872 -0
  71. package/SVF-linux-aarch64/Release-build/include/MSSA/MSSAMuChi.h +722 -0
  72. package/SVF-linux-aarch64/Release-build/include/MSSA/MemPartition.h +169 -0
  73. package/SVF-linux-aarch64/Release-build/include/MSSA/MemRegion.h +489 -0
  74. package/SVF-linux-aarch64/Release-build/include/MSSA/MemSSA.h +452 -0
  75. package/SVF-linux-aarch64/Release-build/include/MSSA/SVFGBuilder.h +98 -0
  76. package/SVF-linux-aarch64/Release-build/include/MTA/LockAnalysis.h +533 -0
  77. package/SVF-linux-aarch64/Release-build/include/MTA/MHP.h +546 -0
  78. package/SVF-linux-aarch64/Release-build/include/MTA/MTA.h +98 -0
  79. package/SVF-linux-aarch64/Release-build/include/MTA/MTAStat.h +73 -0
  80. package/SVF-linux-aarch64/Release-build/include/MTA/TCT.h +620 -0
  81. package/SVF-linux-aarch64/Release-build/include/MemoryModel/AbstractPointsToDS.h +316 -0
  82. package/SVF-linux-aarch64/Release-build/include/MemoryModel/AccessPath.h +194 -0
  83. package/SVF-linux-aarch64/Release-build/include/MemoryModel/ConditionalPT.h +878 -0
  84. package/SVF-linux-aarch64/Release-build/include/MemoryModel/MutablePointsToDS.h +1025 -0
  85. package/SVF-linux-aarch64/Release-build/include/MemoryModel/PersistentPointsToCache.h +463 -0
  86. package/SVF-linux-aarch64/Release-build/include/MemoryModel/PersistentPointsToDS.h +955 -0
  87. package/SVF-linux-aarch64/Release-build/include/MemoryModel/PointerAnalysis.h +429 -0
  88. package/SVF-linux-aarch64/Release-build/include/MemoryModel/PointerAnalysisImpl.h +602 -0
  89. package/SVF-linux-aarch64/Release-build/include/MemoryModel/PointsTo.h +255 -0
  90. package/SVF-linux-aarch64/Release-build/include/MemoryModel/SVFLoop.h +167 -0
  91. package/SVF-linux-aarch64/Release-build/include/SABER/DoubleFreeChecker.h +76 -0
  92. package/SVF-linux-aarch64/Release-build/include/SABER/FileChecker.h +80 -0
  93. package/SVF-linux-aarch64/Release-build/include/SABER/LeakChecker.h +122 -0
  94. package/SVF-linux-aarch64/Release-build/include/SABER/ProgSlice.h +327 -0
  95. package/SVF-linux-aarch64/Release-build/include/SABER/SaberCheckerAPI.h +151 -0
  96. package/SVF-linux-aarch64/Release-build/include/SABER/SaberCondAllocator.h +317 -0
  97. package/SVF-linux-aarch64/Release-build/include/SABER/SaberSVFGBuilder.h +114 -0
  98. package/SVF-linux-aarch64/Release-build/include/SABER/SrcSnkDDA.h +327 -0
  99. package/SVF-linux-aarch64/Release-build/include/SABER/SrcSnkSolver.h +186 -0
  100. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/BasicTypes.h +280 -0
  101. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/BreakConstantExpr.h +94 -0
  102. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/CHGBuilder.h +78 -0
  103. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/CppUtil.h +184 -0
  104. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/DCHG.h +477 -0
  105. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/GEPTypeBridgeIterator.h +183 -0
  106. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/ICFGBuilder.h +160 -0
  107. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/LLVMLoopAnalysis.h +60 -0
  108. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/LLVMModule.h +594 -0
  109. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/LLVMUtil.h +438 -0
  110. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/ObjTypeInference.h +130 -0
  111. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/SVFIRBuilder.h +520 -0
  112. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/SVFLLVMValue.h +387 -0
  113. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/SVFModule.h +186 -0
  114. package/SVF-linux-aarch64/Release-build/include/SVF-LLVM/SymbolTableBuilder.h +132 -0
  115. package/SVF-linux-aarch64/Release-build/include/SVFIR/ObjTypeInfo.h +224 -0
  116. package/SVF-linux-aarch64/Release-build/include/SVFIR/PAGBuilderFromFile.h +80 -0
  117. package/SVF-linux-aarch64/Release-build/include/SVFIR/SVFIR.h +856 -0
  118. package/SVF-linux-aarch64/Release-build/include/SVFIR/SVFStatements.h +1328 -0
  119. package/SVF-linux-aarch64/Release-build/include/SVFIR/SVFType.h +578 -0
  120. package/SVF-linux-aarch64/Release-build/include/SVFIR/SVFValue.h +338 -0
  121. package/SVF-linux-aarch64/Release-build/include/SVFIR/SVFVariables.h +2204 -0
  122. package/SVF-linux-aarch64/Release-build/include/Util/Annotator.h +180 -0
  123. package/SVF-linux-aarch64/Release-build/include/Util/BitVector.h +55 -0
  124. package/SVF-linux-aarch64/Release-build/include/Util/CDGBuilder.h +107 -0
  125. package/SVF-linux-aarch64/Release-build/include/Util/CallGraphBuilder.h +62 -0
  126. package/SVF-linux-aarch64/Release-build/include/Util/Casting.h +426 -0
  127. package/SVF-linux-aarch64/Release-build/include/Util/CommandLine.h +530 -0
  128. package/SVF-linux-aarch64/Release-build/include/Util/CoreBitVector.h +214 -0
  129. package/SVF-linux-aarch64/Release-build/include/Util/CxtStmt.h +502 -0
  130. package/SVF-linux-aarch64/Release-build/include/Util/DPItem.h +618 -0
  131. package/SVF-linux-aarch64/Release-build/include/Util/ExtAPI.h +117 -0
  132. package/SVF-linux-aarch64/Release-build/include/Util/GeneralType.h +127 -0
  133. package/SVF-linux-aarch64/Release-build/include/Util/GraphReachSolver.h +186 -0
  134. package/SVF-linux-aarch64/Release-build/include/Util/NodeIDAllocator.h +203 -0
  135. package/SVF-linux-aarch64/Release-build/include/Util/Options.h +272 -0
  136. package/SVF-linux-aarch64/Release-build/include/Util/PTAStat.h +83 -0
  137. package/SVF-linux-aarch64/Release-build/include/Util/SVFBugReport.h +427 -0
  138. package/SVF-linux-aarch64/Release-build/include/Util/SVFLoopAndDomInfo.h +169 -0
  139. package/SVF-linux-aarch64/Release-build/include/Util/SVFStat.h +103 -0
  140. package/SVF-linux-aarch64/Release-build/include/Util/SVFUtil.h +478 -0
  141. package/SVF-linux-aarch64/Release-build/include/Util/SparseBitVector.h +1252 -0
  142. package/SVF-linux-aarch64/Release-build/include/Util/ThreadAPI.h +189 -0
  143. package/SVF-linux-aarch64/Release-build/include/Util/WorkList.h +317 -0
  144. package/SVF-linux-aarch64/Release-build/include/Util/Z3Expr.h +325 -0
  145. package/SVF-linux-aarch64/Release-build/include/Util/cJSON.h +300 -0
  146. package/SVF-linux-aarch64/Release-build/include/Util/config.h +26 -0
  147. package/SVF-linux-aarch64/Release-build/include/Util/iterator.h +407 -0
  148. package/SVF-linux-aarch64/Release-build/include/Util/iterator_range.h +76 -0
  149. package/SVF-linux-aarch64/Release-build/include/WPA/Andersen.h +435 -0
  150. package/SVF-linux-aarch64/Release-build/include/WPA/AndersenPWC.h +160 -0
  151. package/SVF-linux-aarch64/Release-build/include/WPA/CSC.h +95 -0
  152. package/SVF-linux-aarch64/Release-build/include/WPA/FlowSensitive.h +323 -0
  153. package/SVF-linux-aarch64/Release-build/include/WPA/Steensgaard.h +131 -0
  154. package/SVF-linux-aarch64/Release-build/include/WPA/TypeAnalysis.h +90 -0
  155. package/SVF-linux-aarch64/Release-build/include/WPA/VersionedFlowSensitive.h +295 -0
  156. package/SVF-linux-aarch64/Release-build/include/WPA/WPAFSSolver.h +246 -0
  157. package/SVF-linux-aarch64/Release-build/include/WPA/WPAPass.h +116 -0
  158. package/SVF-linux-aarch64/Release-build/include/WPA/WPASolver.h +205 -0
  159. package/SVF-linux-aarch64/Release-build/include/WPA/WPAStat.h +222 -0
  160. package/SVF-linux-aarch64/Release-build/lib/cmake/SVF/SVFConfig.cmake +58 -0
  161. package/SVF-linux-aarch64/Release-build/lib/cmake/SVF/SVFConfigVersion.cmake +43 -0
  162. package/SVF-linux-aarch64/Release-build/lib/extapi.bc +2449 -0
  163. package/SVF-linux-aarch64/Release-build/lib/libSvfCore.so +0 -0
  164. package/SVF-linux-aarch64/Release-build/lib/libSvfLLVM.so.16 +0 -0
  165. package/package.json +1 -1
@@ -0,0 +1,435 @@
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 Affero 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 Affero General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU Affero 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
+ class ThreadCallGraph;
51
+
52
+ /*!
53
+ * Abstract class of inclusion-based Pointer Analysis
54
+ */
55
+ typedef WPASolver<ConstraintGraph*> WPAConstraintSolver;
56
+
57
+ class AndersenBase: public WPAConstraintSolver, public BVDataPTAImpl
58
+ {
59
+ public:
60
+ typedef OrderedMap<const CallICFGNode*, NodeID> CallSite2DummyValPN;
61
+
62
+ public:
63
+
64
+ /// Constructor
65
+ AndersenBase(SVFIR* _pag, PTATY type = Andersen_BASE, bool alias_check = true)
66
+ : BVDataPTAImpl(_pag, type, alias_check), consCG(nullptr)
67
+ {
68
+ iterationForPrintStat = OnTheFlyIterBudgetForStat;
69
+ }
70
+
71
+ /// Destructor
72
+ ~AndersenBase() override;
73
+
74
+ /// Andersen analysis
75
+ virtual void analyze() override;
76
+
77
+ virtual void solveAndwritePtsToFile(const std::string& filename);
78
+
79
+ virtual void readPtsFromFile(const std::string& filename);
80
+
81
+ virtual void solveConstraints();
82
+
83
+ /// Initialize analysis
84
+ virtual void initialize() override;
85
+
86
+ /// Finalize analysis
87
+ virtual void finalize() override;
88
+
89
+ /// Update call graph
90
+ virtual bool updateCallGraph(const CallSiteToFunPtrMap&) override;
91
+
92
+ /// Update thread call graph
93
+ virtual bool updateThreadCallGraph(const CallSiteToFunPtrMap&, NodePairSet&);
94
+
95
+ /// Connect formal and actual parameters for indirect forksites
96
+ virtual void connectCaller2ForkedFunParams(const CallICFGNode* cs, const FunObjVar* F,
97
+ NodePairSet& cpySrcNodes);
98
+
99
+ /// Connect formal and actual parameters for indirect callsites
100
+ virtual void connectCaller2CalleeParams(const CallICFGNode* cs, const FunObjVar* F,
101
+ NodePairSet& cpySrcNodes);
102
+
103
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
104
+ //@{
105
+ static inline bool classof(const AndersenBase *)
106
+ {
107
+ return true;
108
+ }
109
+ static inline bool classof(const PointerAnalysis *pta)
110
+ {
111
+ return ( pta->getAnalysisTy() == Andersen_BASE
112
+ || pta->getAnalysisTy() == Andersen_WPA
113
+ || pta->getAnalysisTy() == AndersenWaveDiff_WPA
114
+ || pta->getAnalysisTy() == AndersenSCD_WPA
115
+ || pta->getAnalysisTy() == AndersenSFR_WPA
116
+ || pta->getAnalysisTy() == TypeCPP_WPA
117
+ || pta->getAnalysisTy() == Steensgaard_WPA);
118
+ }
119
+ //@}
120
+
121
+ /// Get constraint graph
122
+ ConstraintGraph* getConstraintGraph()
123
+ {
124
+ return consCG;
125
+ }
126
+
127
+ /// SCC methods
128
+ //@{
129
+ inline NodeID sccRepNode(NodeID id) const override
130
+ {
131
+ return consCG->sccRepNode(id);
132
+ }
133
+ inline NodeBS& sccSubNodes(NodeID repId)
134
+ {
135
+ return consCG->sccSubNodes(repId);
136
+ }
137
+ //@}
138
+
139
+ /// Add copy edge on constraint graph
140
+ virtual bool addCopyEdge(NodeID src, NodeID dst) = 0;
141
+
142
+ /// dump statistics
143
+ inline void printStat()
144
+ {
145
+ PointerAnalysis::dumpStat();
146
+ }
147
+
148
+ virtual void normalizePointsTo() override;
149
+
150
+ /// remove redundant gepnodes in constraint graph
151
+ void cleanConsCG(NodeID id);
152
+
153
+ NodeBS redundantGepNodes;
154
+
155
+ /// Statistics
156
+ //@{
157
+ static u32_t numOfProcessedAddr; /// Number of processed Addr edge
158
+ static u32_t numOfProcessedCopy; /// Number of processed Copy edge
159
+ static u32_t numOfProcessedGep; /// Number of processed Gep edge
160
+ static u32_t numOfProcessedLoad; /// Number of processed Load edge
161
+ static u32_t numOfProcessedStore; /// Number of processed Store edge
162
+ static u32_t numOfSfrs;
163
+ static u32_t numOfFieldExpand;
164
+
165
+ static u32_t numOfSCCDetection;
166
+ static double timeOfSCCDetection;
167
+ static double timeOfSCCMerges;
168
+ static double timeOfCollapse;
169
+ static u32_t AveragePointsToSetSize;
170
+ static u32_t MaxPointsToSetSize;
171
+ static double timeOfProcessCopyGep;
172
+ static double timeOfProcessLoadStore;
173
+ static double timeOfUpdateCallGraph;
174
+ //@}
175
+
176
+ protected:
177
+ /// Constraint Graph
178
+ ConstraintGraph* consCG;
179
+ CallSite2DummyValPN
180
+ callsite2DummyValPN; ///< Map an instruction to a dummy obj which
181
+ ///< created at an indirect callsite, which invokes
182
+ ///< a heap allocator
183
+ void heapAllocatorViaIndCall(const CallICFGNode* cs, NodePairSet& cpySrcNodes);
184
+ };
185
+
186
+ /*!
187
+ * Inclusion-based Pointer Analysis
188
+ */
189
+ class Andersen: public AndersenBase
190
+ {
191
+
192
+
193
+ public:
194
+ typedef SCCDetection<ConstraintGraph*> CGSCC;
195
+
196
+ /// Constructor
197
+ Andersen(SVFIR* _pag, PTATY type = Andersen_WPA, bool alias_check = true)
198
+ : AndersenBase(_pag, type, alias_check)
199
+ {
200
+ }
201
+
202
+ /// Destructor
203
+ virtual ~Andersen()
204
+ {
205
+
206
+ }
207
+
208
+ /// Initialize analysis
209
+ virtual void initialize();
210
+
211
+ /// Finalize analysis
212
+ virtual void finalize();
213
+
214
+ /// Reset data
215
+ inline void resetData()
216
+ {
217
+ AveragePointsToSetSize = 0;
218
+ MaxPointsToSetSize = 0;
219
+ timeOfProcessCopyGep = 0;
220
+ timeOfProcessLoadStore = 0;
221
+ }
222
+
223
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
224
+ //@{
225
+ static inline bool classof(const Andersen *)
226
+ {
227
+ return true;
228
+ }
229
+ static inline bool classof(const PointerAnalysis *pta)
230
+ {
231
+ return (pta->getAnalysisTy() == Andersen_WPA
232
+ || pta->getAnalysisTy() == AndersenWaveDiff_WPA
233
+ || pta->getAnalysisTy() == AndersenSCD_WPA
234
+ || pta->getAnalysisTy() == AndersenSFR_WPA);
235
+ }
236
+ //@}
237
+
238
+ /// Operation of points-to set
239
+ virtual inline const PointsTo& getPts(NodeID id)
240
+ {
241
+ return getPTDataTy()->getPts(sccRepNode(id));
242
+ }
243
+ virtual inline bool unionPts(NodeID id, const PointsTo& target)
244
+ {
245
+ id = sccRepNode(id);
246
+ return getPTDataTy()->unionPts(id, target);
247
+ }
248
+ virtual inline bool unionPts(NodeID id, NodeID ptd)
249
+ {
250
+ id = sccRepNode(id);
251
+ ptd = sccRepNode(ptd);
252
+ return getPTDataTy()->unionPts(id,ptd);
253
+ }
254
+
255
+
256
+ void dumpTopLevelPtsTo();
257
+
258
+ void setDetectPWC(bool flag)
259
+ {
260
+ Options::DetectPWC.setValue(flag);
261
+ }
262
+
263
+ protected:
264
+
265
+ CallSite2DummyValPN callsite2DummyValPN; ///< Map an instruction to a dummy obj which created at an indirect callsite, which invokes a heap allocator
266
+
267
+ /// Handle diff points-to set.
268
+ virtual inline void computeDiffPts(NodeID id)
269
+ {
270
+ if (Options::DiffPts())
271
+ {
272
+ NodeID rep = sccRepNode(id);
273
+ getDiffPTDataTy()->computeDiffPts(rep, getDiffPTDataTy()->getPts(rep));
274
+ }
275
+ }
276
+ virtual inline const PointsTo& getDiffPts(NodeID id)
277
+ {
278
+ NodeID rep = sccRepNode(id);
279
+ if (Options::DiffPts())
280
+ return getDiffPTDataTy()->getDiffPts(rep);
281
+ else
282
+ return getPTDataTy()->getPts(rep);
283
+ }
284
+
285
+ /// Handle propagated points-to set.
286
+ inline void updatePropaPts(NodeID dstId, NodeID srcId)
287
+ {
288
+ if (!Options::DiffPts())
289
+ return;
290
+ NodeID srcRep = sccRepNode(srcId);
291
+ NodeID dstRep = sccRepNode(dstId);
292
+ getDiffPTDataTy()->updatePropaPtsMap(srcRep, dstRep);
293
+ }
294
+ inline void clearPropaPts(NodeID src)
295
+ {
296
+ if (Options::DiffPts())
297
+ {
298
+ NodeID rep = sccRepNode(src);
299
+ getDiffPTDataTy()->clearPropaPts(rep);
300
+ }
301
+ }
302
+
303
+ virtual void initWorklist() {}
304
+
305
+ /// Override WPASolver function in order to use the default solver
306
+ virtual void processNode(NodeID nodeId);
307
+
308
+ /// handling various constraints
309
+ //@{
310
+ void processAllAddr();
311
+
312
+ virtual bool processLoad(NodeID node, const ConstraintEdge* load);
313
+ virtual bool processStore(NodeID node, const ConstraintEdge* load);
314
+ virtual bool processCopy(NodeID node, const ConstraintEdge* edge);
315
+ virtual bool processGep(NodeID node, const GepCGEdge* edge);
316
+ virtual void handleCopyGep(ConstraintNode* node);
317
+ virtual void handleLoadStore(ConstraintNode* node);
318
+ virtual void processAddr(const AddrCGEdge* addr);
319
+ virtual bool processGepPts(const PointsTo& pts, const GepCGEdge* edge);
320
+ //@}
321
+
322
+ /// Add copy edge on constraint graph
323
+ virtual inline bool addCopyEdge(NodeID src, NodeID dst)
324
+ {
325
+ if (consCG->addCopyCGEdge(src, dst))
326
+ {
327
+ updatePropaPts(src, dst);
328
+ return true;
329
+ }
330
+ return false;
331
+ }
332
+
333
+ /// Merge sub node to its rep
334
+ virtual void mergeNodeToRep(NodeID nodeId,NodeID newRepId);
335
+
336
+ virtual bool mergeSrcToTgt(NodeID srcId,NodeID tgtId);
337
+
338
+ /// Merge sub node in a SCC cycle to their rep node
339
+ //@{
340
+ void mergeSccNodes(NodeID repNodeId, const NodeBS& subNodes);
341
+ void mergeSccCycle();
342
+ //@}
343
+ /// Collapse a field object into its base for field insensitive analysis
344
+ //@{
345
+ virtual void collapsePWCNode(NodeID nodeId);
346
+ void collapseFields();
347
+ bool collapseNodePts(NodeID nodeId);
348
+ bool collapseField(NodeID nodeId);
349
+ //@}
350
+
351
+ /// Updates subnodes of its rep, and rep node of its subs
352
+ void updateNodeRepAndSubs(NodeID nodeId,NodeID newRepId);
353
+
354
+ /// SCC detection
355
+ virtual NodeStack& SCCDetect();
356
+
357
+
358
+
359
+ /// Sanitize pts for field insensitive objects
360
+ void sanitizePts()
361
+ {
362
+ for(ConstraintGraph::iterator it = consCG->begin(), eit = consCG->end(); it!=eit; ++it)
363
+ {
364
+ const PointsTo& pts = getPts(it->first);
365
+ NodeBS fldInsenObjs;
366
+
367
+ for (NodeID o : pts)
368
+ {
369
+ if(isFieldInsensitive(o))
370
+ fldInsenObjs.set(o);
371
+ }
372
+
373
+ for (NodeID o : fldInsenObjs)
374
+ {
375
+ const NodeBS &allFields = consCG->getAllFieldsObjVars(o);
376
+ for (NodeID f : allFields) addPts(it->first, f);
377
+ }
378
+ }
379
+ }
380
+
381
+ /// Get PTA name
382
+ virtual const std::string PTAName() const
383
+ {
384
+ return "AndersenWPA";
385
+ }
386
+
387
+ /// Runs a Steensgaard analysis and performs clustering based on those
388
+ /// results set the global best mapping.
389
+ virtual void cluster(void) const;
390
+ };
391
+
392
+
393
+
394
+ /**
395
+ * Wave propagation with diff points-to set.
396
+ */
397
+ class AndersenWaveDiff : public Andersen
398
+ {
399
+
400
+ private:
401
+
402
+ static AndersenWaveDiff* diffWave; // static instance
403
+
404
+ public:
405
+ AndersenWaveDiff(SVFIR* _pag, PTATY type = AndersenWaveDiff_WPA, bool alias_check = true): Andersen(_pag, type, alias_check) {}
406
+
407
+ /// Create an singleton instance directly instead of invoking llvm pass manager
408
+ static AndersenWaveDiff* createAndersenWaveDiff(SVFIR* _pag)
409
+ {
410
+ if(diffWave==nullptr)
411
+ {
412
+ diffWave = new AndersenWaveDiff(_pag, AndersenWaveDiff_WPA, false);
413
+ diffWave->analyze();
414
+ return diffWave;
415
+ }
416
+ return diffWave;
417
+ }
418
+ static void releaseAndersenWaveDiff()
419
+ {
420
+ if (diffWave)
421
+ delete diffWave;
422
+ diffWave = nullptr;
423
+ }
424
+
425
+ virtual void initialize();
426
+ virtual void solveWorklist();
427
+ virtual void processNode(NodeID nodeId);
428
+ virtual void postProcessNode(NodeID nodeId);
429
+ virtual bool handleLoad(NodeID id, const ConstraintEdge* load);
430
+ virtual bool handleStore(NodeID id, const ConstraintEdge* store);
431
+ };
432
+
433
+ } // End namespace SVF
434
+
435
+ #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 Affero 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 Affero General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU Affero 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
+ scdAndersen = 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
+ sfrAndersen = 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, APOffset 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 Affero 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 Affero General Public License for more details.
17
+
18
+ // You should have received a copy of the GNU Affero 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 "Graphs/ConsG.h"
34
+ #include "Graphs/SCC.h"
35
+ #include "SVFIR/SVFValue.h" // for NodeBS
36
+ #include "Util/WorkList.h"
37
+ #include <limits.h>
38
+ #include <map>
39
+ #include <stack>
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