svf-tools 1.0.1024 → 1.0.1026

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.1024",
3
+ "version": "1.0.1026",
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": {
@@ -82,7 +82,7 @@ public:
82
82
  }
83
83
 
84
84
  /// Return the corresponding LLVM value, if possible, nullptr otherwise.
85
- virtual const SVFValue* getValue() const
85
+ virtual const SVFVar* getValue() const
86
86
  {
87
87
  return nullptr;
88
88
  }
@@ -190,7 +190,7 @@ public:
190
190
  }
191
191
  //@}
192
192
 
193
- const SVFValue* getValue() const override;
193
+ const SVFVar* getValue() const override;
194
194
  const std::string toString() const override;
195
195
  };
196
196
 
@@ -401,7 +401,9 @@ public:
401
401
 
402
402
  const NodeBS getDefSVFVars() const override;
403
403
 
404
- const SVFValue* getValue() const override;
404
+ const SVFVar* getValue() const override;
405
+
406
+
405
407
  const std::string toString() const override;
406
408
  };
407
409
 
@@ -476,7 +478,7 @@ public:
476
478
 
477
479
  const NodeBS getDefSVFVars() const override;
478
480
 
479
- const SVFValue* getValue() const override;
481
+ const SVFVar* getValue() const override;
480
482
  const std::string toString() const override;
481
483
  };
482
484
 
@@ -736,7 +738,7 @@ public:
736
738
 
737
739
  const NodeBS getDefSVFVars() const override;
738
740
 
739
- const SVFValue* getValue() const override;
741
+ const SVFVar* getValue() const override;
740
742
  const std::string toString() const override;
741
743
  };
742
744
 
@@ -879,7 +881,7 @@ public:
879
881
  }
880
882
  //@}
881
883
 
882
- const SVFValue* getValue() const override;
884
+ const SVFVar* getValue() const override;
883
885
  const std::string toString() const override;
884
886
  };
885
887
 
@@ -585,10 +585,10 @@ private:
585
585
  return addNode(node, i);
586
586
  }
587
587
 
588
- inline NodeID addConstantIntValNode(const SVFValue* curInst, s64_t sval, u64_t zval, const NodeID i,
588
+ inline NodeID addConstantIntValNode(const SVFValue* curInst, const std::pair<s64_t, u64_t>& intValue, const NodeID i,
589
589
  const ICFGNode* icfgNode)
590
590
  {
591
- SVFVar* node = new ConstantIntValVar(curInst, sval, zval, i, icfgNode);
591
+ SVFVar* node = new ConstantIntValVar(curInst, intValue.first, intValue.second, i, icfgNode);
592
592
  return addNode(node, i);
593
593
  }
594
594
 
@@ -656,13 +656,13 @@ private:
656
656
  }
657
657
 
658
658
 
659
- inline NodeID addConstantIntObjNode(const SVFValue* curInst, s64_t sval, u64_t zval, const NodeID i)
659
+ inline NodeID addConstantIntObjNode(const SVFValue* curInst, const std::pair<s64_t, u64_t>& intValue, const NodeID i)
660
660
  {
661
661
  const MemObj* mem = getMemObj(curInst);
662
662
  NodeID base = mem->getId();
663
663
  memToFieldsMap[base].set(mem->getId());
664
664
  ConstantIntObjVar* node =
665
- new ConstantIntObjVar(curInst, sval, zval, mem->getId(), mem);
665
+ new ConstantIntObjVar(curInst, intValue.first, intValue.second, mem->getId(), mem);
666
666
  return addObjNode(curInst, node, mem->getId());
667
667
  }
668
668
 
@@ -78,7 +78,7 @@ public:
78
78
  };
79
79
 
80
80
  private:
81
- const SVFValue* value; ///< LLVM value
81
+ const SVFVar* value; ///< LLVM value
82
82
  const SVFBasicBlock* basicBlock; ///< LLVM BasicBlock
83
83
  ICFGNode* icfgNode; ///< ICFGNode
84
84
  EdgeID edgeId; ///< Edge ID
@@ -134,20 +134,16 @@ public:
134
134
 
135
135
  /// Get/set methods for llvm instruction
136
136
  //@{
137
- inline const SVFInstruction* getInst() const
138
- {
139
- if (const SVFInstruction* i = SVFUtil::dyn_cast<SVFInstruction>(value))
140
- return i;
141
- return nullptr;
142
- }
143
- inline void setValue(const SVFValue* val)
137
+
138
+ inline void setValue(const SVFVar* val)
144
139
  {
145
140
  value = val;
146
141
  }
147
- inline const SVFValue* getValue() const
142
+ inline const SVFVar* getValue() const
148
143
  {
149
144
  return value;
150
145
  }
146
+
151
147
  inline void setBB(const SVFBasicBlock* bb)
152
148
  {
153
149
  basicBlock = bb;
@@ -321,7 +317,7 @@ private:
321
317
  AddrStmt(const AddrStmt&); ///< place holder
322
318
  void operator=(const AddrStmt&); ///< place holder
323
319
 
324
- std::vector<SVFValue*> arrSize; ///< Array size of the allocated memory
320
+ std::vector<SVFVar*> arrSize; ///< Array size of the allocated memory
325
321
 
326
322
  public:
327
323
  /// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -345,13 +341,13 @@ public:
345
341
 
346
342
  virtual const std::string toString() const override;
347
343
 
348
- inline void addArrSize(SVFValue* size) //TODO:addSizeVar
344
+ inline void addArrSize(SVFVar* size) //TODO:addSizeVar
349
345
  {
350
346
  arrSize.push_back(size);
351
347
  }
352
348
 
353
349
  ///< get array size of the allocated memory
354
- inline const std::vector<SVFValue*>& getArrSize() const //TODO:getSizeVars
350
+ inline const std::vector<SVFVar*>& getArrSize() const //TODO:getSizeVars
355
351
  {
356
352
  return arrSize;
357
353
  }
@@ -485,7 +485,6 @@ const SVFType* AbstractState::getPointeeElement(NodeID id)
485
485
 
486
486
  u32_t AbstractState::getAllocaInstByteSize(const AddrStmt *addr)
487
487
  {
488
- SVFIR* svfir = PAG::getPAG();
489
488
  if (const ObjVar* objvar = SVFUtil::dyn_cast<ObjVar>(addr->getRHSVar()))
490
489
  {
491
490
  objvar->getType();
@@ -497,18 +496,18 @@ u32_t AbstractState::getAllocaInstByteSize(const AddrStmt *addr)
497
496
 
498
497
  else
499
498
  {
500
- const std::vector<SVFValue*>& sizes = addr->getArrSize();
499
+ const std::vector<SVFVar*>& sizes = addr->getArrSize();
501
500
  // Default element size is set to 1.
502
501
  u32_t elementSize = 1;
503
502
  u64_t res = elementSize;
504
- for (const SVFValue* value: sizes)
503
+ for (const SVFVar* value: sizes)
505
504
  {
506
- if (!inVarToValTable(svfir->getValueNode(value)))
505
+ if (!inVarToValTable(value->getId()))
507
506
  {
508
- (*this)[svfir->getValueNode(value)] = IntervalValue(Options::MaxFieldLimit());
507
+ (*this)[value->getId()] = IntervalValue(Options::MaxFieldLimit());
509
508
  }
510
509
  IntervalValue itv =
511
- (*this)[svfir->getValueNode(value)].getInterval();
510
+ (*this)[value->getId()].getInterval();
512
511
  res = res * itv.ub().getIntNumeral() > Options::MaxFieldLimit()? Options::MaxFieldLimit(): res * itv.ub().getIntNumeral();
513
512
  }
514
513
  return (u32_t)res;
@@ -1073,29 +1073,29 @@ const SVFFunction* VFG::isFunEntryVFGNode(const VFGNode* node) const
1073
1073
  }
1074
1074
 
1075
1075
 
1076
- const SVFValue* StmtVFGNode::getValue() const
1076
+ const SVFVar* StmtVFGNode::getValue() const
1077
1077
  {
1078
1078
  return getPAGEdge()->getValue();
1079
1079
  }
1080
1080
 
1081
- const SVFValue* CmpVFGNode::getValue() const
1081
+ const SVFVar* CmpVFGNode::getValue() const
1082
1082
  {
1083
- return getRes()->getValue();
1083
+ return getRes();
1084
1084
  }
1085
1085
 
1086
- const SVFValue* BinaryOPVFGNode::getValue() const
1086
+ const SVFVar* BinaryOPVFGNode::getValue() const
1087
1087
  {
1088
- return getRes()->getValue();
1088
+ return getRes();
1089
1089
  }
1090
1090
 
1091
- const SVFValue* PHIVFGNode::getValue() const
1091
+ const SVFVar* PHIVFGNode::getValue() const
1092
1092
  {
1093
- return getRes()->hasValue() ? getRes()->getValue(): nullptr;
1093
+ return getRes()->hasValue() ? getRes(): nullptr;
1094
1094
  }
1095
1095
 
1096
- const SVFValue* ArgumentVFGNode::getValue() const
1096
+ const SVFVar* ArgumentVFGNode::getValue() const
1097
1097
  {
1098
- return param->hasValue() ? param->getValue() : nullptr;
1098
+ return param->hasValue() ? param : nullptr;
1099
1099
  }
1100
1100
 
1101
1101
  /*!
@@ -164,7 +164,7 @@ void MTA::detect(SVFModule* module)
164
164
  for (Set<const StoreStmt*>::const_iterator sit = stores.begin(), esit = stores.end(); sit != esit; ++sit)
165
165
  {
166
166
  const StoreStmt* store = *sit;
167
- if(load->getInst()==nullptr || store->getInst()==nullptr)
167
+ if(SVFUtil::isa<GlobalICFGNode>(load->getICFGNode()) || SVFUtil::isa<GlobalICFGNode>(store->getICFGNode()))
168
168
  continue;
169
169
  if(mhp->mayHappenInParallelInst(load->getICFGNode(),store->getICFGNode()) && pta->alias(load->getRHSVarID(),store->getLHSVarID()))
170
170
  if(lsa->isProtectedByCommonLock(load->getICFGNode(),store->getICFGNode()) == false)
@@ -399,27 +399,28 @@ bool SaberCondAllocator::isTestNotNullExpr(const ICFGNode* test) const
399
399
  bool SaberCondAllocator::isTestContainsNullAndTheValue(const CmpStmt *cmp) const
400
400
  {
401
401
 
402
+ // must be val var?
402
403
  const SVFVar* op0 = cmp->getOpVar(0);
403
404
  const SVFVar* op1 = cmp->getOpVar(1);
404
405
  if (SVFUtil::isa<ConstantNullPtrValVar>(op1))
405
406
  {
406
- Set<const SVFValue* > inDirVal;
407
+ Set<const SVFVar* > inDirVal;
407
408
  inDirVal.insert(getCurEvalSVFGNode()->getValue());
408
409
  for (const auto &it: getCurEvalSVFGNode()->getOutEdges())
409
410
  {
410
411
  inDirVal.insert(it->getDstNode()->getValue());
411
412
  }
412
- return inDirVal.find(op0->getValue()) != inDirVal.end();
413
+ return inDirVal.find(op0) != inDirVal.end();
413
414
  }
414
415
  else if (SVFUtil::isa<ConstantNullPtrValVar>(op0))
415
416
  {
416
- Set<const SVFValue* > inDirVal;
417
+ Set<const SVFVar* > inDirVal;
417
418
  inDirVal.insert(getCurEvalSVFGNode()->getValue());
418
419
  for (const auto &it: getCurEvalSVFGNode()->getOutEdges())
419
420
  {
420
421
  inDirVal.insert(it->getDstNode()->getValue());
421
422
  }
422
- return inDirVal.find(op1->getValue()) != inDirVal.end();
423
+ return inDirVal.find(op1) != inDirVal.end();
423
424
  }
424
425
  return false;
425
426
  }
@@ -52,6 +52,41 @@ inline bool isCallSite(const Value* val)
52
52
  return SVFUtil::isa<CallBase>(val);
53
53
  }
54
54
 
55
+ inline double getDoubleValue(const ConstantFP* fpValue)
56
+ {
57
+ double dval = 0;
58
+ if (fpValue->isNormalFP())
59
+ {
60
+ const llvm::fltSemantics& semantics = fpValue->getValueAPF().getSemantics();
61
+ if (&semantics == &llvm::APFloat::IEEEhalf() ||
62
+ &semantics == &llvm::APFloat::IEEEsingle() ||
63
+ &semantics == &llvm::APFloat::IEEEdouble() ||
64
+ &semantics == &llvm::APFloat::IEEEquad() ||
65
+ &semantics == &llvm::APFloat::x87DoubleExtended())
66
+ {
67
+ dval = fpValue->getValueAPF().convertToDouble();
68
+ }
69
+ else
70
+ {
71
+ assert (false && "Unsupported floating point type");
72
+ abort();
73
+ }
74
+ }
75
+ else
76
+ {
77
+ // other cfp type, like isZero(), isInfinity(), isNegative(), etc.
78
+ // do nothing
79
+ }
80
+ return dval;
81
+ }
82
+
83
+ inline std::pair<s64_t, u64_t> getIntegerValue(const ConstantInt* intValue)
84
+ {
85
+ if (intValue->getBitWidth() <= 64 && intValue->getBitWidth() >= 1)
86
+ return std::make_pair(intValue->getSExtValue(), intValue->getZExtValue());
87
+ else
88
+ return std::make_pair(0,0);
89
+ }
55
90
 
56
91
  /// Return LLVM callsite given a value
57
92
  inline const CallBase* getLLVMCallSite(const Value* value)
@@ -307,8 +307,7 @@ protected:
307
307
  AddrStmt* edge = addAddrEdge(src, dst);
308
308
  if (inst.getArraySize())
309
309
  {
310
- SVFValue* arrSz = llvmModuleSet()->getSVFValue(inst.getArraySize());
311
- edge->addArrSize(arrSz);
310
+ edge->addArrSize(pag->getGNode(getValueNode(inst.getArraySize())));
312
311
  }
313
312
  return edge;
314
313
  }
@@ -334,8 +333,7 @@ protected:
334
333
  if (cs->arg_size() > 0)
335
334
  {
336
335
  const llvm::Value* val = cs->getArgOperand(0);
337
- SVFValue* svfval = llvmModuleSet()->getSVFValue(val);
338
- edge->addArrSize(svfval);
336
+ edge->addArrSize(pag->getGNode(getValueNode(val)));
339
337
  }
340
338
  }
341
339
  // Check if the function called is 'calloc' and process its arguments.
@@ -344,8 +342,10 @@ protected:
344
342
  {
345
343
  if (cs->arg_size() > 1)
346
344
  {
347
- edge->addArrSize(llvmModuleSet()->getSVFValue(cs->getArgOperand(0)));
348
- edge->addArrSize(llvmModuleSet()->getSVFValue(cs->getArgOperand(1)));
345
+ edge->addArrSize(
346
+ pag->getGNode(getValueNode(cs->getArgOperand(0))));
347
+ edge->addArrSize(
348
+ pag->getGNode(getValueNode(cs->getArgOperand(1))));
349
349
  }
350
350
  }
351
351
  else
@@ -353,8 +353,7 @@ protected:
353
353
  if (cs->arg_size() > 0)
354
354
  {
355
355
  const llvm::Value* val = cs->getArgOperand(0);
356
- SVFValue* svfval = llvmModuleSet()->getSVFValue(val);
357
- edge->addArrSize(svfval);
356
+ edge->addArrSize(pag->getGNode(getValueNode(val)));
358
357
  }
359
358
  }
360
359
  return edge;
@@ -661,7 +661,7 @@ s32_t cppUtil::getVCallIdx(const CallBase* cs)
661
661
  }
662
662
  else
663
663
  {
664
- idx_value = (s32_t)idx->getSExtValue();
664
+ idx_value = LLVMUtil::getIntegerValue(idx).first;
665
665
  }
666
666
  return idx_value;
667
667
  }
@@ -1087,7 +1087,7 @@ std::string DCHGraph::diTypeToStr(const DIType *t)
1087
1087
  int64_t count = -1;
1088
1088
  if (const ConstantInt* ci = sr->getCount().dyn_cast<ConstantInt* >())
1089
1089
  {
1090
- count = ci->getSExtValue();
1090
+ count = LLVMUtil::getIntegerValue(ci).first;
1091
1091
  }
1092
1092
 
1093
1093
  ss << "[" << count << "]";
@@ -196,7 +196,7 @@ void ICFGBuilder::processFunBody(WorkList& worklist)
196
196
  /// default case is set to -1;
197
197
  s64_t val = -1;
198
198
  if (condVal && condVal->getBitWidth() <= 64)
199
- val = condVal->getSExtValue();
199
+ val = LLVMUtil::getIntegerValue(condVal).first;
200
200
  icfg->addConditionalIntraEdge(srcNode, dstNode,val);
201
201
  }
202
202
  else
@@ -704,8 +704,7 @@ std::vector<const Function* > LLVMModuleSet::getLLVMGlobalFunctions(const Global
704
704
 
705
705
  if (priority && func)
706
706
  {
707
- queue.push(LLVMGlobalFunction(priority
708
- ->getZExtValue(),
707
+ queue.push(LLVMGlobalFunction(LLVMUtil::getIntegerValue(priority).second,
709
708
  func));
710
709
  }
711
710
  }
@@ -628,7 +628,7 @@ void ObjTypeInference::validateTypeCheck(const CallBase *cs)
628
628
  SVFUtil::dyn_cast<llvm::ConstantInt>(cs->getOperand(1));
629
629
  assert(pInt && "the second argument is a integer");
630
630
  u32_t iTyNum = objTyToNumFields(objType);
631
- if (iTyNum >= pInt->getZExtValue())
631
+ if (iTyNum >= LLVMUtil::getIntegerValue(pInt).second)
632
632
  SVFUtil::outs() << SVFUtil::sucMsg("\t SUCCESS :") << dumpValueAndDbgInfo(cs)
633
633
  << SVFUtil::pasMsg(" TYPE: ")
634
634
  << dumpType(objType) << "\n";
@@ -247,13 +247,13 @@ void SVFIRBuilder::initialiseNodes()
247
247
  }
248
248
  else if (auto fpValue = SVFUtil::dyn_cast<ConstantFP>(llvmValue))
249
249
  {
250
- pag->addConstantFPValNode(iter->first, fpValue->getValueAPF().convertToDouble(), iter->second, icfgNode);
250
+ pag->addConstantFPValNode(iter->first, LLVMUtil::getDoubleValue(fpValue), iter->second, icfgNode);
251
251
  llvmModuleSet()->addToLLVMVal2SVFVarMap(
252
252
  fpValue, pag->getGNode(iter->second));
253
253
  }
254
254
  else if (auto intValue = SVFUtil::dyn_cast<ConstantInt>(llvmValue))
255
255
  {
256
- pag->addConstantIntValNode(iter->first, intValue->getSExtValue(), intValue->getZExtValue(), iter->second, icfgNode);
256
+ pag->addConstantIntValNode(iter->first, LLVMUtil::getIntegerValue(intValue), iter->second, icfgNode);
257
257
  llvmModuleSet()->addToLLVMVal2SVFVarMap(
258
258
  intValue, pag->getGNode(iter->second));
259
259
  }
@@ -322,13 +322,13 @@ void SVFIRBuilder::initialiseNodes()
322
322
  }
323
323
  else if (auto fpValue = SVFUtil::dyn_cast<ConstantFP>(llvmValue))
324
324
  {
325
- pag->addConstantFPObjNode(iter->first, fpValue->getValueAPF().convertToDouble(), iter->second);
325
+ pag->addConstantFPObjNode(iter->first, LLVMUtil::getDoubleValue(fpValue), iter->second);
326
326
  llvmModuleSet()->addToLLVMVal2SVFVarMap(
327
327
  fpValue, pag->getGNode(iter->second));
328
328
  }
329
329
  else if (auto intValue = SVFUtil::dyn_cast<ConstantInt>(llvmValue))
330
330
  {
331
- pag->addConstantIntObjNode(iter->first, intValue->getSExtValue(), intValue->getZExtValue(), iter->second);
331
+ pag->addConstantIntObjNode(iter->first, LLVMUtil::getIntegerValue(intValue), iter->second);
332
332
  llvmModuleSet()->addToLLVMVal2SVFVarMap(
333
333
  intValue, pag->getGNode(iter->second));
334
334
  }
@@ -457,9 +457,9 @@ bool SVFIRBuilder::computeGepOffset(const User *V, AccessPath& ap)
457
457
  // but we can distinguish different field of an array of struct, e.g. s[1].f1 is different from s[0].f2
458
458
  if(const ArrayType* arrTy = SVFUtil::dyn_cast<ArrayType>(gepTy))
459
459
  {
460
- if(!op || (arrTy->getArrayNumElements() <= (u32_t)op->getSExtValue()))
460
+ if(!op || (arrTy->getArrayNumElements() <= (u32_t)LLVMUtil::getIntegerValue(op).first))
461
461
  continue;
462
- APOffset idx = op->getSExtValue();
462
+ APOffset idx = (u32_t)LLVMUtil::getIntegerValue(op).first;
463
463
  u32_t offset = pag->getSymbolInfo()->getFlattenedElemIdx(llvmModuleSet()->getSVFType(arrTy), idx);
464
464
  ap.setFldIdx(ap.getConstantStructFldIdx() + offset);
465
465
  }
@@ -467,7 +467,7 @@ bool SVFIRBuilder::computeGepOffset(const User *V, AccessPath& ap)
467
467
  {
468
468
  assert(op && "non-const offset accessing a struct");
469
469
  //The actual index
470
- APOffset idx = op->getSExtValue();
470
+ APOffset idx = (u32_t)LLVMUtil::getIntegerValue(op).first;
471
471
  u32_t offset = pag->getSymbolInfo()->getFlattenedElemIdx(llvmModuleSet()->getSVFType(ST), idx);
472
472
  ap.setFldIdx(ap.getConstantStructFldIdx() + offset);
473
473
  }
@@ -1176,7 +1176,7 @@ void SVFIRBuilder::visitSwitchInst(SwitchInst &inst)
1176
1176
  /// default case is set to -1;
1177
1177
  s64_t val = -1;
1178
1178
  if (condVal && condVal->getBitWidth() <= 64)
1179
- val = condVal->getSExtValue();
1179
+ val = (u32_t)LLVMUtil::getIntegerValue(condVal).first;
1180
1180
  const ICFGNode* icfgNode = llvmModuleSet()->getICFGNode(succInst);
1181
1181
  successors.push_back(std::make_pair(icfgNode, val));
1182
1182
  }
@@ -1297,7 +1297,7 @@ const Value* SVFIRBuilder::getBaseValueForExtArg(const Value* V)
1297
1297
  for (bridge_gep_iterator gi = bridge_gep_begin(gep), ge = bridge_gep_end(gep); gi != ge; ++gi)
1298
1298
  {
1299
1299
  if(const ConstantInt* op = SVFUtil::dyn_cast<ConstantInt>(gi.getOperand()))
1300
- totalidx += op->getSExtValue();
1300
+ totalidx += LLVMUtil::getIntegerValue(op).first;
1301
1301
  }
1302
1302
  if(totalidx == 0 && !SVFUtil::isa<StructType>(value->getType()))
1303
1303
  value = gep->getPointerOperand();
@@ -1433,7 +1433,7 @@ void SVFIRBuilder::setCurrentBBAndValueForPAGEdge(PAGEdge* edge)
1433
1433
 
1434
1434
  assert(curVal && "current Val is nullptr?");
1435
1435
  edge->setBB(curBB!=nullptr ? curBB : nullptr);
1436
- edge->setValue(curVal);
1436
+ edge->setValue(pag->getGNode(pag->getValueNode(curVal)));
1437
1437
  // backmap in valuToEdgeMap
1438
1438
  pag->mapValueToEdge(curVal, edge);
1439
1439
  ICFGNode* icfgNode = pag->getICFG()->getGlobalICFGNode();
@@ -50,7 +50,8 @@ const Type* SVFIRBuilder::getBaseTypeAndFlattenedFields(const Value* V, std::vec
50
50
  /// use user-specified size for this copy operation if the size is a constaint int
51
51
  if(szValue && SVFUtil::isa<ConstantInt>(szValue))
52
52
  {
53
- numOfElems = (numOfElems > SVFUtil::cast<ConstantInt>(szValue)->getSExtValue()) ? SVFUtil::cast<ConstantInt>(szValue)->getSExtValue() : numOfElems;
53
+ auto szIntVal = LLVMUtil::getIntegerValue(SVFUtil::cast<ConstantInt>(szValue));
54
+ numOfElems = (numOfElems > szIntVal.first) ? szIntVal.first : numOfElems;
54
55
  }
55
56
 
56
57
  LLVMContext& context = LLVMModuleSet::getLLVMModuleSet()->getContext();
@@ -64,7 +65,7 @@ const Type* SVFIRBuilder::getBaseTypeAndFlattenedFields(const Value* V, std::vec
64
65
  {
65
66
  SymbolTableBuilder builder(pag->getSymbolInfo());
66
67
  builder.collectSym(offset);
67
- pag->addConstantIntValNode(svfOffset, offset->getSExtValue(), offset->getZExtValue(), pag->getSymbolInfo()->getValSym(svfOffset), nullptr);
68
+ pag->addConstantIntValNode(svfOffset, LLVMUtil::getIntegerValue(offset), pag->getSymbolInfo()->getValSym(svfOffset), nullptr);
68
69
  }
69
70
  ls.addOffsetVarAndGepTypePair(getPAG()->getGNode(getPAG()->getValueNode(svfOffset)), nullptr);
70
71
  fields.push_back(ls);
@@ -781,7 +781,7 @@ u32_t SymbolTableBuilder::analyzeHeapAllocByteSize(const Value* val)
781
781
  llvm::dyn_cast<llvm::ConstantInt>(arg))
782
782
  {
783
783
  // Multiply the constant Value if all Args are const
784
- product *= constIntArg->getZExtValue();
784
+ product *= LLVMUtil::getIntegerValue(constIntArg).second;
785
785
  }
786
786
  else
787
787
  {
@@ -871,8 +871,8 @@ void SymbolTableBuilder::initTypeInfo(ObjTypeInfo* typeinfo, const Value* val,
871
871
  /// In most cases, `NumElements` is not specified in the instruction, which means there is only one element (objSize=1).
872
872
  if(const ConstantInt* sz = SVFUtil::dyn_cast<ConstantInt>(allocaInst->getArraySize()))
873
873
  {
874
- elemNum = sz->getZExtValue() * getNumOfElements(objTy);
875
- byteSize = sz->getZExtValue() * typeinfo->getType()->getByteSize();
874
+ elemNum = LLVMUtil::getIntegerValue(sz).second * getNumOfElements(objTy);
875
+ byteSize = LLVMUtil::getIntegerValue(sz).second * typeinfo->getType()->getByteSize();
876
876
  }
877
877
  /// if ArraySize is not constant, byteSize is not static determined.
878
878
  else
@@ -41,21 +41,21 @@ using namespace SVF;
41
41
  /*!
42
42
  * An example to query alias results of two SVF values
43
43
  */
44
- SVF::AliasResult aliasQuery(PointerAnalysis* pta, const SVFValue* v1, const SVFValue* v2)
44
+ SVF::AliasResult aliasQuery(PointerAnalysis* pta, const SVFVar* v1, const SVFVar* v2)
45
45
  {
46
- return pta->alias(v1, v2);
46
+ return pta->alias(v1->getId(), v2->getId());
47
47
  }
48
48
 
49
49
  /*!
50
50
  * An example to print points-to set of an SVF value
51
51
  */
52
- std::string printPts(PointerAnalysis* pta, const SVFValue* svfval)
52
+ std::string printPts(PointerAnalysis* pta, const SVFVar* svfval)
53
53
  {
54
54
 
55
55
  std::string str;
56
56
  raw_string_ostream rawstr(str);
57
57
 
58
- NodeID pNodeId = pta->getPAG()->getValueNode(svfval);
58
+ NodeID pNodeId = svfval->getId();
59
59
  const PointsTo& pts = pta->getPts(pNodeId);
60
60
  for (PointsTo::iterator ii = pts.begin(), ie = pts.end();
61
61
  ii != ie; ii++)
@@ -105,13 +105,11 @@ void dummyVisit(const VFGNode* node)
105
105
  /*!
106
106
  * An example to query/collect all the uses of a definition of a value along value-flow graph (VFG)
107
107
  */
108
- void traverseOnVFG(const SVFG* vfg, const SVFValue* svfval)
108
+ void traverseOnVFG(const SVFG* vfg, const SVFVar* svfval)
109
109
  {
110
- SVFIR* pag = SVFIR::getPAG();
111
- PAGNode* pNode = pag->getGNode(pag->getValueNode(svfval));
112
- if (!vfg->hasDefSVFGNode(pNode))
110
+ if (!vfg->hasDefSVFGNode(svfval))
113
111
  return;
114
- const VFGNode* vNode = vfg->getDefSVFGNode(pNode);
112
+ const VFGNode* vNode = vfg->getDefSVFGNode(svfval);
115
113
  FIFOWorkList<const VFGNode*> worklist;
116
114
  Set<const VFGNode*> visited;
117
115
  worklist.push(vNode);