svf-lib 1.0.1066 → 1.0.1069

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.
@@ -248,8 +248,8 @@ public:
248
248
  static const llvm::cl::opt<bool> ShowHiddenNode;
249
249
 
250
250
  // CFL option
251
- static const llvm::cl::opt<std::string> InputFilename;
252
251
  static const llvm::cl::opt<std::string> GrammarFilename;
252
+ static const llvm::cl::opt<std::string> InputFilename;
253
253
  static const llvm::cl::opt<bool> GraphIsFromDot;
254
254
  static const llvm::cl::opt<bool> PrintCFL;
255
255
  static const llvm::cl::opt<bool> FlexSymMap;
Binary file
@@ -44,6 +44,8 @@ class CFLAlias : public PointerAnalysis
44
44
  {
45
45
 
46
46
  public:
47
+ typedef OrderedMap<CallSite, NodeID> CallSite2DummyValPN;
48
+
47
49
  CFLAlias(SVFIR* ir) : PointerAnalysis(ir, PointerAnalysis::CFLFICI_WPA), svfir(ir), graph(nullptr), grammar(nullptr), solver(nullptr)
48
50
  {
49
51
  }
@@ -74,12 +76,45 @@ public:
74
76
  return AliasResult::NoAlias;
75
77
  }
76
78
 
77
- /// Get points-to targets of a pointer.
79
+ /// Get points-to targets of a pointer. V In this context
78
80
  virtual const PointsTo& getPts(NodeID ptr)
79
81
  {
80
- /// Check Outgoing edge Dst of ptr
81
- //PointsTo * ps;
82
- abort(); // to be implemented
82
+ /// Check V Dst of ptr.
83
+ PointsTo *ps = new PointsTo();
84
+ CFLNode *funNode = graph->getGNode(ptr);
85
+ for(auto outedge = funNode->getOutEdges().begin(); outedge!=funNode->getOutEdges().end(); outedge++)
86
+ {
87
+ if((*outedge)->getEdgeKind() == graph->getStartKind())
88
+ {
89
+ // Need to Find dst addr src
90
+ CFLNode *vNode = graph->getGNode((*outedge)->getDstID());
91
+
92
+ for(auto inEdge = vNode->getInEdges().begin(); inEdge!=vNode->getInEdges().end(); inEdge++)
93
+ {
94
+ if((*inEdge)->getEdgeKind() == 0)
95
+ {
96
+ ps->set((*inEdge)->getSrcID());
97
+ }
98
+ }
99
+ }
100
+ }
101
+ return *ps;
102
+ }
103
+
104
+ /// Add copy edge on constraint graph
105
+ virtual inline bool addCopyEdge(NodeID src, NodeID dst)
106
+ {
107
+ const CFLEdge *edge = graph->hasEdge(graph->getGNode(src),graph->getGNode(dst), 1);
108
+ if (edge != nullptr )
109
+ {
110
+ return false;
111
+
112
+ }
113
+ CFLGrammar::Kind copyKind = grammar->str2Kind("Copy");
114
+ CFLGrammar::Kind copybarKind = grammar->str2Kind("Copybar");
115
+ solver->pushIntoWorklist(graph->addCFLEdge(graph->getGNode(src),graph->getGNode(dst), copyKind));
116
+ solver->pushIntoWorklist(graph->addCFLEdge(graph->getGNode(dst),graph->getGNode(src), copybarKind));
117
+ return true;
83
118
  }
84
119
 
85
120
  /// Given an object, get all the nodes having whose pointsto contains the object
@@ -89,7 +124,18 @@ public:
89
124
  abort(); // to be implemented
90
125
  }
91
126
 
127
+ /// Update call graph for the input indirect callsites
128
+ virtual bool updateCallGraph(const CallSiteToFunPtrMap& callsites);
129
+
130
+ /// On the fly call graph construction
131
+ virtual void onTheFlyCallGraphSolve(const CallSiteToFunPtrMap& callsites, CallEdgeMap& newEdges);
132
+
133
+ /// Connect formal and actual parameters for indirect callsites
134
+ void connectCaller2CalleeParams(CallSite cs, const SVFFunction* F);
135
+
136
+ void heapAllocatorViaIndCall(CallSite cs);
92
137
  private:
138
+ CallSite2DummyValPN callsite2DummyValPN; ///< Map an instruction to a dummy obj which created at an indirect callsite, which invokes a heap allocator
93
139
  SVFIR* svfir;
94
140
  CFLGraph* graph;
95
141
  CFLGrammar* grammar;
@@ -54,6 +54,7 @@ public:
54
54
  /// Conversion of u32_t
55
55
  operator u32_t()
56
56
  {
57
+ static_assert(sizeof(struct Symbol)==sizeof(u32_t), "sizeof(struct Symbol)!=sizeof(u32_t)");
57
58
  u32_t num = 0;
58
59
  num += this->variableAttribute << 24;
59
60
  num += this->attribute << 8;
@@ -61,19 +62,10 @@ public:
61
62
  return num;
62
63
  }
63
64
 
64
- /// Conversion of u64_t
65
- operator u64_t()
65
+ operator u32_t() const
66
66
  {
67
- u64_t num = 0;
68
- num += this->variableAttribute << 24;
69
- num += this->attribute << 8;
70
- num += this->kind;
71
- return num;
72
- }
73
-
74
- operator s64_t() const
75
- {
76
- s64_t num = 0;
67
+ static_assert(sizeof(struct Symbol)==sizeof(u32_t), "sizeof(struct Symbol)!=sizeof(u32_t)");
68
+ u32_t num = 0;
77
69
  num += this->variableAttribute << 24;
78
70
  num += this->attribute << 8;
79
71
  num += this->kind;
@@ -82,10 +74,10 @@ public:
82
74
 
83
75
  bool operator<(const Symbol& rhs)
84
76
  {
85
- return this->kind < rhs.kind;
77
+ return u32_t(*this) < u32_t(rhs);
86
78
  }
87
79
 
88
- void operator=(const int& i)
80
+ void operator=(const u32_t& i)
89
81
  {
90
82
  this->kind = EdgeKindMask & i;
91
83
  this->attribute = i >> EdgeKindMaskBits;
@@ -99,11 +91,6 @@ public:
99
91
  this->variableAttribute = num >> 24;
100
92
  }
101
93
 
102
- void operator=(const Kind& kind)
103
- {
104
- this->kind = kind;
105
- }
106
-
107
94
  bool operator==(const Symbol& s)
108
95
  {
109
96
  return ((this->kind == s.kind) && (this->attribute == s.attribute) && (this->variableAttribute == s.variableAttribute));
@@ -119,21 +106,15 @@ public:
119
106
  return ! (*this == s) ;
120
107
  }
121
108
 
122
-
123
- bool operator==(const int& i)
109
+ bool operator==(const u32_t& i)
124
110
  {
125
- return ((this->kind == (EdgeKindMask & i)) && (this->attribute == (i >> EdgeKindMaskBits)) && (this->variableAttribute == (i >> AttributedKindMaskBits)));
111
+ return u32_t(*this) == u32_t(i);
126
112
  }
127
113
 
128
114
  bool operator==(const Kind& k) const
129
115
  {
130
116
  return (this->kind == k);
131
117
  }
132
-
133
- bool operator==(const Kind& k)
134
- {
135
- return (this->kind == k);
136
- }
137
118
  } Symbol;
138
119
 
139
120
  class SymbolHash
@@ -389,7 +370,7 @@ public:
389
370
  void dump(std::string fileName) const;
390
371
 
391
372
 
392
- const inline int num_generator()
373
+ const inline u32_t num_generator()
393
374
  {
394
375
  return newTerminalSubscript++;
395
376
  }
@@ -5,13 +5,34 @@ Terminal:
5
5
  Productions:
6
6
  F -> epsilon;
7
7
  F -> F Copy;
8
+ F -> Addr Memflow;
8
9
  F -> F Store V Load;
9
- Gepbar_j -> Vgepbar Fbar Gepbar_i;
10
+ F -> Store Memflow Load;
10
11
  Fbar -> epsilon;
11
12
  Fbar -> Copybar Fbar;
13
+ Fbar -> Memflowbar Addrbar;
12
14
  Fbar -> Loadbar V Storebar Fbar;
15
+ Fbar -> Loadbar Memflowbar Storebar;
13
16
  V -> Fbar V F;
14
17
  V -> Addrbar Addr;
15
18
  V -> Gepbar_i V Gep_i;
19
+ V -> Gepbarpath V Gep_0;
20
+ V -> Gepbar_i F Gep_i;
21
+ V -> Gepbar_i Fbar Gep_i;
16
22
  Gep_j -> Gep_i F Vgep;
23
+ Gepbar_j -> Vgepbar Fbar Gepbar_i;
24
+ Memflow -> Load Store;
25
+ Memflow -> Fbar Memflow;
26
+ Memflow -> F Memflow Fbar;
27
+ Memflow -> Gep_i Memflow Gepbar_i;
28
+ Memflow -> Gepbar_i Memflow Gep_i;
29
+ Memflowbar -> Storebar Loadbar;
30
+ Memflowbar -> Memflowbar F;
31
+ Memflowbar -> F Memflowbar Fbar;
32
+ Memflowbar -> Gep_i Memflowbar Gepbar_i;
33
+ Memflowbar -> Gepbar_i Memflowbar Gep_i;
34
+ Gepbarpath -> Gepbar_i Gepbar_j;
35
+ Gepbarpath -> Gepbarpath Gepbar_i;
36
+
37
+
17
38
 
@@ -68,14 +68,6 @@ public:
68
68
  {
69
69
  return grammar;
70
70
  }
71
-
72
- protected:
73
- /// Worklist operations
74
- //@{
75
- inline const CFLEdge* popFromWorklist()
76
- {
77
- return worklist.pop();
78
- }
79
71
  inline bool pushIntoWorklist(const CFLEdge* item)
80
72
  {
81
73
  return worklist.push(item);
@@ -84,6 +76,15 @@ protected:
84
76
  {
85
77
  return worklist.empty();
86
78
  }
79
+
80
+ protected:
81
+ /// Worklist operations
82
+ //@{
83
+ inline const CFLEdge* popFromWorklist()
84
+ {
85
+ return worklist.pop();
86
+ }
87
+
87
88
  inline bool isInWorklist(const CFLEdge* item)
88
89
  {
89
90
  return worklist.find(item);
@@ -95,6 +96,7 @@ private:
95
96
  CFLGrammar* grammar;
96
97
  /// Worklist for resolution
97
98
  WorkList worklist;
99
+
98
100
  };
99
101
 
100
102
  }
@@ -111,7 +111,6 @@ public:
111
111
 
112
112
  private:
113
113
  CFLEdgeSet cflEdgeSet;
114
-
115
114
  };
116
115
 
117
116
  }
@@ -28,8 +28,8 @@
28
28
  * Author: Yulei
29
29
  */
30
30
 
31
- #ifndef INCLUDE_UTIL_GRAPHPRINTER_H_
32
- #define INCLUDE_UTIL_GRAPHPRINTER_H_
31
+ #ifndef INCLUDE_GRAPHS_GRAPHPRINTER_H_
32
+ #define INCLUDE_GRAPHS_GRAPHPRINTER_H_
33
33
 
34
34
  #include <system_error>
35
35
  #include <llvm/Support/ToolOutputFile.h>
@@ -116,4 +116,4 @@ public:
116
116
 
117
117
 
118
118
 
119
- #endif /* INCLUDE_UTIL_GRAPHPRINTER_H_ */
119
+ #endif /* INCLUDE_GRAPHS_GRAPHPRINTER_H_ */
@@ -248,10 +248,10 @@ public:
248
248
  static const llvm::cl::opt<bool> ShowHiddenNode;
249
249
 
250
250
  // CFL option
251
- static const llvm::cl::opt<std::string> InputFilename;
252
251
  static const llvm::cl::opt<std::string> GrammarFilename;
252
+ static const llvm::cl::opt<std::string> InputFilename;
253
253
  static const llvm::cl::opt<bool> GraphIsFromDot;
254
- static const llvm::cl::opt<bool> GrammarIsEBNF;
254
+ static const llvm::cl::opt<bool> PrintCFL;
255
255
  static const llvm::cl::opt<bool> FlexSymMap;
256
256
 
257
257
  // Loop Analysis
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.1066",
3
+ "version": "1.0.1069",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {