SVF
ExternalPAG.cpp
Go to the documentation of this file.
1 //===- ExternalPAG.cpp -- Program assignment graph ---------------------------//
2 
3 /*
4  * ExternalPAG.cpp
5  *
6  * Created on: Sep 22, 2018
7  * Author: Mohamad Barbar
8  */
9 
10 #include <iostream>
11 #include <fstream>
12 #include <sstream>
13 
14 #include "Graphs/PAG.h"
15 #include "Graphs/ExternalPAG.h"
16 #include "Util/BasicTypes.h"
17 #include "Graphs/ICFG.h"
18 
19 using namespace SVF;
20 using namespace SVFUtil;
21 
22 llvm::cl::list<std::string> ExternalPAGArgs("extpags",
23  llvm::cl::desc("ExternalPAGs to use during PAG construction (format: func1@/path/to/graph,func2@/foo,..."),
24  llvm::cl::CommaSeparated);
25 
26 llvm::cl::list<std::string> DumpPAGFunctions("dump-function-pags",
27  llvm::cl::desc("Dump PAG for functions"),
28  llvm::cl::CommaSeparated);
29 
30 
34 
35 std::vector<std::pair<std::string, std::string>>
36  ExternalPAG::parseExternalPAGs(llvm::cl::list<std::string> &extpagsArgs)
37 {
38  std::vector<std::pair<std::string, std::string>> parsedExternalPAGs;
39  for (auto arg = extpagsArgs.begin(); arg != extpagsArgs.end();
40  ++arg)
41  {
42  std::stringstream ss(*arg);
43  std::string functionName;
44  getline(ss, functionName, '@');
45  std::string path;
46  getline(ss, path);
47  parsedExternalPAGs.push_back(
48  std::pair<std::string, std::string>(functionName, path));
49  }
50 
51  return parsedExternalPAGs;
52 }
53 
55 {
56  std::vector<std::pair<std::string, std::string>> parsedExternalPAGs
58 
59  // Build ext PAGs (and add them) first to use them in PAG construction.
60  for (auto extpagPair= parsedExternalPAGs.begin();
61  extpagPair != parsedExternalPAGs.end(); ++extpagPair)
62  {
63  std::string fname = extpagPair->first;
64  std::string path = extpagPair->second;
65 
66  ExternalPAG extpag = ExternalPAG(fname);
67  extpag.readFromFile(path);
68  extpag.addExternalPAG(getFunction(fname));
69  }
70 }
71 
73 {
74  PAG *pag = PAG::getPAG();
75 
76  Function* function = cs->getCalledFunction();
77  std::string functionName = function->getName().str();
78 
79  const SVFFunction* svfFun = LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(function);
80  if (!hasExternalPAG(svfFun)) return false;
81 
82  Map<int, PAGNode*> argNodes =
83  functionToExternalPAGEntries[svfFun];
84  PAGNode *retNode = functionToExternalPAGReturns[svfFun];
85 
86  // Handle the return.
87  if (llvm::isa<PointerType>(cs->getType()))
88  {
89  NodeID dstrec = pag->getValueNode(cs->getInstruction());
90  // Does it actually return a pointer?
91  if (SVFUtil::isa<PointerType>(function->getReturnType()))
92  {
93  if (retNode != nullptr)
94  {
95  CallBlockNode* icfgNode = pag->getICFG()->getCallBlockNode(cs->getInstruction());
96  pag->addRetPE(retNode->getId(), dstrec, icfgNode);
97  }
98  }
99  else
100  {
101  // This is a int2ptr cast during parameter passing
102  pag->addBlackHoleAddrPE(dstrec);
103  }
104  }
105 
106  // Handle the arguments;
107  // Actual arguments.
108  CallSite::arg_iterator itA = cs->arg_begin(), ieA = cs->arg_end();
109  Function::const_arg_iterator itF = function->arg_begin(),
110  ieF = function->arg_end();
111  // Formal arguments.
112  size_t formalNodeIndex = 0;
113 
114  for (; itF != ieF ; ++itA, ++itF, ++formalNodeIndex)
115  {
116  if (itA == ieA)
117  {
118  // When unneeded args are left empty, e.g. Linux kernel.
119  break;
120  }
121 
122  // Formal arg node is from the extpag, actual arg node would come from
123  // the main pag.
124  PAGNode *formalArgNode = argNodes[formalNodeIndex];
125  NodeID actualArgNodeId = pag->getValueNode(*itA);
126 
127  const llvm::Value *formalArg = &*itF;
128  if (!SVFUtil::isa<PointerType>(formalArg->getType())) continue;
129 
130  if (SVFUtil::isa<PointerType>((*itA)->getType()))
131  {
132  CallBlockNode* icfgNode = pag->getICFG()->getCallBlockNode(cs->getInstruction());
133  pag->addCallPE(actualArgNodeId, formalArgNode->getId(), icfgNode);
134  }
135  else
136  {
137  // This is a int2ptr cast during parameter passing
138  //addFormalParamBlackHoleAddrEdge(formalArgNode->getId(), &*itF);
139  assert(false && "you need to set the current location of this PAGEdge");
140  pag->addBlackHoleAddrPE(formalArgNode->getId());
141  }
142  // TODO proofread.
143  }
144 
145  return true;
146 }
147 
149 {
150  bool ret = functionToExternalPAGEntries.find(function)
151  != functionToExternalPAGEntries.end();
152  return ret;
153 }
154 
155 int getArgNo(const SVFFunction* function, const Value *arg)
156 {
157  int argNo = 0;
158  for (auto it = function->getLLVMFun()->arg_begin(); it != function->getLLVMFun()->arg_end();
159  ++it, ++argNo)
160  {
161  if (arg->getName() == it->getName()) return argNo;
162  }
163 
164  return -1;
165 }
166 
167 static void outputPAGNodeNoNewLine(raw_ostream &o, PAGNode *pagNode)
168 {
169  o << pagNode->getId() << " ";
170  // TODO: is this check enough?
171  if (!ObjPN::classof(pagNode)) o << "v";
172  else o << "o";
173 }
174 
175 static void outputPAGNode(raw_ostream &o, PAGNode *pagNode)
176 {
177  outputPAGNodeNoNewLine(o, pagNode);
178  o << "\n";
179 }
180 
181 static void outputPAGNode(raw_ostream &o, PAGNode *pagNode, int argno)
182 {
183  outputPAGNodeNoNewLine(o, pagNode);
184  o << " " << argno;
185  o << "\n";
186 }
187 
188 static void outputPAGNode(raw_ostream &o, PAGNode *pagNode,
189  std::string trail)
190 {
191  outputPAGNodeNoNewLine(o, pagNode);
192  o << " " << trail;
193  o << "\n";
194 }
195 
196 static void outputPAGEdge(raw_ostream &o, PAGEdge *pagEdge)
197 {
198  NodeID srcId = pagEdge->getSrcID();
199  NodeID dstId = pagEdge->getDstID();
200  u32_t offset = 0;
201  std::string edgeKind = "-";
202 
203  switch (pagEdge->getEdgeKind())
204  {
205  case PAGEdge::Addr:
206  edgeKind = "addr";
207  break;
208  case PAGEdge::Copy:
209  edgeKind = "copy";
210  break;
211  case PAGEdge::Store:
212  edgeKind = "store";
213  break;
214  case PAGEdge::Load:
215  edgeKind = "load";
216  break;
217  case PAGEdge::Call:
218  edgeKind = "call";
219  break;
220  case PAGEdge::Ret:
221  edgeKind = "ret";
222  break;
223  case PAGEdge::NormalGep:
224  edgeKind = "gep";
225  break;
226  case PAGEdge::VariantGep:
227  edgeKind = "variant-gep";
228  break;
229  case PAGEdge::Cmp:
230  edgeKind = "cmp";
231  break;
232  case PAGEdge::BinaryOp:
233  edgeKind = "binary-op";
234  break;
235  case PAGEdge::UnaryOp:
236  edgeKind = "unary-op";
237  break;
238  case PAGEdge::ThreadFork:
239  outs() << "dump-function-pags: found ThreadFork edge.\n";
240  break;
241  case PAGEdge::ThreadJoin:
242  outs() << "dump-function-pags: found ThreadJoin edge.\n";
243  break;
244  }
245 
246  if (NormalGepPE::classof(pagEdge)) offset =
247  static_cast<NormalGepPE *>(pagEdge)->getOffset();
248 
249  o << srcId << " " << edgeKind << " " << dstId << " " << offset << "\n";
250 }
251 
252 
256 void ExternalPAG::dumpFunctions(std::vector<std::string> functions)
257 {
258  PAG *pag = PAG::getPAG();
259 
260  // Naive: first map functions to entries in PAG, then dump them.
262 
263  Set<PAGNode *> callDsts;
264  for (PAG::iterator it = pag->begin(); it != pag->end(); ++it)
265  {
266  PAGNode *currNode = it->second;
267  if (!currNode->hasOutgoingEdges(PAGEdge::PEDGEK::Call)) continue;
268 
269  // Where are these calls going?
270  for (PAGEdge::PAGEdgeSetTy::iterator it =
271  currNode->getOutgoingEdgesBegin(PAGEdge::PEDGEK::Call);
272  it != currNode->getOutgoingEdgesEnd(PAGEdge::PEDGEK::Call); ++it)
273  {
274  CallPE *callEdge = static_cast<CallPE *>(*it);
275  const Instruction *inst = callEdge->getCallInst()->getCallSite();
276  :: Function* currFunction =
277  static_cast<const CallInst *>(inst)->getCalledFunction();
278 
279  if (currFunction != nullptr)
280  {
281  // Otherwise, it would be an indirect call which we don't want.
282  std::string currFunctionName = currFunction->getName().str();
283 
284  if (std::find(functions.begin(), functions.end(),
285  currFunctionName) != functions.end())
286  {
287  // If the dst has already been added, we'd be duplicating
288  // due to multiple actual->arg call edges.
289  if (callDsts.find(callEdge->getDstNode()) == callDsts.end())
290  {
291  callDsts.insert(callEdge->getDstNode());
292  const SVFFunction* svfFun = LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(currFunction);
293  functionToPAGNodes[svfFun].push_back(callEdge->getDstNode());
294  }
295  }
296  }
297  }
298  }
299 
300  for (auto it = functionToPAGNodes.begin(); it != functionToPAGNodes.end();
301  ++it)
302  {
303  const SVFFunction* function = it->first;
304  std::string functionName = it->first->getName().str();
305 
306  // The final nodes and edges we will print.
307  Set<PAGNode *> nodes;
308  Set<PAGEdge *> edges;
309  // The search stack.
310  std::stack<PAGNode *> todoNodes;
311  // The arguments to the function.
312  std::vector<PAGNode *> argNodes = it->second;
313  PAGNode *retNode = nullptr;
314 
315 
316  outs() << "PAG for function: " << functionName << "\n";
317  for (auto node = argNodes.begin(); node != argNodes.end(); ++node)
318  {
319  todoNodes.push(*node);
320  }
321 
322  while (!todoNodes.empty())
323  {
324  PAGNode *currNode = todoNodes.top();
325  todoNodes.pop();
326 
327  // If the node has been dealt with, ignore it.
328  if (nodes.find(currNode) != nodes.end()) continue;
329  nodes.insert(currNode);
330 
331  // Return signifies the end of a path.
332  if (RetPN::classof(currNode))
333  {
334  retNode = currNode;
335  continue;
336  }
337 
338  auto outEdges = currNode->getOutEdges();
339  for (auto outEdge = outEdges.begin(); outEdge != outEdges.end();
340  ++outEdge)
341  {
342  edges.insert(*outEdge);
343  todoNodes.push((*outEdge)->getDstNode());
344  }
345  }
346 
347  for (auto node = nodes.begin(); node != nodes.end(); ++node)
348  {
349  // TODO: proper file.
350  // Argument nodes use extra information: it's argument number.
351  if (std::find(argNodes.begin(), argNodes.end(), *node)
352  != argNodes.end())
353  {
354  outputPAGNode(outs(), *node,
355  getArgNo(function, (*node)->getValue()));
356  }
357  else if (*node == retNode)
358  {
359  outputPAGNode(outs(), *node, "ret");
360  }
361  else
362  {
363  outputPAGNode(outs(), *node);
364  }
365  }
366 
367  for (auto edge = edges.begin(); edge != edges.end(); ++edge)
368  {
369  // TODO: proper file.
370  outputPAGEdge(outs(), *edge);
371  }
372 
373  outs() << "PAG for functionName " << functionName << " done\n";
374  }
375 }
376 
378 {
379  // The function does not exist in the module - bad arg?
380  // TODO: maybe some warning?
381  if (function == nullptr) return false;
382 
383  PAG *pag = PAG::getPAG();
384  if (hasExternalPAG(function)) return false;
385 
386  outs() << "Adding extpag " << this->getFunctionName() << "\n";
387  // Temporarily trick SVF Module into thinking we are reading from
388  // file to avoid setting BBs/Values (as these nodes don't have any).
389  std::string oldSVFModuleFileName = SVFModule::pagFileName();
391 
392  // We need: the new nodes.
393  // : the new edges.
394  // : to map function names to the entry nodes.
395  // : to map function names to the return node.
396 
397  // To create the new edges.
398  Map<NodeID, PAGNode *> extToNewNodes;
399 
400  // Add the value nodes.
401  for (auto extNodeIt = this->getValueNodes().begin();
402  extNodeIt != this->getValueNodes().end(); ++extNodeIt)
403  {
404  NodeID newNodeId = pag->addDummyValNode();
405  extToNewNodes[*extNodeIt] = pag->getPAGNode(newNodeId);
406  }
407 
408  // Add the object nodes.
409  for (auto extNodeIt = this->getObjectNodes().begin();
410  extNodeIt != this->getObjectNodes().end(); ++extNodeIt)
411  {
412  // TODO: fix obj node - there's more to it?
413  NodeID newNodeId = pag->addDummyObjNode();
414  extToNewNodes[*extNodeIt] = pag->getPAGNode(newNodeId);
415  }
416 
417  // Add the edges.
418  for (auto extEdgeIt = this->getEdges().begin();
419  extEdgeIt != this->getEdges().end(); ++extEdgeIt)
420  {
421  NodeID extSrcId = std::get<0>(*extEdgeIt);
422  NodeID extDstId = std::get<1>(*extEdgeIt);
423  std::string extEdgeType = std::get<2>(*extEdgeIt);
424  int extOffsetOrCSId = std::get<3>(*extEdgeIt);
425 
426  PAGNode *srcNode = extToNewNodes[extSrcId];
427  PAGNode *dstNode = extToNewNodes[extDstId];
428  NodeID srcId = srcNode->getId();
429  NodeID dstId = dstNode->getId();
430 
431  if (extEdgeType == "addr")
432  {
433  pag->addAddrPE(srcId, dstId);
434  }
435  else if (extEdgeType == "copy")
436  {
437  pag->addCopyPE(srcId, dstId);
438  }
439  else if (extEdgeType == "load")
440  {
441  pag->addLoadPE(srcId, dstId);
442  }
443  else if (extEdgeType == "store")
444  {
445  pag->addStorePE(srcId, dstId, nullptr);
446  }
447  else if (extEdgeType == "gep")
448  {
449  pag->addNormalGepPE(srcId, dstId, LocationSet(extOffsetOrCSId));
450  }
451  else if (extEdgeType == "variant-gep")
452  {
453  pag->addVariantGepPE(srcId, dstId);
454  }
455  else if (extEdgeType == "call")
456  {
457  pag->addEdge(srcNode, dstNode, new CallPE(srcNode, dstNode, nullptr));
458  }
459  else if (extEdgeType == "ret")
460  {
461  pag->addEdge(srcNode, dstNode, new RetPE(srcNode, dstNode, nullptr));
462  }
463  else if (extEdgeType == "cmp")
464  {
465  pag->addCmpPE(srcId, dstId);
466  }
467  else if (extEdgeType == "binary-op")
468  {
469  pag->addBinaryOPPE(srcId, dstId);
470  }
471  else if (extEdgeType == "unary-op")
472  {
473  pag->addUnaryOPPE(srcId, dstId);
474  }
475  else
476  {
477  outs() << "Bad edge type found during extpag addition\n";
478  }
479  }
480 
481  // Record the arg nodes.
482  Map<int, PAGNode *> argNodes;
483  for (auto argNodeIt = this->getArgNodes().begin();
484  argNodeIt != this->getArgNodes().end(); ++argNodeIt)
485  {
486  int index = argNodeIt->first;
487  NodeID extNodeId = argNodeIt->second;
488  argNodes[index] = extToNewNodes[extNodeId];
489  }
490 
491  functionToExternalPAGEntries[function] = argNodes;
492 
493  // Record the return node.
494  if (this->hasReturnNode())
495  {
496  functionToExternalPAGReturns[function] =
497  extToNewNodes[this->getReturnNode()];
498  }
499 
500  // Put it back as if nothing happened.
501  SVFModule::setPagFromTXT(oldSVFModuleFileName);
502 
503  return true;
504 }
505 
506 // Very similar implementation to the PAGBuilderFromFile.
507 void ExternalPAG::readFromFile(std::string filename)
508 {
509  std::string line;
510  std::ifstream pagFile(filename.c_str());
511 
512  if (!pagFile.is_open())
513  {
514  outs() << "ExternalPAG::buildFromFile: could not open " << filename
515  << "\n";
516  return;
517  }
518 
519  while (pagFile.good())
520  {
521  std::getline(pagFile, line);
522 
523  Size_t tokenCount = 0;
524  std::string tmps;
525  std::istringstream ss(line);
526  while (ss.good())
527  {
528  ss >> tmps;
529  tokenCount++;
530  }
531 
532  if (tokenCount == 0)
533  {
534  // Empty line.
535  continue;
536  }
537 
538  if (tokenCount == 2 || tokenCount == 3)
539  {
540  // It's a node.
541  NodeID nodeId;
542  std::string nodeType;
543  std::istringstream ss(line);
544  ss >> nodeId;
545  ss >> nodeType;
546 
547  if (nodeType == "v")
548  {
549  valueNodes.insert(nodeId);
550  }
551  else if (nodeType == "o")
552  {
553  objectNodes.insert(nodeId);
554  }
555  else
556  {
557  assert(false
558  && "format not supported, please specify node type");
559  }
560 
561 
562  if (tokenCount == 3)
563  {
564  // If there are 3 tokens, it should be 0, 1, 2, ... or ret.
565  std::string argNoOrRet;
566  ss >> argNoOrRet;
567 
568  if (argNoOrRet == "ret")
569  {
570  setReturnNode(nodeId);
571  }
572  else if (std::all_of(argNoOrRet.begin(), argNoOrRet.end(),
573  ::isdigit))
574  {
575  int argNo = std::stoi(argNoOrRet);
576  argNodes[argNo] = nodeId;
577  }
578  else
579  {
580  assert(false
581  && "format not supported, not arg number or ret");
582  }
583 
584  }
585  }
586  else if (tokenCount == 4)
587  {
588  // It's an edge
589  NodeID nodeSrc;
590  NodeID nodeDst;
591  Size_t offsetOrCSId;
592  std::string edge;
593  std::istringstream ss(line);
594  ss >> nodeSrc;
595  ss >> edge;
596  ss >> nodeDst;
597  ss >> offsetOrCSId;
598 
599  edges.insert(
600  std::tuple<NodeID, NodeID, std::string, int>(nodeSrc, nodeDst,
601  edge,
602  offsetOrCSId));
603  }
604  else
605  {
606  if (!line.empty())
607  {
608  outs() << "format not supported, token count = "
609  << tokenCount << "\n";
610  assert(false && "format not supported");
611  }
612  }
613  }
614 
615  /*
616  TODO: might need to include elsewhere.
618  u32_t lower_bound = 1000;
619  for(u32_t i = 0; i < lower_bound; i++)
620  pag->incNodeNum();
621  */
622 }
623 
llvm::cl::list< std::string > ExternalPAGArgs("extpags", llvm::cl::desc("ExternalPAGs to use during PAG construction (format: func1@/path/to/graph,func2@/foo,..."), llvm::cl::CommaSeparated)
iterator begin()
Iterators.
Definition: GenericGraph.h:365
static Map< const SVFFunction *, Map< int, PAGNode * > > functionToExternalPAGEntries
Definition: ExternalPAG.h:28
GEdgeKind getEdgeKind() const
Definition: GenericGraph.h:81
NodeID getValueNode(const Value *V)
Get PAG Node according to LLVM value.
Definition: PAG.h:521
ICFG * getICFG()
Return ICFG.
Definition: PAG.h:133
llvm::raw_ostream raw_ostream
LLVM outputs.
Definition: BasicTypes.h:99
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
u32_t NodeID
Definition: SVFBasicTypes.h:80
bool addEdge(PAGNode *src, PAGNode *dst, PAGEdge *edge)
Add an edge into PAG.
Definition: PAG.cpp:754
CallBlockNode * getCallBlockNode(const Instruction *inst)
Definition: ICFG.cpp:197
#define assert(ex)
Definition: util.h:141
NodeID getSrcID() const
get methods of the components
Definition: GenericGraph.h:73
llvm::CallInst CallInst
Definition: BasicTypes.h:143
static void outputPAGNodeNoNewLine(raw_ostream &o, PAGNode *pagNode)
NodeID addDummyValNode()
Add a dummy value/object node according to node ID (llvm value is null)
Definition: PAG.h:736
CallBase * getInstruction() const
Definition: BasicTypes.h:316
Definition: PAG.h:47
const llvm::StringRef getName() const
static void outputPAGEdge(raw_ostream &o, PAGEdge *pagEdge)
bool hasOutgoingEdges(PAGEdge::PEDGEK kind) const
Has outgoing PAG edges.
Definition: PAGNode.h:209
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
Definition: SVFBasicTypes.h:98
User::const_op_iterator arg_end() const
Definition: BasicTypes.h:321
unsigned u32_t
Definition: SVFBasicTypes.h:75
static bool hasExternalPAG(const SVFFunction *function)
Whether an external PAG implementing function exists.
NodeID addDummyObjNode(const Type *type=nullptr)
Definition: PAG.h:744
static PAG * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis. ...
Definition: PAG.h:160
PAGEdge * addBlackHoleAddrPE(NodeID node)
Set a pointer points-to black hole (e.g. int2ptr)
Definition: PAG.cpp:528
PAGNode * getPAGNode(NodeID id) const
Get PAGNode ID.
Definition: PAG.h:513
IDToNodeMapTy::iterator iterator
Node Iterators.
Definition: GenericGraph.h:337
static bool classof(const RetPN *)
Definition: PAGNode.h:582
NodeType * getDstNode() const
Definition: GenericGraph.h:89
static std::string pagFileName()
Definition: SVFModule.h:77
llvm::cl::list< std::string > DumpPAGFunctions("dump-function-pags", llvm::cl::desc("Dump PAG for functions"), llvm::cl::CommaSeparated)
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
Definition: SVFBasicTypes.h:93
llvm::Function Function
Definition: BasicTypes.h:76
llvm::Instruction Instruction
Definition: BasicTypes.h:79
AddrPE * addAddrPE(NodeID src, NodeID dst)
Add Address edge.
Definition: PAG.cpp:373
signed long Size_t
Definition: SVFBasicTypes.h:78
const GEdgeSetTy & getOutEdges() const
Definition: GenericGraph.h:177
static void initialise(SVFModule *svfModule)
Definition: ExternalPAG.cpp:54
User::const_op_iterator arg_begin() const
Definition: BasicTypes.h:320
static Map< const SVFFunction *, PAGNode * > functionToExternalPAGReturns
Definition: ExternalPAG.h:29
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 bool classof(const ObjPN *)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition: PAGNode.h:332
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
const CallBlockNode * getCallInst() const
Get method for the call instruction.
Definition: PAGEdge.h:596
RetPE * addRetPE(NodeID src, NodeID dst, const CallBlockNode *cs)
Add Return edge.
Definition: PAG.cpp:511
static void outputPAGNode(raw_ostream &o, PAGNode *pagNode)
PAGEdge::PAGEdgeSetTy::iterator getOutgoingEdgesBegin(PAGEdge::PEDGEK kind) const
Get outgoing PAGEdge iterator.
Definition: PAGNode.h:219
Function * getCalledFunction() const
Definition: BasicTypes.h:326
static LLVMModuleSet * getLLVMModuleSet()
Definition: LLVMModule.h:69
const Instruction * getCallSite() const
Return callsite.
Definition: ICFGNode.h:381
for isBitcode
Definition: ContextDDA.h:15
NodeID getId() const
Get ID.
Definition: GenericGraph.h:164
const SVFFunction * getFunction(StringRef name)
Get the corresponding Function based on its name.
Definition: SVFUtil.h:191
StorePE * addStorePE(NodeID src, NodeID dst, const IntraBlockNode *val)
Add Store edge.
Definition: PAG.cpp:477
Type * getType() const
Definition: BasicTypes.h:319
static void dumpFunctions(std::vector< std::string > functions)
Dump individual PAGs of specified functions. Currently to outs().
User::const_op_iterator arg_iterator
Definition: BasicTypes.h:317
static std::vector< std::pair< std::string, std::string > > parseExternalPAGs(llvm::cl::list< std::string > &extpagsArgs)
Definition: ExternalPAG.cpp:36
static void setPagFromTXT(std::string txt)
Definition: SVFModule.h:72
LoadPE * addLoadPE(NodeID src, NodeID dst)
Add Load edge.
Definition: PAG.cpp:459
void readFromFile(std::string filename)
UnaryOPPE * addUnaryOPPE(NodeID src, NodeID dst)
Add Unary edge.
Definition: PAG.cpp:442
llvm::Value Value
Definition: BasicTypes.h:78
bool addExternalPAG(const SVFFunction *function)
const SVFFunction * getSVFFunction(const Function *fun) const
Definition: LLVMModule.h:110
int getArgNo(const SVFFunction *function, const Value *arg)
PAGEdge::PAGEdgeSetTy::iterator getOutgoingEdgesEnd(PAGEdge::PEDGEK kind) const
Get outgoing PAGEdge iterator.
Definition: PAGNode.h:227
static bool classof(const NormalGepPE *)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition: PAGEdge.h:484
static bool connectCallsiteToExternalPAG(CallSite *cs)
Definition: ExternalPAG.cpp:72