svf-tools 1.0.1036 → 1.0.1038

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.1036",
3
+ "version": "1.0.1038",
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": {
@@ -71,9 +71,6 @@ public:
71
71
 
72
72
  /// various maps defined
73
73
  //{@
74
- /// llvm value to sym id map
75
- /// local (%) and global (@) identifiers are pointer types which have a value node id.
76
- typedef OrderedMap<const SVFValue*, NodeID> ValueToIDMapTy;
77
74
  /// sym id to obj type info map
78
75
  typedef OrderedMap<NodeID, ObjTypeInfo*> IDToTypeInfoMapTy;
79
76
 
@@ -84,8 +81,6 @@ public:
84
81
  //@}
85
82
 
86
83
  private:
87
- ValueToIDMapTy valSymMap; ///< map a value to its sym id
88
- ValueToIDMapTy objSymMap; ///< map a obj reference to its sym id
89
84
  FunToIDMapTy returnSymMap; ///< return map
90
85
  FunToIDMapTy varargSymMap; ///< vararg map
91
86
  IDToTypeInfoMapTy objTypeInfoMap; ///< map a memory sym id to its obj
@@ -114,6 +109,8 @@ protected:
114
109
  bool fromFile; ///< Whether the SVFIR is built according to user specified data from a txt file
115
110
  NodeID nodeNumAfterPAGBuild; ///< initial node number after building SVFIR, excluding later added nodes, e.g., gepobj nodes
116
111
  u32_t totalPTAPAGEdge;
112
+ u32_t valVarNum;
113
+ u32_t objVarNum;
117
114
 
118
115
  /// Add a node into the graph
119
116
  inline NodeID addNode(SVFVar* node)
@@ -139,7 +136,7 @@ protected:
139
136
 
140
137
  public:
141
138
  IRGraph(bool buildFromFile)
142
- : totalSymNum(0), fromFile(buildFromFile), nodeNumAfterPAGBuild(0), totalPTAPAGEdge(0),
139
+ : totalSymNum(0), fromFile(buildFromFile), nodeNumAfterPAGBuild(0), totalPTAPAGEdge(0), valVarNum(0), objVarNum(0),
143
140
  maxStruct(nullptr), maxStSize(0)
144
141
  {
145
142
  }
@@ -210,16 +207,6 @@ public:
210
207
 
211
208
  /// Get different kinds of syms maps
212
209
  //@{
213
- inline ValueToIDMapTy& valSyms()
214
- {
215
- return valSymMap;
216
- }
217
-
218
- inline ValueToIDMapTy& objSyms()
219
- {
220
- return objSymMap;
221
- }
222
-
223
210
  inline IDToTypeInfoMapTy& idToObjTypeInfoMap()
224
211
  {
225
212
  return objTypeInfoMap;
@@ -242,16 +229,6 @@ public:
242
229
 
243
230
  //@}
244
231
 
245
- /// Get SVFIR Node according to LLVM value
246
- ///getNode - Return the node corresponding to the specified pointer.
247
- NodeID getValueNode(const SVFValue* V);
248
-
249
- bool hasValueNode(const SVFValue* V);
250
-
251
- /// getObject - Return the obj node id refer to the memory object for the
252
- /// specified global, heap or alloca instruction according to llvm value.
253
- NodeID getObjectNode(const SVFValue* V);
254
-
255
232
  inline ObjTypeInfo* getObjTypeInfo(NodeID id) const
256
233
  {
257
234
  IDToTypeInfoMapTy::const_iterator iter = objTypeInfoMap.find(id);
@@ -282,14 +259,9 @@ public:
282
259
  return nullPtrSymID();
283
260
  }
284
261
 
285
- inline u32_t getValueNodeNum() const
286
- {
287
- return valSymMap.size();
288
- }
289
- inline u32_t getObjectNodeNum() const
290
- {
291
- return objTypeInfoMap.size();
292
- }
262
+ u32_t getValueNodeNum();
263
+
264
+ u32_t getObjectNodeNum();
293
265
 
294
266
  /// Constant reader that won't change the state of the symbol table
295
267
  //@{
@@ -39,7 +39,6 @@ class CallGraph;
39
39
  /*!
40
40
  * SVF Intermediate representation, representing variables and statements as a Program Assignment Graph (PAG)
41
41
  * Variables as nodes and statements as edges.
42
- * SymID and NodeID are equal here (same numbering).
43
42
  */
44
43
  class SVFIR : public IRGraph
45
44
  {
@@ -63,6 +62,7 @@ public:
63
62
  typedef Map<const CallICFGNode*,SVFVarList> CSToArgsListMap;
64
63
  typedef Map<const RetICFGNode*,const SVFVar*> CSToRetMap;
65
64
  typedef Map<const SVFFunction*,const SVFVar*> FunToRetMap;
65
+ typedef Map<const CallGraphNode*,const FunObjVar *> FunToFunObjVarMap;
66
66
  typedef Map<const SVFFunction*,SVFStmtSet> FunToPAGEdgeSetMap;
67
67
  typedef Map<const ICFGNode*,SVFStmtList> ICFGNode2SVFStmtsMap;
68
68
  typedef Map<NodeID, NodeID> NodeToNodeMap;
@@ -90,6 +90,7 @@ private:
90
90
  CSToArgsListMap callSiteArgsListMap; ///< Map a callsite to a list of all its actual parameters
91
91
  CSToRetMap callSiteRetMap; ///< Map a callsite to its callsite returns PAGNodes
92
92
  FunToRetMap funRetMap; ///< Map a function to its unique function return PAGNodes
93
+ FunToFunObjVarMap funToFunObjvarMap; ///< Map a function to its unique function object PAGNodes
93
94
  CallSiteToFunPtrMap indCallSiteToFunPtrMap; ///< Map an indirect callsite to its function pointer
94
95
  FunPtrToCallSitesMap funPtrToCallSitesMap; ///< Map a function pointer to the callsites where it is used
95
96
  /// Valid pointers for pointer analysis resolution connected by SVFIR edges (constraints)
@@ -330,6 +331,12 @@ public:
330
331
  }
331
332
  //@}
332
333
 
334
+ inline const FunObjVar* getFunObjVar(const CallGraphNode* node) const
335
+ {
336
+ FunToFunObjVarMap::const_iterator it = funToFunObjvarMap.find(node);
337
+ assert(it != funToFunObjvarMap.end() && "this function doesn't have funobjvar");
338
+ return it->second;
339
+ }
333
340
  /// Node and edge statistics
334
341
  //@{
335
342
  inline u32_t getFieldValNodeNum() const
@@ -546,10 +553,10 @@ private:
546
553
  return addValNode(node);
547
554
  }
548
555
 
549
- NodeID addArgValNode(NodeID i, u32_t argNo, const ICFGNode* icfgNode, const CallGraphNode* callGraphNode, const SVFType* type, bool isUncalled = false)
556
+ NodeID addArgValNode(NodeID i, u32_t argNo, const ICFGNode* icfgNode, const CallGraphNode* callGraphNode, const SVFType* type)
550
557
  {
551
558
  ArgValVar* node =
552
- new ArgValVar(i, argNo, icfgNode, callGraphNode, type, isUncalled);
559
+ new ArgValVar(i, argNo, icfgNode, callGraphNode, type);
553
560
  return addValNode(node);
554
561
  }
555
562
 
@@ -622,6 +629,7 @@ private:
622
629
  {
623
630
  memToFieldsMap[id].set(id);
624
631
  FunObjVar* funObj = new FunObjVar(id, ti, callGraphNode, type, node);
632
+ funToFunObjvarMap[callGraphNode] = funObj;
625
633
  return addObjNode(funObj);
626
634
  }
627
635
 
@@ -292,6 +292,8 @@ public:
292
292
  //@}
293
293
  };
294
294
 
295
+ class ArgValVar;
296
+
295
297
  class SVFFunction : public SVFValue
296
298
  {
297
299
  friend class LLVMModuleSet;
@@ -316,7 +318,7 @@ private:
316
318
  const SVFFunctionType* funcType; /// FunctionType, which is different from the type (PointerType) of this SVFFunction
317
319
  SVFLoopAndDomInfo* loopAndDom; /// the loop and dominate information
318
320
  const SVFFunction* realDefFun; /// the definition of a function across multiple modules
319
- std::vector<const SVFArgument*> allArgs; /// all formal arguments of this function
321
+ std::vector<const ArgValVar*> allArgs; /// all formal arguments of this function
320
322
  SVFBasicBlock *exitBlock; /// a 'single' basic block having no successors and containing return instruction in a function
321
323
  const CallGraphNode *callGraphNode; /// call graph node for this function
322
324
  BasicBlockGraph* bbGraph; /// the basic block graph of this function
@@ -327,7 +329,7 @@ protected:
327
329
  callGraphNode = cgn;
328
330
  }
329
331
 
330
- inline void addArgument(SVFArgument* arg)
332
+ inline void addArgument(const ArgValVar* arg)
331
333
  {
332
334
  allArgs.push_back(arg);
333
335
  }
@@ -417,7 +419,7 @@ public:
417
419
  }
418
420
 
419
421
  u32_t arg_size() const;
420
- const SVFArgument* getArg(u32_t idx) const;
422
+ const ArgValVar* getArg(u32_t idx) const;
421
423
  bool isVarArg() const;
422
424
 
423
425
  inline bool hasBasicBlock() const
@@ -368,7 +368,6 @@ class ArgValVar: public ValVar
368
368
  private:
369
369
  const CallGraphNode* cgNode;
370
370
  u32_t argNo;
371
- bool uncalled;
372
371
 
373
372
  protected:
374
373
  /// Constructor to create function argument (for SVFIRReader/deserialization)
@@ -401,7 +400,7 @@ public:
401
400
 
402
401
  /// Constructor
403
402
  ArgValVar(NodeID i, u32_t argNo, const ICFGNode* icn, const CallGraphNode* callGraphNode,
404
- const SVFType* svfType, bool isUncalled = false);
403
+ const SVFType* svfType);
405
404
 
406
405
  /// Return name of a LLVM value
407
406
  inline const std::string getValueName() const
@@ -422,7 +421,7 @@ public:
422
421
 
423
422
  inline bool isArgOfUncalledFunction() const
424
423
  {
425
- return uncalled;
424
+ return getFunction()->isUncalledFunction();
426
425
  }
427
426
 
428
427
  virtual bool isPointer() const;
@@ -598,7 +597,7 @@ public:
598
597
  virtual const std::string toString() const;
599
598
 
600
599
  /// Get the memory object id
601
- inline SymID getId() const
600
+ inline NodeID getId() const
602
601
  {
603
602
  return id;
604
603
  }
@@ -54,7 +54,6 @@ typedef signed short s16_t;
54
54
 
55
55
  typedef u32_t NodeID;
56
56
  typedef u32_t EdgeID;
57
- typedef unsigned SymID;
58
57
  typedef unsigned CallSiteID;
59
58
  typedef unsigned ThreadID;
60
59
  typedef s64_t APOffset;
@@ -167,7 +167,6 @@ typedef OrderedSet<PointsTo, equalPointsTo> PointsToList;
167
167
  void dumpPointsToList(const PointsToList& ptl);
168
168
 
169
169
  /// Return true if it is an llvm intrinsic instruction
170
- bool isIntrinsicInst(const SVFInstruction* inst);
171
170
  bool isIntrinsicInst(const ICFGNode* inst);
172
171
  //@}
173
172
 
@@ -195,7 +195,7 @@ bool ContextDDA::testIndCallReachability(CxtLocDPItem& dpm, const SVFFunction* c
195
195
  CxtVar funptrVar(dpm.getCondVar().get_cond(), id);
196
196
  CxtLocDPItem funptrDpm = getDPIm(funptrVar,getDefSVFGNode(node));
197
197
  PointsTo pts = getBVPointsTo(findPT(funptrDpm));
198
- if(pts.test(getPAG()->getObjectNode(callee)))
198
+ if(pts.test(getPAG()->getFunObjVar(callee->getCallGraphNode())->getId()))
199
199
  return true;
200
200
  else
201
201
  return false;
@@ -56,38 +56,6 @@ IRGraph::~IRGraph()
56
56
  destorySymTable();
57
57
  }
58
58
 
59
- NodeID IRGraph::getValueNode(const SVFValue* val)
60
- {
61
- if(val->isNullPtr())
62
- return nullPtrSymID();
63
- else if (val->isblackHole())
64
- return blkPtrSymID();
65
- else
66
- {
67
- ValueToIDMapTy::const_iterator iter = valSymMap.find(val);
68
- assert(iter!=valSymMap.end() &&"value sym not found");
69
- return iter->second;
70
- }
71
- }
72
-
73
- bool IRGraph::hasValueNode(const SVFValue *val)
74
- {
75
- if (val->isNullPtr() || val->isblackHole())
76
- return true;
77
- else
78
- return (valSymMap.find(val) != valSymMap.end());
79
- }
80
-
81
- NodeID IRGraph::getObjectNode(const SVFValue *val)
82
- {
83
- const SVFValue* svfVal = val;
84
- if(const SVFGlobalValue* g = SVFUtil::dyn_cast<SVFGlobalValue>(val))
85
- svfVal = g->getDefGlobalForMultipleModule();
86
- ValueToIDMapTy::const_iterator iter = objSymMap.find(svfVal);
87
- assert(iter!=objSymMap.end() && "obj sym not found");
88
- return iter->second;
89
- }
90
-
91
59
  NodeID IRGraph::getReturnNode(const SVFFunction *func) const
92
60
  {
93
61
  FunToIDMapTy::const_iterator iter = returnSymMap.find(func);
@@ -102,45 +70,6 @@ NodeID IRGraph::getVarargNode(const SVFFunction *func) const
102
70
  return iter->second;
103
71
  }
104
72
 
105
- void IRGraph::dumpSymTable()
106
- {
107
- OrderedMap<NodeID, SVFValue*> idmap;
108
- for (ValueToIDMapTy::iterator iter = valSymMap.begin(); iter != valSymMap.end();
109
- ++iter)
110
- {
111
- const NodeID i = iter->second;
112
- SVFValue* val = (SVFValue*) iter->first;
113
- idmap[i] = val;
114
- }
115
- for (ValueToIDMapTy::iterator iter = objSymMap.begin(); iter != objSymMap.end();
116
- ++iter)
117
- {
118
- const NodeID i = iter->second;
119
- SVFValue* val = (SVFValue*) iter->first;
120
- idmap[i] = val;
121
- }
122
- for (FunToIDMapTy::iterator iter = returnSymMap.begin(); iter != returnSymMap.end();
123
- ++iter)
124
- {
125
- const NodeID i = iter->second;
126
- SVFValue* val = (SVFValue*) iter->first;
127
- idmap[i] = val;
128
- }
129
- for (FunToIDMapTy::iterator iter = varargSymMap.begin(); iter != varargSymMap.end();
130
- ++iter)
131
- {
132
- const NodeID i = iter->second;
133
- SVFValue* val = (SVFValue*) iter->first;
134
- idmap[i] = val;
135
- }
136
- outs() << "{SymbolTableInfo \n";
137
- for (auto iter : idmap)
138
- {
139
- outs() << iter.first << " " << iter.second->toString() << "\n";
140
- }
141
- outs() << "}\n";
142
- }
143
-
144
73
  void IRGraph::printFlattenFields(const SVFType *type)
145
74
  {
146
75
  if (const SVFArrayType* at = SVFUtil::dyn_cast<SVFArrayType>(type))
@@ -392,6 +321,33 @@ void IRGraph::view()
392
321
  }
393
322
 
394
323
 
324
+ u32_t IRGraph::getValueNodeNum()
325
+ {
326
+ if (valVarNum != 0) return valVarNum;
327
+ u32_t num = 0;
328
+ for (const auto& item: *this)
329
+ {
330
+ if (SVFUtil::isa<ValVar>(item.second))
331
+ num++;
332
+ }
333
+ return valVarNum = num;
334
+ }
335
+
336
+
337
+ u32_t IRGraph::getObjectNodeNum()
338
+ {
339
+ if (objVarNum != 0) return objVarNum;
340
+ u32_t num = 0;
341
+ for (const auto& item: *this)
342
+ {
343
+ if (SVFUtil::isa<ObjVar>(item.second))
344
+ num++;
345
+ }
346
+ return objVarNum = num;
347
+ }
348
+
349
+
350
+
395
351
  namespace SVF
396
352
  {
397
353
  /*!
@@ -160,8 +160,6 @@ SVFFunction::SVFFunction(const SVFType* ty, const SVFFunctionType* ft,
160
160
 
161
161
  SVFFunction::~SVFFunction()
162
162
  {
163
- for(const SVFArgument* arg : allArgs)
164
- delete arg;
165
163
  delete loopAndDom;
166
164
  delete bbGraph;
167
165
  }
@@ -171,7 +169,7 @@ u32_t SVFFunction::arg_size() const
171
169
  return allArgs.size();
172
170
  }
173
171
 
174
- const SVFArgument* SVFFunction::getArg(u32_t idx) const
172
+ const ArgValVar* SVFFunction::getArg(u32_t idx) const
175
173
  {
176
174
  assert (idx < allArgs.size() && "getArg() out of range!");
177
175
  return allArgs[idx];
@@ -102,9 +102,9 @@ const std::string ObjVar::toString() const
102
102
  }
103
103
 
104
104
  ArgValVar::ArgValVar(NodeID i, u32_t argNo, const ICFGNode* icn,
105
- const SVF::CallGraphNode* callGraphNode, const SVFType* svfType, bool isUncalled)
105
+ const SVF::CallGraphNode* callGraphNode, const SVFType* svfType)
106
106
  : ValVar(i, svfType, icn, ArgValNode),
107
- cgNode(callGraphNode), argNo(argNo), uncalled(isUncalled)
107
+ cgNode(callGraphNode), argNo(argNo)
108
108
  {
109
109
 
110
110
  }
@@ -127,7 +127,7 @@ void SVFStat::performStat()
127
127
  u32_t numOfConstant = 0;
128
128
  u32_t fiObjNumber = 0;
129
129
  u32_t fsObjNumber = 0;
130
- Set<SymID> memObjSet;
130
+ Set<NodeID> memObjSet;
131
131
  for(SVFIR::iterator it = pag->begin(), eit = pag->end(); it!=eit; ++it)
132
132
  {
133
133
  PAGNode* node = it->second;
@@ -174,7 +174,7 @@ void SVFStat::performStat()
174
174
 
175
175
 
176
176
 
177
- generalNumMap["TotalPointers"] = pag->getValueNodeNum() + pag->getFieldValNodeNum();
177
+ generalNumMap["TotalPointers"] = pag->getValueNodeNum();
178
178
  generalNumMap["TotalObjects"] = pag->getObjectNodeNum();
179
179
  generalNumMap["TotalFieldObjects"] = pag->getFieldObjNodeNum();
180
180
  generalNumMap["MaxStructSize"] = pag->getMaxStructSize();
@@ -242,21 +242,7 @@ void SVFUtil::increaseStackSize()
242
242
  }
243
243
  }
244
244
 
245
- /*!
246
- * Return true if it is an llvm intrinsic instruction
247
- */
248
- bool SVFUtil::isIntrinsicInst(const SVFInstruction* inst)
249
- {
250
- if (const SVFCallInst* call = SVFUtil::dyn_cast<SVFCallInst>(inst))
251
- {
252
- const SVFFunction* func = call->getCalledFunction();
253
- if (func && func->isIntrinsic())
254
- {
255
- return true;
256
- }
257
- }
258
- return false;
259
- }
245
+
260
246
 
261
247
  std::string SVFUtil::hclustMethodToString(hclust_fast_methods method)
262
248
  {
@@ -313,8 +313,8 @@ void AndersenStat::performStat()
313
313
  timeStatMap["CopyGepTime"] = Andersen::timeOfProcessCopyGep;
314
314
  timeStatMap["UpdateCGTime"] = Andersen::timeOfUpdateCallGraph;
315
315
 
316
- PTNumStatMap["TotalPointers"] = pag->getValueNodeNum() + pag->getFieldValNodeNum();
317
- PTNumStatMap["TotalObjects"] = pag->getObjectNodeNum() + pag->getFieldObjNodeNum();
316
+ PTNumStatMap["TotalPointers"] = pag->getValueNodeNum();
317
+ PTNumStatMap["TotalObjects"] = pag->getObjectNodeNum();
318
318
 
319
319
 
320
320
  PTNumStatMap["AddrProcessed"] = Andersen::numOfProcessedAddr;
@@ -101,7 +101,7 @@ void FlowSensitiveStat::performStat()
101
101
 
102
102
  u32_t fiObjNumber = 0;
103
103
  u32_t fsObjNumber = 0;
104
- Set<SymID> nodeSet;
104
+ Set<NodeID> nodeSet;
105
105
  for (SVFIR::const_iterator nodeIt = pag->begin(), nodeEit = pag->end(); nodeIt != nodeEit; nodeIt++)
106
106
  {
107
107
  NodeID nodeId = nodeIt->first;
@@ -109,7 +109,7 @@ void FlowSensitiveStat::performStat()
109
109
  if(SVFUtil::isa<ObjVar>(pagNode))
110
110
  {
111
111
  const BaseObjVar* baseObj = pag->getBaseObject(nodeId);
112
- SymID baseId = baseObj->getId();
112
+ NodeID baseId = baseObj->getId();
113
113
  if (nodeSet.insert(baseId).second)
114
114
  {
115
115
  if (baseObj->isFieldInsensitive())
@@ -154,8 +154,8 @@ void FlowSensitiveStat::performStat()
154
154
  timeStatMap["UpdateCGTime"] = fspta->updateCallGraphTime;
155
155
  timeStatMap["PhiTime"] = fspta->phiTime;
156
156
 
157
- PTNumStatMap["TotalPointers"] = pag->getValueNodeNum() + pag->getFieldValNodeNum();
158
- PTNumStatMap["TotalObjects"] = pag->getObjectNodeNum() + pag->getFieldObjNodeNum();
157
+ PTNumStatMap["TotalPointers"] = pag->getValueNodeNum();
158
+ PTNumStatMap["TotalObjects"] = pag->getObjectNodeNum();
159
159
 
160
160
  PTNumStatMap["Pointers"] = pag->getValueNodeNum();
161
161
  PTNumStatMap["MemObjects"] = pag->getObjectNodeNum();
@@ -48,7 +48,7 @@ void VersionedFlowSensitiveStat::performStat()
48
48
 
49
49
  u32_t fiObjNumber = 0;
50
50
  u32_t fsObjNumber = 0;
51
- Set<SymID> nodeSet;
51
+ Set<NodeID> nodeSet;
52
52
  for (SVFIR::const_iterator it = pag->begin(); it != pag->end(); ++it)
53
53
  {
54
54
  NodeID nodeId = it->first;
@@ -56,7 +56,7 @@ void VersionedFlowSensitiveStat::performStat()
56
56
  if (SVFUtil::isa<ObjVar>(pagNode))
57
57
  {
58
58
  const BaseObjVar* baseObj = pag->getBaseObject(nodeId);
59
- SymID baseId = baseObj->getId();
59
+ NodeID baseId = baseObj->getId();
60
60
  if (nodeSet.insert(baseId).second)
61
61
  {
62
62
  if (baseObj->isFieldInsensitive()) fiObjNumber++;
@@ -98,8 +98,8 @@ void VersionedFlowSensitiveStat::performStat()
98
98
  timeStatMap["PrelabelingTime"] = vfspta->prelabelingTime;
99
99
  timeStatMap["VersionPropTime"] = vfspta->versionPropTime;
100
100
 
101
- PTNumStatMap["TotalPointers"] = pag->getValueNodeNum() + pag->getFieldValNodeNum();
102
- PTNumStatMap["TotalObjects"] = pag->getObjectNodeNum() + pag->getFieldObjNodeNum();
101
+ PTNumStatMap["TotalPointers"] = pag->getValueNodeNum();
102
+ PTNumStatMap["TotalObjects"] = pag->getObjectNodeNum();
103
103
 
104
104
  PTNumStatMap["Pointers"] = pag->getValueNodeNum();
105
105
  PTNumStatMap["MemObjects"] = pag->getObjectNodeNum();
@@ -39,13 +39,13 @@
39
39
  namespace SVF
40
40
  {
41
41
 
42
- class SymbolTableInfo;
43
42
  class ObjTypeInference;
44
43
 
45
44
  class LLVMModuleSet
46
45
  {
47
46
  friend class SVFIRBuilder;
48
47
  friend class ICFGBuilder;
48
+ friend class SymbolTableBuilder;
49
49
 
50
50
  public:
51
51
 
@@ -73,6 +73,10 @@ public:
73
73
  typedef Map<const Function*, FunEntryICFGNode *> FunToFunEntryNodeMapTy;
74
74
  typedef Map<const Function*, FunExitICFGNode *> FunToFunExitNodeMapTy;
75
75
 
76
+ /// llvm value to sym id map
77
+ /// local (%) and global (@) identifiers are pointer types which have a value node id.
78
+ typedef OrderedMap<const SVFValue*, NodeID> ValueToIDMapTy;
79
+
76
80
  private:
77
81
  static LLVMModuleSet* llvmModuleSet;
78
82
  static bool preProcessed;
@@ -112,6 +116,9 @@ private:
112
116
 
113
117
  Map<const Function*, DominatorTree> FunToDominatorTree;
114
118
 
119
+ ValueToIDMapTy valSymMap; ///< map a value to its sym id
120
+ ValueToIDMapTy objSymMap; ///< map a obj reference to its sym id
121
+
115
122
  /// Constructor
116
123
  LLVMModuleSet();
117
124
 
@@ -170,6 +177,41 @@ public:
170
177
  // Dump modules to files
171
178
  void dumpModulesToFile(const std::string& suffix);
172
179
 
180
+ public:
181
+
182
+ inline u32_t getValueNodeNum() const
183
+ {
184
+ return valSymMap.size();
185
+ }
186
+
187
+ inline u32_t getObjNodeNum() const
188
+ {
189
+ return objSymMap.size();
190
+ }
191
+
192
+ inline ValueToIDMapTy& valSyms()
193
+ {
194
+ return valSymMap;
195
+ }
196
+
197
+ inline ValueToIDMapTy& objSyms()
198
+ {
199
+ return objSymMap;
200
+ }
201
+
202
+ /// Get SVFIR Node according to LLVM value
203
+ ///getNode - Return the node corresponding to the specified pointer.
204
+ NodeID getValueNode(const SVFValue* V);
205
+
206
+ bool hasValueNode(const SVFValue* V);
207
+
208
+ /// getObject - Return the obj node id refer to the memory object for the
209
+ /// specified global, heap or alloca instruction according to llvm value.
210
+ NodeID getObjectNode(const SVFValue* V);
211
+
212
+ void dumpSymTable();
213
+
214
+ public:
173
215
  inline void addFunctionMap(const Function* func, SVFFunction* svfFunc)
174
216
  {
175
217
  LLVMFunc2SVFFunc[func] = svfFunc;
@@ -91,14 +91,14 @@ public:
91
91
 
92
92
  // strip off the constant cast and return the value node
93
93
  SVFValue* svfVal = llvmModuleSet()->getSVFValue(V);
94
- return pag->getValueNode(svfVal);
94
+ return llvmModuleSet()->getValueNode(svfVal);
95
95
  }
96
96
 
97
97
  /// GetObject - Return the object node (stack/global/heap/function) according to a LLVM Value
98
98
  inline NodeID getObjectNode(const Value* V)
99
99
  {
100
100
  SVFValue* svfVal = llvmModuleSet()->getSVFValue(V);
101
- return pag->getObjectNode(svfVal);
101
+ return llvmModuleSet()->getObjectNode(svfVal);
102
102
  }
103
103
 
104
104
  /// getReturnNode - Return the node representing the unique return value of a function.
@@ -84,6 +84,10 @@ protected:
84
84
  void handleCE(const Value* val);
85
85
  // @}
86
86
 
87
+ inline LLVMModuleSet* llvmModuleSet()
88
+ {
89
+ return LLVMModuleSet::getLLVMModuleSet();
90
+ }
87
91
 
88
92
  ObjTypeInference* getTypeInference();
89
93
 
@@ -118,9 +122,9 @@ protected:
118
122
  ///Get a reference to StructInfo.
119
123
  StInfo* getOrAddSVFTypeInfo(const Type* T);
120
124
 
121
- ObjTypeInfo* createBlkObjTypeInfo(SymID symId);
125
+ ObjTypeInfo* createBlkObjTypeInfo(NodeID symId);
122
126
 
123
- ObjTypeInfo* createConstantObjTypeInfo(SymID symId);
127
+ ObjTypeInfo* createConstantObjTypeInfo(NodeID symId);
124
128
  };
125
129
 
126
130
  } // End namespace SVF
@@ -377,7 +377,7 @@ void CHGBuilder::analyzeVTables(const Module &M)
377
377
  string vtblClassName = getClassNameFromVtblObj(globalvalue->getName().str());
378
378
  CHNode *node = chg->getNode(vtblClassName);
379
379
  assert(node && "node not found?");
380
- SymID i = PAG::getPAG()->getObjectNode(llvmModuleSet()->getSVFGlobalValue(globalvalue));
380
+ NodeID i = llvmModuleSet()->getObjectNode(llvmModuleSet()->getSVFGlobalValue(globalvalue));
381
381
  SVFVar* pVar = PAG::getPAG()->getGNode(i);
382
382
  GlobalObjVar* globalObjVar = SVFUtil::cast<GlobalObjVar>(pVar);
383
383
  globalObjVar->setName(vtblClassName);
@@ -178,7 +178,7 @@ void DCHGraph::buildVTables(const SVFModule &module)
178
178
  assert(type && "DCHG::buildVTables: bad metadata for ctir.vt");
179
179
  DCHNode *node = getOrCreateNode(type);
180
180
  const SVFGlobalValue* svfgv = LLVMModuleSet::getLLVMModuleSet()->getSVFGlobalValue(gv);
181
- SymID i = PAG::getPAG()->getObjectNode(svfgv);
181
+ NodeID i = LLVMModuleSet::getLLVMModuleSet()->getObjectNode(svfgv);
182
182
  GlobalObjVar* globalObjVar =
183
183
  SVFUtil::cast<GlobalObjVar>(PAG::getPAG()->getGNode(i));
184
184
  node->setVTable(globalObjVar);