Static Value-Flow Analysis
Loading...
Searching...
No Matches
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/ObjTypeInfo.h"
32#include "SVFIR/SVFType.h"
33#include <sstream>
34#include <llvm/IRReader/IRReader.h>
35#include <llvm/Support/raw_ostream.h>
36#include "SVF-LLVM/LLVMModule.h"
37
38
39using namespace SVF;
40
41const Function* LLVMUtil::getProgFunction(const std::string& funName)
42{
43 for (const Module& M : LLVMModuleSet::getLLVMModuleSet()->getLLVMModules())
44 {
45 for (const Function& fun : M)
46 {
47 if (fun.getName() == funName)
48 return &fun;
49 }
50 }
51 return nullptr;
52}
53
61bool LLVMUtil::isObject(const Value* ref)
62{
64 return true;
66 return true;
68 return true;
69
70 return false;
71}
72
76void LLVMUtil::getFunReachableBBs (const Function* fun, std::vector<const SVFBasicBlock*> &reachableBBs)
77{
78 assert(!LLVMUtil::isExtCall(fun) && "The calling function cannot be an external function.");
79 //initial DominatorTree
81
83 std::vector<const BasicBlock*> bbVec;
84 bbVec.push_back(&fun->getEntryBlock());
85 while(!bbVec.empty())
86 {
87 const BasicBlock* bb = bbVec.back();
88 bbVec.pop_back();
90 reachableBBs.push_back(svfbb);
91 if(DomTreeNode *dtNode = dt.getNode(const_cast<BasicBlock*>(bb)))
92 {
93 for (DomTreeNode::iterator DI = dtNode->begin(), DE = dtNode->end();
94 DI != DE; ++DI)
95 {
96 const BasicBlock* succbb = (*DI)->getBlock();
97 if(visited.find(succbb)==visited.end())
98 visited.insert(succbb);
99 else
100 continue;
101 bbVec.push_back(succbb);
102 }
103 }
104 }
105}
106
111{
112 for (BasicBlock::const_iterator it = bb->begin(), eit = bb->end();
113 it != eit; ++it)
114 {
116 return true;
117 }
118 return false;
119}
120
125{
126 if (LLVMUtil::isExtCall(fun))
127 {
128 return fun->getReturnType()->isVoidTy();
129 }
130 std::vector<const BasicBlock*> bbVec;
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{
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
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;
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 */
316bool 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
337void 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
365std::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
384
386{
387 return fun && LLVMModuleSet::getLLVMModuleSet()->is_ext(fun);
388}
389
391{
392 return fun && LLVMModuleSet::getLLVMModuleSet()->is_memcpy(fun);
393}
394
395
397{
398 return fun && LLVMModuleSet::getLLVMModuleSet()->is_memset(fun);
399}
400
401
406
407
408std::string LLVMUtil::restoreFuncName(std::string funcName)
409{
410 assert(!funcName.empty() && "Empty function name");
411 // Some function names change due to mangling, such as "fopen" to "\01_fopen" on macOS.
412 // Since C function names cannot include '.', change the function name from llvm.memcpy.p0i8.p0i8.i64 to llvm_memcpy_p0i8_p0i8_i64."
413 bool hasSpecialPrefix = funcName[0] == '\01';
414 bool hasDot = funcName.find('.') != std::string::npos;
415
416 if (!hasDot && !hasSpecialPrefix)
417 return funcName;
418
419 // Remove prefix "\01_" or "\01"
420 if (hasSpecialPrefix)
421 {
422 const std::string prefix1 = "\01_";
423 const std::string prefix2 = "\01";
424 if (funcName.substr(0, prefix1.length()) == prefix1)
425 funcName = funcName.substr(prefix1.length());
426 else if (funcName.substr(0, prefix2.length()) == prefix2)
427 funcName = funcName.substr(prefix2.length());
428 }
429 // Replace '.' with '_'
430 if (hasDot)
431 std::replace(funcName.begin(), funcName.end(), '.', '_');
432
433 return funcName;
434}
435
436
437const FunObjVar* LLVMUtil::getFunObjVar(const std::string& name)
438{
440}
442{
444 {
445 if (LLVMModuleSet::getLLVMModuleSet()->hasGlobalRep(gvar))
447 }
448 return val;
449}
450
454const std::string LLVMUtil::getSourceLoc(const Value* val )
455{
456 if(val==nullptr) return "{ empty val }";
457
458 std::string str;
459 std::stringstream rawstr(str);
460 rawstr << "{ ";
461
462 if (const Instruction* inst = SVFUtil::dyn_cast<Instruction>(val))
463 {
464 if (SVFUtil::isa<AllocaInst>(inst))
465 {
466#if LLVM_VERSION_MAJOR >= 20
467 for (llvm::DbgVariableRecord *DVR : llvm::findDVRDeclares(const_cast<Instruction*>(inst)))
468 {
469 llvm::DIVariable *DIVar = DVR->getVariable();
470 rawstr << "\"ln\": " << DIVar->getLine() << ", \"fl\": \"" << DIVar->getFilename().str() << "\"";
471 break;
472 }
473#else
474 for (llvm::DbgInfoIntrinsic *DII : llvm::findDbgDeclares(const_cast<Instruction*>(inst)))
475 {
476 if (llvm::DbgDeclareInst *DDI = SVFUtil::dyn_cast<llvm::DbgDeclareInst>(DII))
477 {
478 llvm::DIVariable *DIVar = SVFUtil::cast<llvm::DIVariable>(DDI->getVariable());
479 rawstr << "\"ln\": " << DIVar->getLine() << ", \"fl\": \"" << DIVar->getFilename().str() << "\"";
480 break;
481 }
482 }
483#endif
484 }
485 else if (MDNode *N = inst->getMetadata("dbg")) // Here I is an LLVM instruction
486 {
487 llvm::DILocation* Loc = SVFUtil::cast<llvm::DILocation>(N); // DILocation is in DebugInfo.h
488 unsigned Line = Loc->getLine();
489 unsigned Column = Loc->getColumn();
490 std::string File = Loc->getFilename().str();
491 //StringRef Dir = Loc.getDirectory();
492 if(File.empty() || Line == 0)
493 {
494 auto inlineLoc = Loc->getInlinedAt();
495 if(inlineLoc)
496 {
497 Line = inlineLoc->getLine();
498 Column = inlineLoc->getColumn();
499 File = inlineLoc->getFilename().str();
500 }
501 }
502 rawstr << "\"ln\": " << Line << ", \"cl\": " << Column << ", \"fl\": \"" << File << "\"";
503 }
504 }
505 else if (const Argument* argument = SVFUtil::dyn_cast<Argument>(val))
506 {
507 if (argument->getArgNo()%10 == 1)
508 rawstr << argument->getArgNo() << "st";
509 else if (argument->getArgNo()%10 == 2)
510 rawstr << argument->getArgNo() << "nd";
511 else if (argument->getArgNo()%10 == 3)
512 rawstr << argument->getArgNo() << "rd";
513 else
514 rawstr << argument->getArgNo() << "th";
515 rawstr << " arg " << argument->getParent()->getName().str() << " "
516 << getSourceLocOfFunction(argument->getParent());
517 }
518 else if (const GlobalVariable* gvar = SVFUtil::dyn_cast<GlobalVariable>(val))
519 {
520 rawstr << "Glob ";
521 NamedMDNode* CU_Nodes = gvar->getParent()->getNamedMetadata("llvm.dbg.cu");
522 if(CU_Nodes)
523 {
524 for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i)
525 {
526 llvm::DICompileUnit *CUNode = SVFUtil::cast<llvm::DICompileUnit>(CU_Nodes->getOperand(i));
527 for (llvm::DIGlobalVariableExpression *GV : CUNode->getGlobalVariables())
528 {
529 llvm::DIGlobalVariable * DGV = GV->getVariable();
530
531 if(DGV->getName() == gvar->getName())
532 {
533 rawstr << "\"ln\": " << DGV->getLine() << ", \"fl\": \"" << DGV->getFilename().str() << "\"";
534 }
535
536 }
537 }
538 }
539 }
540 else if (const Function* func = SVFUtil::dyn_cast<Function>(val))
541 {
542 rawstr << getSourceLocOfFunction(func);
543 }
544 else if (const BasicBlock* bb = SVFUtil::dyn_cast<BasicBlock>(val))
545 {
546 auto nonPhiIt = bb->getFirstNonPHIIt();
547 rawstr << "\"basic block\": " << bb->getName().str() << ", \"location\": " << getSourceLoc(nonPhiIt != bb->end() ? &*nonPhiIt : nullptr);
548 }
550 {
551 rawstr << "constant data";
552 }
553 else
554 {
555 rawstr << "N/A";
556 }
557 rawstr << " }";
558
559 if(rawstr.str()=="{ }")
560 return "";
561 return rawstr.str();
562}
563
564
569{
570 std::string str;
571 std::stringstream rawstr(str);
572 /*
573 * https://reviews.llvm.org/D18074?id=50385
574 * looks like the relevant
575 */
576 if (llvm::DISubprogram *SP = F->getSubprogram())
577 {
578 if (SP->describes(F))
579 rawstr << "\"ln\": " << SP->getLine() << ", \"file\": \"" << SP->getFilename().str() << "\"";
580 }
581 return rawstr.str();
582}
583
585void LLVMUtil::getNextInsts(const Instruction* curInst, std::vector<const Instruction*>& instList)
586{
587 if (!curInst->isTerminator())
588 {
589 const Instruction* nextInst = curInst->getNextNode();
590 if (LLVMUtil::isIntrinsicInst(nextInst))
591 getNextInsts(nextInst, instList);
592 else
593 instList.push_back(nextInst);
594 }
595 else
596 {
597 const BasicBlock *BB = curInst->getParent();
598 // Visit all successors of BB in the CFG
599 for (succ_const_iterator it = succ_begin(BB), ie = succ_end(BB); it != ie; ++it)
600 {
601 const Instruction* nextInst = &((*it)->front());
602 if (LLVMUtil::isIntrinsicInst(nextInst))
603 getNextInsts(nextInst, instList);
604 else
605 instList.push_back(nextInst);
606 }
607 }
608}
609
610
611
612std::string LLVMUtil::dumpValue(const Value* val)
613{
614 std::string str;
615 llvm::raw_string_ostream rawstr(str);
616 if (val)
617 rawstr << " " << *val << " ";
618 else
619 rawstr << " llvm Value is null";
620 return rawstr.str();
621}
622
623std::string LLVMUtil::dumpType(const Type* type)
624{
625 std::string str;
626 llvm::raw_string_ostream rawstr(str);
627 if (type)
628 rawstr << " " << *type << " ";
629 else
630 rawstr << " llvm type is null";
631 return rawstr.str();
632}
633
635{
636 std::string str;
637 llvm::raw_string_ostream rawstr(str);
638 if (val)
639 rawstr << dumpValue(val) << getSourceLoc(val);
640 else
641 rawstr << " llvm Value is null";
642 return rawstr.str();
643}
644
646{
648 bool isPtrTy = inst->getType()->isPointerTy();
649 if (const CallBase* call = SVFUtil::dyn_cast<CallBase>(inst))
650 {
651 const Function* fun = call->getCalledFunction();
652 return fun && isPtrTy &&
653 (pSet->is_alloc(fun) ||
654 pSet->is_realloc(fun));
655 }
656 else
657 return false;
658}
659
661{
662 if (const CallBase* call = SVFUtil::dyn_cast<CallBase>(inst))
663 {
664 const Function* fun = call->getCalledFunction();
665 return fun &&
667 }
668 else
669 {
670 return false;
671 }
672}
673
675{
677 bool isPtrTy = inst->getType()->isPointerTy();
678 if (const CallBase* call = SVFUtil::dyn_cast<CallBase>(inst))
679 {
680 const Function* fun = call->getCalledFunction();
681 return fun && isPtrTy &&
682 pSet->is_alloc_stack_ret(fun);
683 }
684 else
685 return false;
686}
687
695{
696 // Check if the value is an argument in the program entry function
697 if (ArgInProgEntryFunction(val))
698 {
699 // Return true if the value does not have a first use via cast instruction
700 return !getFirstUseViaCastInst(val);
701 }
702 // Check if the value is an instruction and if it is a heap allocation external call
703 else if (SVFUtil::isa<Instruction>(val) &&
705 {
706 return true;
707 }
708 // Return false if none of the above conditions are met
709 return false;
710}
711
717{
719 {
720 return true;
721 }
722 // Check if the value is an instruction and if it is a stack allocation external call
723 else if (SVFUtil::isa<Instruction>(val) &&
725 {
726 return true;
727 }
728 // Return false if none of the above conditions are met
729 return false;
730}
731
733{
734 bool res = false;
735
736 if(isIntrinsicInst(inst))
737 res = false;
738 else
739 res = isCallSite(inst);
740 return res;
741}
742
743namespace SVF
744{
745
746
747const std::string SVFValue::valueOnlyToString() const
748{
749 std::string str;
750 llvm::raw_string_ostream rawstr(str);
751 assert(
755 "invalid value, refer to their toString method");
756 auto llvmVal =
758 if (llvmVal)
759 rawstr << " " << *llvmVal << " ";
760 else
761 rawstr << "";
762 rawstr << getSourceLoc();
763 return rawstr.str();
764}
765
766const bool SVFValue::hasLLVMValue() const
767{
769
770}
771}// namespace SVF
newitem type
Definition cJSON.cpp:2739
const char *const name
Definition cJSON.h:264
bool is_alloc_stack_ret(const Function *F)
const FunObjVar * getFunObjVar(const Function *fun) const
Definition LLVMModule.h:274
static LLVMModuleSet * getLLVMModuleSet()
Definition LLVMModule.h:137
GlobalVariable * getGlobalRep(const GlobalVariable *val) const
Definition LLVMModule.h:366
SVFBasicBlock * getSVFBasicBlock(const BasicBlock *bb)
Definition LLVMModule.h:305
bool hasLLVMValue(const SVFValue *value) const
Definition LLVMModule.h:262
DominatorTree & getDomTree(const Function *fun)
bool is_alloc(const Function *F)
const Value * getLLVMValue(const SVFValue *value) const
Definition LLVMModule.h:267
SVFType * getSVFType(const Type *T)
Get or create SVFType and typeinfo.
bool is_arg_alloc(const Function *F)
s32_t get_alloc_arg_pos(const Function *F)
bool is_ext(const Function *F)
bool is_memset(const Function *F)
bool is_memcpy(const Function *F)
bool is_realloc(const Function *F)
static Option< bool > ModelArrays
Definition Options.h:180
StInfo * getTypeInfo()
Definition SVFType.h:273
virtual const std::string getSourceLoc() const
Definition SVFValue.h:194
const bool hasLLVMValue() const
Definition LLVMUtil.cpp:766
const std::string valueOnlyToString() const
Definition LLVMUtil.cpp:747
u32_t getNumOfFlattenElements() const
Return number of elements after flattening (including array elements).
Definition SVFType.h:164
u32_t getNumOfFlattenFields() const
Return the number of fields after flattening (ignoring array elements).
Definition SVFType.h:170
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:41
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:645
const Value * getFirstUseViaCastInst(const Value *val)
Definition LLVMUtil.cpp:279
bool isHeapAllocExtCall(const Instruction *inst)
Definition LLVMUtil.h:425
void viewCFGOnly(const Function *fun)
Definition LLVMUtil.cpp:240
const std::string getSourceLocOfFunction(const Function *F)
Definition LLVMUtil.cpp:568
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
const ConstantExpr * isInt2PtrConstantExpr(const Value *val)
Definition LLVMUtil.h:227
bool isMemcpyExtFun(const Function *fun)
Definition LLVMUtil.cpp:390
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:57
bool isStackAllocExtCall(const Instruction *inst)
Definition LLVMUtil.h:432
bool functionDoesNotRet(const Function *fun)
Definition LLVMUtil.cpp:124
std::string dumpType(const Type *type)
Definition LLVMUtil.cpp:623
void getNextInsts(const Instruction *curInst, std::vector< const Instruction * > &instList)
Get the next instructions following control flow.
Definition LLVMUtil.cpp:585
std::string dumpValueAndDbgInfo(const Value *val)
Definition LLVMUtil.cpp:634
bool isConstDataOrAggData(const Value *val)
Return true if the value refers to constant data, e.g., i32 0.
Definition LLVMUtil.h:397
const std::string getSourceLoc(const Value *val)
Definition LLVMUtil.cpp:454
bool isHeapObj(const Value *val)
Definition LLVMUtil.cpp:694
const Value * getGlobalRep(const Value *val)
find the unique defined global across multiple modules
Definition LLVMUtil.cpp:441
void getFunReachableBBs(const Function *svfFun, std::vector< const SVFBasicBlock * > &bbs)
Get reachable basic block from function entry.
Definition LLVMUtil.cpp:76
bool isExtCall(const Function *fun)
Definition LLVMUtil.cpp:385
u32_t getNumOfElements(const Type *ety)
Return size of this object based on LLVM value.
Definition LLVMUtil.cpp:297
bool basicBlockHasRetInst(const BasicBlock *bb)
Return true if the function has a return instruction.
Definition LLVMUtil.cpp:110
void viewCFG(const Function *fun)
Definition LLVMUtil.cpp:232
bool isStackObj(const Value *val)
Definition LLVMUtil.cpp:716
bool isHeapAllocExtCallViaArg(const Instruction *inst)
Definition LLVMUtil.cpp:660
bool isMemsetExtFun(const Function *fun)
Definition LLVMUtil.cpp:396
bool isProgEntryFunction(const Function *fun)
Check whether a function is an entry function (i.e., main).
Definition LLVMUtil.h:126
bool isObject(const Value *ref)
Return true if this value refers to a object.
Definition LLVMUtil.cpp:61
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 ArgInProgEntryFunction(const Value *val)
Return true if this is an argument of a program entry function (e.g. main).
Definition LLVMUtil.h:166
bool isStackAllocExtCallViaRet(const Instruction *inst)
Definition LLVMUtil.cpp:674
u32_t getHeapAllocHoldingArgPosition(const Function *fun)
Definition LLVMUtil.cpp:402
std::string restoreFuncName(std::string funcName)
Definition LLVMUtil.cpp:408
const FunObjVar * getFunObjVar(const std::string &name)
Definition LLVMUtil.cpp:437
bool isNonInstricCallSite(const Instruction *inst)
Whether an instruction is a callsite in the application code, excluding llvm intrinsic calls.
Definition LLVMUtil.cpp:732
std::string dumpValue(const Value *val)
Definition LLVMUtil.cpp:612
std::enable_if_t<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type > cast(const Y &Val)
Definition Casting.h:360
LLVM_NODISCARD bool isa(const Y &Val)
Definition Casting.h:241
LLVM_NODISCARD std::enable_if_t<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type > dyn_cast(const Y &Val)
Definition Casting.h:405
for isBitcode
Definition BasicTypes.h:70
llvm::GlobalVariable GlobalVariable
Definition BasicTypes.h:131
llvm::const_succ_iterator succ_const_iterator
LLVM Iterators.
Definition BasicTypes.h:274
llvm::Type Type
Definition BasicTypes.h:81
llvm::CallBase CallBase
Definition BasicTypes.h:147
llvm::BasicBlock BasicBlock
Definition BasicTypes.h:84
llvm::NamedMDNode NamedMDNode
LLVM metadata and debug information.
Definition BasicTypes.h:109
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
Definition GeneralType.h:51
llvm::Argument Argument
Definition BasicTypes.h:146
llvm::Function Function
Definition BasicTypes.h:83
llvm::Instruction Instruction
Definition BasicTypes.h:85
llvm::DomTreeNode DomTreeNode
Definition BasicTypes.h:135
llvm::Value Value
LLVM Basic classes.
Definition BasicTypes.h:80
llvm::ConstantExpr ConstantExpr
Definition BasicTypes.h:118
llvm::CastInst CastInst
Definition BasicTypes.h:159
llvm::Module Module
Definition BasicTypes.h:82
llvm::MDNode MDNode
Definition BasicTypes.h:110
unsigned u32_t
Definition GeneralType.h:67
llvm::DominatorTree DominatorTree
LLVM Dominators.
Definition BasicTypes.h:134