svf-lib 1.0.1277 → 1.0.1279

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 (95) hide show
  1. package/SVF-linux/Release-build/lib/libSvf.a +0 -0
  2. package/SVF-linux/include/DDA/DDAVFSolver.h +1 -2
  3. package/SVF-linux/include/Graphs/ICFG.h +16 -16
  4. package/SVF-linux/include/Graphs/ICFGEdge.h +6 -6
  5. package/SVF-linux/include/Graphs/ICFGNode.h +16 -16
  6. package/SVF-linux/include/Graphs/IRGraph.h +6 -6
  7. package/SVF-linux/include/Graphs/ThreadCallGraph.h +2 -2
  8. package/SVF-linux/include/Graphs/VFGNode.h +1 -1
  9. package/SVF-linux/include/MSSA/MSSAMuChi.h +11 -11
  10. package/SVF-linux/include/MSSA/MemRegion.h +2 -2
  11. package/SVF-linux/include/MSSA/MemSSA.h +13 -13
  12. package/SVF-linux/include/MTA/FSMPTA.h +1 -1
  13. package/SVF-linux/include/MTA/LockAnalysis.h +33 -33
  14. package/SVF-linux/include/MTA/LockResultValidator.h +7 -6
  15. package/SVF-linux/include/MTA/MHP.h +46 -46
  16. package/SVF-linux/include/MTA/MTA.h +4 -4
  17. package/SVF-linux/include/MTA/MTAAnnotator.h +6 -4
  18. package/SVF-linux/include/MTA/MTAResultValidator.h +51 -44
  19. package/SVF-linux/include/MTA/PCG.h +22 -27
  20. package/SVF-linux/include/MTA/TCT.h +28 -37
  21. package/SVF-linux/include/MemoryModel/SVFStatements.h +11 -6
  22. package/SVF-linux/include/MemoryModel/SVFVariables.h +4 -4
  23. package/SVF-linux/include/MemoryModel/SymbolTableInfo.h +13 -19
  24. package/SVF-linux/include/SABER/ProgSlice.h +5 -5
  25. package/SVF-linux/include/SABER/SaberCheckerAPI.h +4 -4
  26. package/SVF-linux/include/SABER/SaberCondAllocator.h +32 -35
  27. package/SVF-linux/include/SVF-FE/BasicTypes.h +10 -0
  28. package/SVF-linux/include/SVF-FE/CPPUtil.h +9 -8
  29. package/SVF-linux/include/SVF-FE/DCHG.h +4 -4
  30. package/SVF-linux/include/SVF-FE/DataFlowUtil.h +1 -1
  31. package/SVF-linux/include/SVF-FE/GEPTypeBridgeIterator.h +1 -1
  32. package/SVF-linux/include/SVF-FE/ICFGBuilder.h +9 -9
  33. package/SVF-linux/include/SVF-FE/IRAnnotator.h +9 -9
  34. package/SVF-linux/include/SVF-FE/LLVMModule.h +119 -22
  35. package/SVF-linux/include/SVF-FE/LLVMUtil.h +31 -52
  36. package/SVF-linux/include/SVF-FE/SVFIRBuilder.h +14 -20
  37. package/SVF-linux/include/SVF-FE/SymbolTableBuilder.h +8 -8
  38. package/SVF-linux/include/Util/Annotator.h +22 -22
  39. package/SVF-linux/include/Util/BasicTypes.h +476 -72
  40. package/SVF-linux/include/Util/Casting.h +1 -1
  41. package/SVF-linux/include/Util/CxtStmt.h +13 -12
  42. package/SVF-linux/include/Util/SVFBasicTypes.h +0 -78
  43. package/SVF-linux/include/Util/SVFInstruction.h +40 -0
  44. package/SVF-linux/include/Util/SVFModule.h +58 -124
  45. package/SVF-linux/include/Util/SVFUtil.h +48 -39
  46. package/SVF-linux/include/Util/ThreadAPI.h +17 -28
  47. package/SVF-linux/include/WPA/WPAPass.h +4 -4
  48. package/SVF-osx/Release-build/lib/libSvf.a +0 -0
  49. package/SVF-osx/include/DDA/DDAVFSolver.h +1 -2
  50. package/SVF-osx/include/Graphs/ICFG.h +16 -16
  51. package/SVF-osx/include/Graphs/ICFGEdge.h +6 -6
  52. package/SVF-osx/include/Graphs/ICFGNode.h +16 -16
  53. package/SVF-osx/include/Graphs/IRGraph.h +6 -6
  54. package/SVF-osx/include/Graphs/ThreadCallGraph.h +2 -2
  55. package/SVF-osx/include/Graphs/VFGNode.h +1 -1
  56. package/SVF-osx/include/MSSA/MSSAMuChi.h +11 -11
  57. package/SVF-osx/include/MSSA/MemRegion.h +2 -2
  58. package/SVF-osx/include/MSSA/MemSSA.h +13 -13
  59. package/SVF-osx/include/MTA/FSMPTA.h +1 -1
  60. package/SVF-osx/include/MTA/LockAnalysis.h +33 -33
  61. package/SVF-osx/include/MTA/LockResultValidator.h +7 -6
  62. package/SVF-osx/include/MTA/MHP.h +46 -46
  63. package/SVF-osx/include/MTA/MTA.h +4 -4
  64. package/SVF-osx/include/MTA/MTAAnnotator.h +6 -4
  65. package/SVF-osx/include/MTA/MTAResultValidator.h +51 -44
  66. package/SVF-osx/include/MTA/PCG.h +22 -27
  67. package/SVF-osx/include/MTA/TCT.h +28 -37
  68. package/SVF-osx/include/MemoryModel/SVFStatements.h +11 -6
  69. package/SVF-osx/include/MemoryModel/SVFVariables.h +4 -4
  70. package/SVF-osx/include/MemoryModel/SymbolTableInfo.h +13 -19
  71. package/SVF-osx/include/SABER/ProgSlice.h +5 -5
  72. package/SVF-osx/include/SABER/SaberCheckerAPI.h +4 -4
  73. package/SVF-osx/include/SABER/SaberCondAllocator.h +32 -35
  74. package/SVF-osx/include/SVF-FE/BasicTypes.h +10 -0
  75. package/SVF-osx/include/SVF-FE/CPPUtil.h +9 -8
  76. package/SVF-osx/include/SVF-FE/DCHG.h +4 -4
  77. package/SVF-osx/include/SVF-FE/DataFlowUtil.h +1 -1
  78. package/SVF-osx/include/SVF-FE/GEPTypeBridgeIterator.h +1 -1
  79. package/SVF-osx/include/SVF-FE/ICFGBuilder.h +9 -9
  80. package/SVF-osx/include/SVF-FE/IRAnnotator.h +9 -9
  81. package/SVF-osx/include/SVF-FE/LLVMModule.h +119 -22
  82. package/SVF-osx/include/SVF-FE/LLVMUtil.h +31 -52
  83. package/SVF-osx/include/SVF-FE/SVFIRBuilder.h +14 -20
  84. package/SVF-osx/include/SVF-FE/SymbolTableBuilder.h +8 -8
  85. package/SVF-osx/include/Util/Annotator.h +22 -22
  86. package/SVF-osx/include/Util/BasicTypes.h +476 -72
  87. package/SVF-osx/include/Util/Casting.h +1 -1
  88. package/SVF-osx/include/Util/CxtStmt.h +13 -12
  89. package/SVF-osx/include/Util/SVFBasicTypes.h +0 -78
  90. package/SVF-osx/include/Util/SVFInstruction.h +40 -0
  91. package/SVF-osx/include/Util/SVFModule.h +58 -124
  92. package/SVF-osx/include/Util/SVFUtil.h +48 -39
  93. package/SVF-osx/include/Util/ThreadAPI.h +17 -28
  94. package/SVF-osx/include/WPA/WPAPass.h +4 -4
  95. package/package.json +1 -1
@@ -52,15 +52,15 @@ protected:
52
52
  std::vector<std::string> split(const std::string &s, char delim);
53
53
 
54
54
  // Get special arguments of given call sites
55
- NodeID getIntArg(const Instruction* inst, unsigned int arg_num);
56
- std::vector<std::string> getStringArg(const Instruction* inst, unsigned int arg_num);
57
- CallStrCxt getCxtArg(const Instruction* inst, unsigned int arg_num);
55
+ NodeID getIntArg(const SVFInstruction* inst, unsigned int arg_num);
56
+ std::vector<std::string> getStringArg(const SVFInstruction* inst, unsigned int arg_num);
57
+ CallStrCxt getCxtArg(const SVFInstruction* inst, unsigned int arg_num);
58
58
 
59
59
  /*
60
60
  * Get the previous LoadInst or StoreInst from Instruction "I" in the
61
61
  * same BasicBlock. Return nullptr if none exists.
62
62
  */
63
- const Instruction *getPreviousMemoryAccessInst(const Instruction *I);
63
+ const Instruction* getPreviousMemoryAccessInst(const Instruction* I);
64
64
 
65
65
  // Compare two cxts
66
66
  bool matchCxt(const CallStrCxt cxt1, const CallStrCxt cxt2) const;
@@ -77,7 +77,7 @@ protected:
77
77
  /*
78
78
  * Collect the callsite targets for validations.
79
79
  * The targets are labeled by "cs1:", "cs2:"... that are the names of its basic blocks.
80
- * The collected targets are stored in csnumToInstMap that maps label "cs1" to CallInst.
80
+ * The collected targets are stored in csnumToInstMap that maps label "cs1" to its Callsite.
81
81
  */
82
82
  bool collectCallsiteTargets();
83
83
 
@@ -117,7 +117,7 @@ protected:
117
117
 
118
118
  private:
119
119
 
120
- typedef Map<NodeID, const CallInst*> csnumToInst;
120
+ typedef Map<NodeID, const SVFInstruction*> csnumToInst;
121
121
  typedef Map<NodeID, CallStrCxt> vthdToCxtMap;
122
122
  typedef Map<NodeID, NodeID> vthdTorthdMap;
123
123
  typedef Map<NodeID, NodeID> rthdTovthdMap;
@@ -177,7 +177,7 @@ public:
177
177
  {
178
178
  public:
179
179
  /// Constructor
180
- AccessPair(const Instruction *I1, const Instruction *I2,
180
+ AccessPair(const Instruction* I1, const Instruction* I2,
181
181
  const RC_FLAG flags) :
182
182
  I1(I1), I2(I2), flags(flags)
183
183
  {
@@ -189,19 +189,19 @@ public:
189
189
  {
190
190
  return flags & flag;
191
191
  }
192
- inline const Instruction *getInstruction1() const
192
+ inline const Instruction* getInstruction1() const
193
193
  {
194
194
  return I1;
195
195
  }
196
- inline const Instruction *getInstruction2() const
196
+ inline const Instruction* getInstruction2() const
197
197
  {
198
198
  return I2;
199
199
  }
200
200
  //@}
201
201
 
202
202
  private:
203
- const Instruction *I1;
204
- const Instruction *I2;
203
+ const Instruction* I1;
204
+ const Instruction* I2;
205
205
  RC_FLAG flags;
206
206
  };
207
207
 
@@ -240,26 +240,26 @@ protected:
240
240
  /// Interface to the specific validation properties.
241
241
  /// Override one or more to implement your own analysis.
242
242
  //@{
243
- virtual bool mayAccessAliases(const Instruction *I1,
244
- const Instruction *I2)
243
+ virtual bool mayAccessAliases(const Instruction* I1,
244
+ const Instruction* I2)
245
245
  {
246
246
  selectedValidationScenarios &= ~RC_ALIASES;
247
247
  return true;
248
248
  }
249
- virtual bool mayHappenInParallel(const Instruction *I1,
250
- const Instruction *I2)
249
+ virtual bool mayHappenInParallel(const Instruction* I1,
250
+ const Instruction* I2)
251
251
  {
252
252
  selectedValidationScenarios &= ~RC_MHP;
253
253
  return true;
254
254
  }
255
- virtual bool protectedByCommonLocks(const Instruction *I1,
256
- const Instruction *I2)
255
+ virtual bool protectedByCommonLocks(const Instruction* I1,
256
+ const Instruction* I2)
257
257
  {
258
258
  selectedValidationScenarios &= ~RC_PROTECTED;
259
259
  return true;
260
260
  }
261
- virtual bool mayHaveDataRace(const Instruction *I1,
262
- const Instruction *I2)
261
+ virtual bool mayHaveDataRace(const Instruction* I1,
262
+ const Instruction* I2)
263
263
  {
264
264
  selectedValidationScenarios &= ~RC_RACE;
265
265
  return true;
@@ -274,15 +274,18 @@ protected:
274
274
  void collectValidationTargets()
275
275
  {
276
276
  // Collect call sites of all RC_ACCESS function calls.
277
- std::vector<const CallInst*> csInsts;
278
- const Function *F = nullptr;
279
- for(auto it = M->llvmFunBegin(); it != M->llvmFunEnd(); it++)
277
+ std::vector<CallSite> csInsts;
278
+ const Function* F = nullptr;
279
+ for (Module &M : LLVMModuleSet::getLLVMModuleSet()->getLLVMModules())
280
280
  {
281
- const std::string fName = (*it)->getName().str();
282
- if(fName.find(RC_ACCESS) != std::string::npos)
281
+ for(auto it = M.begin(); it != M.end(); it++)
283
282
  {
284
- F = (*it);
285
- break;
283
+ const std::string fName = (*it).getName().str();
284
+ if(fName.find(RC_ACCESS) != std::string::npos)
285
+ {
286
+ F = &(*it);
287
+ break;
288
+ }
286
289
  }
287
290
  }
288
291
  if (!F) return;
@@ -292,9 +295,11 @@ protected:
292
295
  {
293
296
  const Use *u = &*it;
294
297
  const Value *user = u->getUser();
295
- const CallInst *csInst = SVFUtil::dyn_cast<CallInst>(user);
296
- assert(csInst);
297
- csInsts.push_back(csInst);
298
+ if(SVFUtil::isCallSite(user))
299
+ {
300
+ CallSite csInst = SVFUtil::getLLVMCallSite(user);
301
+ csInsts.push_back(csInst);
302
+ }
298
303
  }
299
304
  assert(csInsts.size() % 2 == 0 && "We should have RC_ACCESS called in pairs.");
300
305
 
@@ -304,12 +309,12 @@ protected:
304
309
  // Generate access pairs.
305
310
  for (int i = 0, e = csInsts.size(); i != e;)
306
311
  {
307
- const CallInst *CI1 = csInsts[i++];
308
- const CallInst *CI2 = csInsts[i++];
309
- const ConstantInt *C = SVFUtil::dyn_cast<ConstantInt>(CI1->getOperand(1));
312
+ CallSite CI1 = csInsts[i++];
313
+ CallSite CI2 = csInsts[i++];
314
+ const ConstantInt* C = SVFUtil::dyn_cast<ConstantInt>(CI1.getArgOperand(1));
310
315
  assert(C);
311
- const Instruction *I1 = getPreviousMemoryAccessInst(CI1);
312
- const Instruction *I2 = getPreviousMemoryAccessInst(CI2);
316
+ const Instruction* I1 = getPreviousMemoryAccessInst(CI1.getInstruction()->getLLVMInstruction());
317
+ const Instruction* I2 = getPreviousMemoryAccessInst(CI2.getInstruction()->getLLVMInstruction());
313
318
  assert(I1 && I2 && "RC_ACCESS should be placed immediately after the target memory access.");
314
319
  RC_FLAG flags = C->getZExtValue();
315
320
  accessPairs.push_back(AccessPair(I1, I2, flags));
@@ -325,8 +330,8 @@ protected:
325
330
  for (int i = 0, e = accessPairs.size(); i != e; ++i)
326
331
  {
327
332
  const AccessPair &ap = accessPairs[i];
328
- const Instruction *I1 = ap.getInstruction1();
329
- const Instruction *I2 = ap.getInstruction2();
333
+ const Instruction* I1 = ap.getInstruction1();
334
+ const Instruction* I2 = ap.getInstruction2();
330
335
 
331
336
  bool mhp = mayHappenInParallel(I1, I2);
332
337
  bool alias = mayAccessAliases(I1, I2);
@@ -390,12 +395,12 @@ private:
390
395
  * Comparison function to sort the validation targets in ascending order of
391
396
  * the validation id (i.e., the 1st argument of RC_ACCESS function call).
392
397
  */
393
- static bool compare(const CallInst *CI1, const CallInst *CI2)
398
+ static bool compare(CallSite CI1, CallSite CI2)
394
399
  {
395
- const Value *V1 = CI1->getOperand(0);
396
- const Value *V2 = CI2->getOperand(0);
397
- const ConstantInt *C1 = SVFUtil::dyn_cast<ConstantInt>(V1);
398
- const ConstantInt *C2 = SVFUtil::dyn_cast<ConstantInt>(V2);
400
+ const Value *V1 = CI1.getArgOperand(0);
401
+ const Value *V2 = CI2.getArgOperand(0);
402
+ const ConstantInt* C1 = SVFUtil::dyn_cast<ConstantInt>(V1);
403
+ const ConstantInt* C2 = SVFUtil::dyn_cast<ConstantInt>(V2);
399
404
  assert(0 != C1 && 0 != C2);
400
405
  return C1->getZExtValue() < C2->getZExtValue();
401
406
  }
@@ -405,8 +410,8 @@ private:
405
410
  * same BasicBlock.
406
411
  * Return nullptr if none exists.
407
412
  */
408
- const Instruction *getPreviousMemoryAccessInst(
409
- const Instruction *I)
413
+ const Instruction* getPreviousMemoryAccessInst(
414
+ const Instruction* I)
410
415
  {
411
416
  I = I->getPrevNode();
412
417
  while (I)
@@ -414,7 +419,9 @@ private:
414
419
  if (SVFUtil::isa<LoadInst>(I) || SVFUtil::isa<StoreInst>(I))
415
420
  return I;
416
421
 
417
- if (const SVFFunction *callee = SVFUtil::getCallee(I))
422
+ const SVFInstruction* inst = LLVMModuleSet::getLLVMModuleSet()->getSVFInstruction(I);
423
+
424
+ if (const SVFFunction *callee = SVFUtil::getCallee(inst))
418
425
  {
419
426
  if (callee->getName().find("llvm.memset") != std::string::npos)
420
427
  return I;
@@ -51,11 +51,11 @@ class PCG
51
51
  {
52
52
 
53
53
  public:
54
- typedef Set<const Function*> FunSet;
55
- typedef std::vector<const Function*> FunVec;
56
- typedef Set<const Instruction*> CallInstSet;
57
- typedef FIFOWorkList<const Function*> FunWorkList;
58
- typedef FIFOWorkList<const BasicBlock*> BBWorkList;
54
+ typedef Set<const SVFFunction*> FunSet;
55
+ typedef std::vector<const SVFFunction*> FunVec;
56
+ typedef Set<const SVFInstruction*> CallInstSet;
57
+ typedef FIFOWorkList<const SVFFunction*> FunWorkList;
58
+ typedef FIFOWorkList<const SVFBasicBlock*> BBWorkList;
59
59
 
60
60
  private:
61
61
  FunSet spawners;
@@ -72,31 +72,31 @@ private:
72
72
 
73
73
  /// Add/Get methods for thread properties of a procedure
74
74
  //@{
75
- inline bool isSpawnerFun(const Function* fun) const
75
+ inline bool isSpawnerFun(const SVFFunction* fun) const
76
76
  {
77
77
  return spawners.find(fun) != spawners.end();
78
78
  }
79
- inline bool isSpawneeFun(const Function* fun) const
79
+ inline bool isSpawneeFun(const SVFFunction* fun) const
80
80
  {
81
81
  return spawnees.find(fun) != spawnees.end();
82
82
  }
83
- inline bool isFollowerFun(const Function* fun) const
83
+ inline bool isFollowerFun(const SVFFunction* fun) const
84
84
  {
85
85
  return followers.find(fun) != followers.end();
86
86
  }
87
- inline bool addSpawnerFun(const Function* fun)
87
+ inline bool addSpawnerFun(const SVFFunction* fun)
88
88
  {
89
89
  if (fun->isDeclaration())
90
90
  return false;
91
91
  return spawners.insert(fun).second;
92
92
  }
93
- inline bool addSpawneeFun(const Function* fun)
93
+ inline bool addSpawneeFun(const SVFFunction* fun)
94
94
  {
95
95
  if (fun->isDeclaration())
96
96
  return false;
97
97
  return spawnees.insert(fun).second;
98
98
  }
99
- inline bool addFollowerFun(const Function* fun)
99
+ inline bool addFollowerFun(const SVFFunction* fun)
100
100
  {
101
101
  if (fun->isDeclaration())
102
102
  return false;
@@ -106,11 +106,11 @@ private:
106
106
 
107
107
  /// Add/search spawn sites which directly or indirectly create a thread
108
108
  //@{
109
- inline bool addSpawnsite(const Instruction* callInst)
109
+ inline bool addSpawnsite(const SVFInstruction* callInst)
110
110
  {
111
111
  return spawnCallSites.insert(callInst).second;
112
112
  }
113
- inline bool isSpawnsite(const Instruction* callInst)
113
+ inline bool isSpawnsite(const SVFInstruction* callInst)
114
114
  {
115
115
  return spawnCallSites.find(callInst) != spawnCallSites.end();
116
116
  }
@@ -145,18 +145,13 @@ public:
145
145
  {
146
146
  }
147
147
 
148
- CallICFGNode* getCallICFGNode(const Instruction* inst)
148
+ CallICFGNode* getCallICFGNode(const SVFInstruction* inst)
149
149
  {
150
150
  return pta->getICFG()->getCallICFGNode(inst);
151
151
  }
152
- const SVFFunction* getSVFFun(const Function* fun) const
153
- {
154
- return LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(fun);
155
- }
156
152
  /// Interface to query whether two function may happen-in-parallel
157
- virtual bool mayHappenInParallel(const Instruction* i1, const Instruction* i2) const;
158
- bool mayHappenInParallelBetweenFunctions(const Function* fun1, const Function* fun2) const;
159
- //bool mayHappenInParallel(const Function* fun1, const Function* fun2) const;
153
+ virtual bool mayHappenInParallel(const SVFInstruction* i1, const SVFInstruction* i2) const;
154
+ bool mayHappenInParallelBetweenFunctions(const SVFFunction* fun1, const SVFFunction* fun2) const;
160
155
  inline const FunSet& getMHPFunctions() const
161
156
  {
162
157
  return mhpfuns;
@@ -192,27 +187,27 @@ public:
192
187
 
193
188
  /// Iterators for thread properties of a procedure
194
189
  //@{
195
- inline FunSet::const_iterator spawnersBegin(const Function* fun) const
190
+ inline FunSet::const_iterator spawnersBegin(const SVFFunction* fun) const
196
191
  {
197
192
  return spawners.begin();
198
193
  }
199
- inline FunSet::const_iterator spawnersEnd(const Function* fun) const
194
+ inline FunSet::const_iterator spawnersEnd(const SVFFunction* fun) const
200
195
  {
201
196
  return spawners.end();
202
197
  }
203
- inline FunSet::const_iterator spawneesBegin(const Function* fun) const
198
+ inline FunSet::const_iterator spawneesBegin(const SVFFunction* fun) const
204
199
  {
205
200
  return spawnees.begin();
206
201
  }
207
- inline FunSet::const_iterator spawneesEnd(const Function* fun) const
202
+ inline FunSet::const_iterator spawneesEnd(const SVFFunction* fun) const
208
203
  {
209
204
  return spawnees.end();
210
205
  }
211
- inline FunSet::const_iterator followersBegin(const Function* fun) const
206
+ inline FunSet::const_iterator followersBegin(const SVFFunction* fun) const
212
207
  {
213
208
  return followers.begin();
214
209
  }
215
- inline FunSet::const_iterator followersEnd(const Function* fun) const
210
+ inline FunSet::const_iterator followersEnd(const SVFFunction* fun) const
216
211
  {
217
212
  return followers.end();
218
213
  }
@@ -51,7 +51,6 @@ typedef GenericEdge<TCTNode> GenericTCTEdgeTy;
51
51
  class TCTEdge: public GenericTCTEdgeTy
52
52
  {
53
53
  public:
54
- typedef Set<const Instruction*> CallInstSet;
55
54
  enum CEDGEK
56
55
  {
57
56
  ThreadCreateEdge
@@ -140,14 +139,14 @@ class TCT: public GenericThreadCreateTreeTy
140
139
  public:
141
140
  typedef TCTEdge::ThreadCreateEdgeSet ThreadCreateEdgeSet;
142
141
  typedef ThreadCreateEdgeSet::iterator TCTNodeIter;
143
- typedef Set<const Function*> FunSet;
144
- typedef std::vector<const Instruction*> InstVec;
145
- typedef Set<const Instruction*> InstSet;
142
+ typedef Set<const SVFFunction*> FunSet;
143
+ typedef std::vector<const SVFInstruction*> InstVec;
144
+ typedef Set<const SVFInstruction*> InstSet;
146
145
  typedef Set<const PTACallGraphNode*> PTACGNodeSet;
147
146
  typedef Map<CxtThread,TCTNode*> CxtThreadToNodeMap;
148
147
  typedef Map<CxtThread,CallStrCxt> CxtThreadToForkCxt;
149
- typedef Map<CxtThread,const Function*> CxtThreadToFun;
150
- typedef Map<const Instruction*, const Loop*> InstToLoopMap;
148
+ typedef Map<CxtThread,const SVFFunction*> CxtThreadToFun;
149
+ typedef Map<const SVFInstruction*, const Loop*> InstToLoopMap;
151
150
  typedef FIFOWorkList<CxtThreadProc> CxtThreadProcVec;
152
151
  typedef Set<CxtThreadProc> CxtThreadProcSet;
153
152
  typedef SCCDetection<PTACallGraph*> ThreadCallGraphSCC;
@@ -169,15 +168,10 @@ public:
169
168
  destroy();
170
169
  }
171
170
  /// Get CallICFGNode given inst
172
- CallICFGNode* getCallICFGNode(const Instruction* inst)
171
+ CallICFGNode* getCallICFGNode(const SVFInstruction* inst)
173
172
  {
174
173
  return pta->getICFG()->getCallICFGNode(inst);
175
174
  }
176
- /// Get SVFFuntion given Function
177
- const SVFFunction* getSVFFun(const Function* fun) const
178
- {
179
- return LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(fun);
180
- }
181
175
  /// Get SVFFModule
182
176
  SVFModule* getSVFModule() const
183
177
  {
@@ -272,18 +266,14 @@ public:
272
266
  for(PTACallGraph::FunctionSet::const_iterator cit = callees.begin(),
273
267
  ecit = callees.end(); cit!=ecit; cit++)
274
268
  {
275
- if(candidateFuncSet.find((*cit)->getLLVMFun())!=candidateFuncSet.end())
269
+ if(candidateFuncSet.find((*cit))!=candidateFuncSet.end())
276
270
  return true;
277
271
  }
278
272
  return false;
279
273
  }
280
- inline bool isCandidateFun(const Function* fun) const
281
- {
282
- return candidateFuncSet.find(fun)!=candidateFuncSet.end();
283
- }
284
274
  inline bool isCandidateFun(const SVFFunction* fun) const
285
275
  {
286
- return isCandidateFun(fun->getLLVMFun());
276
+ return candidateFuncSet.find(fun)!=candidateFuncSet.end();
287
277
  }
288
278
  /// Whether two functions in the same callgraph scc
289
279
  inline bool inSameCallGraphSCC(const PTACallGraphNode* src,const PTACallGraphNode* dst)
@@ -357,7 +347,7 @@ public:
357
347
  }
358
348
 
359
349
  /// get the start routine function of a thread
360
- const Function* getStartRoutineOfCxtThread(const CxtThread& ct) const
350
+ const SVFFunction* getStartRoutineOfCxtThread(const CxtThread& ct) const
361
351
  {
362
352
  CxtThreadToFun::const_iterator it = ctToRoutineFunMap.find(ct);
363
353
  assert(it!=ctToRoutineFunMap.end() && "Cxt Thread not found!!");
@@ -365,7 +355,7 @@ public:
365
355
  }
366
356
 
367
357
  /// Get loop for join site
368
- inline const Loop* getJoinLoop(const Instruction* join)
358
+ inline const Loop* getJoinLoop(const SVFInstruction* join)
369
359
  {
370
360
  assert(tcg->getThreadAPI()->isTDJoin(join) && "not a join site");
371
361
  InstToLoopMap::const_iterator it = joinSiteToLoopMap.find(join);
@@ -374,24 +364,24 @@ public:
374
364
  return nullptr;
375
365
  }
376
366
  /// Return true if a join instruction must be executed inside a loop
377
- bool isJoinMustExecutedInLoop(const Loop* lp,const Instruction* join);
367
+ bool isJoinMustExecutedInLoop(const Loop* lp,const SVFInstruction* join);
378
368
  /// Get loop for an instruction
379
- const Loop* getLoop(const Instruction* inst);
369
+ const Loop* getLoop(const SVFInstruction* inst);
380
370
  /// Get dominator for a function
381
371
  const DominatorTree* getDT(const Function* fun);
382
372
  /// Get dominator for a function
383
373
  const PostDominatorTree* getPostDT(const Function* fun);
384
374
  /// Get loop for fork/join site
385
- const Loop* getLoop(const BasicBlock* bb);
375
+ const Loop* getLoop(const SVFBasicBlock* bb);
386
376
  /// Get SE for function
387
- ScalarEvolution* getSE(const Instruction* inst);
377
+ ScalarEvolution* getSE(const SVFInstruction* inst);
388
378
 
389
379
  /// Get the next instructions following control flow
390
- void getNextInsts(const Instruction* inst, InstVec& instSet);
380
+ void getNextInsts(const SVFInstruction* inst, InstVec& instSet);
391
381
  /// Push calling context
392
- void pushCxt(CallStrCxt& cxt, const Instruction* call, const Function* callee);
382
+ void pushCxt(CallStrCxt& cxt, const SVFInstruction* call, const SVFFunction* callee);
393
383
  /// Match context
394
- bool matchCxt(CallStrCxt& cxt, const Instruction* call, const Function* callee);
384
+ bool matchCxt(CallStrCxt& cxt, const SVFInstruction* call, const SVFFunction* callee);
395
385
 
396
386
  inline void pushCxt(CallStrCxt& cxt, CallSiteID csId)
397
387
  {
@@ -400,7 +390,7 @@ public:
400
390
  MaxCxtSize = cxt.size();
401
391
  }
402
392
  /// Whether a join site is in recursion
403
- inline bool isJoinSiteInRecursion(const Instruction* join) const
393
+ inline bool isJoinSiteInRecursion(const SVFInstruction* join) const
404
394
  {
405
395
  assert(tcg->getThreadAPI()->isTDJoin(join) && "not a join site");
406
396
  return inRecurJoinSites.find(join)!=inRecurJoinSites.end();
@@ -452,7 +442,7 @@ private:
452
442
  /// Mark relevant procedures that are backward reachable from any fork/join site
453
443
  //@{
454
444
  void markRelProcs();
455
- void markRelProcs(const Function* fun);
445
+ void markRelProcs(const SVFFunction* fun);
456
446
  //@}
457
447
 
458
448
  /// Get entry functions that are neither called by other functions nor extern functions
@@ -467,17 +457,17 @@ private:
467
457
  /// collect loop info for join sites
468
458
  void collectLoopInfoForJoin();
469
459
  /// Whether a given bb is a loop head of a inloop join site
470
- bool isLoopHeaderOfJoinLoop(const BasicBlock* bb);
460
+ bool isLoopHeaderOfJoinLoop(const SVFBasicBlock* bb);
471
461
  /// Whether a given bb is an exit of a inloop join site
472
- bool isLoopExitOfJoinLoop(const BasicBlock* bb);
462
+ bool isLoopExitOfJoinLoop(const SVFBasicBlock* bb);
473
463
  //@}
474
464
 
475
465
  /// Multi-forked threads
476
466
  //@{
477
467
  /// Whether an instruction is in a loop
478
- bool isInLoopInstruction(const Instruction* inst);
468
+ bool isInLoopInstruction(const SVFInstruction* inst);
479
469
  /// Whether an instruction is in a recursion
480
- bool isInRecursion(const Instruction* inst) const;
470
+ bool isInRecursion(const SVFInstruction* inst) const;
481
471
  //@}
482
472
 
483
473
  /// Handle call relations
@@ -485,7 +475,7 @@ private:
485
475
 
486
476
  /// Get or create a tct node based on CxtThread
487
477
  //@{
488
- inline TCTNode* getOrCreateTCTNode(const CallStrCxt& cxt, const CallInst* fork,const CallStrCxt& oldCxt, const Function* routine)
478
+ inline TCTNode* getOrCreateTCTNode(const CallStrCxt& cxt, const SVFInstruction* fork,const CallStrCxt& oldCxt, const SVFFunction* routine)
489
479
  {
490
480
  CxtThread ct(cxt,fork);
491
481
  CxtThreadToNodeMap::const_iterator it = ctpToNodeMap.find(ct);
@@ -508,8 +498,9 @@ private:
508
498
  /// non-main thread
509
499
  if(ct.getThread() != nullptr)
510
500
  {
511
- ct.setInloop(isInLoopInstruction(ct.getThread()));
512
- ct.setIncycle(isInRecursion(ct.getThread()));
501
+ const SVFInstruction* svfInst = ct.getThread();
502
+ ct.setInloop(isInLoopInstruction(svfInst));
503
+ ct.setIncycle(isInRecursion(svfInst));
513
504
  }
514
505
  /// main thread
515
506
  else
@@ -525,7 +516,7 @@ private:
525
516
  ctToForkCxtMap[ct] = cxt;
526
517
  }
527
518
  /// Add start routine function of a cxt thread
528
- void addStartRoutineOfCxtThread(const Function* fun, const CxtThread& ct)
519
+ void addStartRoutineOfCxtThread(const SVFFunction* fun, const CxtThread& ct)
529
520
  {
530
521
  ctToRoutineFunMap[ct] = fun;
531
522
  }
@@ -58,7 +58,7 @@ public:
58
58
 
59
59
  private:
60
60
  const Value* value; ///< LLVM value
61
- const BasicBlock *basicBlock; ///< LLVM BasicBlock
61
+ const SVFBasicBlock* basicBlock; ///< LLVM BasicBlock
62
62
  ICFGNode *icfgNode; ///< ICFGNode
63
63
  EdgeID edgeId; ///< Edge ID
64
64
  public:
@@ -104,11 +104,16 @@ public:
104
104
 
105
105
  /// Get/set methods for llvm instruction
106
106
  //@{
107
- inline const Instruction* getInst() const
107
+ inline const SVFInstruction* getInst() const
108
108
  {
109
- return SVFUtil::dyn_cast<Instruction>(value);
109
+ if(const Instruction* i = SVFUtil::dyn_cast<Instruction>(value))
110
+ {
111
+ return LLVMModuleSet::getLLVMModuleSet()->getSVFInstruction(i);
112
+ }
113
+ else
114
+ return nullptr;
110
115
  }
111
- inline void setValue(const Value *val)
116
+ inline void setValue(const Value* val)
112
117
  {
113
118
  value = val;
114
119
  }
@@ -116,11 +121,11 @@ public:
116
121
  {
117
122
  return value;
118
123
  }
119
- inline void setBB(const BasicBlock *bb)
124
+ inline void setBB(const SVFBasicBlock* bb)
120
125
  {
121
126
  basicBlock = bb;
122
127
  }
123
- inline const BasicBlock* getBB() const
128
+ inline const SVFBasicBlock* getBB() const
124
129
  {
125
130
  return basicBlock;
126
131
  }
@@ -124,16 +124,16 @@ public:
124
124
  virtual const std::string getValueName() const = 0;
125
125
 
126
126
  /// Return the function that this SVFVar resides in. Return nullptr if it is a global or constantexpr node
127
- virtual inline const Function* getFunction() const
127
+ virtual inline const SVFFunction* getFunction() const
128
128
  {
129
129
  if(value)
130
130
  {
131
131
  if(const Instruction* inst = SVFUtil::dyn_cast<Instruction>(value))
132
- return inst->getParent()->getParent();
132
+ return LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(inst->getParent()->getParent());
133
133
  else if (const Argument* arg = SVFUtil::dyn_cast<Argument>(value))
134
- return arg->getParent();
134
+ return LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(arg->getParent());
135
135
  else if (const Function* fun = SVFUtil::dyn_cast<Function>(value))
136
- return fun;
136
+ return LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(fun);
137
137
  }
138
138
  return nullptr;
139
139
  }
@@ -67,17 +67,14 @@ public:
67
67
  //{@
68
68
  /// llvm value to sym id map
69
69
  /// local (%) and global (@) identifiers are pointer types which have a value node id.
70
- typedef OrderedMap<const Value *, SymID> ValueToIDMapTy;
70
+ typedef OrderedMap<const Value*, SymID> ValueToIDMapTy;
71
71
  /// sym id to memory object map
72
72
  typedef OrderedMap<SymID,MemObj*> IDToMemMapTy;
73
73
  /// function to sym id map
74
- typedef OrderedMap<const Function *, SymID> FunToIDMapTy;
74
+ typedef OrderedMap<const SVFFunction*, SymID> FunToIDMapTy;
75
75
  /// struct type to struct info map
76
76
  typedef OrderedMap<const Type*, StInfo*> TypeToFieldInfoMap;
77
77
  typedef Set<CallSite> CallSiteSet;
78
- typedef OrderedMap<const Instruction*,CallSiteID> CallSiteToIDMapTy;
79
- typedef OrderedMap<CallSiteID,const Instruction*> IDToCallSiteMapTy;
80
-
81
78
  //@}
82
79
 
83
80
  private:
@@ -161,15 +158,12 @@ public:
161
158
 
162
159
  /// special value
163
160
  // @{
164
- static bool isNullPtrSym(const Value *val);
165
- static bool isBlackholeSym(const Value *val);
166
- static bool isArgOfUncalledFunction(const Value *val);
167
- static bool isReturn(const Instruction *inst);
168
- static bool isPtrInUncalledFunction (const Value * value);
169
- static const u32_t getBBSuccessorNum(const BasicBlock *bb);
161
+ static bool isBlackholeSym(const Value* val);
162
+ static bool isArgOfUncalledFunction(const Value* val);
163
+ static bool isReturn(const SVFInstruction *inst);
164
+ static bool isPtrInUncalledFunction (const Value* value);
165
+ static const u32_t getBBSuccessorNum(const SVFBasicBlock* bb);
170
166
  static const Type* getPtrElementType(const PointerType* pty);
171
- static const u32_t getBBSuccessorPos(const BasicBlock *BB, const BasicBlock *Succ);
172
- static const u32_t getBBPredecessorPos(const BasicBlock *BB, const BasicBlock *Pred);
173
167
 
174
168
  static inline bool isBlkPtr(NodeID id)
175
169
  {
@@ -231,11 +225,11 @@ public:
231
225
 
232
226
  /// Get different kinds of syms
233
227
  //@{
234
- SymID getValSym(const Value *val);
228
+ SymID getValSym(const Value* val);
235
229
 
236
230
  bool hasValSym(const Value* val);
237
231
 
238
- inline SymID getObjSym(const Value *val) const
232
+ inline SymID getObjSym(const Value* val) const
239
233
  {
240
234
  ValueToIDMapTy::const_iterator iter = objSymMap.find(SVFUtil::getGlobalRep(val));
241
235
  assert(iter!=objSymMap.end() && "obj sym not found");
@@ -249,14 +243,14 @@ public:
249
243
  return iter->second;
250
244
  }
251
245
 
252
- inline SymID getRetSym(const Function *val) const
246
+ inline SymID getRetSym(const SVFFunction* val) const
253
247
  {
254
248
  FunToIDMapTy::const_iterator iter = returnSymMap.find(val);
255
249
  assert(iter!=returnSymMap.end() && "ret sym not found");
256
250
  return iter->second;
257
251
  }
258
252
 
259
- inline SymID getVarargSym(const Function *val) const
253
+ inline SymID getVarargSym(const SVFFunction* val) const
260
254
  {
261
255
  FunToIDMapTy::const_iterator iter = varargSymMap.find(val);
262
256
  assert(iter!=varargSymMap.end() && "vararg sym not found");
@@ -382,13 +376,13 @@ private:
382
376
  /// Type information of this object
383
377
  ObjTypeInfo* typeInfo;
384
378
  /// The unique value of this symbol/variable
385
- const Value *refVal;
379
+ const Value* refVal;
386
380
  /// The unique id to represent this symbol
387
381
  SymID symId;
388
382
 
389
383
  public:
390
384
  /// Constructor
391
- MemObj(SymID id, ObjTypeInfo* ti, const Value *val = nullptr);
385
+ MemObj(SymID id, ObjTypeInfo* ti, const Value* val = nullptr);
392
386
 
393
387
  /// Destructor
394
388
  virtual ~MemObj()