svf-tools 1.0.1063 → 1.0.1065

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.1063",
3
+ "version": "1.0.1065",
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": {
@@ -72,7 +72,7 @@ public:
72
72
  typedef OrderedMap<const Function*, NodeID> FunToIDMapTy;
73
73
 
74
74
  typedef std::vector<const Function*> FunctionSet;
75
- typedef Map<const Function*, const SVFBasicBlock*> FunToExitBBMap;
75
+ typedef Map<const Function*, const BasicBlock*> FunToExitBBMap;
76
76
  typedef Map<const Function*, const Function *> FunToRealDefFunMap;
77
77
 
78
78
  private:
@@ -173,7 +173,7 @@ public:
173
173
 
174
174
  public:
175
175
 
176
- inline const SVFBasicBlock* getFunExitBB(const Function* fun) const
176
+ inline const BasicBlock* getFunExitBB(const Function* fun) const
177
177
  {
178
178
  auto it = funToExitBB.find(fun);
179
179
  if (it == funToExitBB.end()) return nullptr;
@@ -435,7 +435,7 @@ private:
435
435
  funSet.push_back(svfFunc);
436
436
  }
437
437
 
438
- inline void setFunExitBB(const Function* fun, const SVFBasicBlock* bb)
438
+ inline void setFunExitBB(const Function* fun, const BasicBlock* bb)
439
439
  {
440
440
  funToExitBB[fun] = bb;
441
441
  }
@@ -205,6 +205,34 @@ void LLVMModuleSet::createSVFDataStructure()
205
205
  addFunctionSet(func);
206
206
  }
207
207
 
208
+ // set function exit block
209
+ for (const auto& func: funSet) {
210
+ for (Function::const_iterator bit = func->begin(), ebit = func->end(); bit != ebit; ++bit)
211
+ {
212
+ const BasicBlock* bb = &*bit;
213
+ /// set exit block: exit basic block must have no successors and have a return instruction
214
+ if (succ_size(bb) == 0)
215
+ {
216
+ if (LLVMUtil::basicBlockHasRetInst(bb))
217
+ {
218
+ assert((LLVMUtil::functionDoesNotRet(func) ||
219
+ SVFUtil::isa<ReturnInst>(bb->back())) &&
220
+ "last inst must be return inst");
221
+ setFunExitBB(func, bb);
222
+ }
223
+ }
224
+ }
225
+ // For no return functions, we set the last block as exit BB
226
+ // This ensures that each function that has definition must have an exit BB
227
+ if (func->size() != 0 && !getFunExitBB(func))
228
+ {
229
+ assert((LLVMUtil::functionDoesNotRet(func) ||
230
+ SVFUtil::isa<ReturnInst>(&func->back().back())) &&
231
+ "last inst must be return inst");
232
+ setFunExitBB(func, &func->back());
233
+ }
234
+ }
235
+
208
236
  // Store annotations of functions in extapi.bc
209
237
  for (const auto& pair : ExtFun2Annotations)
210
238
  {
@@ -626,7 +626,7 @@ Set<const Value *> &ObjTypeInference::bwfindAllocOfVar(const Value *var)
626
626
  {
627
627
 
628
628
  LLVMModuleSet* llvmmodule = LLVMModuleSet::getLLVMModuleSet();
629
- const BasicBlock* exitBB = SVFUtil::dyn_cast<BasicBlock>(llvmmodule->getLLVMValue(llvmmodule->getFunExitBB(callee)));
629
+ const BasicBlock* exitBB = llvmmodule->getFunExitBB(callee);
630
630
  assert (exitBB && "exit bb is not a basic block?");
631
631
  const Value *pValue = &exitBB->back();
632
632
  const auto *retInst = SVFUtil::dyn_cast<ReturnInst>(pValue);
@@ -934,7 +934,7 @@ Set<const Value *> &ObjTypeInference::bwFindAllocOrClsNameSources(const Value *s
934
934
  if (!callee->isDeclaration())
935
935
  {
936
936
  LLVMModuleSet* llvmmodule = LLVMModuleSet::getLLVMModuleSet();
937
- const BasicBlock* exitBB = SVFUtil::dyn_cast<BasicBlock>(llvmmodule->getLLVMValue(llvmmodule->getFunExitBB(callee)));
937
+ const BasicBlock* exitBB = llvmmodule->getFunExitBB(callee);
938
938
  assert (exitBB && "exit bb is not a basic block?");
939
939
  const Value *pValue = &exitBB->back();
940
940
  const auto *retInst = SVFUtil::dyn_cast<ReturnInst>(pValue);
@@ -242,7 +242,6 @@ void SVFIRBuilder::initSVFBasicBlock(const Function* func)
242
242
  SVFUtil::isa<ReturnInst>(bb->back())) &&
243
243
  "last inst must be return inst");
244
244
  svfFun->setExitBlock(svfbb);
245
- llvmModuleSet()->setFunExitBB(func, svfbb);
246
245
  }
247
246
  }
248
247
  }
@@ -255,7 +254,6 @@ void SVFIRBuilder::initSVFBasicBlock(const Function* func)
255
254
  SVFUtil::isa<ReturnInst>(&func->back().back())) &&
256
255
  "last inst must be return inst");
257
256
  svfFun->setExitBlock(retBB);
258
- llvmModuleSet()->setFunExitBB(func, retBB);
259
257
  }
260
258
  }
261
259