Static Value-Flow Analysis
LLVMUtil.cpp
Go to the documentation of this file.
1 //===- SVFUtil.cpp -- Analysis helper functions----------------------------//
2 //
3 // SVF: Static Value-Flow Analysis
4 //
5 // Copyright (C) <2013-> <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  * LLVMUtil.cpp
25  *
26  * Created on: Apr 11, 2013
27  * Author: Yulei Sui
28  */
29 
30 #include "SVF-LLVM/LLVMUtil.h"
31 #include "SVFIR/SymbolTableInfo.h"
32 #include <sstream>
33 #include <llvm/Support/raw_ostream.h>
34 #include "SVF-LLVM/LLVMModule.h"
35 
36 
37 using namespace SVF;
38 
40 {
41  for (const Module& M : LLVMModuleSet::getLLVMModuleSet()->getLLVMModules())
42  {
43  for (const Function& fun : M)
44  {
45  if (fun.getName() == funName)
46  return &fun;
47  }
48  }
49  return nullptr;
50 }
51 
59 bool LLVMUtil::isObject(const Value* ref)
60 {
61  if (SVFUtil::isa<Instruction>(ref) && isHeapAllocExtCallViaRet(SVFUtil::cast<Instruction>(ref)))
62  return true;
63  if (SVFUtil::isa<GlobalVariable>(ref))
64  return true;
65  if (SVFUtil::isa<Function, AllocaInst>(ref))
66  return true;
67 
68  return false;
69 }
70 
74 void LLVMUtil::getFunReachableBBs (const Function* fun, std::vector<const SVFBasicBlock*> &reachableBBs)
75 {
76  assert(!SVFUtil::isExtCall(LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(fun)) && "The calling function cannot be an external function.");
77  //initial DominatorTree
78  DominatorTree dt;
79  dt.recalculate(const_cast<Function&>(*fun));
80 
81  Set<const BasicBlock*> visited;
82  std::vector<const BasicBlock*> bbVec;
83  bbVec.push_back(&fun->getEntryBlock());
84  while(!bbVec.empty())
85  {
86  const BasicBlock* bb = bbVec.back();
87  bbVec.pop_back();
89  reachableBBs.push_back(svfbb);
90  if(DomTreeNode *dtNode = dt.getNode(const_cast<BasicBlock*>(bb)))
91  {
92  for (DomTreeNode::iterator DI = dtNode->begin(), DE = dtNode->end();
93  DI != DE; ++DI)
94  {
95  const BasicBlock* succbb = (*DI)->getBlock();
96  if(visited.find(succbb)==visited.end())
97  visited.insert(succbb);
98  else
99  continue;
100  bbVec.push_back(succbb);
101  }
102  }
103  }
104 }
105 
110 {
111  for (BasicBlock::const_iterator it = bb->begin(), eit = bb->end();
112  it != eit; ++it)
113  {
114  if(SVFUtil::isa<ReturnInst>(*it))
115  return true;
116  }
117  return false;
118 }
119 
124 {
126  if (SVFUtil::isExtCall(svffun))
127  {
128  return fun->getReturnType()->isVoidTy();
129  }
130  std::vector<const BasicBlock*> bbVec;
131  Set<const BasicBlock*> visited;
132  bbVec.push_back(&fun->getEntryBlock());
133  while(!bbVec.empty())
134  {
135  const BasicBlock* bb = bbVec.back();
136  bbVec.pop_back();
137  if (basicBlockHasRetInst(bb))
138  {
139  return false;
140  }
141 
142  for (succ_const_iterator sit = succ_begin(bb), esit = succ_end(bb);
143  sit != esit; ++sit)
144  {
145  const BasicBlock* succbb = (*sit);
146  if(visited.find(succbb)==visited.end())
147  visited.insert(succbb);
148  else
149  continue;
150  bbVec.push_back(succbb);
151  }
152  }
153  return true;
154 }
155 
160 {
161  if(fun->hasAddressTaken())
162  return false;
164  return false;
165  for (Value::const_user_iterator i = fun->user_begin(), e = fun->user_end(); i != e; ++i)
166  {
167  if (LLVMUtil::isCallSite(*i))
168  return false;
169  }
170  return true;
171 }
172 
177 {
178  if(const Instruction* inst = SVFUtil::dyn_cast<Instruction>(value))
179  {
180  if(isUncalledFunction(inst->getParent()->getParent()))
181  return true;
182  }
183  else if(const Argument* arg = SVFUtil::dyn_cast<Argument>(value))
184  {
185  if(isUncalledFunction(arg->getParent()))
186  return true;
187  }
188  return false;
189 }
190 
192 {
193  if (func && (func->getIntrinsicID() == llvm::Intrinsic::donothing ||
194  func->getIntrinsicID() == llvm::Intrinsic::dbg_declare ||
195  func->getIntrinsicID() == llvm::Intrinsic::dbg_label ||
196  func->getIntrinsicID() == llvm::Intrinsic::dbg_value))
197  {
198  return true;
199  }
200  return false;
201 }
202 
205 {
206  if (const CallBase* call = SVFUtil::dyn_cast<CallBase>(inst))
207  {
208  const Function* func = call->getCalledFunction();
209  if (isIntrinsicFun(func))
210  {
211  return true;
212  }
213  }
214  return false;
215 }
216 
221 {
222  if (SVFUtil::isa<GlobalValue>(val) || isInt2PtrConstantExpr(val))
223  return val;
224  else if (const ConstantExpr *CE = SVFUtil::dyn_cast<ConstantExpr>(val))
225  {
226  if (Instruction::isCast(CE->getOpcode()))
227  return stripConstantCasts(CE->getOperand(0));
228  }
229  return val;
230 }
231 
232 void LLVMUtil::viewCFG(const Function* fun)
233 {
234  if (fun != nullptr)
235  {
236  fun->viewCFG();
237  }
238 }
239 
241 {
242  if (fun != nullptr)
243  {
244  fun->viewCFGOnly();
245  }
246 }
247 
252 {
253  while (true)
254  {
255  if (const CastInst *ci = SVFUtil::dyn_cast<CastInst>(val))
256  {
257  val = ci->getOperand(0);
258  }
259  else if (const ConstantExpr *ce = SVFUtil::dyn_cast<ConstantExpr>(val))
260  {
261  if(ce->isCast())
262  val = ce->getOperand(0);
263  else
264  return val;
265  }
266  else
267  {
268  return val;
269  }
270  }
271  return nullptr;
272 }
273 
274 /*
275  * Get the first dominated cast instruction for heap allocations since they typically come from void* (i8*)
276  * for example, %4 = call align 16 i8* @malloc(i64 10); %5 = bitcast i8* %4 to i32*
277  * return %5 whose type is i32* but not %4 whose type is i8*
278  */
280 {
281  assert(SVFUtil::isa<PointerType>(val->getType()) && "this value should be a pointer type!");
283  const Value *latestUse = nullptr;
284  for (const auto &it : val->uses())
285  {
286  if (SVFUtil::isa<BitCastInst>(it.getUser()))
287  latestUse = it.getUser();
288  else
289  latestUse = nullptr;
290  }
291  return latestUse;
292 }
293 
298 {
299  assert(ety && "type is null?");
300  u32_t numOfFields = 1;
301  if (SVFUtil::isa<StructType, ArrayType>(ety))
302  {
305  else
307  }
308  return numOfFields;
309 }
310 
311 /*
312  * Reference functions:
313  * llvm::parseIRFile (lib/IRReader/IRReader.cpp)
314  * llvm::parseIR (lib/IRReader/IRReader.cpp)
315  */
316 bool LLVMUtil::isIRFile(const std::string &filename)
317 {
318  llvm::LLVMContext context;
319  llvm::SMDiagnostic err;
320 
321  // Parse the input LLVM IR file into a module
322  std::unique_ptr<llvm::Module> module = llvm::parseIRFile(filename, err, context);
323 
324  // Check if the parsing succeeded
325  if (!module)
326  {
327  err.print("isIRFile", llvm::errs());
328  return false; // Not an LLVM IR file
329  }
330 
331  return true; // It is an LLVM IR file
332 }
333 
334 
337 void LLVMUtil::processArguments(int argc, char **argv, int &arg_num, char **arg_value,
338  std::vector<std::string> &moduleNameVec)
339 {
340  bool first_ir_file = true;
341  for (int i = 0; i < argc; ++i)
342  {
343  std::string argument(argv[i]);
344  if (LLVMUtil::isIRFile(argument))
345  {
346  if (find(moduleNameVec.begin(), moduleNameVec.end(), argument)
347  == moduleNameVec.end())
348  moduleNameVec.push_back(argument);
349  if (first_ir_file)
350  {
351  arg_value[arg_num] = argv[i];
352  arg_num++;
353  first_ir_file = false;
354  }
355  }
356  else
357  {
358  arg_value[arg_num] = argv[i];
359  arg_num++;
360  }
361  }
362 }
363 
365 std::vector<const Function *> LLVMUtil::getCalledFunctions(const Function *F)
366 {
367  std::vector<const Function *> calledFunctions;
368  for (const Instruction &I : instructions(F))
369  {
370  if (const CallBase *callInst = SVFUtil::dyn_cast<CallBase>(&I))
371  {
372  Function *calledFunction = callInst->getCalledFunction();
373  if (calledFunction)
374  {
375  calledFunctions.push_back(calledFunction);
376  std::vector<const Function *> nestedCalledFunctions = getCalledFunctions(calledFunction);
377  calledFunctions.insert(calledFunctions.end(), nestedCalledFunctions.begin(), nestedCalledFunctions.end());
378  }
379  }
380  }
381  return calledFunctions;
382 }
383 
385 {
386  assert(!funcName.empty() && "Empty function name");
387  // Some function names change due to mangling, such as "fopen" to "\01_fopen" on macOS.
388  // Since C function names cannot include '.', change the function name from llvm.memcpy.p0i8.p0i8.i64 to llvm_memcpy_p0i8_p0i8_i64."
389  bool hasSpecialPrefix = funcName[0] == '\01';
390  bool hasDot = funcName.find('.') != std::string::npos;
391 
392  if (!hasDot && !hasSpecialPrefix)
393  return funcName;
394 
395  // Remove prefix "\01_" or "\01"
396  if (hasSpecialPrefix)
397  {
398  const std::string prefix1 = "\01_";
399  const std::string prefix2 = "\01";
400  if (funcName.substr(0, prefix1.length()) == prefix1)
401  funcName = funcName.substr(prefix1.length());
402  else if (funcName.substr(0, prefix2.length()) == prefix2)
403  funcName = funcName.substr(prefix2.length());
404  }
405  // Replace '.' with '_'
406  if (hasDot)
407  std::replace(funcName.begin(), funcName.end(), '.', '_');
408 
409  return funcName;
410 }
411 
413 {
415 }
416 
418 {
419  if (const GlobalVariable* gvar = SVFUtil::dyn_cast<GlobalVariable>(val))
420  {
421  if (LLVMModuleSet::getLLVMModuleSet()->hasGlobalRep(gvar))
423  }
424  return val;
425 }
426 
431 {
432  if(val==nullptr) return "{ empty val }";
433 
434  std::string str;
435  std::stringstream rawstr(str);
436  rawstr << "{ ";
437 
438  if (const Instruction* inst = SVFUtil::dyn_cast<Instruction>(val))
439  {
440  if (SVFUtil::isa<AllocaInst>(inst))
441  {
442  for (llvm::DbgInfoIntrinsic *DII : FindDbgDeclareUses(const_cast<Instruction*>(inst)))
443  {
444  if (llvm::DbgDeclareInst *DDI = SVFUtil::dyn_cast<llvm::DbgDeclareInst>(DII))
445  {
446  llvm::DIVariable *DIVar = SVFUtil::cast<llvm::DIVariable>(DDI->getVariable());
447  rawstr << "\"ln\": " << DIVar->getLine() << ", \"fl\": \"" << DIVar->getFilename().str() << "\"";
448  break;
449  }
450  }
451  }
452  else if (MDNode *N = inst->getMetadata("dbg")) // Here I is an LLVM instruction
453  {
454  llvm::DILocation* Loc = SVFUtil::cast<llvm::DILocation>(N); // DILocation is in DebugInfo.h
455  unsigned Line = Loc->getLine();
456  unsigned Column = Loc->getColumn();
457  std::string File = Loc->getFilename().str();
458  //StringRef Dir = Loc.getDirectory();
459  if(File.empty() || Line == 0)
460  {
461  auto inlineLoc = Loc->getInlinedAt();
462  if(inlineLoc)
463  {
464  Line = inlineLoc->getLine();
465  Column = inlineLoc->getColumn();
466  File = inlineLoc->getFilename().str();
467  }
468  }
469  rawstr << "\"ln\": " << Line << ", \"cl\": " << Column << ", \"fl\": \"" << File << "\"";
470  }
471  }
472  else if (const Argument* argument = SVFUtil::dyn_cast<Argument>(val))
473  {
474  if (argument->getArgNo()%10 == 1)
475  rawstr << argument->getArgNo() << "st";
476  else if (argument->getArgNo()%10 == 2)
477  rawstr << argument->getArgNo() << "nd";
478  else if (argument->getArgNo()%10 == 3)
479  rawstr << argument->getArgNo() << "rd";
480  else
481  rawstr << argument->getArgNo() << "th";
482  rawstr << " arg " << argument->getParent()->getName().str() << " "
483  << getSourceLocOfFunction(argument->getParent());
484  }
485  else if (const GlobalVariable* gvar = SVFUtil::dyn_cast<GlobalVariable>(val))
486  {
487  rawstr << "Glob ";
488  NamedMDNode* CU_Nodes = gvar->getParent()->getNamedMetadata("llvm.dbg.cu");
489  if(CU_Nodes)
490  {
491  for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i)
492  {
493  llvm::DICompileUnit *CUNode = SVFUtil::cast<llvm::DICompileUnit>(CU_Nodes->getOperand(i));
494  for (llvm::DIGlobalVariableExpression *GV : CUNode->getGlobalVariables())
495  {
496  llvm::DIGlobalVariable * DGV = GV->getVariable();
497 
498  if(DGV->getName() == gvar->getName())
499  {
500  rawstr << "\"ln\": " << DGV->getLine() << ", \"fl\": \"" << DGV->getFilename().str() << "\"";
501  }
502 
503  }
504  }
505  }
506  }
507  else if (const Function* func = SVFUtil::dyn_cast<Function>(val))
508  {
509  rawstr << getSourceLocOfFunction(func);
510  }
511  else if (const BasicBlock* bb = SVFUtil::dyn_cast<BasicBlock>(val))
512  {
513  rawstr << "\"basic block\": " << bb->getName().str() << ", \"location\": " << getSourceLoc(bb->getFirstNonPHI());
514  }
515  else if(LLVMUtil::isConstDataOrAggData(val))
516  {
517  rawstr << "constant data";
518  }
519  else
520  {
521  rawstr << "N/A";
522  }
523  rawstr << " }";
524 
525  if(rawstr.str()=="{ }")
526  return "";
527  return rawstr.str();
528 }
529 
530 
535 {
536  std::string str;
537  std::stringstream rawstr(str);
538  /*
539  * https://reviews.llvm.org/D18074?id=50385
540  * looks like the relevant
541  */
542  if (llvm::DISubprogram *SP = F->getSubprogram())
543  {
544  if (SP->describes(F))
545  rawstr << "\"ln\": " << SP->getLine() << ", \"file\": \"" << SP->getFilename().str() << "\"";
546  }
547  return rawstr.str();
548 }
549 
551 void LLVMUtil::getNextInsts(const Instruction* curInst, std::vector<const Instruction*>& instList)
552 {
553  if (!curInst->isTerminator())
554  {
555  const Instruction* nextInst = curInst->getNextNode();
556  if (LLVMUtil::isIntrinsicInst(nextInst))
557  getNextInsts(nextInst, instList);
558  else
559  instList.push_back(nextInst);
560  }
561  else
562  {
563  const BasicBlock *BB = curInst->getParent();
564  // Visit all successors of BB in the CFG
565  for (succ_const_iterator it = succ_begin(BB), ie = succ_end(BB); it != ie; ++it)
566  {
567  const Instruction* nextInst = &((*it)->front());
568  if (LLVMUtil::isIntrinsicInst(nextInst))
569  getNextInsts(nextInst, instList);
570  else
571  instList.push_back(nextInst);
572  }
573  }
574 }
575 
576 
577 
580 {
581  return isConstantObjSym(LLVMModuleSet::getLLVMModuleSet()->getLLVMValue(val));
582 }
583 
584 
586 {
587  std::string str;
588  llvm::raw_string_ostream rawstr(str);
589  if (val)
590  rawstr << " " << *val << " ";
591  else
592  rawstr << " llvm Value is null";
593  return rawstr.str();
594 }
595 
597 {
598  std::string str;
599  llvm::raw_string_ostream rawstr(str);
600  if (type)
601  rawstr << " " << *type << " ";
602  else
603  rawstr << " llvm type is null";
604  return rawstr.str();
605 }
606 
608 {
609  std::string str;
610  llvm::raw_string_ostream rawstr(str);
611  if (val)
612  rawstr << dumpValue(val) << getSourceLoc(val);
613  else
614  rawstr << " llvm Value is null";
615  return rawstr.str();
616 }
617 
619 {
621  ExtAPI* extApi = ExtAPI::getExtAPI();
622  bool isPtrTy = inst->getType()->isPointerTy();
623  if (const CallBase* call = SVFUtil::dyn_cast<CallBase>(inst))
624  {
625  const Function* fun = call->getCalledFunction();
626  return fun && isPtrTy &&
627  (extApi->is_alloc(pSet->getSVFFunction(fun)) ||
628  extApi->is_realloc(pSet->getSVFFunction(fun)));
629  }
630  else
631  return false;
632 }
633 
635 {
636  if (const CallBase* call = SVFUtil::dyn_cast<CallBase>(inst))
637  {
638  const Function* fun = call->getCalledFunction();
639  return fun &&
641  LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(fun));
642  }
643  else
644  {
645  return false;
646  }
647 }
648 
650 {
651  bool res = false;
652 
653  if(isIntrinsicInst(inst))
654  res = false;
655  else
656  res = isCallSite(inst);
657  return res;
658 }
659 
660 namespace SVF
661 {
662 
664 {
665  std::string str;
666  llvm::raw_string_ostream rawstr(str);
667  if (const SVF::SVFFunction* fun = SVFUtil::dyn_cast<SVFFunction>(this))
668  {
669  rawstr << "Function: " << fun->getName() << " ";
670  }
671  else if (const SVFBasicBlock* bb = SVFUtil::dyn_cast<SVFBasicBlock>(this))
672  {
673  rawstr << "BasicBlock: " << bb->getName() << " ";
674  }
675  else
676  {
677  auto llvmVal = LLVMModuleSet::getLLVMModuleSet()->getLLVMValue(this);
678  if (llvmVal)
679  rawstr << " " << *llvmVal << " ";
680  else
681  rawstr << " No llvmVal found";
682  }
683  rawstr << this->getSourceLoc();
684  return rawstr.str();
685 }
686 
687 
689 {
690  std::string str;
691  llvm::raw_string_ostream rawstr(str);
692  if (const SVF::PTACallGraphNode* fun = SVFUtil::dyn_cast<PTACallGraphNode>(this))
693  {
694  rawstr << "Function: " << fun->getFunction()->getName() << " ";
695  }
696  else
697  {
698  auto llvmVal = LLVMModuleSet::getLLVMModuleSet()->getLLVMValue(this);
699  if (llvmVal)
700  rawstr << " " << *llvmVal << " ";
701  else
702  rawstr << " No llvmVal found";
703  }
704  rawstr << getSourceLoc();
705  return rawstr.str();
706 }
707 
708 } // namespace SVF
#define F(f)
newitem type
Definition: cJSON.cpp:2739
const char *const name
Definition: cJSON.h:264
const char *const string
Definition: cJSON.h:172
bool is_alloc(const SVFFunction *F)
Definition: ExtAPI.cpp:217
bool is_arg_alloc(const SVFFunction *F)
Definition: ExtAPI.cpp:223
static ExtAPI * getExtAPI()
Definition: ExtAPI.cpp:42
bool is_realloc(const SVFFunction *F)
Definition: ExtAPI.cpp:245
SVFFunction * getSVFFunction(const Function *fun) const
Definition: LLVMModule.h:230
SVFType * getSVFType(const Type *T)
Get or create SVFType and typeinfo.
GlobalVariable * getGlobalRep(const GlobalVariable *val) const
Definition: LLVMModule.h:327
const Value * getLLVMValue(const SVFValue *value) const
Definition: LLVMModule.h:216
SVFBasicBlock * getSVFBasicBlock(const BasicBlock *bb) const
Definition: LLVMModule.h:237
static LLVMModuleSet * getLLVMModuleSet()
Definition: LLVMModule.h:118
static const Option< bool > ModelArrays
Definition: Options.h:188
const std::string valueOnlyToString() const
Definition: LLVMUtil.cpp:688
virtual const std::string getSourceLoc() const
Definition: GenericGraph.h:281
const SVFType * getReturnType() const
Returns the FunctionType.
Definition: SVFValue.h:388
StInfo * getTypeInfo()
Definition: SVFType.h:230
std::string toString() const
Needs to be implemented by a SVF front end.
Definition: LLVMUtil.cpp:663
virtual const std::string getSourceLoc() const
Definition: SVFValue.h:280
u32_t getNumOfFlattenElements() const
Return number of elements after flattening (including array elements)
Definition: SVFType.h:139
u32_t getNumOfFlattenFields() const
Return the number of fields after flattening (ignoring array elements)
Definition: SVFType.h:145
bool isIntrinsicInst(const Instruction *inst)
Return true if it is an intrinsic instruction.
Definition: LLVMUtil.cpp:204
const Function * getProgFunction(const std::string &funName)
Get program entry function from module.
Definition: LLVMUtil.cpp:39
const Value * stripConstantCasts(const Value *val)
Strip off the constant casts.
Definition: LLVMUtil.cpp:220
bool isPtrInUncalledFunction(const Value *value)
Return true if this is value in a dead function (function without any caller)
Definition: LLVMUtil.cpp:176
bool isHeapAllocExtCallViaRet(const Instruction *inst)
Definition: LLVMUtil.cpp:618
const Value * getFirstUseViaCastInst(const Value *val)
Definition: LLVMUtil.cpp:279
void viewCFGOnly(const Function *fun)
Definition: LLVMUtil.cpp:240
const std::string getSourceLocOfFunction(const Function *F)
Definition: LLVMUtil.cpp:534
bool isUncalledFunction(const Function *fun)
whether this is a function without any possible caller?
Definition: LLVMUtil.cpp:159
const Value * stripAllCasts(const Value *val)
Strip off the all casts.
Definition: LLVMUtil.cpp:251
bool isIntrinsicFun(const Function *func)
Definition: LLVMUtil.cpp:191
std::vector< const Function * > getCalledFunctions(const Function *F)
Get all called funcions in a parent function.
Definition: LLVMUtil.cpp:365
bool isCallSite(const Instruction *inst)
Whether an instruction is a call or invoke instruction.
Definition: LLVMUtil.h:45
bool functionDoesNotRet(const Function *fun)
Definition: LLVMUtil.cpp:123
std::string dumpType(const Type *type)
Definition: LLVMUtil.cpp:596
void getNextInsts(const Instruction *curInst, std::vector< const Instruction * > &instList)
Get the next instructions following control flow.
Definition: LLVMUtil.cpp:551
std::string dumpValueAndDbgInfo(const Value *val)
Definition: LLVMUtil.cpp:607
bool isConstDataOrAggData(const Value *val)
Return true if the value refers to constant data, e.g., i32 0.
Definition: LLVMUtil.h:327
const std::string getSourceLoc(const Value *val)
Definition: LLVMUtil.cpp:430
const Value * getGlobalRep(const Value *val)
find the unique defined global across multiple modules
Definition: LLVMUtil.cpp:417
void getFunReachableBBs(const Function *svfFun, std::vector< const SVFBasicBlock * > &bbs)
Get reachable basic block from function entry.
Definition: LLVMUtil.cpp:74
u32_t getNumOfElements(const Type *ety)
Return size of this object based on LLVM value.
Definition: LLVMUtil.cpp:297
const SVFFunction * getFunction(const std::string &name)
Get the corresponding Function based on its name.
Definition: LLVMUtil.cpp:412
bool basicBlockHasRetInst(const BasicBlock *bb)
Return true if the function has a return instruction.
Definition: LLVMUtil.cpp:109
void viewCFG(const Function *fun)
Definition: LLVMUtil.cpp:232
bool isHeapAllocExtCallViaArg(const Instruction *inst)
Definition: LLVMUtil.cpp:634
bool isProgEntryFunction(const Function *fun)
Check whether a function is an entry function (i.e., main)
Definition: LLVMUtil.h:79
bool isObject(const Value *ref)
Return true if this value refers to a object.
Definition: LLVMUtil.cpp:59
void processArguments(int argc, char **argv, int &arg_num, char **arg_value, std::vector< std::string > &moduleNameVec)
Parse argument for multi-module analysis.
Definition: LLVMUtil.cpp:337
bool isIRFile(const std::string &filename)
Check whether a file is an LLVM IR file.
Definition: LLVMUtil.cpp:316
bool isConstantObjSym(const SVFValue *val)
Check whether this value points-to a constant object.
Definition: LLVMUtil.cpp:579
const ConstantExpr * isInt2PtrConstantExpr(const Value *val)
Definition: LLVMUtil.h:191
std::string restoreFuncName(std::string funcName)
Definition: LLVMUtil.cpp:384
bool isNonInstricCallSite(const Instruction *inst)
Whether an instruction is a callsite in the application code, excluding llvm intrinsic calls.
Definition: LLVMUtil.cpp:649
std::string dumpValue(const Value *val)
Definition: LLVMUtil.cpp:585
bool isExtCall(const SVFFunction *fun)
Definition: SVFUtil.h:278
std::ostream & errs()
Overwrite llvm::errs()
Definition: SVFUtil.h:56
for isBitcode
Definition: BasicTypes.h:68
llvm::GlobalVariable GlobalVariable
Definition: BasicTypes.h:130
llvm::Type Type
Definition: BasicTypes.h:83
llvm::CallBase CallBase
Definition: BasicTypes.h:146
llvm::BasicBlock BasicBlock
Definition: BasicTypes.h:86
llvm::NamedMDNode NamedMDNode
LLVM metadata and debug information.
Definition: BasicTypes.h:111
llvm::succ_const_iterator succ_const_iterator
LLVM Iterators.
Definition: BasicTypes.h:276
llvm::Argument Argument
Definition: BasicTypes.h:145
llvm::Function Function
Definition: BasicTypes.h:85
llvm::Instruction Instruction
Definition: BasicTypes.h:87
llvm::DomTreeNode DomTreeNode
Definition: BasicTypes.h:134
llvm::SMDiagnostic SMDiagnostic
Definition: BasicTypes.h:90
llvm::DISubprogram DISubprogram
Definition: BasicTypes.h:113
llvm::Value Value
LLVM Basic classes.
Definition: BasicTypes.h:82
llvm::ConstantExpr ConstantExpr
Definition: BasicTypes.h:120
llvm::CastInst CastInst
Definition: BasicTypes.h:158
llvm::Module Module
Definition: BasicTypes.h:84
llvm::MDNode MDNode
Definition: BasicTypes.h:112
unsigned u32_t
Definition: GeneralType.h:46
llvm::DominatorTree DominatorTree
LLVM Dominators.
Definition: BasicTypes.h:133
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
Definition: GeneralType.h:96
llvm::LLVMContext LLVMContext
Definition: BasicTypes.h:70