svf-tools 1.0.1057 → 1.0.1059

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 (44) hide show
  1. package/package.json +1 -1
  2. package/svf/include/Graphs/CHG.h +0 -1
  3. package/svf/include/Graphs/CallGraph.h +0 -1
  4. package/svf/include/Graphs/ThreadCallGraph.h +0 -1
  5. package/svf/include/MTA/MTA.h +0 -1
  6. package/svf/include/MemoryModel/PointerAnalysis.h +0 -1
  7. package/svf/include/SVFIR/SVFVariables.h +11 -3
  8. package/svf/include/Util/CallGraphBuilder.h +0 -1
  9. package/svf/include/Util/ThreadAPI.h +0 -1
  10. package/svf/include/WPA/Andersen.h +0 -1
  11. package/svf/include/WPA/FlowSensitive.h +0 -1
  12. package/svf/include/WPA/VersionedFlowSensitive.h +0 -1
  13. package/svf/include/WPA/WPAPass.h +0 -1
  14. package/svf/lib/SVFIR/SVFValue.cpp +9 -7
  15. package/svf/lib/SVFIR/SVFVariables.cpp +1 -1
  16. package/svf-llvm/include/SVF-LLVM/BreakConstantExpr.h +0 -1
  17. package/svf-llvm/include/SVF-LLVM/CppUtil.h +1 -1
  18. package/svf-llvm/include/SVF-LLVM/DCHG.h +3 -7
  19. package/svf-llvm/include/SVF-LLVM/LLVMModule.h +67 -139
  20. package/svf-llvm/include/SVF-LLVM/LLVMUtil.h +4 -9
  21. package/svf-llvm/include/SVF-LLVM/ObjTypeInference.h +0 -1
  22. package/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h +21 -18
  23. package/svf-llvm/include/SVF-LLVM/SymbolTableBuilder.h +1 -1
  24. package/svf-llvm/lib/BreakConstantExpr.cpp +2 -0
  25. package/svf-llvm/lib/CHGBuilder.cpp +1 -2
  26. package/svf-llvm/lib/DCHG.cpp +3 -4
  27. package/svf-llvm/lib/ICFGBuilder.cpp +2 -3
  28. package/svf-llvm/lib/LLVMModule.cpp +46 -342
  29. package/svf-llvm/lib/LLVMUtil.cpp +11 -42
  30. package/svf-llvm/lib/ObjTypeInference.cpp +6 -5
  31. package/svf-llvm/lib/SVFIRBuilder.cpp +258 -143
  32. package/svf-llvm/lib/SVFIRExtAPI.cpp +19 -21
  33. package/svf-llvm/lib/SymbolTableBuilder.cpp +14 -24
  34. package/svf-llvm/tools/AE/ae.cpp +2 -2
  35. package/svf-llvm/tools/CFL/cfl.cpp +2 -2
  36. package/svf-llvm/tools/DDA/dda.cpp +2 -2
  37. package/svf-llvm/tools/Example/svf-ex.cpp +2 -2
  38. package/svf-llvm/tools/MTA/mta.cpp +2 -2
  39. package/svf-llvm/tools/SABER/saber.cpp +2 -2
  40. package/svf-llvm/tools/WPA/wpa.cpp +2 -2
  41. package/svf-llvm/include/SVF-LLVM/SVFLLVMValue.h +0 -387
  42. package/svf-llvm/include/SVF-LLVM/SVFModule.h +0 -186
  43. package/svf-llvm/lib/SVFLLVMValue.cpp +0 -66
  44. package/svf-llvm/lib/SVFModule.cpp +0 -77
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.1057",
3
+ "version": "1.0.1059",
4
4
  "description": "* <b>[TypeClone](https://github.com/SVF-tools/SVF/wiki/TypeClone) published in our [ECOOP paper](https://yuleisui.github.io/publications/ecoop20.pdf) is now available in SVF </b> * <b>SVF now uses a single script for its build. Just type [`source ./build.sh`](https://github.com/SVF-tools/SVF/blob/master/build.sh) in your terminal, that's it!</b> * <b>SVF now supports LLVM-10.0.0! </b> * <b>We thank [bsauce](https://github.com/bsauce) for writing a user manual of SVF ([link1](https://www.jianshu.com/p/068a08ec749c) and [link2](https://www.jianshu.com/p/777c30d4240e)) in Chinese </b> * <b>SVF now supports LLVM-9.0.0 (Thank [Byoungyoung Lee](https://github.com/SVF-tools/SVF/issues/142) for his help!). </b> * <b>SVF now supports a set of [field-sensitive pointer analyses](https://yuleisui.github.io/publications/sas2019a.pdf). </b> * <b>[Use SVF as an external lib](https://github.com/SVF-tools/SVF/wiki/Using-SVF-as-a-lib-in-your-own-tool) for your own project (Contributed by [Hongxu Chen](https://github.com/HongxuChen)). </b> * <b>SVF now supports LLVM-7.0.0. </b> * <b>SVF now supports Docker. [Try SVF in Docker](https://github.com/SVF-tools/SVF/wiki/Try-SVF-in-Docker)! </b> * <b>SVF now supports [LLVM-6.0.0](https://github.com/svf-tools/SVF/pull/38) (Contributed by [Jack Anthony](https://github.com/jackanth)). </b> * <b>SVF now supports [LLVM-4.0.0](https://github.com/svf-tools/SVF/pull/23) (Contributed by Jared Carlson. Thank [Jared](https://github.com/jcarlson23) and [Will](https://github.com/dtzWill) for their in-depth [discussions](https://github.com/svf-tools/SVF/pull/18) about updating SVF!) </b> * <b>SVF now supports analysis for C++ programs.</b> <br />",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -40,7 +40,6 @@
40
40
  namespace SVF
41
41
  {
42
42
 
43
- class SVFModule;
44
43
  class CHNode;
45
44
  class GlobalObjVar;
46
45
 
@@ -39,7 +39,6 @@ namespace SVF
39
39
  {
40
40
 
41
41
  class CallGraphNode;
42
- class SVFModule;
43
42
  class CallGraph;
44
43
 
45
44
 
@@ -35,7 +35,6 @@
35
35
  namespace SVF
36
36
  {
37
37
 
38
- class SVFModule;
39
38
  class ThreadAPI;
40
39
  class PointerAnalysis;
41
40
  /*!
@@ -48,7 +48,6 @@ class MTAStat;
48
48
  class TCT;
49
49
  class MHP;
50
50
  class LockAnalysis;
51
- class SVFModule;
52
51
 
53
52
  /*!
54
53
  * Base data race detector
@@ -48,7 +48,6 @@ namespace SVF
48
48
 
49
49
  class CommonCHGraph;
50
50
 
51
- class SVFModule;
52
51
  class ICFG;
53
52
  class PTAStat;
54
53
  /*
@@ -955,6 +955,7 @@ class FunObjVar : public BaseObjVar
955
955
  friend class SVFIRWriter;
956
956
  friend class SVFIRReader;
957
957
  friend class SVFIRBuilder;
958
+ friend class LLVMModuleSet;
958
959
 
959
960
  public:
960
961
  typedef SVFLoopAndDomInfo::BBSet BBSet;
@@ -976,7 +977,7 @@ private:
976
977
  const FunObjVar * realDefFun; /// the definition of a function across multiple modules
977
978
  BasicBlockGraph* bbGraph; /// the basic block graph of this function
978
979
  std::vector<const ArgValVar*> allArgs; /// all formal arguments of this function
979
- SVFBasicBlock *exitBlock; /// a 'single' basic block having no successors and containing return instruction in a function
980
+ const SVFBasicBlock *exitBlock; /// a 'single' basic block having no successors and containing return instruction in a function
980
981
 
981
982
 
982
983
  private:
@@ -1015,9 +1016,16 @@ public:
1015
1016
  /// Constructor
1016
1017
  FunObjVar(NodeID i, ObjTypeInfo* ti, const SVFType* svfType, const ICFGNode* node);
1017
1018
 
1019
+
1020
+ virtual ~FunObjVar()
1021
+ {
1022
+ delete loopAndDom;
1023
+ delete bbGraph;
1024
+ }
1025
+
1018
1026
  void initFunObjVar(bool decl, bool intrinc, bool addr, bool uncalled, bool notret, bool vararg, const SVFFunctionType *ft,
1019
1027
  SVFLoopAndDomInfo *ld, const FunObjVar *real, BasicBlockGraph *bbg,
1020
- const std::vector<const ArgValVar *> &allarg, SVFBasicBlock *exit);
1028
+ const std::vector<const ArgValVar *> &allarg, const SVFBasicBlock *exit);
1021
1029
 
1022
1030
  void setRelDefFun(const FunObjVar *real)
1023
1031
  {
@@ -1072,7 +1080,7 @@ public:
1072
1080
  return funcType->getReturnType();
1073
1081
  }
1074
1082
 
1075
- inline SVFLoopAndDomInfo* getLoopAndDomInfo()
1083
+ inline SVFLoopAndDomInfo* getLoopAndDomInfo() const
1076
1084
  {
1077
1085
  return loopAndDom;
1078
1086
  }
@@ -37,7 +37,6 @@ namespace SVF
37
37
  {
38
38
 
39
39
  class ICFG;
40
- class SVFModule;
41
40
  class CallGraph;
42
41
  class ThreadCallGraph;
43
42
 
@@ -35,7 +35,6 @@
35
35
  namespace SVF
36
36
  {
37
37
 
38
- class SVFModule;
39
38
  class ICFGNode;
40
39
  class CallICFGNode;
41
40
  class SVFVar;
@@ -45,7 +45,6 @@
45
45
  namespace SVF
46
46
  {
47
47
 
48
- class SVFModule;
49
48
 
50
49
  class ThreadCallGraph;
51
50
 
@@ -40,7 +40,6 @@ namespace SVF
40
40
  {
41
41
 
42
42
  class AndersenWaveDiff;
43
- class SVFModule;
44
43
 
45
44
  /*!
46
45
  * Flow sensitive whole program pointer analysis
@@ -24,7 +24,6 @@ namespace SVF
24
24
  {
25
25
 
26
26
  class AndersenWaveDiff;
27
- class SVFModule;
28
27
 
29
28
  /*!
30
29
  * Versioned flow sensitive whole program pointer analysis
@@ -42,7 +42,6 @@
42
42
  namespace SVF
43
43
  {
44
44
 
45
- class SVFModule;
46
45
  class SVFG;
47
46
 
48
47
  /*!
@@ -7,6 +7,15 @@
7
7
  using namespace SVF;
8
8
  using namespace SVFUtil;
9
9
 
10
+
11
+ __attribute__((weak))
12
+ const std::string SVFValue::valueOnlyToString() const
13
+ {
14
+ assert("SVFBaseNode::valueOnlyToString should be implemented or supported by fronted" && false);
15
+ abort();
16
+ }
17
+
18
+
10
19
  /// Add field (index and offset) with its corresponding type
11
20
  void StInfo::addFldWithType(u32_t fldIdx, const SVFType* type, u32_t elemIdx)
12
21
  {
@@ -149,11 +158,4 @@ bool SVFLoopAndDomInfo::isLoopHeader(const SVFBasicBlock* bb) const
149
158
  return blocks.front() == bb;
150
159
  }
151
160
  return false;
152
- }
153
-
154
- __attribute__((weak))
155
- const std::string SVFValue::valueOnlyToString() const
156
- {
157
- assert("SVFBaseNode::valueOnlyToString should be implemented or supported by fronted" && false);
158
- abort();
159
161
  }
@@ -445,7 +445,7 @@ FunObjVar::FunObjVar(NodeID i, ObjTypeInfo* ti, const SVFType* svfType, const IC
445
445
 
446
446
  void FunObjVar::initFunObjVar(bool decl, bool intrinc, bool addr, bool uncalled, bool notret, bool vararg,
447
447
  const SVFFunctionType *ft, SVFLoopAndDomInfo *ld, const FunObjVar *real, BasicBlockGraph *bbg,
448
- const std::vector<const ArgValVar *> &allarg, SVFBasicBlock *exit)
448
+ const std::vector<const ArgValVar *> &allarg, const SVFBasicBlock *exit)
449
449
  {
450
450
  isDecl = decl;
451
451
  intrinsic = intrinc;
@@ -15,7 +15,6 @@
15
15
  #ifndef BREAKCONSTANTGEPS_H
16
16
  #define BREAKCONSTANTGEPS_H
17
17
 
18
- #include "SVF-LLVM/SVFLLVMValue.h"
19
18
 
20
19
  namespace SVF
21
20
  {
@@ -30,8 +30,8 @@
30
30
  #ifndef CPPUtil_H_
31
31
  #define CPPUtil_H_
32
32
 
33
- #include "SVF-LLVM/SVFLLVMValue.h"
34
33
  #include "SVF-LLVM/BasicTypes.h"
34
+ #include "Util/GeneralType.h"
35
35
 
36
36
  namespace SVF
37
37
  {
@@ -17,14 +17,12 @@
17
17
  #include "Graphs/GenericGraph.h"
18
18
  #include "Graphs/CHG.h"
19
19
  #include "SVF-LLVM/BasicTypes.h"
20
- #include "SVF-LLVM/SVFModule.h"
21
20
  #include "Util/SVFUtil.h"
22
21
  #include "Util/WorkList.h"
23
22
 
24
23
  namespace SVF
25
24
  {
26
25
 
27
- class SVFModule;
28
26
  class DCHNode;
29
27
 
30
28
  class DCHEdge : public GenericEdge<DCHNode>
@@ -230,8 +228,8 @@ public:
230
228
  static bool isAgg(const DIType* t);
231
229
 
232
230
  public:
233
- DCHGraph(const SVFModule *svfMod)
234
- : svfModule(svfMod), numTypes(0) // vfID(0), buildingCHGTime(0) {
231
+ DCHGraph()
232
+ :numTypes(0) // vfID(0), buildingCHGTime(0) {
235
233
  {
236
234
  this->kind = DI;
237
235
  }
@@ -358,8 +356,6 @@ public:
358
356
  bool isFirstField(const DIType* f, const DIType* b);
359
357
 
360
358
  protected:
361
- /// SVF Module this CHG is built from.
362
- const SVFModule* svfModule;
363
359
  /// Whether this CHG is an extended CHG (first-field). Set by buildCHG.
364
360
  bool extended = false;
365
361
  /// Maps DITypes to their nodes.
@@ -394,7 +390,7 @@ private:
394
390
  void handleDISubroutineType(const DISubroutineType* subroutineType);
395
391
 
396
392
  /// Finds all defined virtual functions and attaches them to nodes.
397
- void buildVTables(const SVFModule& module);
393
+ void buildVTables();
398
394
 
399
395
  /// Returns a set of all children of type (CHA). Also gradually builds chaMap.
400
396
  const NodeBS& cha(const DIType* type, bool firstField);
@@ -31,8 +31,6 @@
31
31
  #define INCLUDE_SVF_FE_LLVMMODULE_H_
32
32
 
33
33
  #include "SVF-LLVM/BasicTypes.h"
34
- #include "SVF-LLVM/SVFLLVMValue.h"
35
- #include "SVF-LLVM/SVFModule.h"
36
34
  #include "Util/Options.h"
37
35
  #include "Graphs/BasicBlockG.h"
38
36
 
@@ -54,14 +52,8 @@ public:
54
52
  typedef Map<const Function*, FunctionSetType> FunDefToDeclsMapTy;
55
53
  typedef Map<const GlobalVariable*, GlobalVariable*> GlobalDefToRepMapTy;
56
54
 
57
- typedef Map<const Function*, SVFFunction*> LLVMFun2SVFFunMap;
58
55
  typedef Map<const Function*, FunObjVar*> LLVMFun2FunObjVarMap;
59
56
  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
57
  typedef Map<const SVFValue*, const Value*> SVFBaseNode2LLVMValueMap;
66
58
  typedef Map<const Type*, SVFType*> LLVMType2SVFTypeMap;
67
59
  typedef Map<const Type*, StInfo*> Type2TypeInfoMap;
@@ -75,16 +67,18 @@ public:
75
67
 
76
68
  /// llvm value to sym id map
77
69
  /// local (%) and global (@) identifiers are pointer types which have a value node id.
78
- typedef OrderedMap<const SVFLLVMValue*, NodeID> ValueToIDMapTy;
70
+ typedef OrderedMap<const Value*, NodeID> ValueToIDMapTy;
79
71
 
80
- typedef OrderedMap<const SVFFunction*, NodeID> FunToIDMapTy;
72
+ typedef OrderedMap<const Function*, NodeID> FunToIDMapTy;
81
73
 
74
+ typedef std::vector<const Function*> FunctionSet;
75
+ typedef Map<const Function*, const SVFBasicBlock*> FunToExitBBMap;
76
+ typedef Map<const Function*, const Function *> FunToRealDefFunMap;
82
77
 
83
78
  private:
84
79
  static LLVMModuleSet* llvmModuleSet;
85
80
  static bool preProcessed;
86
81
  SVFIR* svfir;
87
- SVFModule* svfModule; ///< Borrowed from singleton SVFModule::svfModule
88
82
  std::unique_ptr<LLVMContext> owned_ctx;
89
83
  std::vector<std::unique_ptr<Module>> owned_modules;
90
84
  std::vector<std::reference_wrapper<Module>> modules;
@@ -95,19 +89,13 @@ private:
95
89
  Fun2AnnoMap ExtFun2Annotations;
96
90
 
97
91
  // Map SVFFunction to its annotations
98
- Map<const SVFFunction*, std::vector<std::string>> func2Annotations;
92
+ Map<const Function*, std::vector<std::string>> func2Annotations;
99
93
 
100
94
  /// Global definition to a rep definition map
101
95
  GlobalDefToRepMapTy GlobalDefToRepMap;
102
96
 
103
- LLVMFun2SVFFunMap LLVMFunc2SVFFunc; ///< Map an LLVM Function to an SVF Function
104
97
  LLVMFun2FunObjVarMap LLVMFun2FunObjVar; ///< Map an LLVM Function to an SVF Funobjvar
105
98
  LLVMBB2SVFBBMap LLVMBB2SVFBB;
106
- LLVMInst2SVFInstMap LLVMInst2SVFInst;
107
- LLVMArgument2SVFArgumentMap LLVMArgument2SVFArgument;
108
- LLVMConst2SVFConstMap LLVMConst2SVFConst;
109
- LLVMValue2SVFOtherValueMap LLVMValue2SVFOtherValue;
110
- SVFValue2LLVMValueMap SVFValue2LLVMValue;
111
99
  LLVMType2SVFTypeMap LLVMType2SVFType;
112
100
  Type2TypeInfoMap Type2TypeInfo;
113
101
  ObjTypeInference* typeInference;
@@ -126,6 +114,10 @@ private:
126
114
  FunToIDMapTy returnSymMap; ///< return map
127
115
  FunToIDMapTy varargSymMap; ///< vararg map
128
116
 
117
+ FunctionSet funSet;
118
+ FunToExitBBMap funToExitBB;
119
+ FunToRealDefFunMap funToRealDefFun;
120
+
129
121
  /// Constructor
130
122
  LLVMModuleSet();
131
123
 
@@ -148,15 +140,10 @@ public:
148
140
  }
149
141
 
150
142
  // Build an SVF module from a given LLVM Module instance (for use e.g. in a LLVM pass)
151
- static SVFModule* buildSVFModule(Module& mod);
143
+ static void buildSVFModule(Module& mod);
152
144
 
153
145
  // 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
- }
146
+ static void buildSVFModule(const std::vector<std::string>& moduleNameVec);
160
147
 
161
148
  static void preProcessBCs(std::vector<std::string>& moduleNameVec);
162
149
 
@@ -186,6 +173,25 @@ public:
186
173
 
187
174
  public:
188
175
 
176
+ inline const SVFBasicBlock* getFunExitBB(const Function* fun) const
177
+ {
178
+ auto it = funToExitBB.find(fun);
179
+ if (it == funToExitBB.end()) return nullptr;
180
+ else return it->second;
181
+ }
182
+
183
+ inline const Function* getRealDefFun(const Function* fun) const
184
+ {
185
+ auto it = funToRealDefFun.find(fun);
186
+ if (it == funToRealDefFun.end()) return nullptr;
187
+ else return it->second;
188
+ }
189
+
190
+ inline const FunctionSet& getFunctionSet() const
191
+ {
192
+ return funSet;
193
+ }
194
+
189
195
  inline u32_t getValueNodeNum() const
190
196
  {
191
197
  return valSymMap.size();
@@ -208,36 +214,26 @@ public:
208
214
 
209
215
  /// Get SVFIR Node according to LLVM value
210
216
  ///getNode - Return the node corresponding to the specified pointer.
211
- NodeID getValueNode(const SVFLLVMValue* V);
217
+ NodeID getValueNode(const Value* V);
212
218
 
213
- bool hasValueNode(const SVFLLVMValue* V);
219
+ bool hasValueNode(const Value* V);
214
220
 
215
221
  /// getObject - Return the obj node id refer to the memory object for the
216
222
  /// specified global, heap or alloca instruction according to llvm value.
217
- NodeID getObjectNode(const SVFLLVMValue* V);
223
+ NodeID getObjectNode(const Value* V);
218
224
 
219
225
  void dumpSymTable();
220
226
 
221
227
  public:
222
- inline void addFunctionMap(const Function* func, SVFFunction* svfFunc)
223
- {
224
- LLVMFunc2SVFFunc[func] = svfFunc;
225
- setValueAttr(func,svfFunc);
226
- }
227
228
 
228
229
  // create a SVFBasicBlock according to LLVM BasicBlock, then add it to SVFFunction's BasicBlockGraph
229
- inline void addBasicBlock(SVFFunction* fun, const BasicBlock* bb)
230
+ inline void addBasicBlock(FunObjVar* fun, const BasicBlock* bb)
230
231
  {
231
232
  SVFBasicBlock* svfBB = fun->getBasicBlockGraph()->addBasicBlock(bb->getName().str());
232
233
  LLVMBB2SVFBB[bb] = svfBB;
233
234
  SVFBaseNode2LLVMValue[svfBB] = bb;
234
235
  }
235
236
 
236
- inline void addInstructionMap(const Instruction* inst, SVFLLVMValue* svfInst)
237
- {
238
- LLVMInst2SVFInst[inst] = svfInst;
239
- setValueAttr(inst,svfInst);
240
- }
241
237
  inline void addInstructionMap(const Instruction* inst, CallICFGNode* svfInst)
242
238
  {
243
239
  CSToCallNodeMap[inst] = svfInst;
@@ -254,46 +250,6 @@ public:
254
250
  addToSVFVar2LLVMValueMap(inst, svfInst);
255
251
  }
256
252
 
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
253
  const Value* getLLVMValue(const SVFValue* value) const
298
254
  {
299
255
  SVFBaseNode2LLVMValueMap ::const_iterator it = SVFBaseNode2LLVMValue.find(value);
@@ -301,13 +257,6 @@ public:
301
257
  return it->second;
302
258
  }
303
259
 
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
260
  inline const FunObjVar* getFunObjVar(const Function* fun) const
312
261
  {
313
262
  LLVMFun2FunObjVarMap::const_iterator it = LLVMFun2FunObjVar.find(fun);
@@ -325,14 +274,14 @@ public:
325
274
  return varargSymMap;
326
275
  }
327
276
 
328
- NodeID getReturnNode(const SVFFunction *func) const
277
+ NodeID getReturnNode(const Function *func) const
329
278
  {
330
279
  FunToIDMapTy::const_iterator iter = returnSymMap.find(func);
331
280
  assert(iter!=returnSymMap.end() && "ret sym not found");
332
281
  return iter->second;
333
282
  }
334
283
 
335
- NodeID getVarargNode(const SVFFunction *func) const
284
+ NodeID getVarargNode(const Function *func) const
336
285
  {
337
286
  FunToIDMapTy::const_iterator iter = varargSymMap.find(func);
338
287
  assert(iter!=varargSymMap.end() && "vararg sym not found");
@@ -346,39 +295,8 @@ public:
346
295
  return it->second;
347
296
  }
348
297
 
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
298
  /// Get the corresponding Function based on its name
381
- inline const SVFFunction* getSVFFunction(const std::string& name)
299
+ inline const Function* getFunction(const std::string& name)
382
300
  {
383
301
  Function* fun = nullptr;
384
302
 
@@ -388,7 +306,7 @@ public:
388
306
  fun = mod->getFunction(name);
389
307
  if (fun)
390
308
  {
391
- return llvmModuleSet->getSVFFunction(fun);
309
+ return fun;
392
310
  }
393
311
  }
394
312
  return nullptr;
@@ -473,45 +391,59 @@ public:
473
391
 
474
392
  DominatorTree& getDomTree(const Function* fun);
475
393
 
476
- std::string getExtFuncAnnotation(const SVFFunction* fun, const std::string& funcAnnotation);
394
+ std::string getExtFuncAnnotation(const Function* fun, const std::string& funcAnnotation);
477
395
 
478
- const std::vector<std::string>& getExtFuncAnnotations(const SVFFunction* fun);
396
+ const std::vector<std::string>& getExtFuncAnnotations(const Function* fun);
479
397
 
480
398
  // Does (F) have some annotation?
481
- bool hasExtFuncAnnotation(const SVFFunction* fun, const std::string& funcAnnotation);
399
+ bool hasExtFuncAnnotation(const Function* fun, const std::string& funcAnnotation);
482
400
 
483
401
  // Does (F) have a static var X (unavailable to us) that its return points to?
484
- bool has_static(const SVFFunction *F);
402
+ bool has_static(const Function *F);
485
403
 
486
404
  // Does (F) have a memcpy_like operation?
487
- bool is_memcpy(const SVFFunction *F);
405
+ bool is_memcpy(const Function *F);
488
406
 
489
407
  // Does (F) have a memset_like operation?
490
- bool is_memset(const SVFFunction *F);
408
+ bool is_memset(const Function *F);
491
409
 
492
410
  // Does (F) allocate a new object and return it?
493
- bool is_alloc(const SVFFunction *F);
411
+ bool is_alloc(const Function *F);
494
412
 
495
413
  // Does (F) allocate a new object and assign it to one of its arguments?
496
- bool is_arg_alloc(const SVFFunction *F);
414
+ bool is_arg_alloc(const Function *F);
497
415
 
498
416
  // Does (F) allocate a new stack object and return it?
499
- bool is_alloc_stack_ret(const SVFFunction *F);
417
+ bool is_alloc_stack_ret(const Function *F);
500
418
 
501
419
  // Get the position of argument which holds the new object
502
- s32_t get_alloc_arg_pos(const SVFFunction *F);
420
+ s32_t get_alloc_arg_pos(const Function *F);
503
421
 
504
422
  // Does (F) reallocate a new object?
505
- bool is_realloc(const SVFFunction *F);
423
+ bool is_realloc(const Function *F);
506
424
 
507
425
  // Should (F) be considered "external" (either not defined in the program
508
426
  // or a user-defined version of a known alloc or no-op)?
509
- bool is_ext(const SVFFunction *F);
427
+ bool is_ext(const Function *F);
510
428
 
511
429
  // Set the annotation of (F)
512
- void setExtFuncAnnotations(const SVFFunction* fun, const std::vector<std::string>& funcAnnotations);
430
+ void setExtFuncAnnotations(const Function* fun, const std::vector<std::string>& funcAnnotations);
513
431
 
514
432
  private:
433
+ inline void addFunctionSet(const Function* svfFunc)
434
+ {
435
+ funSet.push_back(svfFunc);
436
+ }
437
+
438
+ inline void setFunExitBB(const Function* fun, const SVFBasicBlock* bb)
439
+ {
440
+ funToExitBB[fun] = bb;
441
+ }
442
+
443
+ inline void setFunRealDefFun(const Function* fun, const Function* realDefFun)
444
+ {
445
+ funToRealDefFun[fun] = realDefFun;
446
+ }
515
447
  /// Create SVFTypes
516
448
  SVFType* addSVFTypeInfo(const Type* t);
517
449
  /// Collect a type info
@@ -531,11 +463,7 @@ private:
531
463
  void addSVFMain();
532
464
 
533
465
  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);
466
+
539
467
  void addToSVFVar2LLVMValueMap(const Value* val, SVFValue* svfBaseNode);
540
468
  void buildFunToFunMap();
541
469
  void buildGlobalDefToRepMap();
@@ -32,7 +32,6 @@
32
32
 
33
33
  #include "Util/SVFUtil.h"
34
34
  #include "SVF-LLVM/BasicTypes.h"
35
- #include "SVF-LLVM/SVFLLVMValue.h"
36
35
  #include "Util/ThreadAPI.h"
37
36
 
38
37
  namespace SVF
@@ -355,15 +354,14 @@ std::vector<const Function *> getCalledFunctions(const Function *F);
355
354
  // Converts a mangled name to C naming style to match functions in extapi.c.
356
355
  std::string restoreFuncName(std::string funcName);
357
356
 
358
- bool isExtCall(const SVFFunction* fun);
357
+ bool isExtCall(const Function* fun);
359
358
 
360
- bool isMemcpyExtFun(const SVFFunction *fun);
359
+ bool isMemcpyExtFun(const Function *fun);
361
360
 
362
- bool isMemsetExtFun(const SVFFunction* fun);
361
+ bool isMemsetExtFun(const Function* fun);
363
362
 
364
- u32_t getHeapAllocHoldingArgPosition(const SVFFunction* fun);
363
+ u32_t getHeapAllocHoldingArgPosition(const Function* fun);
365
364
 
366
- const SVFFunction* getFunction(const std::string& name);
367
365
  const FunObjVar* getFunObjVar(const std::string&name);
368
366
 
369
367
  /// Return true if the value refers to constant data, e.g., i32 0
@@ -376,9 +374,6 @@ inline bool isConstDataOrAggData(const Value* val)
376
374
  /// find the unique defined global across multiple modules
377
375
  const Value* getGlobalRep(const Value* val);
378
376
 
379
- /// Check whether this value points-to a constant object
380
- bool isConstantObjSym(const SVFLLVMValue* val);
381
-
382
377
  /// Check whether this value points-to a constant object
383
378
  bool isConstantObjSym(const Value* val);
384
379
 
@@ -32,7 +32,6 @@
32
32
 
33
33
  #include "Util/SVFUtil.h"
34
34
  #include "SVF-LLVM/BasicTypes.h"
35
- #include "SVF-LLVM/SVFLLVMValue.h"
36
35
  #include "Util/ThreadAPI.h"
37
36
 
38
37
  namespace SVF