Static Value-Flow Analysis
SVFIRBuilder.h
Go to the documentation of this file.
1 //===- SVFIRBuilder.h -- Building SVFIR-------------------------------------------//
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 Affero 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 Affero General Public License for more details.
17 
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 //
21 //===----------------------------------------------------------------------===//
22 
23 /*
24  * SVFIRBuilder.h
25  *
26  * Created on: Nov 1, 2013
27  * Author: Yulei Sui
28  */
29 
30 #ifndef PAGBUILDER_H_
31 #define PAGBUILDER_H_
32 
33 #include "SVFIR/SVFIR.h"
34 #include "SVF-LLVM/BasicTypes.h"
35 #include "SVF-LLVM/ICFGBuilder.h"
36 #include "SVF-LLVM/LLVMModule.h"
37 #include "SVF-LLVM/LLVMUtil.h"
38 
39 namespace SVF
40 {
41 
42 class SVFModule;
46 class SVFIRBuilder: public llvm::InstVisitor<SVFIRBuilder>
47 {
48 
49 private:
53  const SVFValue* curVal;
54 
55 public:
57  SVFIRBuilder(SVFModule* mod): pag(SVFIR::getPAG()), svfModule(mod), curBB(nullptr),curVal(nullptr)
58  {
59  }
61  virtual ~SVFIRBuilder()
62  {
63  }
64 
66  virtual SVFIR* build();
67 
69  SVFIR* getPAG() const
70  {
71  return pag;
72  }
73 
75 
76  void initialiseNodes();
77  void addEdge(NodeID src, NodeID dst, SVFStmt::PEDGEK kind,
78  APOffset offset = 0, Instruction* cs = nullptr);
79  // @}
80 
82  void sanityCheck();
83 
85 
86  // GetValNode - Return the value node according to a LLVM Value.
88  {
89  // first handle gep edge if val if a constant expression
90  processCE(V);
91 
92  // strip off the constant cast and return the value node
93  SVFValue* svfVal = llvmModuleSet()->getSVFValue(V);
94  return pag->getValueNode(svfVal);
95  }
96 
98  inline NodeID getObjectNode(const Value* V)
99  {
100  SVFValue* svfVal = llvmModuleSet()->getSVFValue(V);
101  return pag->getObjectNode(svfVal);
102  }
103 
105  inline NodeID getReturnNode(const SVFFunction *func)
106  {
107  return pag->getReturnNode(func);
108  }
109 
111  inline NodeID getVarargNode(const SVFFunction *func)
112  {
113  return pag->getVarargNode(func);
114  }
116 
117 
119 
120  // Instructions that cannot be folded away.
121  virtual void visitAllocaInst(AllocaInst &AI);
122  void visitPHINode(PHINode &I);
123  void visitStoreInst(StoreInst &I);
124  void visitLoadInst(LoadInst &I);
126  void visitCallInst(CallInst &I);
127  void visitInvokeInst(InvokeInst &II);
128  void visitCallBrInst(CallBrInst &I);
129  void visitCallSite(CallBase* cs);
130  void visitReturnInst(ReturnInst &I);
131  void visitCastInst(CastInst &I);
132  void visitSelectInst(SelectInst &I);
134  void visitBranchInst(BranchInst &I);
135  void visitSwitchInst(SwitchInst &I);
137  {
139  }
140  // TerminatorInst and UnwindInst have been removed since llvm-8.0.0
141  // void visitTerminatorInst(TerminatorInst &TI) {}
142  // void visitUnwindInst(UnwindInst &I) { /*returns void*/}
143 
146  void visitCmpInst(CmpInst &I);
147 
150  void visitVAArgInst(VAArgInst&);
154 
158  void visitFreezeInst(FreezeInst& I);
159 
161 
163  {
165  }
167  {
169  }
171  {
173  }
174 
176  void visitResumeInst(ResumeInst&) /*returns void*/
177  {
178  }
179  void visitUnreachableInst(UnreachableInst&) /*returns void*/
180  {
181  }
182  void visitFenceInst(FenceInst &I) /*returns void*/
183  {
185  }
187  {
189  }
191  {
193  }
194 
197  {
198  // If a new instruction is added to LLVM that we don't handle.
199  // TODO: ignore here:
200  }
201  //}@
202 
204  void updateCallGraph(PTACallGraph* callgraph);
205 
206 protected:
208 
210  void InitialGlobal(const GlobalVariable *gvar, Constant *C,
211  u32_t offset);
214 
216  void processCE(const Value* val);
217 
220 
222  bool computeGepOffset(const User *V, AccessPath& ap);
223 
225  const Value* getBaseValueForExtArg(const Value* V);
226 
228  void handleDirectCall(CallBase* cs, const Function *F);
229 
231  void handleIndCall(CallBase* cs);
232 
234 
235  virtual const Type *getBaseTypeAndFlattenedFields(const Value *V, std::vector<AccessPath> &fields, const Value* szValue);
236  virtual void addComplexConsForExt(Value *D, Value *S, const Value* sz);
237  virtual void handleExtCall(const CallBase* cs, const SVFFunction* svfCallee);
239 
241  inline void setCurrentLocation(const Value* val, const BasicBlock* bb)
242  {
243  curBB = (bb == nullptr? nullptr : llvmModuleSet()->getSVFBasicBlock(bb));
244  curVal = (val == nullptr ? nullptr: llvmModuleSet()->getSVFValue(val));
245  }
246  inline void setCurrentLocation(const SVFValue* val, const SVFBasicBlock* bb)
247  {
248  curBB = bb;
249  curVal = val;
250  }
251  inline const SVFValue* getCurrentValue() const
252  {
253  return curVal;
254  }
255  inline const SVFBasicBlock* getCurrentBB() const
256  {
257  return curBB;
258  }
259 
261  void addGlobalBlackHoleAddrEdge(NodeID node, const ConstantExpr *int2Ptrce)
262  {
263  const SVFValue* cval = getCurrentValue();
264  const SVFBasicBlock* cbb = getCurrentBB();
265  setCurrentLocation(int2Ptrce,nullptr);
266  addBlackHoleAddrEdge(node);
267  setCurrentLocation(cval,cbb);
268  }
269 
272  {
274  ConstantPointerNull* constNull = ConstantPointerNull::get(PointerType::getUnqual(cxt));
275  NodeID nullPtr = pag->addValNode(llvmModuleSet()->getSVFValue(constNull),pag->getNullPtr(), nullptr);
276  setCurrentLocation(constNull, nullptr);
278  return nullPtr;
279  }
280 
281  NodeID getGepValVar(const Value* val, const AccessPath& ap, const SVFType* elementType);
282 
284 
285  inline void addBlackHoleAddrEdge(NodeID node)
286  {
287  if(PAGEdge *edge = pag->addBlackHoleAddrStmt(node))
289  }
290 
292  inline AddrStmt* addAddrEdge(NodeID src, NodeID dst)
293  {
294  if(AddrStmt *edge = pag->addAddrStmt(src, dst))
295  {
297  return edge;
298  }
299  return nullptr;
300  }
301 
304  {
305  AddrStmt* edge = addAddrEdge(src, dst);
306  if (inst.getArraySize())
307  {
308  SVFValue* arrSz = llvmModuleSet()->getSVFValue(inst.getArraySize());
309  edge->addArrSize(arrSz);
310  }
311  return edge;
312  }
313 
315  inline AddrStmt* addAddrWithHeapSz(NodeID src, NodeID dst, const CallBase* cs)
316  {
317  // get name of called function
318  AddrStmt* edge = addAddrEdge(src, dst);
319 
320  llvm::Function* calledFunc = cs->getCalledFunction();
321  std::string functionName;
322  if (calledFunc)
323  {
324  functionName = calledFunc->getName().str();
325  }
326  else
327  {
328  SVFUtil::wrnMsg("not support indirect call to add AddrStmt.\n");
329  }
330  if (functionName == "malloc")
331  {
332  if (cs->arg_size() > 0)
333  {
334  const llvm::Value* val = cs->getArgOperand(0);
335  SVFValue* svfval = llvmModuleSet()->getSVFValue(val);
336  edge->addArrSize(svfval);
337  }
338  }
339  // Check if the function called is 'calloc' and process its arguments.
340  // e.g. "%5 = call i8* @calloc(1, 8)", edge should add two SVFValue (1 and 8)
341  else if (functionName == "calloc")
342  {
343  if (cs->arg_size() > 1)
344  {
345  edge->addArrSize(llvmModuleSet()->getSVFValue(cs->getArgOperand(0)));
346  edge->addArrSize(llvmModuleSet()->getSVFValue(cs->getArgOperand(1)));
347  }
348  }
349  else
350  {
351  if (cs->arg_size() > 0)
352  {
353  const llvm::Value* val = cs->getArgOperand(0);
354  SVFValue* svfval = llvmModuleSet()->getSVFValue(val);
355  edge->addArrSize(svfval);
356  }
357  }
358  return edge;
359  }
360 
362  {
363  if(CopyStmt *edge = pag->addCopyStmt(src, dst, kind))
364  {
366  return edge;
367  }
368  return nullptr;
369  }
370 
372  {
373  // COPYVAL, ZEXT, SEXT, BITCAST, FPTRUNC, FPTOUI, FPTOSI, UITOFP, SITOFP, INTTOPTR, PTRTOINT
374  if (const Instruction* inst = SVFUtil::dyn_cast<Instruction>(val))
375  {
376  switch (inst->getOpcode())
377  {
378  case Instruction::ZExt:
379  return CopyStmt::ZEXT;
380  case Instruction::SExt:
381  return CopyStmt::SEXT;
382  case Instruction::BitCast:
383  return CopyStmt::BITCAST;
384  case Instruction ::Trunc:
385  return CopyStmt::TRUNC;
386  case Instruction::FPTrunc:
387  return CopyStmt::FPTRUNC;
388  case Instruction::FPToUI:
389  return CopyStmt::FPTOUI;
390  case Instruction::FPToSI:
391  return CopyStmt::FPTOSI;
392  case Instruction::UIToFP:
393  return CopyStmt::UITOFP;
394  case Instruction::SIToFP:
395  return CopyStmt::SITOFP;
396  case Instruction::IntToPtr:
397  return CopyStmt::INTTOPTR;
398  case Instruction::PtrToInt:
399  return CopyStmt::PTRTOINT;
400  default:
401  return CopyStmt::COPYVAL;
402  }
403  }
404  assert (false && "Unknown cast inst!");
405  }
406 
408  inline void addPhiStmt(NodeID res, NodeID opnd, const ICFGNode* pred)
409  {
411  if(PhiStmt *edge = pag->addPhiStmt(res,opnd,pred))
413  }
415  inline void addSelectStmt(NodeID res, NodeID op1, NodeID op2, NodeID cond)
416  {
417  if(SelectStmt *edge = pag->addSelectStmt(res,op1,op2,cond))
419  }
421  inline void addCmpEdge(NodeID op1, NodeID op2, NodeID dst, u32_t predict)
422  {
423  if(CmpStmt *edge = pag->addCmpStmt(op1, op2, dst, predict))
425  }
427  inline void addBinaryOPEdge(NodeID op1, NodeID op2, NodeID dst, u32_t opcode)
428  {
429  if(BinaryOPStmt *edge = pag->addBinaryOPStmt(op1, op2, dst, opcode))
431  }
433  inline void addUnaryOPEdge(NodeID src, NodeID dst, u32_t opcode)
434  {
435  if(UnaryOPStmt *edge = pag->addUnaryOPStmt(src, dst, opcode))
437  }
439  inline void addBranchStmt(NodeID br, NodeID cond, const BranchStmt::SuccAndCondPairVec& succs)
440  {
441  if(BranchStmt *edge = pag->addBranchStmt(br, cond, succs))
443  }
445  inline void addLoadEdge(NodeID src, NodeID dst)
446  {
447  if(LoadStmt *edge = pag->addLoadStmt(src, dst))
449  }
451  inline void addStoreEdge(NodeID src, NodeID dst)
452  {
453  ICFGNode* node;
454  if (const SVFInstruction* inst = SVFUtil::dyn_cast<SVFInstruction>(curVal))
455  node = llvmModuleSet()->getICFGNode(
456  SVFUtil::cast<Instruction>(llvmModuleSet()->getLLVMValue(inst)));
457  else
458  node = nullptr;
459  if (StoreStmt* edge = pag->addStoreStmt(src, dst, node))
461  }
463  inline void addCallEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunEntryICFGNode* entry)
464  {
465  if (CallPE* edge = pag->addCallPE(src, dst, cs, entry))
467  }
469  inline void addRetEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunExitICFGNode* exit)
470  {
471  if (RetPE* edge = pag->addRetPE(src, dst, cs, exit))
473  }
475  inline void addGepEdge(NodeID src, NodeID dst, const AccessPath& ap, bool constGep)
476  {
477  if (GepStmt* edge = pag->addGepStmt(src, dst, ap, constGep))
479  }
481  inline void addNormalGepEdge(NodeID src, NodeID dst, const AccessPath& ap)
482  {
483  if (GepStmt* edge = pag->addNormalGepStmt(src, dst, ap))
485  }
487  inline void addVariantGepEdge(NodeID src, NodeID dst, const AccessPath& ap)
488  {
489  if (GepStmt* edge = pag->addVariantGepStmt(src, dst, ap))
491  }
493  inline void addThreadForkEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunEntryICFGNode* entry)
494  {
495  if (TDForkPE* edge = pag->addThreadForkPE(src, dst, cs, entry))
497  }
499  inline void addThreadJoinEdge(NodeID src, NodeID dst, const CallICFGNode* cs, const FunExitICFGNode* exit)
500  {
501  if (TDJoinPE* edge = pag->addThreadJoinPE(src, dst, cs, exit))
503  }
505 
507 
508 private:
510  {
512  }
513 };
514 
515 } // End namespace SVF
516 
517 #endif /* PAGBUILDER_H_ */
#define F(f)
buffer offset
Definition: cJSON.cpp:1113
const char *const string
Definition: cJSON.h:172
void addArrSize(SVFValue *size)
get array size of the allocated memory
std::vector< std::pair< const ICFGNode *, s32_t > > SuccAndCondPairVec
NodeID getBlkPtr() const
Definition: IRGraph.h:169
NodeID getNullPtr() const
Definition: IRGraph.h:173
NodeID getValueNode(const SVFValue *V)
Definition: IRGraph.h:137
NodeID getVarargNode(const SVFFunction *func) const
getVarargNode - Return the unique node representing the variadic argument of a variadic function.
Definition: IRGraph.h:157
NodeID getReturnNode(const SVFFunction *func) const
GetReturnNode - Return the unique node representing the return value of a function.
Definition: IRGraph.h:152
NodeID getObjectNode(const SVFValue *V)
Definition: IRGraph.h:147
ICFGNode * getICFGNode(const Instruction *inst)
Get a basic block ICFGNode.
SVFBasicBlock * getSVFBasicBlock(const BasicBlock *bb) const
Definition: LLVMModule.h:237
LLVMContext & getContext() const
Definition: LLVMModule.h:349
static LLVMModuleSet * getLLVMModuleSet()
Definition: LLVMModule.h:118
SVFValue * getSVFValue(const Value *value)
u32_t inferFieldIdxFromByteOffset(const llvm::GEPOperator *gepOp, DataLayout *dl, AccessPath &ap, APOffset idx)
Infer field index from byteoffset.
CopyStmt::CopyKind getCopyKind(const Value *val)
Definition: SVFIRBuilder.h:371
void sanityCheck()
Sanity check for SVFIR.
void visitLandingPadInst(LandingPadInst &I)
Definition: SVFIRBuilder.h:170
void setCurrentLocation(const Value *val, const BasicBlock *bb)
Set current basic block in order to keep track of control flow information.
Definition: SVFIRBuilder.h:241
NodeID addNullPtrNode()
Add NullPtr PAGNode.
Definition: SVFIRBuilder.h:271
void visitLoadInst(LoadInst &I)
void setCurrentLocation(const SVFValue *val, const SVFBasicBlock *bb)
Definition: SVFIRBuilder.h:246
SVFIRBuilder(SVFModule *mod)
Constructor.
Definition: SVFIRBuilder.h:57
void updateCallGraph(PTACallGraph *callgraph)
connect PAG edges based on callgraph
CopyStmt * addCopyEdge(NodeID src, NodeID dst, CopyStmt::CopyKind kind)
Definition: SVFIRBuilder.h:361
AddrStmt * addAddrEdge(NodeID src, NodeID dst)
Add Address edge.
Definition: SVFIRBuilder.h:292
void addPhiStmt(NodeID res, NodeID opnd, const ICFGNode *pred)
Add Copy edge.
Definition: SVFIRBuilder.h:408
void addStoreEdge(NodeID src, NodeID dst)
Add Store edge.
Definition: SVFIRBuilder.h:451
void visitInvokeInst(InvokeInst &II)
void handleDirectCall(CallBase *cs, const Function *F)
Handle direct call.
void addBinaryOPEdge(NodeID op1, NodeID op2, NodeID dst, u32_t opcode)
Add Copy edge.
Definition: SVFIRBuilder.h:427
NodeID getVarargNode(const SVFFunction *func)
getVarargNode - Return the node representing the unique variadic argument of a function.
Definition: SVFIRBuilder.h:111
void visitCallInst(CallInst &I)
void addLoadEdge(NodeID src, NodeID dst)
Add Load edge.
Definition: SVFIRBuilder.h:445
void visitGetElementPtrInst(GetElementPtrInst &I)
void visitBranchInst(BranchInst &I)
virtual void visitAllocaInst(AllocaInst &AI)
Our visit overrides.
void visitGlobal(SVFModule *svfModule)
Handle globals including (global variable and functions)
void addGepEdge(NodeID src, NodeID dst, const AccessPath &ap, bool constGep)
Add Gep edge.
Definition: SVFIRBuilder.h:475
void addCmpEdge(NodeID op1, NodeID op2, NodeID dst, u32_t predict)
Add Copy edge.
Definition: SVFIRBuilder.h:421
void visitInsertValueInst(InsertValueInst &I)
Definition: SVFIRBuilder.h:136
void visitStoreInst(StoreInst &I)
void visitVAStartInst(VAStartInst &)
Definition: SVFIRBuilder.h:153
void addThreadForkEdge(NodeID src, NodeID dst, const CallICFGNode *cs, const FunEntryICFGNode *entry)
Add Thread fork edge for parameter passing.
Definition: SVFIRBuilder.h:493
void addGlobalBlackHoleAddrEdge(NodeID node, const ConstantExpr *int2Ptrce)
Add global black hole Address edge.
Definition: SVFIRBuilder.h:261
virtual ~SVFIRBuilder()
Destructor.
Definition: SVFIRBuilder.h:61
NodeID getObjectNode(const Value *V)
GetObject - Return the object node (stack/global/heap/function) according to a LLVM Value.
Definition: SVFIRBuilder.h:98
void visitCallSite(CallBase *cs)
void processCE(const Value *val)
Process constant expression.
void handleIndCall(CallBase *cs)
Handle indirect call.
void addSelectStmt(NodeID res, NodeID op1, NodeID op2, NodeID cond)
Add SelectStmt.
Definition: SVFIRBuilder.h:415
void addBranchStmt(NodeID br, NodeID cond, const BranchStmt::SuccAndCondPairVec &succs)
Add Branch statement.
Definition: SVFIRBuilder.h:439
virtual SVFIR * build()
Start building SVFIR here.
void visitCallBrInst(CallBrInst &I)
const SVFBasicBlock * getCurrentBB() const
Definition: SVFIRBuilder.h:255
SVFModule * svfModule
Definition: SVFIRBuilder.h:51
void visitExtractValueInst(ExtractValueInst &EVI)
AccessPath getAccessPathFromBaseNode(NodeID nodeId)
const SVFBasicBlock * curBB
Current basic block during SVFIR construction when visiting the module.
Definition: SVFIRBuilder.h:52
void visitSwitchInst(SwitchInst &I)
The following implementation follows ICFGBuilder::processFunBody.
void visitFreezeInst(FreezeInst &I)
void visitFenceInst(FenceInst &I)
Definition: SVFIRBuilder.h:182
LLVMModuleSet * llvmModuleSet()
Definition: SVFIRBuilder.h:509
const Value * getBaseValueForExtArg(const Value *V)
Get the base value of (i8* src and i8* dst) for external argument (e.g. memcpy(i8* dst,...
void addRetEdge(NodeID src, NodeID dst, const CallICFGNode *cs, const FunExitICFGNode *exit)
Add Return edge.
Definition: SVFIRBuilder.h:469
virtual void handleExtCall(const CallBase *cs, const SVFFunction *svfCallee)
void addBlackHoleAddrEdge(NodeID node)
Definition: SVFIRBuilder.h:285
void visitInstruction(Instruction &)
Provide base case for our instruction visit.
Definition: SVFIRBuilder.h:196
const SVFValue * getCurrentValue() const
Definition: SVFIRBuilder.h:251
void addNormalGepEdge(NodeID src, NodeID dst, const AccessPath &ap)
Add Offset(Gep) edge.
Definition: SVFIRBuilder.h:481
void visitResumeInst(ResumeInst &)
Instruction not that often.
Definition: SVFIRBuilder.h:176
AddrStmt * addAddrWithStackArraySz(NodeID src, NodeID dst, llvm::AllocaInst &inst)
Add Address edge from allocinst with arraysize like "%4 = alloca i8, i64 3".
Definition: SVFIRBuilder.h:303
void visitInsertElementInst(InsertElementInst &I)
Definition: SVFIRBuilder.h:162
void addUnaryOPEdge(NodeID src, NodeID dst, u32_t opcode)
Add Unary edge.
Definition: SVFIRBuilder.h:433
void visitVAEndInst(VAEndInst &)
Definition: SVFIRBuilder.h:152
virtual const Type * getBaseTypeAndFlattenedFields(const Value *V, std::vector< AccessPath > &fields, const Value *szValue)
Handle external call.
Definition: SVFIRExtAPI.cpp:43
void visitPHINode(PHINode &I)
AddrStmt * addAddrWithHeapSz(NodeID src, NodeID dst, const CallBase *cs)
Add Address edge from ext call with args like "%5 = call i8* @malloc(i64 noundef 5)".
Definition: SVFIRBuilder.h:315
void addCallEdge(NodeID src, NodeID dst, const CallICFGNode *cs, const FunEntryICFGNode *entry)
Add Call edge.
Definition: SVFIRBuilder.h:463
void setCurrentBBAndValueForPAGEdge(PAGEdge *edge)
void visitSelectInst(SelectInst &I)
void visitVAArgInst(VAArgInst &)
void visitAtomicCmpXchgInst(AtomicCmpXchgInst &I)
Definition: SVFIRBuilder.h:186
void addEdge(NodeID src, NodeID dst, SVFStmt::PEDGEK kind, APOffset offset=0, Instruction *cs=nullptr)
void visitCmpInst(CmpInst &I)
void visitExtractElementInst(ExtractElementInst &I)
bool computeGepOffset(const User *V, AccessPath &ap)
Compute offset of a gep instruction or gep constant expression.
void visitReturnInst(ReturnInst &I)
void visitShuffleVectorInst(ShuffleVectorInst &I)
Definition: SVFIRBuilder.h:166
NodeID getValueNode(const Value *V)
Get different kinds of node.
Definition: SVFIRBuilder.h:87
void visitCastInst(CastInst &I)
virtual void addComplexConsForExt(Value *D, Value *S, const Value *sz)
Definition: SVFIRExtAPI.cpp:78
void visitAtomicRMWInst(AtomicRMWInst &I)
Definition: SVFIRBuilder.h:190
NodeID getGepValVar(const Value *val, const AccessPath &ap, const SVFType *elementType)
void visitUnreachableInst(UnreachableInst &)
Definition: SVFIRBuilder.h:179
void InitialGlobal(const GlobalVariable *gvar, Constant *C, u32_t offset)
void visitUnaryOperator(UnaryOperator &I)
void visitBinaryOperator(BinaryOperator &I)
void addThreadJoinEdge(NodeID src, NodeID dst, const CallICFGNode *cs, const FunExitICFGNode *exit)
Add Thread join edge for parameter passing.
Definition: SVFIRBuilder.h:499
const SVFValue * curVal
Current Value during SVFIR construction when visiting the module.
Definition: SVFIRBuilder.h:53
SVFIR * getPAG() const
Return SVFIR.
Definition: SVFIRBuilder.h:69
void initialiseNodes()
Initialize nodes and edges.
NodeID getGlobalVarField(const GlobalVariable *gvar, u32_t offset, SVFType *tpy)
void addVariantGepEdge(NodeID src, NodeID dst, const AccessPath &ap)
Add Variant(Gep) edge.
Definition: SVFIRBuilder.h:487
void visitVACopyInst(VACopyInst &)
Definition: SVFIRBuilder.h:151
NodeID getReturnNode(const SVFFunction *func)
getReturnNode - Return the node representing the unique return value of a function.
Definition: SVFIRBuilder.h:105
GepStmt * addVariantGepStmt(NodeID src, NodeID dst, const AccessPath &ap)
Add Variant(Gep) edge.
Definition: SVFIR.cpp:365
CopyStmt * addCopyStmt(NodeID src, NodeID dst, CopyStmt::CopyKind type)
Add Copy edge.
Definition: SVFIR.cpp:64
RetPE * addRetPE(NodeID src, NodeID dst, const CallICFGNode *cs, const FunExitICFGNode *exit)
Add Return edge.
Definition: SVFIR.cpp:259
GepStmt * addGepStmt(NodeID src, NodeID dst, const AccessPath &ap, bool constGep)
Add Gep edge.
Definition: SVFIR.cpp:327
SVFStmt * addBlackHoleAddrStmt(NodeID node)
Set a pointer points-to black hole (e.g. int2ptr)
Definition: SVFIR.cpp:277
LoadStmt * addLoadStmt(NodeID src, NodeID dst)
Add Load edge.
Definition: SVFIR.cpp:204
GepStmt * addNormalGepStmt(NodeID src, NodeID dst, const AccessPath &ap)
Add Offset(Gep) edge.
Definition: SVFIR.cpp:346
CallPE * addCallPE(NodeID src, NodeID dst, const CallICFGNode *cs, const FunEntryICFGNode *entry)
Add Call edge.
Definition: SVFIR.cpp:241
TDJoinPE * addThreadJoinPE(NodeID src, NodeID dst, const CallICFGNode *cs, const FunExitICFGNode *exit)
Add Thread join edge for parameter passing.
Definition: SVFIR.cpp:306
CmpStmt * addCmpStmt(NodeID op1, NodeID op2, NodeID dst, u32_t predict)
Add Copy edge.
Definition: SVFIR.cpp:127
AddrStmt * addAddrStmt(NodeID src, NodeID dst)
Add an edge into SVFIR.
Definition: SVFIR.cpp:46
UnaryOPStmt * addUnaryOPStmt(NodeID src, NodeID dst, u32_t opcode)
Add Unary edge.
Definition: SVFIR.cpp:168
TDForkPE * addThreadForkPE(NodeID src, NodeID dst, const CallICFGNode *cs, const FunEntryICFGNode *entry)
Add Thread fork edge for parameter passing.
Definition: SVFIR.cpp:288
BinaryOPStmt * addBinaryOPStmt(NodeID op1, NodeID op2, NodeID dst, u32_t opcode)
Add Copy edge.
Definition: SVFIR.cpp:148
NodeID addValNode(const SVFValue *val, NodeID i, const SVFBaseNode *gNode)
add node into SVFIR
Definition: SVFIR.h:547
StoreStmt * addStoreStmt(NodeID src, NodeID dst, const ICFGNode *val)
Add Store edge.
Definition: SVFIR.cpp:223
PhiStmt * addPhiStmt(NodeID res, NodeID opnd, const ICFGNode *pred)
Add phi node information.
Definition: SVFIR.cpp:82
SelectStmt * addSelectStmt(NodeID res, NodeID op1, NodeID op2, NodeID cond)
Add SelectStmt.
Definition: SVFIR.cpp:106
BranchStmt * addBranchStmt(NodeID br, NodeID cond, const BranchStmt::SuccAndCondPairVec &succs)
Add BranchStmt.
Definition: SVFIR.cpp:186
std::string wrnMsg(const std::string &msg)
Returns warning message by converting a string into yellow string output.
Definition: SVFUtil.cpp:61
for isBitcode
Definition: BasicTypes.h:68
llvm::DataLayout DataLayout
Definition: BasicTypes.h:108
llvm::GlobalVariable GlobalVariable
Definition: BasicTypes.h:130
llvm::VACopyInst VACopyInst
Definition: BasicTypes.h:176
llvm::Type Type
Definition: BasicTypes.h:83
llvm::CallBase CallBase
Definition: BasicTypes.h:146
llvm::BasicBlock BasicBlock
Definition: BasicTypes.h:86
llvm::UnaryOperator UnaryOperator
Definition: BasicTypes.h:180
llvm::AllocaInst AllocaInst
Definition: BasicTypes.h:150
llvm::SwitchInst SwitchInst
Definition: BasicTypes.h:155
u32_t NodeID
Definition: GeneralType.h:55
llvm::AtomicRMWInst AtomicRMWInst
Definition: BasicTypes.h:152
llvm::InsertValueInst InsertValueInst
Definition: BasicTypes.h:167
llvm::InvokeInst InvokeInst
Definition: BasicTypes.h:163
llvm::AtomicCmpXchgInst AtomicCmpXchgInst
Definition: BasicTypes.h:151
llvm::LoadInst LoadInst
Definition: BasicTypes.h:149
s64_t APOffset
Definition: GeneralType.h:60
llvm::CmpInst CmpInst
Definition: BasicTypes.h:159
llvm::Function Function
Definition: BasicTypes.h:85
llvm::FenceInst FenceInst
Definition: BasicTypes.h:168
llvm::ShuffleVectorInst ShuffleVectorInst
Definition: BasicTypes.h:164
llvm::InsertElementInst InsertElementInst
Definition: BasicTypes.h:171
llvm::Instruction Instruction
Definition: BasicTypes.h:87
llvm::Constant Constant
Definition: BasicTypes.h:124
llvm::GEPOperator GEPOperator
Definition: BasicTypes.h:182
llvm::UnreachableInst UnreachableInst
Definition: BasicTypes.h:170
llvm::ResumeInst ResumeInst
Definition: BasicTypes.h:173
llvm::Value Value
LLVM Basic classes.
Definition: BasicTypes.h:82
llvm::ConstantPointerNull ConstantPointerNull
Definition: BasicTypes.h:127
llvm::ConstantExpr ConstantExpr
Definition: BasicTypes.h:120
llvm::CastInst CastInst
Definition: BasicTypes.h:158
llvm::FreezeInst FreezeInst
Definition: BasicTypes.h:169
llvm::BinaryOperator BinaryOperator
Definition: BasicTypes.h:179
llvm::StoreInst StoreInst
Definition: BasicTypes.h:148
llvm::SelectInst SelectInst
Definition: BasicTypes.h:174
llvm::VAArgInst VAArgInst
Definition: BasicTypes.h:175
llvm::GetElementPtrInst GetElementPtrInst
Definition: BasicTypes.h:162
llvm::CallBrInst CallBrInst
Definition: BasicTypes.h:156
llvm::ReturnInst ReturnInst
Definition: BasicTypes.h:157
llvm::PHINode PHINode
Definition: BasicTypes.h:165
llvm::BranchInst BranchInst
Definition: BasicTypes.h:154
llvm::ExtractValueInst ExtractValueInst
Definition: BasicTypes.h:160
unsigned u32_t
Definition: GeneralType.h:46
llvm::VAStartInst VAStartInst
Definition: BasicTypes.h:178
llvm::VAEndInst VAEndInst
Definition: BasicTypes.h:177
llvm::CallInst CallInst
Definition: BasicTypes.h:147
llvm::LandingPadInst LandingPadInst
Definition: BasicTypes.h:172
llvm::ExtractElementInst ExtractElementInst
Definition: BasicTypes.h:161
llvm::User User
Definition: BasicTypes.h:142
llvm::LLVMContext LLVMContext
Definition: BasicTypes.h:70