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