SVF
PAG.cpp
Go to the documentation of this file.
1 //===- PAG.cpp -- Program assignment graph------------------------------------//
2 //
3 // SVF: Static Value-Flow Analysis
4 //
5 // Copyright (C) <2013-2017> <Yulei Sui>
6 //
7 
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
12 
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 
18 // You should have received a copy of the GNU General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 //
21 //===----------------------------------------------------------------------===//
22 
23 /*
24  * PAG.cpp
25  *
26  * Created on: Nov 1, 2013
27  * Author: Yulei Sui
28  */
29 
30 #include "Util/Options.h"
31 #include "Graphs/PAG.h"
32 #include "SVF-FE/LLVMUtil.h"
33 #include "SVF-FE/ICFGBuilder.h"
34 
35 using namespace SVF;
36 using namespace SVFUtil;
37 
38 
42 
43 PAG* PAG::pag = nullptr;
44 
45 
46 const std::string PAGNode::toString() const {
47  std::string str;
48  raw_string_ostream rawstr(str);
49  rawstr << "PAGNode ID: " << getId();
50  return rawstr.str();
51 }
52 
54 const std::string PAGNode::getNodeAttrForDotDisplay() const {
55  // TODO: Maybe use over-rides instead of these ifs,
56  // But this puts them conveniently together.
57  if (SVFUtil::isa<ValPN>(this))
58  {
59  if(SVFUtil::isa<GepValPN>(this))
60  return "shape=hexagon";
61  else if (SVFUtil::isa<DummyValPN>(this))
62  return "shape=diamond";
63  else
64  return "shape=box";
65  }
66  else if (SVFUtil::isa<ObjPN>(this))
67  {
68  if(SVFUtil::isa<GepObjPN>(this))
69  return "shape=doubleoctagon";
70  else if(SVFUtil::isa<FIObjPN>(this))
71  return "shape=box3d";
72  else if (SVFUtil::isa<DummyObjPN>(this))
73  return "shape=tab";
74  else
75  return "shape=component";
76  }
77  else if (SVFUtil::isa<RetPN>(this))
78  {
79  return "shape=Mrecord";
80  }
81  else if (SVFUtil::isa<VarArgPN>(this))
82  {
83  return "shape=octagon";
84  }
85  else
86  {
87  assert(0 && "no such kind!!");
88  }
89  return "";
90 }
91 
92 void PAGNode::dump() const {
93  outs() << this->toString() << "\n";
94 }
95 
96 const std::string ValPN::toString() const {
97  std::string str;
98  raw_string_ostream rawstr(str);
99  rawstr << "ValPN ID: " << getId();
101  rawstr << "\n";
102  }
103  rawstr << value2String(value);
104  return rawstr.str();
105 }
106 
107 const std::string ObjPN::toString() const {
108  std::string str;
109  raw_string_ostream rawstr(str);
110  rawstr << "ObjPN ID: " << getId();
112  rawstr << "\n";
113  }
114  rawstr << value2String(value);
115  return rawstr.str();
116 }
117 
118 const std::string GepValPN::toString() const {
119  std::string str;
120  raw_string_ostream rawstr(str);
121  rawstr << "GepValPN ID: " << getId() << " with offset_" + llvm::utostr(getOffset());
123  rawstr << "\n";
124  }
125  rawstr << value2String(value);
126  return rawstr.str();
127 }
128 
129 const std::string GepObjPN::toString() const {
130  std::string str;
131  raw_string_ostream rawstr(str);
132  rawstr << "GepObjPN ID: " << getId() << " with offset_" + llvm::itostr(ls.getOffset());
134  rawstr << "\n";
135  }
136  rawstr << value2String(value);
137  return rawstr.str();
138 }
139 
140 const std::string FIObjPN::toString() const {
141  std::string str;
142  raw_string_ostream rawstr(str);
143  rawstr << "FIObjPN ID: " << getId() << " (base object)";
145  rawstr << "\n";
146  }
147  rawstr << value2String(value);
148  return rawstr.str();
149 }
150 
151 const std::string RetPN::toString() const {
152  std::string str;
153  raw_string_ostream rawstr(str);
154  rawstr << "RetPN ID: " << getId() << " unique return node for function " << SVFUtil::cast<Function>(value)->getName();
155  return rawstr.str();
156 }
157 
158 const std::string VarArgPN::toString() const {
159  std::string str;
160  raw_string_ostream rawstr(str);
161  rawstr << "VarArgPN ID: " << getId() << " Var arg node for function " << SVFUtil::cast<Function>(value)->getName();
162  return rawstr.str();
163 }
164 
165 const std::string DummyValPN::toString() const {
166  std::string str;
167  raw_string_ostream rawstr(str);
168  rawstr << "DummyValPN ID: " << getId();
169  return rawstr.str();
170 }
171 
172 const std::string DummyObjPN::toString() const {
173  std::string str;
174  raw_string_ostream rawstr(str);
175  rawstr << "DummyObjPN ID: " << getId();
176  return rawstr.str();
177 }
178 
179 const std::string CloneDummyObjPN::toString() const {
180  std::string str;
181  raw_string_ostream rawstr(str);
182  rawstr << "CloneDummyObjPN ID: " << getId();
183  return rawstr.str();
184 }
185 
186 const std::string CloneGepObjPN::toString() const {
187  std::string str;
188  raw_string_ostream rawstr(str);
189  rawstr << "CloneGepObjPN ID: " << getId();
190  return rawstr.str();
191 }
192 
193 const std::string CloneFIObjPN::toString() const {
194  std::string str;
195  raw_string_ostream rawstr(str);
196  rawstr << "CloneFIObjPN ID: " << getId();
197  return rawstr.str();
198 }
199 
200 const std::string PAGEdge::toString() const {
201  std::string str;
202  raw_string_ostream rawstr(str);
203  rawstr << "PAGEdge: [" << getDstID() << "<--" << getSrcID() << "]\t";
204  return rawstr.str();
205 }
206 
207 const std::string AddrPE::toString() const{
208  std::string str;
209  raw_string_ostream rawstr(str);
210  rawstr << "AddrPE: [" << getDstID() << "<--" << getSrcID() << "]\t";
212  rawstr << "\n";
213  }
214  rawstr << value2String(getValue());
215  return rawstr.str();
216 }
217 
218 const std::string CopyPE::toString() const{
219  std::string str;
220  raw_string_ostream rawstr(str);
221  rawstr << "CopyPE: [" << getDstID() << "<--" << getSrcID() << "]\t";
223  rawstr << "\n";
224  }
225  rawstr << value2String(getValue());
226  return rawstr.str();
227 }
228 
229 const std::string CmpPE::toString() const{
230  std::string str;
231  raw_string_ostream rawstr(str);
232  rawstr << "CmpPE: [" << getDstID() << "<--" << getSrcID() << "]\t";
234  rawstr << "\n";
235  }
236  rawstr << value2String(getValue());
237  return rawstr.str();
238 }
239 
240 const std::string BinaryOPPE::toString() const{
241  std::string str;
242  raw_string_ostream rawstr(str);
243  rawstr << "BinaryOPPE: [" << getDstID() << "<--" << getSrcID() << "]\t";
245  rawstr << "\n";
246  }
247  rawstr << value2String(getValue());
248  return rawstr.str();
249 }
250 
251 const std::string UnaryOPPE::toString() const{
252  std::string str;
253  raw_string_ostream rawstr(str);
254  rawstr << "UnaryOPPE: [" << getDstID() << "<--" << getSrcID() << "]\t";
256  rawstr << "\n";
257  }
258  rawstr << value2String(getValue());
259  return rawstr.str();
260 }
261 
262 const std::string LoadPE::toString() const{
263  std::string str;
264  raw_string_ostream rawstr(str);
265  rawstr << "LoadPE: [" << getDstID() << "<--" << getSrcID() << "]\t";
267  rawstr << "\n";
268  }
269  rawstr << value2String(getValue());
270  return rawstr.str();
271 }
272 
273 const std::string StorePE::toString() const{
274  std::string str;
275  raw_string_ostream rawstr(str);
276  rawstr << "StorePE: [" << getDstID() << "<--" << getSrcID() << "]\t";
278  rawstr << "\n";
279  }
280  rawstr << value2String(getValue());
281  return rawstr.str();
282 }
283 
284 const std::string GepPE::toString() const{
285  std::string str;
286  raw_string_ostream rawstr(str);
287  rawstr << "GepPE: [" << getDstID() << "<--" << getSrcID() << "]\t";
289  rawstr << "\n";
290  }
291  rawstr << value2String(getValue());
292  return rawstr.str();
293 }
294 
295 const std::string NormalGepPE::toString() const{
296  std::string str;
297  raw_string_ostream rawstr(str);
298  rawstr << "NormalGepPE: [" << getDstID() << "<--" << getSrcID() << "]\t";
300  rawstr << "\n";
301  }
302  rawstr << value2String(getValue());
303  return rawstr.str();
304 }
305 
306 const std::string VariantGepPE::toString() const{
307  std::string str;
308  raw_string_ostream rawstr(str);
309  rawstr << "VariantGepPE: [" << getDstID() << "<--" << getSrcID() << "]\t";
311  rawstr << "\n";
312  }
313  rawstr << value2String(getValue());
314  return rawstr.str();
315 }
316 
317 const std::string CallPE::toString() const{
318  std::string str;
319  raw_string_ostream rawstr(str);
320  rawstr << "CallPE: [" << getDstID() << "<--" << getSrcID() << "]\t";
322  rawstr << "\n";
323  }
324  rawstr << value2String(getValue());
325  return rawstr.str();
326 }
327 
328 const std::string RetPE::toString() const{
329  std::string str;
330  raw_string_ostream rawstr(str);
331  rawstr << "RetPE: [" << getDstID() << "<--" << getSrcID() << "]\t";
333  rawstr << "\n";
334  }
335  rawstr << value2String(getValue());
336  return rawstr.str();
337 }
338 
339 const std::string TDForkPE::toString() const{
340  std::string str;
341  raw_string_ostream rawstr(str);
342  rawstr << "TDForkPE: [" << getDstID() << "<--" << getSrcID() << "]\t";
344  rawstr << "\n";
345  }
346  rawstr << value2String(getValue());
347  return rawstr.str();
348 }
349 
350 const std::string TDJoinPE::toString() const{
351  std::string str;
352  raw_string_ostream rawstr(str);
353  rawstr << "TDJoinPE: [" << getDstID() << "<--" << getSrcID() << "]\t";
355  rawstr << "\n";
356  }
357  rawstr << value2String(getValue());
358  return rawstr.str();
359 }
360 
361 
362 PAG::PAG(bool buildFromFile) : fromFile(buildFromFile), nodeNumAfterPAGBuild(0), totalPTAPAGEdge(0)
363 {
365  icfg = new ICFG();
366  ICFGBuilder builder(icfg);
367  builder.build(getModule());
368 }
369 
374 {
375  PAGNode* srcNode = getPAGNode(src);
376  PAGNode* dstNode = getPAGNode(dst);
377  if(PAGEdge* edge = hasNonlabeledEdge(srcNode,dstNode, PAGEdge::Addr))
378  return SVFUtil::cast<AddrPE>(edge);
379  else
380  {
381  AddrPE* addrPE = new AddrPE(srcNode, dstNode);
382  addEdge(srcNode,dstNode, addrPE);
383  return addrPE;
384  }
385 }
386 
391 {
392  PAGNode* srcNode = getPAGNode(src);
393  PAGNode* dstNode = getPAGNode(dst);
394  if(PAGEdge* edge = hasNonlabeledEdge(srcNode,dstNode, PAGEdge::Copy))
395  return SVFUtil::cast<CopyPE>(edge);
396  else
397  {
398  CopyPE* copyPE = new CopyPE(srcNode, dstNode);
399  addEdge(srcNode,dstNode, copyPE);
400  return copyPE;
401  }
402 }
403 
408 {
409  PAGNode* srcNode = getPAGNode(src);
410  PAGNode* dstNode = getPAGNode(dst);
411  if(PAGEdge* edge = hasNonlabeledEdge(srcNode,dstNode, PAGEdge::Cmp))
412  return SVFUtil::cast<CmpPE>(edge);
413  else
414  {
415  CmpPE* cmp = new CmpPE(srcNode, dstNode);
416  addEdge(srcNode,dstNode, cmp);
417  return cmp;
418  }
419 }
420 
421 
426 {
427  PAGNode* srcNode = getPAGNode(src);
428  PAGNode* dstNode = getPAGNode(dst);
429  if(PAGEdge* edge = hasNonlabeledEdge(srcNode,dstNode, PAGEdge::BinaryOp))
430  return SVFUtil::cast<BinaryOPPE>(edge);
431  else
432  {
433  BinaryOPPE* binaryOP = new BinaryOPPE(srcNode, dstNode);
434  addEdge(srcNode,dstNode, binaryOP);
435  return binaryOP;
436  }
437 }
438 
443 {
444  PAGNode* srcNode = getPAGNode(src);
445  PAGNode* dstNode = getPAGNode(dst);
446  if(PAGEdge* edge = hasNonlabeledEdge(srcNode,dstNode, PAGEdge::UnaryOp))
447  return SVFUtil::cast<UnaryOPPE>(edge);
448  else
449  {
450  UnaryOPPE* unaryOP = new UnaryOPPE(srcNode, dstNode);
451  addEdge(srcNode,dstNode, unaryOP);
452  return unaryOP;
453  }
454 }
455 
460 {
461  PAGNode* srcNode = getPAGNode(src);
462  PAGNode* dstNode = getPAGNode(dst);
463  if(PAGEdge* edge = hasNonlabeledEdge(srcNode,dstNode, PAGEdge::Load))
464  return SVFUtil::cast<LoadPE>(edge);
465  else
466  {
467  LoadPE* loadPE = new LoadPE(srcNode, dstNode);
468  addEdge(srcNode,dstNode, loadPE);
469  return loadPE;
470  }
471 }
472 
478 {
479  PAGNode* srcNode = getPAGNode(src);
480  PAGNode* dstNode = getPAGNode(dst);
481  if(PAGEdge* edge = hasLabeledEdge(srcNode,dstNode, PAGEdge::Store, curVal))
482  return SVFUtil::cast<StorePE>(edge);
483  else
484  {
485  StorePE* storePE = new StorePE(srcNode, dstNode, curVal);
486  addEdge(srcNode,dstNode, storePE);
487  return storePE;
488  }
489 }
490 
495 {
496  PAGNode* srcNode = getPAGNode(src);
497  PAGNode* dstNode = getPAGNode(dst);
498  if(PAGEdge* edge = hasLabeledEdge(srcNode,dstNode, PAGEdge::Call, cs))
499  return SVFUtil::cast<CallPE>(edge);
500  else
501  {
502  CallPE* callPE = new CallPE(srcNode, dstNode, cs);
503  addEdge(srcNode,dstNode, callPE);
504  return callPE;
505  }
506 }
507 
512 {
513  PAGNode* srcNode = getPAGNode(src);
514  PAGNode* dstNode = getPAGNode(dst);
515  if(PAGEdge* edge = hasLabeledEdge(srcNode,dstNode, PAGEdge::Ret, cs))
516  return SVFUtil::cast<RetPE>(edge);
517  else
518  {
519  RetPE* retPE = new RetPE(srcNode, dstNode, cs);
520  addEdge(srcNode,dstNode, retPE);
521  return retPE;
522  }
523 }
524 
529 {
531  return pag->addAddrPE(pag->getBlackHoleNode(), node);
532  else
533  return pag->addCopyPE(pag->getNullPtr(), node);
534 }
535 
540 {
541  PAGNode* srcNode = getPAGNode(src);
542  PAGNode* dstNode = getPAGNode(dst);
543  if(PAGEdge* edge = hasLabeledEdge(srcNode,dstNode, PAGEdge::ThreadFork, cs))
544  return SVFUtil::cast<TDForkPE>(edge);
545  else
546  {
547  TDForkPE* forkPE = new TDForkPE(srcNode, dstNode, cs);
548  addEdge(srcNode,dstNode, forkPE);
549  return forkPE;
550  }
551 }
552 
557 {
558  PAGNode* srcNode = getPAGNode(src);
559  PAGNode* dstNode = getPAGNode(dst);
560  if(PAGEdge* edge = hasLabeledEdge(srcNode,dstNode, PAGEdge::ThreadJoin, cs))
561  return SVFUtil::cast<TDJoinPE>(edge);
562  else
563  {
564  TDJoinPE* joinPE = new TDJoinPE(srcNode, dstNode, cs);
565  addEdge(srcNode,dstNode, joinPE);
566  return joinPE;
567  }
568 }
569 
570 
576 GepPE* PAG::addGepPE(NodeID src, NodeID dst, const LocationSet& ls, bool constGep)
577 {
578 
579  PAGNode* node = getPAGNode(src);
580  if (!constGep || node->hasIncomingVariantGepEdge())
581  {
584  return addVariantGepPE(src, dst);
585  }
586  else
587  {
588  return addNormalGepPE(src, dst, ls);
589  }
590 }
591 
596 {
597  const LocationSet& baseLS = getLocationSetFromBaseNode(src);
598  PAGNode* baseNode = getPAGNode(getBaseValNode(src));
599  PAGNode* dstNode = getPAGNode(dst);
600  if(PAGEdge* edge = hasNonlabeledEdge(baseNode, dstNode, PAGEdge::NormalGep))
601  return SVFUtil::cast<NormalGepPE>(edge);
602  else
603  {
604  NormalGepPE* gepPE = new NormalGepPE(baseNode, dstNode, ls+baseLS);
605  addEdge(baseNode, dstNode, gepPE);
606  return gepPE;
607  }
608 }
609 
615 {
616 
617  PAGNode* baseNode = getPAGNode(getBaseValNode(src));
618  PAGNode* dstNode = getPAGNode(dst);
619  if(PAGEdge* edge = hasNonlabeledEdge(baseNode, dstNode, PAGEdge::VariantGep))
620  return SVFUtil::cast<VariantGepPE>(edge);
621  else
622  {
623  VariantGepPE* gepPE = new VariantGepPE(baseNode, dstNode);
624  addEdge(baseNode, dstNode, gepPE);
625  return gepPE;
626  }
627 }
628 
629 
630 
635 NodeID PAG::addGepValNode(const Value* curInst,const Value* gepVal, const LocationSet& ls, NodeID i, const Type *type, u32_t fieldidx)
636 {
637  NodeID base = getBaseValNode(getValueNode(gepVal));
638  //assert(findPAGNode(i) == false && "this node should not be created before");
639  assert(0==GepValNodeMap[curInst].count(std::make_pair(base, ls))
640  && "this node should not be created before");
641  GepValNodeMap[curInst][std::make_pair(base, ls)] = i;
642  GepValPN *node = new GepValPN(gepVal, i, ls, type, fieldidx);
643  return addValNode(gepVal, node, i);
644 }
645 
650 {
651  PAGNode* node = pag->getPAGNode(id);
652  if (GepObjPN* gepNode = SVFUtil::dyn_cast<GepObjPN>(node))
653  return getGepObjNode(gepNode->getMemObj(), gepNode->getLocationSet() + ls);
654  else if (FIObjPN* baseNode = SVFUtil::dyn_cast<FIObjPN>(node))
655  return getGepObjNode(baseNode->getMemObj(), ls);
656  else if (DummyObjPN* baseNode = SVFUtil::dyn_cast<DummyObjPN>(node))
657  return getGepObjNode(baseNode->getMemObj(), ls);
658  else
659  {
660  assert(false && "new gep obj node kind?");
661  return id;
662  }
663 }
664 
672 {
673  NodeID base = getObjectNode(obj);
674 
676  if (obj->isFieldInsensitive())
677  return getFIObjNode(obj);
678 
680 
681  // Base and first field are the same memory location.
682  if (Options::FirstFieldEqBase && newLS.getOffset() == 0) return base;
683 
684  NodeLocationSetMap::iterator iter = GepObjNodeMap.find(std::make_pair(base, newLS));
685  if (iter == GepObjNodeMap.end())
686  return addGepObjNode(obj, newLS);
687  else
688  return iter->second;
689 
690 }
691 
696 {
697  //assert(findPAGNode(i) == false && "this node should not be created before");
698  NodeID base = getObjectNode(obj);
699  assert(0==GepObjNodeMap.count(std::make_pair(base, ls))
700  && "this node should not be created before");
701 
703  GepObjNodeMap[std::make_pair(base, ls)] = gepId;
704  GepObjPN *node = new GepObjPN(obj, gepId, ls);
705  memToFieldsMap[base].set(gepId);
706  return addObjNode(obj->getRefVal(), node, gepId);
707 }
708 
713 {
714  //assert(findPAGNode(i) == false && "this node should not be created before");
715  NodeID base = getObjectNode(obj);
716  memToFieldsMap[base].set(obj->getSymId());
717  FIObjPN *node = new FIObjPN(obj->getRefVal(), obj->getSymId(), obj);
718  return addObjNode(obj->getRefVal(), node, obj->getSymId());
719 }
720 
721 
726 {
727  PAGEdge edge(src,dst,kind);
728  PAGEdge::PAGEdgeSetTy::iterator it = PAGEdgeKindToSetMap[kind].find(&edge);
729  if (it != PAGEdgeKindToSetMap[kind].end())
730  {
731  return *it;
732  }
733  return nullptr;
734 }
735 
740 {
741  PAGEdge edge(src,dst,PAGEdge::makeEdgeFlagWithCallInst(kind,callInst));
742  PAGEdge::PAGEdgeSetTy::iterator it = PAGEdgeKindToSetMap[kind].find(&edge);
743  if (it != PAGEdgeKindToSetMap[kind].end())
744  {
745  return *it;
746  }
747  return nullptr;
748 }
749 
750 
754 bool PAG::addEdge(PAGNode* src, PAGNode* dst, PAGEdge* edge)
755 {
756 
758  outs() << "add edge from " << src->getId() << " kind :"
759  << src->getNodeKind() << " to " << dst->getId()
760  << " kind :" << dst->getNodeKind() << "\n");
761  src->addOutEdge(edge);
762  dst->addInEdge(edge);
763  bool added = PAGEdgeKindToSetMap[edge->getEdgeKind()].insert(edge).second;
764  assert(added && "duplicated edge, not added!!!");
765  if (edge->isPTAEdge())
766  {
767  totalPTAPAGEdge++;
768  PTAPAGEdgeKindToSetMap[edge->getEdgeKind()].insert(edge);
769  }
770  return true;
771 }
772 
777 {
778  NodeID base = getObjectNode(obj);
779  return memToFieldsMap[base];
780 }
781 
786 {
787  const PAGNode* node = pag->getPAGNode(id);
788  assert(SVFUtil::isa<ObjPN>(node) && "need an object node");
789  const ObjPN* obj = SVFUtil::cast<ObjPN>(node);
790  return getAllFieldsObjNode(obj->getMemObj());
791 }
792 
799 {
800  const PAGNode* node = pag->getPAGNode(id);
801  assert(SVFUtil::isa<ObjPN>(node) && "need an object node");
802  const MemObj* mem = SVFUtil::cast<ObjPN>(node)->getMemObj();
803  if(mem->isFieldInsensitive())
804  {
805  NodeBS bs;
806  bs.set(getFIObjNode(mem));
807  return bs;
808  }
809  else
810  return getAllFieldsObjNode(mem);
811 }
812 
819 {
820  PAGNode* node = getPAGNode(nodeId);
822  {
825 
826  assert(((ngeps.size()+vgeps.size())==1) && "one node can only be connected by at most one gep edge!");
827 
829  if(!ngeps.empty())
830  it = ngeps.begin();
831  else
832  it = vgeps.begin();
833 
834  assert(SVFUtil::isa<GepPE>(*it) && "not a gep edge??");
835  return (*it)->getSrcID();
836  }
837  else
838  return nodeId;
839 }
840 
848 {
849  PAGNode* node = getPAGNode(nodeId);
852  if(geps.empty())
853  return LocationSet(0);
854 
855  assert(geps.size()==1 && "one node can only be connected by at most one gep edge!");
856  PAGNode::iterator it = geps.begin();
857  const PAGEdge* edge = *it;
858  assert(SVFUtil::isa<NormalGepPE>(edge) && "not a get edge??");
859  const NormalGepPE* gepEdge = SVFUtil::cast<NormalGepPE>(edge);
860  return gepEdge->getLocationSet();
861 }
862 
867 {
868  for (PAGEdge::PAGKindToEdgeSetMapTy::iterator I =
869  PAGEdgeKindToSetMap.begin(), E = PAGEdgeKindToSetMap.end(); I != E;
870  ++I)
871  {
872  for (PAGEdge::PAGEdgeSetTy::iterator edgeIt = I->second.begin(),
873  endEdgeIt = I->second.end(); edgeIt != endEdgeIt; ++edgeIt)
874  {
875  delete *edgeIt;
876  }
877  }
879  symInfo = nullptr;
880 }
881 
886 {
887 
888  outs() << "-------------------PAG------------------------------------\n";
890  for (PAGEdge::PAGEdgeSetTy::iterator iter = addrs.begin(), eiter =
891  addrs.end(); iter != eiter; ++iter)
892  {
893  outs() << (*iter)->getSrcID() << " -- Addr --> " << (*iter)->getDstID()
894  << "\n";
895  }
896 
898  for (PAGEdge::PAGEdgeSetTy::iterator iter = copys.begin(), eiter =
899  copys.end(); iter != eiter; ++iter)
900  {
901  outs() << (*iter)->getSrcID() << " -- Copy --> " << (*iter)->getDstID()
902  << "\n";
903  }
904 
906  for (PAGEdge::PAGEdgeSetTy::iterator iter = calls.begin(), eiter =
907  calls.end(); iter != eiter; ++iter)
908  {
909  outs() << (*iter)->getSrcID() << " -- Call --> " << (*iter)->getDstID()
910  << "\n";
911  }
912 
914  for (PAGEdge::PAGEdgeSetTy::iterator iter = rets.begin(), eiter =
915  rets.end(); iter != eiter; ++iter)
916  {
917  outs() << (*iter)->getSrcID() << " -- Ret --> " << (*iter)->getDstID()
918  << "\n";
919  }
920 
922  for (PAGEdge::PAGEdgeSetTy::iterator iter = tdfks.begin(), eiter =
923  tdfks.end(); iter != eiter; ++iter)
924  {
925  outs() << (*iter)->getSrcID() << " -- ThreadFork --> "
926  << (*iter)->getDstID() << "\n";
927  }
928 
930  for (PAGEdge::PAGEdgeSetTy::iterator iter = tdjns.begin(), eiter =
931  tdjns.end(); iter != eiter; ++iter)
932  {
933  outs() << (*iter)->getSrcID() << " -- ThreadJoin --> "
934  << (*iter)->getDstID() << "\n";
935  }
936 
938  for (PAGEdge::PAGEdgeSetTy::iterator iter = ngeps.begin(), eiter =
939  ngeps.end(); iter != eiter; ++iter)
940  {
941  NormalGepPE* gep = SVFUtil::cast<NormalGepPE>(*iter);
942  outs() << gep->getSrcID() << " -- NormalGep (" << gep->getOffset()
943  << ") --> " << gep->getDstID() << "\n";
944  }
945 
947  for (PAGEdge::PAGEdgeSetTy::iterator iter = vgeps.begin(), eiter =
948  vgeps.end(); iter != eiter; ++iter)
949  {
950  outs() << (*iter)->getSrcID() << " -- VariantGep --> "
951  << (*iter)->getDstID() << "\n";
952  }
953 
955  for (PAGEdge::PAGEdgeSetTy::iterator iter = loads.begin(), eiter =
956  loads.end(); iter != eiter; ++iter)
957  {
958  outs() << (*iter)->getSrcID() << " -- Load --> " << (*iter)->getDstID()
959  << "\n";
960  }
961 
963  for (PAGEdge::PAGEdgeSetTy::iterator iter = stores.begin(), eiter =
964  stores.end(); iter != eiter; ++iter)
965  {
966  outs() << (*iter)->getSrcID() << " -- Store --> " << (*iter)->getDstID()
967  << "\n";
968  }
969  outs() << "----------------------------------------------------------\n";
970 
971 }
972 
973 /*
974  * If this is a dummy node or node does not have incoming edges we assume it is not a pointer here
975  */
976 bool PAG::isValidPointer(NodeID nodeId) const
977 {
978  PAGNode* node = pag->getPAGNode(nodeId);
979  if ((node->getInEdges().empty() && node->getOutEdges().empty()))
980  return false;
981  return node->isPointer();
982 }
983 
985 {
986  if (node->isTopLevelPtr())
987  {
988  if (isValidPointer(node->getId()) && node->hasValue())
989  {
991  return false;
992  return true;
993  }
994  }
995  return false;
996 }
1001  GenericPAGEdgeTy(s,d,k),value(nullptr),basicBlock(nullptr),icfgNode(nullptr)
1002 {
1004  PAG::getPAG()->incEdgeNum();
1005 }
1006 
1011 {
1012  return getSrcNode()->isPointer() && getDstNode()->isPointer();
1013 }
1014 
1019  GenericPAGNodeTy(i,k), value(val)
1020 {
1021 
1022  assert( ValNode <= k && k <= CloneDummyObjNode && "new PAG node kind?");
1023 
1024  switch (k)
1025  {
1026  case ValNode:
1027  case GepValNode:
1028  {
1029  assert(val != nullptr && "value is nullptr for ValPN or GepValNode");
1030  isTLPointer = val->getType()->isPointerTy();
1031  isATPointer = false;
1032  break;
1033  }
1034 
1035  case RetNode:
1036  {
1037  assert(val != nullptr && "value is nullptr for RetNode");
1038  isTLPointer = SVFUtil::cast<Function>(val)->getReturnType()->isPointerTy();
1039  isATPointer = false;
1040  break;
1041  }
1042 
1043  case VarargNode:
1044  case DummyValNode:
1045  {
1046  isTLPointer = true;
1047  isATPointer = false;
1048  break;
1049  }
1050 
1051  case ObjNode:
1052  case GepObjNode:
1053  case FIObjNode:
1054  case DummyObjNode:
1055  case CloneGepObjNode:
1056  case CloneFIObjNode:
1057  case CloneDummyObjNode:
1058  {
1059  isTLPointer = false;
1060  isATPointer = true;
1061  break;
1062  }
1063  }
1064 }
1065 
1067  if (getInEdges().empty() && getOutEdges().empty())
1068  return true;
1069  else if (isConstantData())
1070  return true;
1071  else if (value && SVFUtil::isa<Function>(value))
1072  return SVFUtil::isIntrinsicFun(SVFUtil::cast<Function>(value));
1073  else
1074  return false;
1075 }
1076 
1077 
1081 void PAG::dump(std::string name)
1082 {
1083  GraphPrinter::WriteGraphToFile(outs(), name, this);
1084 }
1085 
1090 {
1091  llvm::ViewGraph(this, "ProgramAssignmentGraph");
1092 }
1093 
1098 {
1100 }
1101 
1102 namespace llvm
1103 {
1107 template<>
1108 struct DOTGraphTraits<PAG*> : public DefaultDOTGraphTraits
1109 {
1110 
1113  DOTGraphTraits(bool isSimple = false) :
1114  DefaultDOTGraphTraits(isSimple)
1115  {
1116  }
1117 
1119  static std::string getGraphName(PAG *graph)
1120  {
1121  return graph->getGraphName();
1122  }
1123 
1126 #if LLVM_VERSION_MAJOR >= 12
1127  static bool isNodeHidden(PAGNode *node, PAG*) {
1128 #else
1129  static bool isNodeHidden(PAGNode *node) {
1130 #endif
1131  return node->isIsolatedNode();
1132  }
1133 
1136  static std::string getNodeLabel(PAGNode *node, PAG*)
1137  {
1138  std::string str;
1139  raw_string_ostream rawstr(str);
1140  // print function info
1141  if (node->getFunction())
1142  rawstr << "[" << node->getFunction()->getName() << "] ";
1143 
1144  rawstr << node->toString();
1145 
1146  return rawstr.str();
1147 
1148  }
1149 
1150  static std::string getNodeAttributes(PAGNode *node, PAG*)
1151  {
1152  return node->getNodeAttrForDotDisplay();
1153  }
1154 
1155  template<class EdgeIter>
1156  static std::string getEdgeAttributes(PAGNode*, EdgeIter EI, PAG*)
1157  {
1158  const PAGEdge* edge = *(EI.getCurrent());
1159  assert(edge && "No edge found!!");
1160  if (SVFUtil::isa<AddrPE>(edge))
1161  {
1162  return "color=green";
1163  }
1164  else if (SVFUtil::isa<CopyPE>(edge))
1165  {
1166  return "color=black";
1167  }
1168  else if (SVFUtil::isa<GepPE>(edge))
1169  {
1170  return "color=purple";
1171  }
1172  else if (SVFUtil::isa<StorePE>(edge))
1173  {
1174  return "color=blue";
1175  }
1176  else if (SVFUtil::isa<LoadPE>(edge))
1177  {
1178  return "color=red";
1179  }
1180  else if (SVFUtil::isa<CmpPE>(edge))
1181  {
1182  return "color=grey";
1183  }
1184  else if (SVFUtil::isa<BinaryOPPE>(edge))
1185  {
1186  return "color=grey";
1187  }
1188  else if (SVFUtil::isa<UnaryOPPE>(edge))
1189  {
1190  return "color=grey";
1191  }
1192  else if (SVFUtil::isa<TDForkPE>(edge))
1193  {
1194  return "color=Turquoise";
1195  }
1196  else if (SVFUtil::isa<TDJoinPE>(edge))
1197  {
1198  return "color=Turquoise";
1199  }
1200  else if (SVFUtil::isa<CallPE>(edge))
1201  {
1202  return "color=black,style=dashed";
1203  }
1204  else if (SVFUtil::isa<RetPE>(edge))
1205  {
1206  return "color=black,style=dotted";
1207  }
1208 
1209  assert(false && "No such kind edge!!");
1210  exit(1);
1211  }
1212 
1213  template<class EdgeIter>
1214  static std::string getEdgeSourceLabel(PAGNode*, EdgeIter EI)
1215  {
1216  const PAGEdge* edge = *(EI.getCurrent());
1217  assert(edge && "No edge found!!");
1218  if(const CallPE* calledge = SVFUtil::dyn_cast<CallPE>(edge))
1219  {
1220  const Instruction* callInst= calledge->getCallSite()->getCallSite();
1221  return SVFUtil::getSourceLoc(callInst);
1222  }
1223  else if(const RetPE* retedge = SVFUtil::dyn_cast<RetPE>(edge))
1224  {
1225  const Instruction* callInst= retedge->getCallSite()->getCallSite();
1226  return SVFUtil::getSourceLoc(callInst);
1227  }
1228  return "";
1229  }
1230 };
1231 } // End namespace llvm
virtual const std::string toString() const
Definition: PAG.cpp:179
const LocationSet & getLocationSet() const
Definition: PAGEdge.h:511
NodeID addValNode(const Value *val, NodeID i)
Add a value (pointer) node.
Definition: PAG.h:701
static PAG * pag
Singleton pattern here to enable instance of PAG can only be created once.
Definition: PAG.h:100
GEdgeKind getEdgeKind() const
Definition: GenericGraph.h:81
u32_t getTotalEdgeNum() const
Definition: GenericGraph.h:421
VOID_OR_INT exit()
NodeID getValueNode(const Value *V)
Get PAG Node according to LLVM value.
Definition: PAG.h:521
virtual const std::string toString() const
Definition: PAG.cpp:46
bool isIsolatedNode() const
Whether this is an isoloated node on the PAG graph.
Definition: PAG.cpp:1066
Definition: ConsG.h:385
NodeID getBaseValNode(NodeID nodeId)
Base and Offset methods for Value and Object node.
Definition: PAG.cpp:818
static void handleBlackHole(bool b)
PAG build configurations.
Definition: PAG.cpp:1097
u32_t totalPTAPAGEdge
Definition: PAG.h:118
virtual const std::string toString() const
Definition: PAG.cpp:158
virtual const std::string toString() const
Definition: PAG.cpp:295
NodeID addGepObjNode(const MemObj *obj, const LocationSet &ls)
Add a field obj node, this method can only invoked by getGepObjNode.
Definition: PAG.cpp:695
virtual LocationSet getModulusOffset(const MemObj *obj, const LocationSet &ls)
Given an offset from a Gep Instruction, return it modulus offset by considering memory layout...
virtual const std::string toString() const
Definition: PAG.cpp:218
const GEdgeSetTy & getInEdges() const
Definition: GenericGraph.h:181
const MemObj * getMemObj() const
Return memory object.
Definition: PAGNode.h:359
CallPE * addCallPE(NodeID src, NodeID dst, const CallBlockNode *cs)
Add Call edge.
Definition: PAG.cpp:494
BinaryOPPE * addBinaryOPPE(NodeID src, NodeID dst)
Add Copy edge.
Definition: PAG.cpp:425
NodeID getDstID() const
Definition: GenericGraph.h:77
virtual const std::string toString() const
Definition: PAG.cpp:186
u32_t NodeID
Definition: SVFBasicTypes.h:80
DOTGraphTraits(bool isSimple=false)
Definition: PAG.cpp:1113
virtual const std::string toString() const
Definition: PAG.cpp:96
bool hasIncomingEdges(PAGEdge::PEDGEK kind) const
Has incoming PAG edges.
Definition: PAGNode.h:172
llvm::Type Type
Definition: BasicTypes.h:75
bool addEdge(PAGNode *src, PAGNode *dst, PAGEdge *edge)
Add an edge into PAG.
Definition: PAG.cpp:754
bool isTLPointer
Definition: PAGNode.h:80
#define assert(ex)
Definition: util.h:141
GenericNode< PAGNode, PAGEdge >::GEdgeSetTy PAGEdgeSetTy
Definition: PAGEdge.h:169
void destroy()
Clean up memory.
Definition: PAG.cpp:866
NodeID getSrcID() const
get methods of the components
Definition: GenericGraph.h:73
static Inst2LabelMap inst2LabelMap
Call site Instruction to label map.
Definition: PAGEdge.h:175
virtual const std::string toString() const
Definition: PAG.cpp:328
ICFG * icfg
Definition: PAG.h:108
virtual const std::string toString() const
Definition: PAG.cpp:129
PAGEdge::PAGEdgeSetTy & getIncomingEdges(PAGEdge::PEDGEK kind)
Get incoming PAG edges.
Definition: PAGNode.h:160
static std::string getEdgeSourceLabel(PAGNode *, EdgeIter EI)
Definition: PAG.cpp:1214
LocationSet getLocationSetFromBaseNode(NodeID nodeId)
Definition: PAG.cpp:847
static std::string getNodeLabel(PAGNode *node, PAG *)
Definition: PAG.cpp:1136
NodeID addObjNode(const Value *val, NodeID i)
Add a memory obj node.
Definition: PAG.h:707
bool isFieldInsensitive() const
Return true if its field limit is 0.
Definition: MemModel.h:337
Definition: PAG.h:47
MemObjToFieldsMap memToFieldsMap
Map a mem object id to all its fields.
Definition: PAG.h:90
std::string getSourceLoc(const Value *val)
Return source code including line number and file name from debug information.
Definition: SVFUtil.cpp:259
PAGEdge::PAGKindToEdgeSetMapTy PTAPAGEdgeKindToSetMap
Definition: PAG.h:85
void view()
View graph from the debugger.
Definition: PAG.cpp:1089
const Value * getValue() const
Get/has methods of the components.
Definition: PAGNode.h:93
GNodeK getNodeKind() const
Get node kind.
Definition: GenericGraph.h:170
const Value * value
value of this PAG node
Definition: PAGNode.h:77
bool isPTAEdge() const
Whether src and dst nodes are both of pointer type.
Definition: PAG.cpp:1010
GEdgeSetTy::iterator iterator
Definition: GenericGraph.h:139
virtual const std::string toString() const
Definition: PAG.cpp:151
unsigned u32_t
Definition: SVFBasicTypes.h:75
NodeID getObjectNode(const Value *V)
Definition: PAG.h:531
virtual const std::string toString() const
Definition: PAG.cpp:306
NodeID allocateGepObjectId(NodeID base, u32_t offset, u32_t maxFieldLimit)
GepPE * addGepPE(NodeID src, NodeID dst, const LocationSet &ls, bool constGep)
Add Gep edge.
Definition: PAG.cpp:576
bool isIntrinsicFun(const Function *func)
Definition: SVFUtil.h:131
NodeID getFIObjNode(const MemObj *obj) const
Get a field-insensitive obj PAG node according to a mem obj.
Definition: PAG.h:574
NodeBS & getAllFieldsObjNode(const MemObj *obj)
Get all fields of an object.
Definition: PAG.cpp:776
PAGEdge::PAGKindToEdgeSetMapTy PAGEdgeKindToSetMap
Definition: PAG.h:84
virtual const std::string toString() const
Definition: PAG.cpp:240
static PAG * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis. ...
Definition: PAG.h:160
virtual const Function * getFunction() const
Return the function that this PAGNode resides in. Return nullptr if it is a global or constantexpr no...
Definition: PAGNode.h:145
bool isATPointer
top-level pointer
Definition: PAGNode.h:81
PAGEdge * addBlackHoleAddrPE(NodeID node)
Set a pointer points-to black hole (e.g. int2ptr)
Definition: PAG.cpp:528
void build(SVFModule *svfModule)
Definition: ICFGBuilder.cpp:41
NodeID addGepValNode(const Value *curInst, const Value *val, const LocationSet &ls, NodeID i, const Type *type, u32_t fieldidx)
Add a temp field value node, this method can only invoked by getGepValNode.
Definition: PAG.cpp:635
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513
virtual const std::string toString() const
Definition: PAG.cpp:165
PAGEdge * hasLabeledEdge(PAGNode *src, PAGNode *dst, PAGEdge::PEDGEK kind, const ICFGNode *cs)
Definition: PAG.cpp:739
virtual const std::string toString() const
Definition: PAG.cpp:172
const Value * getRefVal() const
Get the reference value to this object.
Definition: MemModel.h:325
NodeType * getDstNode() const
Definition: GenericGraph.h:89
static const llvm::cl::opt< bool > PAGDotGraphShorter
Definition: Options.h:88
NodeBS getFieldsAfterCollapse(NodeID id)
Definition: PAG.cpp:798
static void releaseSymbolInfo()
bool isConstantData() const
Definition: PAGNode.h:130
llvm::Instruction Instruction
Definition: BasicTypes.h:79
NodeID getGepObjNode(const MemObj *obj, const LocationSet &ls)
Get a field PAG Object node according to base mem obj and offset.
Definition: PAG.cpp:671
AddrPE * addAddrPE(NodeID src, NodeID dst)
Add Address edge.
Definition: PAG.cpp:373
static u64_t callEdgeLabelCounter
Call site Instruction counter.
Definition: PAGEdge.h:176
NodeID getBlackHoleNode() const
Get black hole and constant id.
Definition: PAG.h:589
const GEdgeSetTy & getOutEdges() const
Definition: GenericGraph.h:177
llvm::raw_string_ostream raw_string_ostream
Definition: BasicTypes.h:100
static bool isNodeHidden(PAGNode *node)
Definition: PAG.cpp:1129
NodeID getNullPtr() const
Definition: PAG.h:601
CopyPE * addCopyPE(NodeID src, NodeID dst)
Add Copy edge.
Definition: PAG.cpp:390
NormalGepPE * addNormalGepPE(NodeID src, NodeID dst, const LocationSet &ls)
Add Offset(Gep) edge.
Definition: PAG.cpp:595
static u32_t getMaxFieldLimit()
Definition: MemModel.h:88
Map< const ICFGNode *, u32_t > Inst2LabelMap
Definition: PAGEdge.h:174
virtual const std::string toString() const
Definition: PAG.cpp:350
static SymbolTableInfo * SymbolInfo()
Singleton design here to make sure we only have one instance during any analysis. ...
const std::string value2String(const Value *value)
Definition: SVFUtil.cpp:359
bool hasValue() const
Definition: PAGNode.h:109
NodeType * getSrcNode() const
Definition: GenericGraph.h:85
VariantGepPE * addVariantGepPE(NodeID src, NodeID dst)
Add Variant(Gep) edge.
Definition: PAG.cpp:614
CmpPE * addCmpPE(NodeID src, NodeID dst)
Add Copy edge.
Definition: PAG.cpp:407
raw_ostream & outs()
Overwrite llvm::outs()
Definition: SVFUtil.h:47
RetPE * addRetPE(NodeID src, NodeID dst, const CallBlockNode *cs)
Add Return edge.
Definition: PAG.cpp:511
PAGEdge::PAGEdgeSetTy & getEdgeSet(PAGEdge::PEDGEK kind)
Get/set methods to get control flow information of a PAGEdge.
Definition: PAG.h:208
virtual const std::string toString() const
Definition: PAG.cpp:317
Definition: ICFG.h:46
EdgeID edgeId
Edge ID.
Definition: PAGEdge.h:63
virtual const std::string toString() const
Definition: PAG.cpp:262
std::string getGraphName() const
Return graph name.
Definition: PAG.h:846
SVFModule * getModule()
Get LLVM Module.
Definition: PAG.h:193
SymID getSymId() const
Get the memory object id.
Definition: MemModel.h:331
static const llvm::cl::opt< bool > FirstFieldEqBase
Definition: Options.h:67
void dump(std::string name)
Dump PAG.
Definition: PAG.cpp:1081
bool isTopLevelPtr() const
Whether it is a top-level pointer.
Definition: PAGNode.h:119
bool ArgInNoCallerFunction(const Value *val)
Return true if the argument in a function does not have a caller.
Definition: LLVMUtil.h:479
GepValPNMap GepValNodeMap
Map a pair<base,off> to a gep value node id.
Definition: PAG.h:88
TDForkPE * addThreadForkPE(NodeID src, NodeID dst, const CallBlockNode *cs)
Add Thread fork edge for parameter passing.
Definition: PAG.cpp:539
Size_t getOffset() const
Get methods.
Definition: LocationSet.h:194
static llvm::cl::opt< bool > HandBlackHole
Definition: Options.h:66
bool hasIncomingVariantGepEdge() const
Has incoming VariantGepEdges.
Definition: PAGNode.h:182
bool isValidPointer(NodeID nodeId) const
Whether a node is a valid pointer.
Definition: PAG.cpp:976
bool isValidTopLevelPtr(const PAGNode *node)
Definition: PAG.cpp:984
virtual const std::string toString() const
Definition: PAG.cpp:118
for isBitcode
Definition: ContextDDA.h:15
void addInEdge(PAGEdge *inEdge)
add methods of the components
Definition: PAGNode.h:237
static GEdgeFlag makeEdgeFlagWithCallInst(GEdgeKind k, const ICFGNode *cs)
Compute the unique edgeFlag value from edge kind and call site Instruction.
Definition: PAGEdge.h:139
virtual const std::string toString() const
Definition: PAG.cpp:229
virtual const std::string toString() const
Definition: PAG.cpp:193
virtual const std::string toString() const
Definition: PAG.cpp:107
static NodeIDAllocator * get(void)
Return (singleton) allocator.
NodeID getId() const
Get ID.
Definition: GenericGraph.h:164
StorePE * addStorePE(NodeID src, NodeID dst, const IntraBlockNode *val)
Add Store edge.
Definition: PAG.cpp:477
llvm::SparseBitVector NodeBS
Definition: SVFBasicTypes.h:87
static std::string getGraphName(PAG *graph)
Return name of the graph.
Definition: PAG.cpp:1119
#define DPAGBuild
PAGNode(const Value *val, NodeID i, PNODEK k)
address-taken pointer
Definition: PAG.cpp:1018
TDJoinPE * addThreadJoinPE(NodeID src, NodeID dst, const CallBlockNode *cs)
Add Thread join edge for parameter passing.
Definition: PAG.cpp:556
virtual const std::string toString() const
Definition: PAG.cpp:339
static std::string getNodeAttributes(PAGNode *node, PAG *)
Definition: PAG.cpp:1150
virtual const std::string toString() const
Definition: PAG.cpp:273
PAGEdge(PAGNode *s, PAGNode *d, GEdgeFlag k)
Constructor.
Definition: PAG.cpp:1000
virtual const std::string toString() const
Definition: PAG.cpp:200
static std::string getEdgeAttributes(PAGNode *, EdgeIter EI, PAG *)
Definition: PAG.cpp:1156
virtual const std::string toString() const
Definition: PAG.cpp:207
virtual const std::string getNodeAttrForDotDisplay() const
Get shape and/or color of node for .dot display.
Definition: PAG.cpp:54
void print()
Print PAG.
Definition: PAG.cpp:885
NodeType::iterator ChildIteratorType
Definition: PAG.cpp:1112
const Value * value
LLVM value.
Definition: PAGEdge.h:60
LoadPE * addLoadPE(NodeID src, NodeID dst)
Add Load edge.
Definition: PAG.cpp:459
NodeLocationSetMap GepObjNodeMap
Map a pair<base,off> to a gep obj node id.
Definition: PAG.h:89
NodeID addFIObjNode(const MemObj *obj)
Add a field-insensitive node, this method can only invoked by getFIGepObjNode.
Definition: PAG.cpp:712
u32_t getOffset() const
offset of the gep edge
Definition: PAGEdge.h:507
static DdNode * empty
Definition: cuddZddLin.c:94
virtual const std::string toString() const
Definition: PAG.cpp:284
PAG(bool buildFromFile)
all the callsites of a program
Definition: PAG.cpp:362
PAGEdge * hasNonlabeledEdge(PAGNode *src, PAGNode *dst, PAGEdge::PEDGEK kind)
Definition: PAG.cpp:725
static u64_t storeEdgeLabelCounter
Store Instruction counter.
Definition: PAGEdge.h:177
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DEBUG model of each pass.
UnaryOPPE * addUnaryOPPE(NodeID src, NodeID dst)
Add Unary edge.
Definition: PAG.cpp:442
llvm::Value Value
Definition: BasicTypes.h:78
virtual const std::string toString() const
Definition: PAG.cpp:140
void dump() const
Dump to console for debugging.
Definition: PAG.cpp:92
virtual bool isPointer() const
Whether it is a pointer.
Definition: PAGNode.h:114
virtual const std::string toString() const
Definition: PAG.cpp:251
SymbolTableInfo * symInfo
Definition: PAG.h:81
void addOutEdge(PAGEdge *outEdge)
Definition: PAGNode.h:244
unsigned long long u64_t
Definition: SVFBasicTypes.h:76
static void WriteGraphToFile(llvm::raw_ostream &O, const std::string &GraphName, const GraphType &GT, bool simple=false)
Definition: GraphPrinter.h:56