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,183 @@
1
+ // GEPTypeBridgeIterator
2
+ //
3
+ //
4
+ #ifndef SVF_GEPTYPEBRIDGEITERATOR_H
5
+ #define SVF_GEPTYPEBRIDGEITERATOR_H
6
+
7
+ #include "llvm/IR/DerivedTypes.h"
8
+ #include "llvm/IR/Operator.h"
9
+ #include "llvm/IR/User.h"
10
+ #include "llvm/ADT/PointerIntPair.h"
11
+ #include "llvm/IR/GetElementPtrTypeIterator.h"
12
+
13
+ namespace llvm
14
+ {
15
+
16
+ template<typename ItTy = User::const_op_iterator>
17
+ class generic_bridge_gep_type_iterator : public std::iterator<std::forward_iterator_tag, Type*, ptrdiff_t>
18
+ {
19
+
20
+ typedef std::iterator<std::forward_iterator_tag,Type*, ptrdiff_t> super;
21
+ ItTy OpIt;
22
+ PointerIntPair<Type*,1> CurTy;
23
+ unsigned AddrSpace;
24
+ generic_bridge_gep_type_iterator() {}
25
+ public:
26
+
27
+ static generic_bridge_gep_type_iterator begin(Type* Ty, ItTy It)
28
+ {
29
+ generic_bridge_gep_type_iterator I;
30
+ I.CurTy.setPointer(Ty);
31
+ I.OpIt = It;
32
+ return I;
33
+ }
34
+
35
+ static generic_bridge_gep_type_iterator begin(Type* Ty, unsigned AddrSpace,
36
+ ItTy It)
37
+ {
38
+ generic_bridge_gep_type_iterator I;
39
+ I.CurTy.setPointer(Ty);
40
+ I.CurTy.setInt(true);
41
+ I.AddrSpace = AddrSpace;
42
+ I.OpIt = It;
43
+ return I;
44
+ }
45
+
46
+ static generic_bridge_gep_type_iterator end(ItTy It)
47
+ {
48
+ generic_bridge_gep_type_iterator I;
49
+ I.OpIt = It;
50
+ return I;
51
+ }
52
+
53
+ bool operator==(const generic_bridge_gep_type_iterator& x) const
54
+ {
55
+ return OpIt == x.OpIt;
56
+ }
57
+
58
+ bool operator!=(const generic_bridge_gep_type_iterator& x) const
59
+ {
60
+ return !operator==(x);
61
+ }
62
+
63
+ Type* operator*() const
64
+ {
65
+ if ( CurTy.getInt() )
66
+ return CurTy.getPointer()->getPointerTo(AddrSpace);
67
+ return CurTy.getPointer();
68
+ }
69
+
70
+ Type* getIndexedType() const
71
+ {
72
+ assert(false && "needs to be refactored");
73
+ if ( CurTy.getInt() )
74
+ return CurTy.getPointer();
75
+ #if LLVM_VERSION_MAJOR >= 11
76
+ Type* CT = CurTy.getPointer();
77
+ if (auto ST = dyn_cast<StructType>(CT))
78
+ return ST->getTypeAtIndex(getOperand());
79
+ else if (auto Array = dyn_cast<ArrayType>(CT))
80
+ return Array->getElementType();
81
+ else if (auto Vector = dyn_cast<VectorType>(CT))
82
+ return Vector->getElementType();
83
+ else
84
+ return CT;
85
+ #else
86
+ CompositeType *CT = llvm::cast<CompositeType>( CurTy.getPointer() );
87
+ return CT->getTypeAtIndex(getOperand());
88
+ #endif
89
+ }
90
+
91
+ // non-standard operators, these may not need be bridged but seems it's
92
+ // predunt to do so...
93
+ Type* operator->() const
94
+ {
95
+ return operator*();
96
+ }
97
+
98
+ Value* getOperand() const
99
+ {
100
+ return const_cast<Value*>(&**OpIt);
101
+ }
102
+
103
+
104
+ generic_bridge_gep_type_iterator& operator++()
105
+ {
106
+ if ( CurTy.getInt() )
107
+ {
108
+ CurTy.setInt(false);
109
+ }
110
+ #if LLVM_VERSION_MAJOR >= 11
111
+ else if ( Type* CT = CurTy.getPointer() )
112
+ {
113
+ if (auto ST = dyn_cast<StructType>(CT))
114
+ CurTy.setPointer(ST->getTypeAtIndex(getOperand()));
115
+ else if (auto Array = dyn_cast<ArrayType>(CT))
116
+ CurTy.setPointer(Array->getElementType());
117
+ else if (auto Vector = dyn_cast<VectorType>(CT))
118
+ CurTy.setPointer(Vector->getElementType());
119
+ else
120
+ CurTy.setPointer(nullptr);
121
+ }
122
+ #else
123
+ else if ( CompositeType * CT = dyn_cast<CompositeType>(CurTy.getPointer()) )
124
+ {
125
+ CurTy.setPointer(CT->getTypeAtIndex(getOperand()));
126
+ }
127
+ #endif
128
+ else
129
+ {
130
+ CurTy.setPointer(nullptr);
131
+ }
132
+ ++OpIt;
133
+ return *this;
134
+ }
135
+
136
+
137
+ generic_bridge_gep_type_iterator operator++(int)
138
+ {
139
+ generic_bridge_gep_type_iterator tmp = *this;
140
+ ++*this;
141
+ return tmp;
142
+ }
143
+
144
+ };
145
+
146
+
147
+ typedef generic_bridge_gep_type_iterator<> bridge_gep_iterator;
148
+
149
+ inline bridge_gep_iterator bridge_gep_begin(const User* GEP)
150
+ {
151
+ auto *GEPOp = llvm::cast<GEPOperator>(GEP);
152
+ return bridge_gep_iterator::begin(GEPOp->getSourceElementType(),
153
+ llvm::cast<PointerType>(GEPOp->getPointerOperandType()->getScalarType())->getAddressSpace(),
154
+ GEP->op_begin() + 1);
155
+ }
156
+
157
+ inline bridge_gep_iterator bridge_gep_end(const User* GEP)
158
+ {
159
+ return bridge_gep_iterator::end(GEP->op_end());
160
+ }
161
+
162
+ inline bridge_gep_iterator bridge_gep_begin(const User &GEP)
163
+ {
164
+ auto &GEPOp = llvm::cast<GEPOperator>(GEP);
165
+ return bridge_gep_iterator::begin( GEPOp.getSourceElementType(),
166
+ llvm::cast<PointerType>(GEPOp.getPointerOperandType()->getScalarType())->getAddressSpace(),
167
+ GEP.op_begin() + 1);
168
+ }
169
+
170
+ inline bridge_gep_iterator bridge_gep_end(const User &GEP)
171
+ {
172
+ return bridge_gep_iterator::end(GEP.op_end());
173
+ }
174
+
175
+ template<typename T>
176
+ inline generic_bridge_gep_type_iterator<const T*> bridge_gep_end( Type* /*Op0*/, ArrayRef<T> A )
177
+ {
178
+ return generic_bridge_gep_type_iterator<const T*>::end(A.end());
179
+ }
180
+
181
+ } // End namespace llvm
182
+
183
+ #endif
@@ -0,0 +1,106 @@
1
+ //===- ICFGBuilder.h ----------------------------------------------------------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-> <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
+ * ICFGBuilder.h
25
+ *
26
+ * Created on:
27
+ * Author: yulei
28
+ */
29
+
30
+ #ifndef INCLUDE_UTIL_ICFGBUILDER_H_
31
+ #define INCLUDE_UTIL_ICFGBUILDER_H_
32
+
33
+ #include "Graphs/ICFG.h"
34
+ #include "Util/WorkList.h"
35
+
36
+ namespace SVF
37
+ {
38
+
39
+ class ICFGBuilder
40
+ {
41
+
42
+ public:
43
+
44
+ typedef std::vector<const Instruction*> InstVec;
45
+ typedef Set<const Instruction*> BBSet;
46
+
47
+ private:
48
+ ICFG* icfg;
49
+
50
+ public:
51
+ typedef FIFOWorkList<const Instruction*> WorkList;
52
+
53
+ ICFGBuilder(ICFG* i): icfg(i)
54
+ {
55
+
56
+ }
57
+ void build(SVFModule* svfModule);
58
+
59
+ private:
60
+ /// Create edges between ICFG nodes within a function
61
+ ///@{
62
+ void processFunEntry(const Function* fun, WorkList& worklist);
63
+
64
+ void processFunBody(WorkList& worklist);
65
+
66
+ void processFunExit(const Function* fun);
67
+ //@}
68
+
69
+ void connectGlobalToProgEntry(SVFModule* svfModule);
70
+
71
+ /// Add/Get an inter block ICFGNode
72
+ InterICFGNode* getOrAddInterBlockICFGNode(const SVFInstruction* inst);
73
+
74
+ /// Add/Get a basic block ICFGNode
75
+ inline ICFGNode* getOrAddBlockICFGNode(const SVFInstruction* inst)
76
+ {
77
+ if(SVFUtil::isNonInstricCallSite(inst))
78
+ return getOrAddInterBlockICFGNode(inst);
79
+ else
80
+ return getOrAddIntraBlockICFGNode(inst);
81
+ }
82
+
83
+ /// Create edges between ICFG nodes across functions
84
+ void addICFGInterEdges(const SVFInstruction* cs, const SVFFunction* callee);
85
+
86
+ /// Add a call node
87
+ inline CallICFGNode* getCallICFGNode(const SVFInstruction* cs)
88
+ {
89
+ return icfg->getCallICFGNode(cs);
90
+ }
91
+ /// Add a return node
92
+ inline RetICFGNode* getRetICFGNode(const SVFInstruction* cs)
93
+ {
94
+ return icfg->getRetICFGNode(cs);
95
+ }
96
+
97
+ /// Add and get IntraBlock ICFGNode
98
+ IntraICFGNode* getOrAddIntraBlockICFGNode(const SVFInstruction* inst)
99
+ {
100
+ return icfg->getIntraICFGNode(inst);
101
+ }
102
+ };
103
+
104
+ } // End namespace SVF
105
+
106
+ #endif /* INCLUDE_UTIL_ICFGBUILDER_H_ */
@@ -0,0 +1,61 @@
1
+ //===- LLVMLoopAnalysis.h -- LoopAnalysis of SVF --------------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-2022> <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
+ * LLVMLoopAnalysis.h
25
+ *
26
+ * Created on: 14, 06, 2022
27
+ * Author: Jiawei Wang, Xiao Cheng
28
+ */
29
+
30
+ #ifndef SVF_LLVMLOOPANALYSIS_H
31
+ #define SVF_LLVMLOOPANALYSIS_H
32
+
33
+ #include "SVFIR/SVFIR.h"
34
+ #include "MemoryModel/SVFLoop.h"
35
+ #include "SVF-LLVM/BasicTypes.h"
36
+
37
+ namespace SVF
38
+ {
39
+ class LLVMLoopAnalysis
40
+ {
41
+ public:
42
+
43
+ /// Constructor
44
+ LLVMLoopAnalysis() = default;;
45
+
46
+ /// Destructor
47
+ virtual ~LLVMLoopAnalysis() = default;
48
+
49
+ /// Build llvm loops based on LoopInfo analysis
50
+ virtual void buildLLVMLoops(SVFModule *mod, std::vector<const Loop *> &llvmLoops,
51
+ llvm::LoopInfoBase<llvm::BasicBlock, llvm::Loop> * loopInfo);
52
+
53
+ /// Start from here
54
+ virtual void build(ICFG *icfg);
55
+
56
+ /// Build SVF loops based on llvm loops
57
+ virtual void buildSVFLoops(ICFG *icfg, std::vector<const Loop *> &llvmLoops);
58
+ };
59
+ } // End namespace SVF
60
+
61
+ #endif //SVF_LLVMLOOPANALYSIS_H
@@ -0,0 +1,360 @@
1
+ //===- LLVMModule.h -- LLVM Module class-----------------------------------------//
2
+ //
3
+ // SVF: Static Value-Flow Analysis
4
+ //
5
+ // Copyright (C) <2013-> <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
+ * LLVMModule.h
25
+ *
26
+ * Created on: 23 Mar.2020
27
+ * Author: Yulei Sui
28
+ */
29
+
30
+ #ifndef INCLUDE_SVF_FE_LLVMMODULE_H_
31
+ #define INCLUDE_SVF_FE_LLVMMODULE_H_
32
+
33
+ #include "SVF-LLVM/BasicTypes.h"
34
+ #include "Util/CppUtil.h"
35
+ #include "SVFIR/SVFValue.h"
36
+ #include "SVFIR/SVFModule.h"
37
+
38
+ namespace SVF
39
+ {
40
+
41
+ class SymbolTableInfo;
42
+
43
+ class LLVMModuleSet
44
+ {
45
+
46
+ public:
47
+
48
+ typedef std::vector<const Function*> FunctionSetType;
49
+ typedef Map<const Function*, const Function*> FunDeclToDefMapTy;
50
+ typedef Map<const Function*, FunctionSetType> FunDefToDeclsMapTy;
51
+ typedef Map<const GlobalVariable*, GlobalVariable*> GlobalDefToRepMapTy;
52
+
53
+ typedef Map<const Function*, SVFFunction*> LLVMFun2SVFFunMap;
54
+ typedef Map<const BasicBlock*, SVFBasicBlock*> LLVMBB2SVFBBMap;
55
+ typedef Map<const Instruction*, SVFInstruction*> LLVMInst2SVFInstMap;
56
+ typedef Map<const Argument*, SVFArgument*> LLVMArgument2SVFArgumentMap;
57
+ typedef Map<const Constant*, SVFConstant*> LLVMConst2SVFConstMap;
58
+ typedef Map<const Value*, SVFOtherValue*> LLVMValue2SVFOtherValueMap;
59
+ typedef Map<const SVFValue*, const Value*> SVFValue2LLVMValueMap;
60
+ typedef Map<const Type*, SVFType*> LLVMType2SVFTypeMap;
61
+ typedef Map<const Type*, StInfo*> Type2TypeInfoMap;
62
+
63
+ private:
64
+ static LLVMModuleSet* llvmModuleSet;
65
+ SymbolTableInfo *symInfo;
66
+ std::unique_ptr<SVFModule> svfModule;
67
+ std::unique_ptr<LLVMContext> cxts;
68
+ std::vector<std::unique_ptr<Module>> owned_modules;
69
+ std::vector<std::reference_wrapper<Module>> modules;
70
+
71
+ /// Function declaration to function definition map
72
+ FunDeclToDefMapTy FunDeclToDefMap;
73
+ /// Function definition to function declaration map
74
+ FunDefToDeclsMapTy FunDefToDeclsMap;
75
+ /// Global definition to a rep definition map
76
+ GlobalDefToRepMapTy GlobalDefToRepMap;
77
+
78
+ LLVMFun2SVFFunMap LLVMFunc2SVFFunc; ///< Map an LLVM Function to an SVF Function
79
+ LLVMBB2SVFBBMap LLVMBB2SVFBB;
80
+ LLVMInst2SVFInstMap LLVMInst2SVFInst;
81
+ LLVMArgument2SVFArgumentMap LLVMArgument2SVFArgument;
82
+ LLVMConst2SVFConstMap LLVMConst2SVFConst;
83
+ LLVMValue2SVFOtherValueMap LLVMValue2SVFOtherValue;
84
+ SVFValue2LLVMValueMap SVFValue2LLVMValue;
85
+ LLVMType2SVFTypeMap LLVMType2SVFType;
86
+ Type2TypeInfoMap Type2TypeInfo;
87
+ Set<const StInfo*> StInfos;
88
+
89
+ /// Constructor
90
+ LLVMModuleSet();
91
+ ~LLVMModuleSet();
92
+
93
+ void build();
94
+
95
+ public:
96
+ static inline LLVMModuleSet* getLLVMModuleSet()
97
+ {
98
+ if (llvmModuleSet == nullptr)
99
+ llvmModuleSet = new LLVMModuleSet();
100
+ return llvmModuleSet;
101
+ }
102
+
103
+ static void releaseLLVMModuleSet()
104
+ {
105
+ if (llvmModuleSet)
106
+ delete llvmModuleSet;
107
+ llvmModuleSet = nullptr;
108
+ }
109
+
110
+ SVFModule* buildSVFModule(Module& mod);
111
+ SVFModule* buildSVFModule(const std::vector<std::string>& moduleNameVec);
112
+
113
+ inline SVFModule* getSVFModule()
114
+ {
115
+ assert(svfModule && "svfModule has not been built yet!");
116
+ return svfModule.get();
117
+ }
118
+
119
+ void preProcessBCs(std::vector<std::string>& moduleNameVec);
120
+
121
+ u32_t getModuleNum() const
122
+ {
123
+ return modules.size();
124
+ }
125
+
126
+ const std::vector<std::reference_wrapper<Module>>& getLLVMModules() const
127
+ {
128
+ return modules;
129
+ }
130
+
131
+ Module *getModule(u32_t idx) const
132
+ {
133
+ return &getModuleRef(idx);
134
+ }
135
+
136
+ Module &getModuleRef(u32_t idx) const
137
+ {
138
+ assert(idx < getModuleNum() && "Out of range.");
139
+ return modules[idx];
140
+ }
141
+
142
+ // Dump modules to files
143
+ void dumpModulesToFile(const std::string suffix);
144
+
145
+ inline void addFunctionMap(const Function* func, SVFFunction* svfFunc)
146
+ {
147
+ LLVMFunc2SVFFunc[func] = svfFunc;
148
+ setValueAttr(func,svfFunc);
149
+ }
150
+ inline void addBasicBlockMap(const BasicBlock* bb, SVFBasicBlock* svfBB)
151
+ {
152
+ LLVMBB2SVFBB[bb] = svfBB;
153
+ setValueAttr(bb,svfBB);
154
+ }
155
+ inline void addInstructionMap(const Instruction* inst, SVFInstruction* svfInst)
156
+ {
157
+ LLVMInst2SVFInst[inst] = svfInst;
158
+ setValueAttr(inst,svfInst);
159
+ }
160
+ inline void addArgumentMap(const Argument* arg, SVFArgument* svfArg)
161
+ {
162
+ LLVMArgument2SVFArgument[arg] = svfArg;
163
+ setValueAttr(arg,svfArg);
164
+ }
165
+ inline void addGlobalValueMap(const GlobalValue* glob, SVFGlobalValue* svfglob)
166
+ {
167
+ LLVMConst2SVFConst[glob] = svfglob;
168
+ setValueAttr(glob,svfglob);
169
+ }
170
+ inline void addConstantDataMap(const ConstantData* cd, SVFConstantData* svfcd)
171
+ {
172
+ LLVMConst2SVFConst[cd] = svfcd;
173
+ setValueAttr(cd,svfcd);
174
+ }
175
+ inline void addOtherConstantMap(const Constant* cons, SVFConstant* svfcons)
176
+ {
177
+ LLVMConst2SVFConst[cons] = svfcons;
178
+ setValueAttr(cons,svfcons);
179
+ }
180
+ inline void addOtherValueMap(const Value* ov, SVFOtherValue* svfov)
181
+ {
182
+ LLVMValue2SVFOtherValue[ov] = svfov;
183
+ setValueAttr(ov,svfov);
184
+ }
185
+
186
+ SVFValue* getSVFValue(const Value* value);
187
+
188
+ const Value* getLLVMValue(const SVFValue* value) const
189
+ {
190
+ SVFValue2LLVMValueMap::const_iterator it = SVFValue2LLVMValue.find(value);
191
+ assert(it!=SVFValue2LLVMValue.end() && "can't find corresponding llvm value!");
192
+ return it->second;
193
+ }
194
+
195
+ inline SVFFunction* getSVFFunction(const Function* fun) const
196
+ {
197
+ LLVMFun2SVFFunMap::const_iterator it = LLVMFunc2SVFFunc.find(fun);
198
+ assert(it!=LLVMFunc2SVFFunc.end() && "SVF Function not found!");
199
+ return it->second;
200
+ }
201
+
202
+ inline SVFBasicBlock* getSVFBasicBlock(const BasicBlock* bb) const
203
+ {
204
+ LLVMBB2SVFBBMap::const_iterator it = LLVMBB2SVFBB.find(bb);
205
+ assert(it!=LLVMBB2SVFBB.end() && "SVF BasicBlock not found!");
206
+ return it->second;
207
+ }
208
+
209
+ inline SVFInstruction* getSVFInstruction(const Instruction* inst) const
210
+ {
211
+ LLVMInst2SVFInstMap::const_iterator it = LLVMInst2SVFInst.find(inst);
212
+ assert(it!=LLVMInst2SVFInst.end() && "SVF Instruction not found!");
213
+ return it->second;
214
+ }
215
+
216
+ inline SVFArgument* getSVFArgument(const Argument* arg) const
217
+ {
218
+ LLVMArgument2SVFArgumentMap::const_iterator it = LLVMArgument2SVFArgument.find(arg);
219
+ assert(it!=LLVMArgument2SVFArgument.end() && "SVF Argument not found!");
220
+ return it->second;
221
+ }
222
+
223
+ inline SVFGlobalValue* getSVFGlobalValue(const GlobalValue* g) const
224
+ {
225
+ LLVMConst2SVFConstMap::const_iterator it = LLVMConst2SVFConst.find(g);
226
+ assert(it!=LLVMConst2SVFConst.end() && "SVF Global not found!");
227
+ assert(SVFUtil::isa<SVFGlobalValue>(it->second) && "not a SVFGlobal type!");
228
+ return SVFUtil::cast<SVFGlobalValue>(it->second);
229
+ }
230
+
231
+ SVFConstantData* getSVFConstantData(const ConstantData* cd);
232
+ SVFConstant* getOtherSVFConstant(const Constant* oc);
233
+
234
+ SVFOtherValue* getSVFOtherValue(const Value* ov);
235
+
236
+ /// Get the corresponding Function based on its name
237
+ inline const SVFFunction* getSVFFunction(const std::string& name)
238
+ {
239
+ Function* fun = nullptr;
240
+
241
+ for (u32_t i = 0; i < llvmModuleSet->getModuleNum(); ++i)
242
+ {
243
+ Module* mod = llvmModuleSet->getModule(i);
244
+ fun = mod->getFunction(name);
245
+ if (fun)
246
+ {
247
+ return llvmModuleSet->getSVFFunction(fun);
248
+ }
249
+ }
250
+ return nullptr;
251
+ }
252
+
253
+ bool hasDefinition(const Function* fun) const
254
+ {
255
+ assert(fun->isDeclaration() && "not a function declaration?");
256
+ FunDeclToDefMapTy::const_iterator it = FunDeclToDefMap.find(fun);
257
+ return it != FunDeclToDefMap.end();
258
+ }
259
+
260
+ const Function* getDefinition(const Function* fun) const
261
+ {
262
+ assert(fun->isDeclaration() && "not a function declaration?");
263
+ FunDeclToDefMapTy::const_iterator it = FunDeclToDefMap.find(fun);
264
+ assert(it != FunDeclToDefMap.end() && "has no definition?");
265
+ return it->second;
266
+ }
267
+
268
+ bool hasDeclaration(const Function* fun) const
269
+ {
270
+ if(fun->isDeclaration() && !hasDefinition(fun))
271
+ return false;
272
+
273
+ const Function* funDef = fun;
274
+ if(fun->isDeclaration() && hasDefinition(fun))
275
+ funDef = getDefinition(fun);
276
+
277
+ FunDefToDeclsMapTy::const_iterator it = FunDefToDeclsMap.find(funDef);
278
+ return it != FunDefToDeclsMap.end();
279
+ }
280
+
281
+ const FunctionSetType& getDeclaration(const Function* fun) const
282
+ {
283
+ const Function* funDef = fun;
284
+ if(fun->isDeclaration() && hasDefinition(fun))
285
+ funDef = getDefinition(fun);
286
+
287
+ FunDefToDeclsMapTy::const_iterator it = FunDefToDeclsMap.find(funDef);
288
+ assert(it != FunDefToDeclsMap.end() && "does not have a function definition (body)?");
289
+ return it->second;
290
+ }
291
+
292
+ /// Global to rep
293
+ bool hasGlobalRep(const GlobalVariable* val) const
294
+ {
295
+ GlobalDefToRepMapTy::const_iterator it = GlobalDefToRepMap.find(val);
296
+ return it != GlobalDefToRepMap.end();
297
+ }
298
+
299
+ GlobalVariable *getGlobalRep(const GlobalVariable* val) const
300
+ {
301
+ GlobalDefToRepMapTy::const_iterator it = GlobalDefToRepMap.find(val);
302
+ assert(it != GlobalDefToRepMap.end() && "has no rep?");
303
+ return it->second;
304
+ }
305
+
306
+
307
+ Module* getMainLLVMModule() const
308
+ {
309
+ return getModule(0);
310
+ }
311
+
312
+ LLVMContext& getContext() const
313
+ {
314
+ assert(!empty() && "empty LLVM module!!");
315
+ return getMainLLVMModule()->getContext();
316
+ }
317
+
318
+ bool empty() const
319
+ {
320
+ return getModuleNum() == 0;
321
+ }
322
+
323
+ /// Get or create SVFType and typeinfo
324
+ SVFType* getSVFType(const Type* T);
325
+ /// Get LLVM Type
326
+ const Type* getLLVMType(const SVFType* T) const;
327
+
328
+ private:
329
+ /// Create SVFTypes
330
+ SVFType* addSVFTypeInfo(const Type* t);
331
+ /// Collect a type info
332
+ StInfo* collectTypeInfo(const Type* ty);
333
+ /// Collect the struct info; nf contains the number of fields after flattening
334
+ StInfo* collectStructInfo(const StructType *T, u32_t& nf);
335
+ /// Collect the array info
336
+ StInfo* collectArrayInfo(const ArrayType* T);
337
+ /// Collect simple type (non-aggregate) info
338
+ StInfo* collectSimpleTypeInfo(const Type* T);
339
+
340
+ std::vector<const Function*> getLLVMGlobalFunctions(const GlobalVariable* global);
341
+
342
+ void loadModules(const std::vector<std::string>& moduleNameVec);
343
+ void addSVFMain();
344
+
345
+ void createSVFDataStructure();
346
+ void initSVFFunction();
347
+ void initSVFBasicBlock(const Function* func);
348
+ void initDomTree(SVFFunction* func, const Function* f);
349
+ void setValueAttr(const Value* val, SVFValue* value);
350
+ void buildFunToFunMap();
351
+ void buildGlobalDefToRepMap();
352
+ /// Invoke llvm passes to modify module
353
+ void prePassSchedule();
354
+ bool preProcessed;
355
+ void build_symbol_table() const;
356
+ };
357
+
358
+ } // End namespace SVF
359
+
360
+ #endif /* INCLUDE_SVF_FE_LLVMMODULE_H_ */