svf-lib 1.0.1276 → 1.0.1278

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 (60) hide show
  1. package/SVF-linux/Release-build/lib/libSvf.a +0 -0
  2. package/SVF-linux/include/Graphs/ConsGNode.h +48 -24
  3. package/SVF-linux/include/Graphs/GenericGraph.h +4 -2
  4. package/SVF-linux/include/Graphs/ICFG.h +3 -2
  5. package/SVF-linux/include/Graphs/SVFGOPT.h +7 -7
  6. package/SVF-linux/include/Graphs/VFG.h +3 -2
  7. package/SVF-linux/include/MSSA/MemSSA.h +6 -6
  8. package/SVF-linux/include/MemoryModel/PersistentPointsToDS.h +1 -1
  9. package/SVF-linux/include/MemoryModel/SVFIR.h +3 -1
  10. package/SVF-linux/include/SABER/SaberCondAllocator.h +7 -2
  11. package/SVF-linux/include/SVF-FE/IRAnnotator.h +3 -1
  12. package/SVF-linux/include/Util/SparseBitVector.h +2 -0
  13. package/SVF-osx/Release-build/lib/libSvf.a +0 -0
  14. package/SVF-osx/include/DDA/DDAVFSolver.h +1 -2
  15. package/SVF-osx/include/Graphs/ICFG.h +16 -16
  16. package/SVF-osx/include/Graphs/ICFGEdge.h +6 -6
  17. package/SVF-osx/include/Graphs/ICFGNode.h +16 -16
  18. package/SVF-osx/include/Graphs/IRGraph.h +6 -6
  19. package/SVF-osx/include/Graphs/ThreadCallGraph.h +2 -2
  20. package/SVF-osx/include/Graphs/VFGNode.h +1 -1
  21. package/SVF-osx/include/MSSA/MSSAMuChi.h +11 -11
  22. package/SVF-osx/include/MSSA/MemRegion.h +2 -2
  23. package/SVF-osx/include/MSSA/MemSSA.h +13 -13
  24. package/SVF-osx/include/MTA/FSMPTA.h +1 -1
  25. package/SVF-osx/include/MTA/LockAnalysis.h +33 -33
  26. package/SVF-osx/include/MTA/LockResultValidator.h +7 -6
  27. package/SVF-osx/include/MTA/MHP.h +46 -46
  28. package/SVF-osx/include/MTA/MTA.h +4 -4
  29. package/SVF-osx/include/MTA/MTAAnnotator.h +6 -4
  30. package/SVF-osx/include/MTA/MTAResultValidator.h +51 -44
  31. package/SVF-osx/include/MTA/PCG.h +22 -27
  32. package/SVF-osx/include/MTA/TCT.h +28 -37
  33. package/SVF-osx/include/MemoryModel/SVFStatements.h +11 -6
  34. package/SVF-osx/include/MemoryModel/SVFVariables.h +4 -4
  35. package/SVF-osx/include/MemoryModel/SymbolTableInfo.h +13 -19
  36. package/SVF-osx/include/SABER/ProgSlice.h +5 -5
  37. package/SVF-osx/include/SABER/SaberCheckerAPI.h +4 -4
  38. package/SVF-osx/include/SABER/SaberCondAllocator.h +32 -35
  39. package/SVF-osx/include/SVF-FE/BasicTypes.h +10 -0
  40. package/SVF-osx/include/SVF-FE/CPPUtil.h +9 -8
  41. package/SVF-osx/include/SVF-FE/DCHG.h +4 -4
  42. package/SVF-osx/include/SVF-FE/DataFlowUtil.h +1 -1
  43. package/SVF-osx/include/SVF-FE/GEPTypeBridgeIterator.h +1 -1
  44. package/SVF-osx/include/SVF-FE/ICFGBuilder.h +9 -9
  45. package/SVF-osx/include/SVF-FE/IRAnnotator.h +9 -9
  46. package/SVF-osx/include/SVF-FE/LLVMModule.h +119 -22
  47. package/SVF-osx/include/SVF-FE/LLVMUtil.h +31 -52
  48. package/SVF-osx/include/SVF-FE/SVFIRBuilder.h +14 -20
  49. package/SVF-osx/include/SVF-FE/SymbolTableBuilder.h +8 -8
  50. package/SVF-osx/include/Util/Annotator.h +22 -22
  51. package/SVF-osx/include/Util/BasicTypes.h +476 -72
  52. package/SVF-osx/include/Util/Casting.h +1 -1
  53. package/SVF-osx/include/Util/CxtStmt.h +13 -12
  54. package/SVF-osx/include/Util/SVFBasicTypes.h +0 -78
  55. package/SVF-osx/include/Util/SVFInstruction.h +40 -0
  56. package/SVF-osx/include/Util/SVFModule.h +58 -124
  57. package/SVF-osx/include/Util/SVFUtil.h +48 -39
  58. package/SVF-osx/include/Util/ThreadAPI.h +17 -28
  59. package/SVF-osx/include/WPA/WPAPass.h +4 -4
  60. package/package.json +1 -1
@@ -172,13 +172,13 @@ public:
172
172
  }
173
173
 
174
174
  /// Returns the vector of virtual function vectors.
175
- const std::vector<std::vector<const Function *>> &getVfnVectors(void) const
175
+ const std::vector<std::vector<const Function* >> &getVfnVectors(void) const
176
176
  {
177
177
  return vfnVectors;
178
178
  }
179
179
 
180
180
  /// Return the nth virtual function vector in the vtable.
181
- std::vector<const Function *> &getVfnVector(unsigned n)
181
+ std::vector<const Function* > &getVfnVector(unsigned n)
182
182
  {
183
183
  if (vfnVectors.size() < n + 1)
184
184
  {
@@ -197,7 +197,7 @@ private:
197
197
  std::string typeName;
198
198
  size_t flags;
199
199
  /// The virtual functions which this class actually defines/overrides.
200
- std::vector<const Function *> primaryVTable;
200
+ std::vector<const Function* > primaryVTable;
201
201
  /// If a vtable is split into more than one vfn vector for multiple inheritance,
202
202
  /// 0 would be the primary base + this classes virtual functions, 1 would be
203
203
  /// the second parent, 2 would be third parent, etc.
@@ -406,7 +406,7 @@ private:
406
406
  /// Retrieves the metadata associated with a *virtual* callsite.
407
407
  const DIType *getCSStaticType(CallSite cs) const
408
408
  {
409
- MDNode *md = cs.getInstruction()->getMetadata(cppUtil::ctir::derefMDName);
409
+ MDNode *md = cs.getInstruction()->getLLVMInstruction()->getMetadata(cppUtil::ctir::derefMDName);
410
410
  assert(md != nullptr && "Missing type metadata at virtual callsite");
411
411
  DIType *diType = SVFUtil::dyn_cast<DIType>(md);
412
412
  assert(diType != nullptr && "Incorrect metadata type at virtual callsite");
@@ -75,7 +75,7 @@ public:
75
75
  const SCEV *scev;
76
76
  const Value* start;
77
77
  const Value* step;
78
- const Value *ptr;
78
+ const Value* ptr;
79
79
  bool inloop;
80
80
  unsigned tripcount;
81
81
 
@@ -95,7 +95,7 @@ public:
95
95
  return operator*();
96
96
  }
97
97
 
98
- Value *getOperand() const
98
+ Value* getOperand() const
99
99
  {
100
100
  return const_cast<Value*>(&**OpIt);
101
101
  }
@@ -41,14 +41,14 @@ class ICFGBuilder
41
41
 
42
42
  public:
43
43
 
44
- typedef std::vector<const Instruction*> InstVec;
45
- typedef Set<const Instruction*> BBSet;
44
+ typedef std::vector<const SVFInstruction*> InstVec;
45
+ typedef Set<const SVFInstruction*> BBSet;
46
46
 
47
47
  private:
48
48
  ICFG* icfg;
49
49
 
50
50
  public:
51
- typedef FIFOWorkList<const Instruction*> WorkList;
51
+ typedef FIFOWorkList<const SVFInstruction*> WorkList;
52
52
 
53
53
  ICFGBuilder(ICFG* i): icfg(i)
54
54
  {
@@ -69,10 +69,10 @@ private:
69
69
  void connectGlobalToProgEntry(SVFModule* svfModule);
70
70
 
71
71
  /// Add/Get an inter block ICFGNode
72
- InterICFGNode* getOrAddInterBlockICFGNode(const Instruction* inst);
72
+ InterICFGNode* getOrAddInterBlockICFGNode(const SVFInstruction* inst);
73
73
 
74
74
  /// Add/Get a basic block ICFGNode
75
- inline ICFGNode* getOrAddBlockICFGNode(const Instruction* inst)
75
+ inline ICFGNode* getOrAddBlockICFGNode(const SVFInstruction* inst)
76
76
  {
77
77
  if(SVFUtil::isNonInstricCallSite(inst))
78
78
  return getOrAddInterBlockICFGNode(inst);
@@ -81,21 +81,21 @@ private:
81
81
  }
82
82
 
83
83
  /// Create edges between ICFG nodes across functions
84
- void addICFGInterEdges(const Instruction* cs, const SVFFunction* callee);
84
+ void addICFGInterEdges(const SVFInstruction* cs, const SVFFunction* callee);
85
85
 
86
86
  /// Add a call node
87
- inline CallICFGNode* getCallICFGNode(const Instruction* cs)
87
+ inline CallICFGNode* getCallICFGNode(const SVFInstruction* cs)
88
88
  {
89
89
  return icfg->getCallICFGNode(cs);
90
90
  }
91
91
  /// Add a return node
92
- inline RetICFGNode* getRetICFGNode(const Instruction* cs)
92
+ inline RetICFGNode* getRetICFGNode(const SVFInstruction* cs)
93
93
  {
94
94
  return icfg->getRetICFGNode(cs);
95
95
  }
96
96
 
97
97
  /// Add and get IntraBlock ICFGNode
98
- IntraICFGNode* getOrAddIntraBlockICFGNode(const Instruction* inst)
98
+ IntraICFGNode* getOrAddIntraBlockICFGNode(const SVFInstruction* inst)
99
99
  {
100
100
  return icfg->getIntraICFGNode(inst);
101
101
  }
@@ -108,17 +108,17 @@ private:
108
108
  }
109
109
 
110
110
  // Deduce the LLVM value's type, and process the metadata accordingly
111
- void processPAGNode(const Value *value, SVF::NodeID nodeId, bool writeFlag)
111
+ void processPAGNode(const Value* value, SVF::NodeID nodeId, bool writeFlag)
112
112
  {
113
- if (auto instruction = const_cast<Instruction *>(SVFUtil::dyn_cast<Instruction>(value)))
113
+ if (auto instruction = const_cast<Instruction* >(SVFUtil::dyn_cast<Instruction>(value)))
114
114
  {
115
115
  processInstructionNode(instruction, nodeId, writeFlag);
116
116
  }
117
- else if (auto argument = const_cast<Argument *>(SVFUtil::dyn_cast<Argument>(value)))
117
+ else if (auto argument = const_cast<Argument* >(SVFUtil::dyn_cast<Argument>(value)))
118
118
  {
119
119
  processArgumentNode(argument, nodeId, writeFlag);
120
120
  }
121
- else if (auto function = const_cast<Function *>(SVFUtil::dyn_cast<Function>(value)))
121
+ else if (auto function = const_cast<Function* >(SVFUtil::dyn_cast<Function>(value)))
122
122
  {
123
123
  processFunctionNode(function, nodeId, writeFlag);
124
124
  }
@@ -126,7 +126,7 @@ private:
126
126
  {
127
127
  processGlobalVarNode(globalVar, nodeId, writeFlag);
128
128
  }
129
- else if (auto basicBlock = const_cast<BasicBlock *>(SVFUtil::dyn_cast<BasicBlock>(value)))
129
+ else if (auto basicBlock = const_cast<BasicBlock* >(SVFUtil::dyn_cast<BasicBlock>(value)))
130
130
  {
131
131
  processBasicBlockNode(basicBlock, nodeId, writeFlag);
132
132
  }
@@ -145,7 +145,7 @@ private:
145
145
  }
146
146
  }
147
147
 
148
- void processInstructionNode(Instruction *instruction, const SVF::NodeID &nodeId, bool writeFlag)
148
+ void processInstructionNode(Instruction* instruction, const SVF::NodeID &nodeId, bool writeFlag)
149
149
  {
150
150
  std::string label = "inode-" + std::to_string(nodeId);
151
151
 
@@ -163,7 +163,7 @@ private:
163
163
  }
164
164
  }
165
165
 
166
- void processArgumentNode(Argument *argument, const SVF::NodeID &nodeId, bool writeFlag)
166
+ void processArgumentNode(Argument* argument, const SVF::NodeID &nodeId, bool writeFlag)
167
167
  {
168
168
  std::string label = "anode-" + std::to_string(nodeId);
169
169
 
@@ -181,7 +181,7 @@ private:
181
181
  }
182
182
  }
183
183
 
184
- void processFunctionNode(Function *function, const SVF::NodeID &nodeId, bool writeFlag)
184
+ void processFunctionNode(Function* function, const SVF::NodeID &nodeId, bool writeFlag)
185
185
  {
186
186
  std::string label = "fnode-" + std::to_string(nodeId);
187
187
 
@@ -217,7 +217,7 @@ private:
217
217
  }
218
218
  }
219
219
 
220
- void processBasicBlockNode(BasicBlock *basicBlock, const SVF::NodeID &nodeId, bool writeFlag)
220
+ void processBasicBlockNode(BasicBlock* basicBlock, const SVF::NodeID &nodeId, bool writeFlag)
221
221
  {
222
222
  std::string label = "bnode-" + std::to_string(nodeId);
223
223
 
@@ -47,8 +47,16 @@ public:
47
47
  typedef Map<const Function*, FunctionSetType> FunDefToDeclsMapTy;
48
48
  typedef Map<const GlobalVariable*, GlobalVariable*> GlobalDefToRepMapTy;
49
49
 
50
+ typedef Map<const Function*, SVFFunction*> LLVMFun2SVFFunMap;
51
+ typedef Map<const BasicBlock*, SVFBasicBlock*> LLVMBB2SVFBBMap;
52
+ typedef Map<const Instruction*, SVFInstruction*> LLVMInst2SVFInstMap;
53
+ typedef Map<const GlobalValue*, SVFGlobalValue*> LLVMGlobal2SVFGlobalMap;
54
+ typedef Map<const Argument*, SVFArgument*> LLVMArgument2SVFArgumentMap;
55
+ typedef Map<const ConstantData*, SVFConstantData*> LLVMConstData2SVFConstDataMap;
56
+ typedef Map<const Value*, SVFOtherValue*> LLVMValue2SVFOtherValueMap;
57
+
50
58
  private:
51
- static LLVMModuleSet *llvmModuleSet;
59
+ static LLVMModuleSet* llvmModuleSet;
52
60
  SVFModule* svfModule;
53
61
  std::unique_ptr<LLVMContext> cxts;
54
62
  std::vector<std::unique_ptr<Module>> owned_modules;
@@ -61,13 +69,21 @@ private:
61
69
  /// Global definition to a rep definition map
62
70
  GlobalDefToRepMapTy GlobalDefToRepMap;
63
71
 
72
+ LLVMFun2SVFFunMap LLVMFunc2SVFFunc; ///< Map an LLVM Function to an SVF Function
73
+ LLVMBB2SVFBBMap LLVMBB2SVFBB;
74
+ LLVMInst2SVFInstMap LLVMInst2SVFInst;
75
+ LLVMArgument2SVFArgumentMap LLVMArgument2SVFArgument;
76
+ LLVMGlobal2SVFGlobalMap LLVMGlobal2SVFGlobal;
77
+ LLVMConstData2SVFConstDataMap LLVMConstData2SVFConstData;
78
+ LLVMValue2SVFOtherValueMap LLVMValue2SVFOtherValue;
79
+
64
80
  /// Constructor
65
81
  LLVMModuleSet(): svfModule(nullptr), cxts(nullptr), preProcessed(false) {}
66
82
 
67
83
  void build();
68
84
 
69
85
  public:
70
- static inline LLVMModuleSet *getLLVMModuleSet()
86
+ static inline LLVMModuleSet* getLLVMModuleSet()
71
87
  {
72
88
  if (llvmModuleSet == nullptr)
73
89
  llvmModuleSet = new LLVMModuleSet();
@@ -81,8 +97,8 @@ public:
81
97
  llvmModuleSet = nullptr;
82
98
  }
83
99
 
84
- SVFModule* buildSVFModule(Module &mod);
85
- SVFModule* buildSVFModule(const std::vector<std::string> &moduleNameVec);
100
+ SVFModule* buildSVFModule(Module& mod);
101
+ SVFModule* buildSVFModule(const std::vector<std::string>& moduleNameVec);
86
102
 
87
103
  inline SVFModule* getSVFModule()
88
104
  {
@@ -90,13 +106,18 @@ public:
90
106
  return svfModule;
91
107
  }
92
108
 
93
- void preProcessBCs(std::vector<std::string> &moduleNameVec);
109
+ void preProcessBCs(std::vector<std::string>& moduleNameVec);
94
110
 
95
111
  u32_t getModuleNum() const
96
112
  {
97
113
  return modules.size();
98
114
  }
99
115
 
116
+ const std::vector<std::reference_wrapper<Module>>& getLLVMModules() const
117
+ {
118
+ return modules;
119
+ }
120
+
100
121
  Module *getModule(u32_t idx) const
101
122
  {
102
123
  return &getModuleRef(idx);
@@ -111,19 +132,91 @@ public:
111
132
  // Dump modules to files
112
133
  void dumpModulesToFile(const std::string suffix);
113
134
 
114
- const SVFFunction *getSVFFunction(const Function *fun) const
135
+ inline void addFunctionMap(const Function* func, SVFFunction* svfFunc)
136
+ {
137
+ LLVMFunc2SVFFunc[func] = svfFunc;
138
+ setValueAttr(func,svfFunc);
139
+ }
140
+ inline void addBasicBlockMap(const BasicBlock* bb, SVFBasicBlock* svfBB)
141
+ {
142
+ LLVMBB2SVFBB[bb] = svfBB;
143
+ setValueAttr(bb,svfBB);
144
+ }
145
+ inline void addInstructionMap(const Instruction* inst, SVFInstruction* svfInst)
146
+ {
147
+ LLVMInst2SVFInst[inst] = svfInst;
148
+ setValueAttr(inst,svfInst);
149
+ }
150
+ inline void addArgumentMap(const Argument* arg, SVFArgument* svfArg)
115
151
  {
116
- return svfModule->getSVFFunction(fun);
152
+ LLVMArgument2SVFArgument[arg] = svfArg;
153
+ setValueAttr(arg,svfArg);
117
154
  }
155
+ inline void addGlobalValueMap(const GlobalValue* glob, SVFGlobalValue* svfglob)
156
+ {
157
+ LLVMGlobal2SVFGlobal[glob] = svfglob;
158
+ setValueAttr(glob,svfglob);
159
+ }
160
+ inline void addConstantDataMap(const ConstantData* cd, SVFConstantData* svfcd)
161
+ {
162
+ LLVMConstData2SVFConstData[cd] = svfcd;
163
+ setValueAttr(cd,svfcd);
164
+ }
165
+ inline void addOtherValueMap(const Value* ov, SVFOtherValue* svfov)
166
+ {
167
+ LLVMValue2SVFOtherValue[ov] = svfov;
168
+ setValueAttr(ov,svfov);
169
+ }
170
+
171
+ SVFValue* getSVFValue(const Value* value);
172
+
173
+ inline SVFFunction* getSVFFunction(const Function* fun) const
174
+ {
175
+ LLVMFun2SVFFunMap::const_iterator it = LLVMFunc2SVFFunc.find(fun);
176
+ assert(it!=LLVMFunc2SVFFunc.end() && "SVF Function not found!");
177
+ return it->second;
178
+ }
179
+
180
+ inline SVFBasicBlock* getSVFBasicBlock(const BasicBlock* bb) const
181
+ {
182
+ LLVMBB2SVFBBMap::const_iterator it = LLVMBB2SVFBB.find(bb);
183
+ assert(it!=LLVMBB2SVFBB.end() && "SVF BasicBlock not found!");
184
+ return it->second;
185
+ }
186
+
187
+ inline SVFInstruction* getSVFInstruction(const Instruction* inst) const
188
+ {
189
+ LLVMInst2SVFInstMap::const_iterator it = LLVMInst2SVFInst.find(inst);
190
+ assert(it!=LLVMInst2SVFInst.end() && "SVF Instruction not found!");
191
+ return it->second;
192
+ }
193
+
194
+ inline SVFArgument* getSVFArgument(const Argument* arg) const
195
+ {
196
+ LLVMArgument2SVFArgumentMap::const_iterator it = LLVMArgument2SVFArgument.find(arg);
197
+ assert(it!=LLVMArgument2SVFArgument.end() && "SVF Argument not found!");
198
+ return it->second;
199
+ }
200
+
201
+ inline SVFGlobalValue* getSVFGlobalValue(const GlobalValue* g) const
202
+ {
203
+ LLVMGlobal2SVFGlobalMap::const_iterator it = LLVMGlobal2SVFGlobal.find(g);
204
+ assert(it!=LLVMGlobal2SVFGlobal.end() && "SVF Global not found!");
205
+ return it->second;
206
+ }
207
+
208
+ SVFConstantData* getSVFConstantData(const ConstantData* cd);
209
+
210
+ SVFOtherValue* getSVFOtherValue(const Value* ov);
118
211
 
119
212
  /// Get the corresponding Function based on its name
120
- inline const SVFFunction *getSVFFunction(std::string name)
213
+ inline const SVFFunction* getSVFFunction(std::string name)
121
214
  {
122
- Function *fun = nullptr;
215
+ Function* fun = nullptr;
123
216
 
124
217
  for (u32_t i = 0; i < llvmModuleSet->getModuleNum(); ++i)
125
218
  {
126
- Module *mod = llvmModuleSet->getModule(i);
219
+ Module* mod = llvmModuleSet->getModule(i);
127
220
  fun = mod->getFunction(name);
128
221
  if (fun)
129
222
  {
@@ -133,14 +226,14 @@ public:
133
226
  return nullptr;
134
227
  }
135
228
 
136
- bool hasDefinition(const Function *fun) const
229
+ bool hasDefinition(const Function* fun) const
137
230
  {
138
231
  assert(fun->isDeclaration() && "not a function declaration?");
139
232
  FunDeclToDefMapTy::const_iterator it = FunDeclToDefMap.find(fun);
140
233
  return it != FunDeclToDefMap.end();
141
234
  }
142
235
 
143
- const Function *getDefinition(const Function *fun) const
236
+ const Function* getDefinition(const Function* fun) const
144
237
  {
145
238
  assert(fun->isDeclaration() && "not a function declaration?");
146
239
  FunDeclToDefMapTy::const_iterator it = FunDeclToDefMap.find(fun);
@@ -148,7 +241,7 @@ public:
148
241
  return it->second;
149
242
  }
150
243
 
151
- bool hasDeclaration(const Function *fun) const
244
+ bool hasDeclaration(const Function* fun) const
152
245
  {
153
246
  if(fun->isDeclaration() && !hasDefinition(fun))
154
247
  return false;
@@ -161,7 +254,7 @@ public:
161
254
  return it != FunDefToDeclsMap.end();
162
255
  }
163
256
 
164
- const FunctionSetType& getDeclaration(const Function *fun) const
257
+ const FunctionSetType& getDeclaration(const Function* fun) const
165
258
  {
166
259
  const Function* funDef = fun;
167
260
  if(fun->isDeclaration() && hasDefinition(fun))
@@ -173,13 +266,13 @@ public:
173
266
  }
174
267
 
175
268
  /// Global to rep
176
- bool hasGlobalRep(const GlobalVariable *val) const
269
+ bool hasGlobalRep(const GlobalVariable* val) const
177
270
  {
178
271
  GlobalDefToRepMapTy::const_iterator it = GlobalDefToRepMap.find(val);
179
272
  return it != GlobalDefToRepMap.end();
180
273
  }
181
274
 
182
- GlobalVariable *getGlobalRep(const GlobalVariable *val) const
275
+ GlobalVariable *getGlobalRep(const GlobalVariable* val) const
183
276
  {
184
277
  GlobalDefToRepMapTy::const_iterator it = GlobalDefToRepMap.find(val);
185
278
  assert(it != GlobalDefToRepMap.end() && "has no rep?");
@@ -187,7 +280,7 @@ public:
187
280
  }
188
281
 
189
282
 
190
- Module *getMainLLVMModule() const
283
+ Module* getMainLLVMModule() const
191
284
  {
192
285
  return getModule(0);
193
286
  }
@@ -204,12 +297,16 @@ public:
204
297
  }
205
298
 
206
299
  private:
207
- std::vector<const Function *> getLLVMGlobalFunctions(
208
- const GlobalVariable *global);
300
+ std::vector<const Function*> getLLVMGlobalFunctions(const GlobalVariable* global);
209
301
 
210
- void loadModules(const std::vector<std::string> &moduleNameVec);
302
+ void loadModules(const std::vector<std::string>& moduleNameVec);
211
303
  void addSVFMain();
212
- void initialize();
304
+
305
+ void createSVFDataStructure();
306
+ void initSVFFunction();
307
+ void initSVFBasicBlock(const SVFFunction* func);
308
+ void initDomTree(const SVFFunction* func);
309
+ void setValueAttr(const Value* val, SVFValue* value);
213
310
  void buildFunToFunMap();
214
311
  void buildGlobalDefToRepMap();
215
312
  /// Invoke llvm passes to modify module
@@ -219,4 +316,4 @@ private:
219
316
 
220
317
  } // End namespace SVF
221
318
 
222
- #endif /* INCLUDE_SVF_FE_LLVMMODULE_H_ */
319
+ #endif /* INCLUDE_SVF_FE_LLVMMODULE_H_ */
@@ -45,13 +45,13 @@ namespace LLVMUtil
45
45
 
46
46
 
47
47
  /// Check whether this value is a black hole
48
- inline bool isBlackholeSym(const Value *val)
48
+ inline bool isBlackholeSym(const Value* val)
49
49
  {
50
50
  return (SVFUtil::isa<UndefValue>(val));
51
51
  }
52
52
 
53
53
  /// Check whether this value is a black hole
54
- inline bool isNullPtrSym(const Value *val)
54
+ inline bool isNullPtrSym(const Value* val)
55
55
  {
56
56
  if (const Constant* v = SVFUtil::dyn_cast<Constant>(val))
57
57
  {
@@ -61,14 +61,7 @@ inline bool isNullPtrSym(const Value *val)
61
61
  }
62
62
 
63
63
  /// Check whether this value points-to a constant object
64
- bool isConstantObjSym(const Value *val);
65
-
66
-
67
- /// Whether an instruction is a return instruction
68
- inline bool isReturn(const Instruction* inst)
69
- {
70
- return SVFUtil::isa<ReturnInst>(inst);
71
- }
64
+ bool isConstantObjSym(const Value* val);
72
65
 
73
66
  static inline Type *getPtrElementType(const PointerType* pty)
74
67
  {
@@ -89,7 +82,7 @@ inline const PointerType *getRefTypeOfHeapAllocOrStatic(const CallSite cs)
89
82
  if (SVFUtil::isHeapAllocExtCallViaArg(cs))
90
83
  {
91
84
  int argPos = SVFUtil::getHeapAllocHoldingArgPosition(cs);
92
- const Value *arg = cs.getArgument(argPos);
85
+ const Value* arg = cs.getArgument(argPos);
93
86
  if (const PointerType *argType = SVFUtil::dyn_cast<PointerType>(arg->getType()))
94
87
  refType = SVFUtil::dyn_cast<PointerType>(getPtrElementType(argType));
95
88
  }
@@ -104,24 +97,24 @@ inline const PointerType *getRefTypeOfHeapAllocOrStatic(const CallSite cs)
104
97
  return refType;
105
98
  }
106
99
 
107
- inline const PointerType *getRefTypeOfHeapAllocOrStatic(const Instruction *inst)
100
+ inline const PointerType *getRefTypeOfHeapAllocOrStatic(const SVFInstruction* inst)
108
101
  {
109
- CallSite cs(const_cast<Instruction*>(inst));
102
+ CallSite cs(inst);
110
103
  return getRefTypeOfHeapAllocOrStatic(cs);
111
104
  }
112
105
  //@}
113
106
 
114
107
  /// Return true if this value refers to a object
115
- bool isObject (const Value * ref);
108
+ bool isObject (const Value* ref);
116
109
 
117
110
  /// Method for dead function, which does not have any possible caller
118
111
  /// function address is not taken and never be used in call or invoke instruction
119
112
  //@{
120
113
  /// whether this is a function without any possible caller?
121
- bool isUncalledFunction (const Function * fun);
114
+ bool isUncalledFunction (const Function* fun);
122
115
 
123
116
  /// whether this is an argument in dead function
124
- inline bool ArgInDeadFunction (const Value * val)
117
+ inline bool ArgInDeadFunction (const Value* val)
125
118
  {
126
119
  return SVFUtil::isa<Argument>(val)
127
120
  && isUncalledFunction(SVFUtil::cast<Argument>(val)->getParent());
@@ -129,13 +122,13 @@ inline bool ArgInDeadFunction (const Value * val)
129
122
  //@}
130
123
 
131
124
  /// Return true if this is an argument of a program entry function (e.g. main)
132
- inline bool ArgInProgEntryFunction (const Value * val)
125
+ inline bool ArgInProgEntryFunction (const Value* val)
133
126
  {
134
127
  return SVFUtil::isa<Argument>(val)
135
128
  && SVFUtil::isProgEntryFunction(SVFUtil::cast<Argument>(val)->getParent());
136
129
  }
137
130
  /// Return true if this is value in a dead function (function without any caller)
138
- bool isPtrInUncalledFunction (const Value * value);
131
+ bool isPtrInUncalledFunction (const Value* value);
139
132
  //@}
140
133
 
141
134
  //@}
@@ -143,13 +136,13 @@ bool isPtrInUncalledFunction (const Value * value);
143
136
  /// Function does not have any possible caller in the call graph
144
137
  //@{
145
138
  /// Return true if the function does not have a caller (either it is a main function or a dead function)
146
- inline bool isNoCallerFunction (const Function * fun)
139
+ inline bool isNoCallerFunction (const Function* fun)
147
140
  {
148
141
  return isUncalledFunction(fun) || SVFUtil::isProgEntryFunction(fun);
149
142
  }
150
143
 
151
144
  /// Return true if the argument in a function does not have a caller
152
- inline bool isArgOfUncalledFunction (const Value * val)
145
+ inline bool isArgOfUncalledFunction (const Value* val)
153
146
  {
154
147
  return SVFUtil::isa<Argument>(val)
155
148
  && isNoCallerFunction(SVFUtil::cast<Argument>(val)->getParent());
@@ -157,34 +150,26 @@ inline bool isArgOfUncalledFunction (const Value * val)
157
150
  //@}
158
151
 
159
152
  /// Return true if the function has a return instruction reachable from function entry
160
- bool functionDoesNotRet (const Function * fun);
153
+ bool functionDoesNotRet (const Function* fun);
161
154
 
162
155
  /// Get reachable basic block from function entry
163
- void getFunReachableBBs (const SVFFunction* svfFun, std::vector<const BasicBlock*>& bbs);
156
+ void getFunReachableBBs (const SVFFunction* svfFun, std::vector<const SVFBasicBlock*>& bbs);
164
157
 
165
- /// Get function exit basic block
166
- /// FIXME: this back() here is only valid when UnifyFunctionExitNodes pass is invoked
167
- inline const BasicBlock* getFunExitBB(const SVFFunction* svfFun)
168
- {
169
- const Function* fun = svfFun->getLLVMFun();
170
- assert(!SVFUtil::isExtCall(svfFun) && "The function cannot be an external call");
171
- return &fun->back();
172
- }
173
158
  /// Strip off the constant casts
174
- const Value * stripConstantCasts(const Value *val);
159
+ const Value* stripConstantCasts(const Value* val);
175
160
 
176
161
  /// Strip off the all casts
177
- const Value *stripAllCasts(const Value *val) ;
162
+ const Value* stripAllCasts(const Value* val) ;
178
163
 
179
164
  /// Get the type of the heap allocation
180
- const Type *getTypeOfHeapAlloc(const llvm::Instruction *inst) ;
165
+ const Type *getTypeOfHeapAlloc(const SVFInstruction* inst) ;
181
166
 
182
167
  /// Return the bitcast instruction which is val's only use site, otherwise return nullptr
183
168
  const Value* getUniqueUseViaCastInst(const Value* val);
184
169
 
185
170
  /// Return corresponding constant expression, otherwise return nullptr
186
171
  //@{
187
- inline const ConstantExpr *isGepConstantExpr(const Value *val)
172
+ inline const ConstantExpr *isGepConstantExpr(const Value* val)
188
173
  {
189
174
  if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
190
175
  {
@@ -194,7 +179,7 @@ inline const ConstantExpr *isGepConstantExpr(const Value *val)
194
179
  return nullptr;
195
180
  }
196
181
 
197
- inline const ConstantExpr *isInt2PtrConstantExpr(const Value *val)
182
+ inline const ConstantExpr *isInt2PtrConstantExpr(const Value* val)
198
183
  {
199
184
  if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
200
185
  {
@@ -204,7 +189,7 @@ inline const ConstantExpr *isInt2PtrConstantExpr(const Value *val)
204
189
  return nullptr;
205
190
  }
206
191
 
207
- inline const ConstantExpr *isPtr2IntConstantExpr(const Value *val)
192
+ inline const ConstantExpr *isPtr2IntConstantExpr(const Value* val)
208
193
  {
209
194
  if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
210
195
  {
@@ -214,7 +199,7 @@ inline const ConstantExpr *isPtr2IntConstantExpr(const Value *val)
214
199
  return nullptr;
215
200
  }
216
201
 
217
- inline const ConstantExpr *isCastConstantExpr(const Value *val)
202
+ inline const ConstantExpr *isCastConstantExpr(const Value* val)
218
203
  {
219
204
  if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
220
205
  {
@@ -224,7 +209,7 @@ inline const ConstantExpr *isCastConstantExpr(const Value *val)
224
209
  return nullptr;
225
210
  }
226
211
 
227
- inline const ConstantExpr *isSelectConstantExpr(const Value *val)
212
+ inline const ConstantExpr *isSelectConstantExpr(const Value* val)
228
213
  {
229
214
  if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
230
215
  {
@@ -234,7 +219,7 @@ inline const ConstantExpr *isSelectConstantExpr(const Value *val)
234
219
  return nullptr;
235
220
  }
236
221
 
237
- inline const ConstantExpr *isTruncConstantExpr(const Value *val)
222
+ inline const ConstantExpr *isTruncConstantExpr(const Value* val)
238
223
  {
239
224
  if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
240
225
  {
@@ -248,7 +233,7 @@ inline const ConstantExpr *isTruncConstantExpr(const Value *val)
248
233
  return nullptr;
249
234
  }
250
235
 
251
- inline const ConstantExpr *isCmpConstantExpr(const Value *val)
236
+ inline const ConstantExpr *isCmpConstantExpr(const Value* val)
252
237
  {
253
238
  if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
254
239
  {
@@ -258,7 +243,7 @@ inline const ConstantExpr *isCmpConstantExpr(const Value *val)
258
243
  return nullptr;
259
244
  }
260
245
 
261
- inline const ConstantExpr *isBinaryConstantExpr(const Value *val)
246
+ inline const ConstantExpr *isBinaryConstantExpr(const Value* val)
262
247
  {
263
248
  if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
264
249
  {
@@ -268,7 +253,7 @@ inline const ConstantExpr *isBinaryConstantExpr(const Value *val)
268
253
  return nullptr;
269
254
  }
270
255
 
271
- inline const ConstantExpr *isUnaryConstantExpr(const Value *val)
256
+ inline const ConstantExpr *isUnaryConstantExpr(const Value* val)
272
257
  {
273
258
  if(const ConstantExpr* constExpr = SVFUtil::dyn_cast<ConstantExpr>(val))
274
259
  {
@@ -287,19 +272,13 @@ inline static DataLayout* getDataLayout(Module* mod)
287
272
  }
288
273
 
289
274
  /// Get the next instructions following control flow
290
- void getNextInsts(const Instruction* curInst, std::vector<const Instruction*>& instList);
275
+ void getNextInsts(const SVFInstruction* curInst, std::vector<const SVFInstruction*>& instList);
291
276
 
292
277
  /// Get the previous instructions following control flow
293
- void getPrevInsts(const Instruction* curInst, std::vector<const Instruction*>& instList);
294
-
295
- /// Get basic block successor position
296
- u32_t getBBSuccessorPos(const BasicBlock *BB, const BasicBlock *Succ);
297
- /// Get num of BB's successors
298
- u32_t getBBSuccessorNum(const BasicBlock *BB);
299
- /// Get basic block predecessor positin
300
- u32_t getBBPredecessorPos(const BasicBlock *BB, const BasicBlock *Pred);
278
+ void getPrevInsts(const SVFInstruction* curInst, std::vector<const SVFInstruction*>& instList);
279
+
301
280
  /// Get num of BB's predecessors
302
- u32_t getBBPredecessorNum(const BasicBlock *BB);
281
+ u32_t getBBPredecessorNum(const BasicBlock* BB);
303
282
 
304
283
 
305
284