svf-lib 1.0.2238 → 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,594 @@
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 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
+ * 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 "SVF-LLVM/SVFLLVMValue.h"
35
+ #include "SVF-LLVM/SVFModule.h"
36
+ #include "Util/Options.h"
37
+ #include "Graphs/BasicBlockG.h"
38
+
39
+ namespace SVF
40
+ {
41
+
42
+ class ObjTypeInference;
43
+
44
+ class LLVMModuleSet
45
+ {
46
+ friend class SVFIRBuilder;
47
+ friend class ICFGBuilder;
48
+ friend class SymbolTableBuilder;
49
+
50
+ public:
51
+
52
+ typedef std::vector<const Function*> FunctionSetType;
53
+ typedef Map<const Function*, const Function*> FunDeclToDefMapTy;
54
+ typedef Map<const Function*, FunctionSetType> FunDefToDeclsMapTy;
55
+ typedef Map<const GlobalVariable*, GlobalVariable*> GlobalDefToRepMapTy;
56
+
57
+ typedef Map<const Function*, SVFFunction*> LLVMFun2SVFFunMap;
58
+ typedef Map<const Function*, FunObjVar*> LLVMFun2FunObjVarMap;
59
+ typedef Map<const BasicBlock*, SVFBasicBlock*> LLVMBB2SVFBBMap;
60
+ typedef Map<const Instruction*, SVFLLVMValue*> LLVMInst2SVFInstMap;
61
+ typedef Map<const Argument*, SVFLLVMValue*> LLVMArgument2SVFArgumentMap;
62
+ typedef Map<const Constant*, SVFLLVMValue*> LLVMConst2SVFConstMap;
63
+ typedef Map<const Value*, SVFLLVMValue*> LLVMValue2SVFOtherValueMap;
64
+ typedef Map<const SVFLLVMValue*, const Value*> SVFValue2LLVMValueMap;
65
+ typedef Map<const SVFValue*, const Value*> SVFBaseNode2LLVMValueMap;
66
+ typedef Map<const Type*, SVFType*> LLVMType2SVFTypeMap;
67
+ typedef Map<const Type*, StInfo*> Type2TypeInfoMap;
68
+ typedef Map<std::string, std::vector<std::string>> Fun2AnnoMap;
69
+
70
+ typedef Map<const Instruction*, CallICFGNode *> CSToCallNodeMapTy;
71
+ typedef Map<const Instruction*, RetICFGNode *> CSToRetNodeMapTy;
72
+ typedef Map<const Instruction*, IntraICFGNode *> InstToBlockNodeMapTy;
73
+ typedef Map<const Function*, FunEntryICFGNode *> FunToFunEntryNodeMapTy;
74
+ typedef Map<const Function*, FunExitICFGNode *> FunToFunExitNodeMapTy;
75
+
76
+ /// llvm value to sym id map
77
+ /// local (%) and global (@) identifiers are pointer types which have a value node id.
78
+ typedef OrderedMap<const SVFLLVMValue*, NodeID> ValueToIDMapTy;
79
+
80
+ typedef OrderedMap<const SVFFunction*, NodeID> FunToIDMapTy;
81
+
82
+
83
+ private:
84
+ static LLVMModuleSet* llvmModuleSet;
85
+ static bool preProcessed;
86
+ SVFIR* svfir;
87
+ SVFModule* svfModule; ///< Borrowed from singleton SVFModule::svfModule
88
+ std::unique_ptr<LLVMContext> owned_ctx;
89
+ std::vector<std::unique_ptr<Module>> owned_modules;
90
+ std::vector<std::reference_wrapper<Module>> modules;
91
+
92
+ /// Record some "sse_" function declarations used in other ext function definition, e.g., svf_ext_foo(), and svf_ext_foo() used in app functions
93
+ FunctionSetType ExtFuncsVec;
94
+ /// Record annotations of function in extapi.bc
95
+ Fun2AnnoMap ExtFun2Annotations;
96
+
97
+ // Map SVFFunction to its annotations
98
+ Map<const SVFFunction*, std::vector<std::string>> func2Annotations;
99
+
100
+ /// Global definition to a rep definition map
101
+ GlobalDefToRepMapTy GlobalDefToRepMap;
102
+
103
+ LLVMFun2SVFFunMap LLVMFunc2SVFFunc; ///< Map an LLVM Function to an SVF Function
104
+ LLVMFun2FunObjVarMap LLVMFun2FunObjVar; ///< Map an LLVM Function to an SVF Funobjvar
105
+ LLVMBB2SVFBBMap LLVMBB2SVFBB;
106
+ LLVMInst2SVFInstMap LLVMInst2SVFInst;
107
+ LLVMArgument2SVFArgumentMap LLVMArgument2SVFArgument;
108
+ LLVMConst2SVFConstMap LLVMConst2SVFConst;
109
+ LLVMValue2SVFOtherValueMap LLVMValue2SVFOtherValue;
110
+ SVFValue2LLVMValueMap SVFValue2LLVMValue;
111
+ LLVMType2SVFTypeMap LLVMType2SVFType;
112
+ Type2TypeInfoMap Type2TypeInfo;
113
+ ObjTypeInference* typeInference;
114
+
115
+ SVFBaseNode2LLVMValueMap SVFBaseNode2LLVMValue;
116
+ CSToCallNodeMapTy CSToCallNodeMap; ///< map a callsite to its CallICFGNode
117
+ CSToRetNodeMapTy CSToRetNodeMap; ///< map a callsite to its RetICFGNode
118
+ InstToBlockNodeMapTy InstToBlockNodeMap; ///< map a basic block to its ICFGNode
119
+ FunToFunEntryNodeMapTy FunToFunEntryNodeMap; ///< map a function to its FunExitICFGNode
120
+ FunToFunExitNodeMapTy FunToFunExitNodeMap; ///< map a function to its FunEntryICFGNode
121
+
122
+ Map<const Function*, DominatorTree> FunToDominatorTree;
123
+
124
+ ValueToIDMapTy valSymMap; ///< map a value to its sym id
125
+ ValueToIDMapTy objSymMap; ///< map a obj reference to its sym id
126
+ FunToIDMapTy returnSymMap; ///< return map
127
+ FunToIDMapTy varargSymMap; ///< vararg map
128
+
129
+ /// Constructor
130
+ LLVMModuleSet();
131
+
132
+ void build();
133
+
134
+ public:
135
+ ~LLVMModuleSet();
136
+
137
+ static inline LLVMModuleSet* getLLVMModuleSet()
138
+ {
139
+ if (!llvmModuleSet)
140
+ llvmModuleSet = new LLVMModuleSet;
141
+ return llvmModuleSet;
142
+ }
143
+
144
+ static void releaseLLVMModuleSet()
145
+ {
146
+ delete llvmModuleSet;
147
+ llvmModuleSet = nullptr;
148
+ }
149
+
150
+ // Build an SVF module from a given LLVM Module instance (for use e.g. in a LLVM pass)
151
+ static SVFModule* buildSVFModule(Module& mod);
152
+
153
+ // Build an SVF module from the bitcode files provided in `moduleNameVec`
154
+ static SVFModule* buildSVFModule(const std::vector<std::string>& moduleNameVec);
155
+
156
+ inline SVFModule* getSVFModule()
157
+ {
158
+ return svfModule;
159
+ }
160
+
161
+ static void preProcessBCs(std::vector<std::string>& moduleNameVec);
162
+
163
+ u32_t getModuleNum() const
164
+ {
165
+ return modules.size();
166
+ }
167
+
168
+ const std::vector<std::reference_wrapper<Module>>& getLLVMModules() const
169
+ {
170
+ return modules;
171
+ }
172
+
173
+ Module *getModule(u32_t idx) const
174
+ {
175
+ return &getModuleRef(idx);
176
+ }
177
+
178
+ Module &getModuleRef(u32_t idx) const
179
+ {
180
+ assert(idx < getModuleNum() && "Out of range.");
181
+ return modules[idx];
182
+ }
183
+
184
+ // Dump modules to files
185
+ void dumpModulesToFile(const std::string& suffix);
186
+
187
+ public:
188
+
189
+ inline u32_t getValueNodeNum() const
190
+ {
191
+ return valSymMap.size();
192
+ }
193
+
194
+ inline u32_t getObjNodeNum() const
195
+ {
196
+ return objSymMap.size();
197
+ }
198
+
199
+ inline ValueToIDMapTy& valSyms()
200
+ {
201
+ return valSymMap;
202
+ }
203
+
204
+ inline ValueToIDMapTy& objSyms()
205
+ {
206
+ return objSymMap;
207
+ }
208
+
209
+ /// Get SVFIR Node according to LLVM value
210
+ ///getNode - Return the node corresponding to the specified pointer.
211
+ NodeID getValueNode(const SVFLLVMValue* V);
212
+
213
+ bool hasValueNode(const SVFLLVMValue* V);
214
+
215
+ /// getObject - Return the obj node id refer to the memory object for the
216
+ /// specified global, heap or alloca instruction according to llvm value.
217
+ NodeID getObjectNode(const SVFLLVMValue* V);
218
+
219
+ void dumpSymTable();
220
+
221
+ public:
222
+ inline void addFunctionMap(const Function* func, SVFFunction* svfFunc)
223
+ {
224
+ LLVMFunc2SVFFunc[func] = svfFunc;
225
+ setValueAttr(func,svfFunc);
226
+ }
227
+
228
+ // create a SVFBasicBlock according to LLVM BasicBlock, then add it to SVFFunction's BasicBlockGraph
229
+ inline void addBasicBlock(SVFFunction* fun, const BasicBlock* bb)
230
+ {
231
+ SVFBasicBlock* svfBB = fun->getBasicBlockGraph()->addBasicBlock(bb->getName().str());
232
+ LLVMBB2SVFBB[bb] = svfBB;
233
+ SVFBaseNode2LLVMValue[svfBB] = bb;
234
+ }
235
+
236
+ inline void addInstructionMap(const Instruction* inst, SVFLLVMValue* svfInst)
237
+ {
238
+ LLVMInst2SVFInst[inst] = svfInst;
239
+ setValueAttr(inst,svfInst);
240
+ }
241
+ inline void addInstructionMap(const Instruction* inst, CallICFGNode* svfInst)
242
+ {
243
+ CSToCallNodeMap[inst] = svfInst;
244
+ addToSVFVar2LLVMValueMap(inst, svfInst);
245
+ }
246
+ inline void addInstructionMap(const Instruction* inst, RetICFGNode* svfInst)
247
+ {
248
+ CSToRetNodeMap[inst] = svfInst;
249
+ addToSVFVar2LLVMValueMap(inst, svfInst);
250
+ }
251
+ inline void addInstructionMap(const Instruction* inst, IntraICFGNode* svfInst)
252
+ {
253
+ InstToBlockNodeMap[inst] = svfInst;
254
+ addToSVFVar2LLVMValueMap(inst, svfInst);
255
+ }
256
+
257
+ inline void addArgumentMap(const Argument* arg, SVFLLVMValue* svfArg)
258
+ {
259
+ LLVMArgument2SVFArgument[arg] = svfArg;
260
+ setValueAttr(arg,svfArg);
261
+ }
262
+ inline void addGlobalValueMap(const GlobalValue* glob, SVFLLVMValue* svfglob)
263
+ {
264
+ if (auto glob_var = llvm::dyn_cast<llvm::GlobalVariable>(glob);
265
+ hasGlobalRep(glob_var))
266
+ {
267
+ glob = getGlobalRep(glob_var);
268
+ }
269
+ LLVMConst2SVFConst[glob] = svfglob;
270
+ setValueAttr(glob,svfglob);
271
+ }
272
+ inline void addConstantDataMap(const ConstantData* cd, SVFLLVMValue* svfcd)
273
+ {
274
+ LLVMConst2SVFConst[cd] = svfcd;
275
+ setValueAttr(cd,svfcd);
276
+ }
277
+ inline void addOtherConstantMap(const Constant* cons, SVFLLVMValue* svfcons)
278
+ {
279
+ LLVMConst2SVFConst[cons] = svfcons;
280
+ setValueAttr(cons,svfcons);
281
+ }
282
+ inline void addOtherValueMap(const Value* ov, SVFLLVMValue* svfov)
283
+ {
284
+ LLVMValue2SVFOtherValue[ov] = svfov;
285
+ setValueAttr(ov,svfov);
286
+ }
287
+
288
+ SVFLLVMValue* getSVFValue(const Value* value);
289
+
290
+ const Value* getLLVMValue(const SVFLLVMValue* value) const
291
+ {
292
+ SVFValue2LLVMValueMap::const_iterator it = SVFValue2LLVMValue.find(value);
293
+ assert(it!=SVFValue2LLVMValue.end() && "can't find corresponding llvm value!");
294
+ return it->second;
295
+ }
296
+
297
+ const Value* getLLVMValue(const SVFValue* value) const
298
+ {
299
+ SVFBaseNode2LLVMValueMap ::const_iterator it = SVFBaseNode2LLVMValue.find(value);
300
+ assert(it != SVFBaseNode2LLVMValue.end() && "can't find corresponding llvm value!");
301
+ return it->second;
302
+ }
303
+
304
+ inline SVFFunction* getSVFFunction(const Function* fun) const
305
+ {
306
+ LLVMFun2SVFFunMap::const_iterator it = LLVMFunc2SVFFunc.find(fun);
307
+ assert(it!=LLVMFunc2SVFFunc.end() && "SVF Function not found!");
308
+ return it->second;
309
+ }
310
+
311
+ inline const FunObjVar* getFunObjVar(const Function* fun) const
312
+ {
313
+ LLVMFun2FunObjVarMap::const_iterator it = LLVMFun2FunObjVar.find(fun);
314
+ assert(it!=LLVMFun2FunObjVar.end() && "SVF Function not found!");
315
+ return it->second;
316
+ }
317
+
318
+ inline FunToIDMapTy& retSyms()
319
+ {
320
+ return returnSymMap;
321
+ }
322
+
323
+ inline FunToIDMapTy& varargSyms()
324
+ {
325
+ return varargSymMap;
326
+ }
327
+
328
+ NodeID getReturnNode(const SVFFunction *func) const
329
+ {
330
+ FunToIDMapTy::const_iterator iter = returnSymMap.find(func);
331
+ assert(iter!=returnSymMap.end() && "ret sym not found");
332
+ return iter->second;
333
+ }
334
+
335
+ NodeID getVarargNode(const SVFFunction *func) const
336
+ {
337
+ FunToIDMapTy::const_iterator iter = varargSymMap.find(func);
338
+ assert(iter!=varargSymMap.end() && "vararg sym not found");
339
+ return iter->second;
340
+ }
341
+
342
+ SVFBasicBlock* getSVFBasicBlock(const BasicBlock* bb)
343
+ {
344
+ LLVMBB2SVFBBMap::const_iterator it = LLVMBB2SVFBB.find(bb);
345
+ assert(it!=LLVMBB2SVFBB.end() && "SVF BasicBlock not found!");
346
+ return it->second;
347
+ }
348
+
349
+ inline SVFLLVMValue* getSVFInstruction(const Instruction* inst) const
350
+ {
351
+ LLVMInst2SVFInstMap::const_iterator it = LLVMInst2SVFInst.find(inst);
352
+ assert(it!=LLVMInst2SVFInst.end() && "SVF Instruction not found!");
353
+ return it->second;
354
+ }
355
+
356
+ inline SVFLLVMValue* getSVFArgument(const Argument* arg) const
357
+ {
358
+ LLVMArgument2SVFArgumentMap::const_iterator it = LLVMArgument2SVFArgument.find(arg);
359
+ assert(it!=LLVMArgument2SVFArgument.end() && "SVF Argument not found!");
360
+ return it->second;
361
+ }
362
+
363
+ inline SVFLLVMValue* getSVFGlobalValue(const GlobalValue* g) const
364
+ {
365
+ if (auto glob_var = llvm::dyn_cast<llvm::GlobalVariable>(g);
366
+ hasGlobalRep(glob_var))
367
+ {
368
+ g = getGlobalRep(glob_var);
369
+ }
370
+ LLVMConst2SVFConstMap::const_iterator it = LLVMConst2SVFConst.find(g);
371
+ assert(it!=LLVMConst2SVFConst.end() && "SVF Global not found!");
372
+ return it->second;
373
+ }
374
+
375
+ SVFLLVMValue* getSVFConstantData(const ConstantData* cd);
376
+ SVFLLVMValue* getOtherSVFConstant(const Constant* oc);
377
+
378
+ SVFLLVMValue* getSVFOtherValue(const Value* ov);
379
+
380
+ /// Get the corresponding Function based on its name
381
+ inline const SVFFunction* getSVFFunction(const std::string& name)
382
+ {
383
+ Function* fun = nullptr;
384
+
385
+ for (u32_t i = 0; i < llvmModuleSet->getModuleNum(); ++i)
386
+ {
387
+ Module* mod = llvmModuleSet->getModule(i);
388
+ fun = mod->getFunction(name);
389
+ if (fun)
390
+ {
391
+ return llvmModuleSet->getSVFFunction(fun);
392
+ }
393
+ }
394
+ return nullptr;
395
+ }
396
+
397
+ /// Get the corresponding Function based on its name
398
+ const FunObjVar* getFunObjVar(const std::string& name);
399
+
400
+ ICFGNode* getICFGNode(const Instruction* inst);
401
+
402
+ bool hasICFGNode(const Instruction* inst);
403
+
404
+ /// get a call node
405
+ CallICFGNode* getCallICFGNode(const Instruction* cs);
406
+ /// get a return node
407
+ RetICFGNode* getRetICFGNode(const Instruction* cs);
408
+ /// get a intra node
409
+ IntraICFGNode* getIntraICFGNode(const Instruction* inst);
410
+
411
+ /// Add a function entry node
412
+ inline FunEntryICFGNode* getFunEntryICFGNode(const Function* fun)
413
+ {
414
+ FunEntryICFGNode* b = getFunEntryBlock(fun);
415
+ assert(b && "Function entry not created?");
416
+ return b;
417
+ }
418
+ /// Add a function exit node
419
+ inline FunExitICFGNode* getFunExitICFGNode(const Function* fun)
420
+ {
421
+ FunExitICFGNode* b = getFunExitBlock(fun);
422
+ assert(b && "Function exit not created?");
423
+ return b;
424
+ }
425
+
426
+
427
+ /// Global to rep
428
+ bool hasGlobalRep(const GlobalVariable* val) const
429
+ {
430
+ GlobalDefToRepMapTy::const_iterator it = GlobalDefToRepMap.find(val);
431
+ return it != GlobalDefToRepMap.end();
432
+ }
433
+
434
+ GlobalVariable *getGlobalRep(const GlobalVariable* val) const
435
+ {
436
+ GlobalDefToRepMapTy::const_iterator it = GlobalDefToRepMap.find(val);
437
+ assert(it != GlobalDefToRepMap.end() && "has no rep?");
438
+ return it->second;
439
+ }
440
+
441
+ Module* getMainLLVMModule() const
442
+ {
443
+ assert(!empty() && "empty LLVM module!!");
444
+ for (size_t i = 0; i < getModuleNum(); ++i)
445
+ {
446
+ Module& module = getModuleRef(i);
447
+ if (module.getName().str() != ExtAPI::getExtAPI()->getExtBcPath())
448
+ {
449
+ return &module;
450
+ }
451
+ }
452
+ assert(false && "no main module found!");
453
+ return nullptr;
454
+ }
455
+
456
+ LLVMContext& getContext() const
457
+ {
458
+ assert(!empty() && "empty LLVM module!!");
459
+ return getMainLLVMModule()->getContext();
460
+ }
461
+
462
+ bool empty() const
463
+ {
464
+ return getModuleNum() == 0;
465
+ }
466
+
467
+ /// Get or create SVFType and typeinfo
468
+ SVFType* getSVFType(const Type* T);
469
+ /// Get LLVM Type
470
+ const Type* getLLVMType(const SVFType* T) const;
471
+
472
+ ObjTypeInference* getTypeInference();
473
+
474
+ DominatorTree& getDomTree(const Function* fun);
475
+
476
+ std::string getExtFuncAnnotation(const SVFFunction* fun, const std::string& funcAnnotation);
477
+
478
+ const std::vector<std::string>& getExtFuncAnnotations(const SVFFunction* fun);
479
+
480
+ // Does (F) have some annotation?
481
+ bool hasExtFuncAnnotation(const SVFFunction* fun, const std::string& funcAnnotation);
482
+
483
+ // Does (F) have a static var X (unavailable to us) that its return points to?
484
+ bool has_static(const SVFFunction *F);
485
+
486
+ // Does (F) have a memcpy_like operation?
487
+ bool is_memcpy(const SVFFunction *F);
488
+
489
+ // Does (F) have a memset_like operation?
490
+ bool is_memset(const SVFFunction *F);
491
+
492
+ // Does (F) allocate a new object and return it?
493
+ bool is_alloc(const SVFFunction *F);
494
+
495
+ // Does (F) allocate a new object and assign it to one of its arguments?
496
+ bool is_arg_alloc(const SVFFunction *F);
497
+
498
+ // Does (F) allocate a new stack object and return it?
499
+ bool is_alloc_stack_ret(const SVFFunction *F);
500
+
501
+ // Get the position of argument which holds the new object
502
+ s32_t get_alloc_arg_pos(const SVFFunction *F);
503
+
504
+ // Does (F) reallocate a new object?
505
+ bool is_realloc(const SVFFunction *F);
506
+
507
+ // Should (F) be considered "external" (either not defined in the program
508
+ // or a user-defined version of a known alloc or no-op)?
509
+ bool is_ext(const SVFFunction *F);
510
+
511
+ // Set the annotation of (F)
512
+ void setExtFuncAnnotations(const SVFFunction* fun, const std::vector<std::string>& funcAnnotations);
513
+
514
+ private:
515
+ /// Create SVFTypes
516
+ SVFType* addSVFTypeInfo(const Type* t);
517
+ /// Collect a type info
518
+ StInfo* collectTypeInfo(const Type* ty);
519
+ /// Collect the struct info and set the number of fields after flattening
520
+ StInfo* collectStructInfo(const StructType* structTy, u32_t& numFields);
521
+ /// Collect the array info
522
+ StInfo* collectArrayInfo(const ArrayType* T);
523
+ /// Collect simple type (non-aggregate) info
524
+ StInfo* collectSimpleTypeInfo(const Type* T);
525
+
526
+ std::vector<const Function*> getLLVMGlobalFunctions(const GlobalVariable* global);
527
+
528
+ void loadModules(const std::vector<std::string>& moduleNameVec);
529
+ // Loads ExtAPI bitcode file; uses LLVMContext made while loading module bitcode files or from Module
530
+ void loadExtAPIModules();
531
+ void addSVFMain();
532
+
533
+ void createSVFDataStructure();
534
+ void createSVFFunction(const Function* func);
535
+ void initSVFFunction();
536
+ void initSVFBasicBlock(const Function* func);
537
+ void initDomTree(SVFFunction* func, const Function* f);
538
+ void setValueAttr(const Value* val, SVFLLVMValue* value);
539
+ void addToSVFVar2LLVMValueMap(const Value* val, SVFValue* svfBaseNode);
540
+ void buildFunToFunMap();
541
+ void buildGlobalDefToRepMap();
542
+ /// Invoke llvm passes to modify module
543
+ void prePassSchedule();
544
+ void buildSymbolTable() const;
545
+ void collectExtFunAnnotations(const Module* mod);
546
+
547
+ /// Get/Add a call node
548
+ inline CallICFGNode* getCallBlock(const Instruction* cs)
549
+ {
550
+ CSToCallNodeMapTy::const_iterator it = CSToCallNodeMap.find(cs);
551
+ if (it == CSToCallNodeMap.end())
552
+ return nullptr;
553
+ return it->second;
554
+ }
555
+
556
+ /// Get/Add a return node
557
+ inline RetICFGNode* getRetBlock(const Instruction* cs)
558
+ {
559
+ CSToRetNodeMapTy::const_iterator it = CSToRetNodeMap.find(cs);
560
+ if (it == CSToRetNodeMap.end())
561
+ return nullptr;
562
+ return it->second;
563
+ }
564
+
565
+ inline IntraICFGNode* getIntraBlock(const Instruction* inst)
566
+ {
567
+ InstToBlockNodeMapTy::const_iterator it = InstToBlockNodeMap.find(inst);
568
+ if (it == InstToBlockNodeMap.end())
569
+ return nullptr;
570
+ return it->second;
571
+ }
572
+
573
+ /// Get/Add a function entry node
574
+ inline FunEntryICFGNode* getFunEntryBlock(const Function* fun)
575
+ {
576
+ FunToFunEntryNodeMapTy::const_iterator it = FunToFunEntryNodeMap.find(fun);
577
+ if (it == FunToFunEntryNodeMap.end())
578
+ return nullptr;
579
+ return it->second;
580
+ }
581
+
582
+ /// Get/Add a function exit node
583
+ inline FunExitICFGNode* getFunExitBlock(const Function* fun)
584
+ {
585
+ FunToFunExitNodeMapTy::const_iterator it = FunToFunExitNodeMap.find(fun);
586
+ if (it == FunToFunExitNodeMap.end())
587
+ return nullptr;
588
+ return it->second;
589
+ }
590
+ };
591
+
592
+ } // End namespace SVF
593
+
594
+ #endif /* INCLUDE_SVF_FE_LLVMMODULE_H_ */