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{
44 {
45 for (const Function& fun : M)
46 {
47 if (fun.getName() == funName)
48 return &fun;
49 }
50 }
51 return nullptr;
52}
53
62{
63 if (SVFUtil::isa<Instruction>(ref) && isHeapAllocExtCallViaRet(SVFUtil::cast<Instruction>(ref)))
64 return true;
65 if (SVFUtil::isa<GlobalVariable>(ref))
66 return true;
67 if (SVFUtil::isa<Function, AllocaInst>(ref))
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 {
115 if(SVFUtil::isa<ReturnInst>(*it))
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
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 {
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
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 */
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]);
345 {
346 if (find(moduleNameVec.begin(), moduleNameVec.end(), argument)
347 == moduleNameVec.end())
348 moduleNameVec.push_back(argument);
349 if (first_ir_file)
350 {
352 arg_num++;
353 first_ir_file = false;
354 }
355 }
356 else
357 {
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 {
376 std::vector<const Function *> nestedCalledFunctions = getCalledFunctions(calledFunction);
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"
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{
443 if (const GlobalVariable* gvar = SVFUtil::dyn_cast<GlobalVariable>(val))
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#if LLVM_VERSION_MAJOR > 16
475 for (llvm::DbgInfoIntrinsic *DII : llvm::findDbgDeclares(const_cast<Instruction*>(inst)))
476#else
477 for (llvm::DbgInfoIntrinsic *DII : FindDbgDeclareUses(const_cast<Instruction*>(inst)))
478#endif
479 {
480 if (llvm::DbgDeclareInst *DDI = SVFUtil::dyn_cast<llvm::DbgDeclareInst>(DII))
481 {
482 llvm::DIVariable *DIVar = SVFUtil::cast<llvm::DIVariable>(DDI->getVariable());
483 rawstr << "\"ln\": " << DIVar->getLine() << ", \"fl\": \"" << DIVar->getFilename().str() << "\"";
484 break;
485 }
486 }
487#endif
488 }
489 else if (MDNode *N = inst->getMetadata("dbg")) // Here I is an LLVM instruction
490 {
491 llvm::DILocation* Loc = SVFUtil::cast<llvm::DILocation>(N); // DILocation is in DebugInfo.h
492 unsigned Line = Loc->getLine();
493 unsigned Column = Loc->getColumn();
494 std::string File = Loc->getFilename().str();
495 //StringRef Dir = Loc.getDirectory();
496 if(File.empty() || Line == 0)
497 {
498 auto inlineLoc = Loc->getInlinedAt();
499 if(inlineLoc)
500 {
501 Line = inlineLoc->getLine();
502 Column = inlineLoc->getColumn();
503 File = inlineLoc->getFilename().str();
504 }
505 }
506 rawstr << "\"ln\": " << Line << ", \"cl\": " << Column << ", \"fl\": \"" << File << "\"";
507 }
508 }
509 else if (const Argument* argument = SVFUtil::dyn_cast<Argument>(val))
510 {
511 if (argument->getArgNo()%10 == 1)
512 rawstr << argument->getArgNo() << "st";
513 else if (argument->getArgNo()%10 == 2)
514 rawstr << argument->getArgNo() << "nd";
515 else if (argument->getArgNo()%10 == 3)
516 rawstr << argument->getArgNo() << "rd";
517 else
518 rawstr << argument->getArgNo() << "th";
519 rawstr << " arg " << argument->getParent()->getName().str() << " "
520 << getSourceLocOfFunction(argument->getParent());
521 }
522 else if (const GlobalVariable* gvar = SVFUtil::dyn_cast<GlobalVariable>(val))
523 {
524 rawstr << "Glob ";
525 NamedMDNode* CU_Nodes = gvar->getParent()->getNamedMetadata("llvm.dbg.cu");
526 if(CU_Nodes)
527 {
528 for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i)
529 {
530 llvm::DICompileUnit *CUNode = SVFUtil::cast<llvm::DICompileUnit>(CU_Nodes->getOperand(i));
531 for (llvm::DIGlobalVariableExpression *GV : CUNode->getGlobalVariables())
532 {
533 llvm::DIGlobalVariable * DGV = GV->getVariable();
534
535 if(DGV->getName() == gvar->getName())
536 {
537 rawstr << "\"ln\": " << DGV->getLine() << ", \"fl\": \"" << DGV->getFilename().str() << "\"";
538 }
539
540 }
541 }
542 }
543 }
544 else if (const Function* func = SVFUtil::dyn_cast<Function>(val))
545 {
547 }
548 else if (const BasicBlock* bb = SVFUtil::dyn_cast<BasicBlock>(val))
549 {
550 auto nonPhiIt = bb->getFirstNonPHIIt();
551 rawstr << "\"basic block\": " << bb->getName().str() << ", \"location\": " << getSourceLoc(nonPhiIt != bb->end() ? &*nonPhiIt : nullptr);
552 }
554 {
555 rawstr << "constant data";
556 }
557 else
558 {
559 rawstr << "N/A";
560 }
561 rawstr << " }";
562
563 if(rawstr.str()=="{ }")
564 return "";
565 return rawstr.str();
566}
567
568
573{
574 std::string str;
575 std::stringstream rawstr(str);
576 /*
577 * https://reviews.llvm.org/D18074?id=50385
578 * looks like the relevant
579 */
580 if (llvm::DISubprogram *SP = F->getSubprogram())
581 {
582 if (SP->describes(F))
583 rawstr << "\"ln\": " << SP->getLine() << ", \"file\": \"" << SP->getFilename().str() << "\"";
584 }
585 return rawstr.str();
586}
587
589void LLVMUtil::getNextInsts(const Instruction* curInst, std::vector<const Instruction*>& instList)
590{
591 if (!curInst->isTerminator())
592 {
593 const Instruction* nextInst = curInst->getNextNode();
596 else
597 instList.push_back(nextInst);
598 }
599 else
600 {
601 const BasicBlock *BB = curInst->getParent();
602 // Visit all successors of BB in the CFG
603 for (succ_const_iterator it = succ_begin(BB), ie = succ_end(BB); it != ie; ++it)
604 {
605 const Instruction* nextInst = &((*it)->front());
608 else
609 instList.push_back(nextInst);
610 }
611 }
612}
613
614
615
616std::string LLVMUtil::dumpValue(const Value* val)
617{
618 std::string str;
619 llvm::raw_string_ostream rawstr(str);
620 if (val)
621 rawstr << " " << *val << " ";
622 else
623 rawstr << " llvm Value is null";
624 return rawstr.str();
625}
626
627std::string LLVMUtil::dumpType(const Type* type)
628{
629 std::string str;
630 llvm::raw_string_ostream rawstr(str);
631 if (type)
632 rawstr << " " << *type << " ";
633 else
634 rawstr << " llvm type is null";
635 return rawstr.str();
636}
637
639{
640 std::string str;
641 llvm::raw_string_ostream rawstr(str);
642 if (val)
644 else
645 rawstr << " llvm Value is null";
646 return rawstr.str();
647}
648
650{
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 (pSet->is_alloc(fun) ||
658 pSet->is_realloc(fun));
659 }
660 else
661 return false;
662}
663
665{
666 if (const CallBase* call = SVFUtil::dyn_cast<CallBase>(inst))
667 {
668 const Function* fun = call->getCalledFunction();
669 return fun &&
671 }
672 else
673 {
674 return false;
675 }
676}
677
679{
681 bool isPtrTy = inst->getType()->isPointerTy();
682 if (const CallBase* call = SVFUtil::dyn_cast<CallBase>(inst))
683 {
684 const Function* fun = call->getCalledFunction();
685 return fun && isPtrTy &&
686 pSet->is_alloc_stack_ret(fun);
687 }
688 else
689 return false;
690}
691
699{
700 // Check if the value is an argument in the program entry function
702 {
703 // Return true if the value does not have a first use via cast instruction
705 }
706 // Check if the value is an instruction and if it is a heap allocation external call
707 else if (SVFUtil::isa<Instruction>(val) &&
708 LLVMUtil::isHeapAllocExtCall(SVFUtil::cast<Instruction>(val)))
709 {
710 return true;
711 }
712 // Return false if none of the above conditions are met
713 return false;
714}
715
721{
722 if (SVFUtil::isa<AllocaInst>(val))
723 {
724 return true;
725 }
726 // Check if the value is an instruction and if it is a stack allocation external call
727 else if (SVFUtil::isa<Instruction>(val) &&
728 LLVMUtil::isStackAllocExtCall(SVFUtil::cast<Instruction>(val)))
729 {
730 return true;
731 }
732 // Return false if none of the above conditions are met
733 return false;
734}
735
737{
738 bool res = false;
739
740 if(isIntrinsicInst(inst))
741 res = false;
742 else
743 res = isCallSite(inst);
744 return res;
745}
746
747namespace SVF
748{
749
750
751const std::string SVFValue::valueOnlyToString() const
752{
753 std::string str;
754 llvm::raw_string_ostream rawstr(str);
755 assert(
756 !SVFUtil::isa<GepObjVar>(this) && !SVFUtil::isa<GepValVar>(this) &&
757 !SVFUtil::isa<DummyObjVar>(this) &&!SVFUtil::isa<DummyValVar>(this) &&
758 !SVFUtil::isa<BlackHoleValVar>(this) &&
759 "invalid value, refer to their toString method");
760 auto llvmVal =
762 if (llvmVal)
763 rawstr << " " << *llvmVal << " ";
764 else
765 rawstr << "";
766 rawstr << getSourceLoc();
767 return rawstr.str();
768}
769
770const bool SVFValue::hasLLVMValue() const
771{
773
774}
775}// namespace SVF
newitem type
Definition cJSON.cpp:2739
const char *const name
Definition cJSON.h:264
const FunObjVar * getFunObjVar(const Function *fun) const
Definition LLVMModule.h:270
static LLVMModuleSet * getLLVMModuleSet()
Definition LLVMModule.h:133
GlobalVariable * getGlobalRep(const GlobalVariable *val) const
Definition LLVMModule.h:362
SVFBasicBlock * getSVFBasicBlock(const BasicBlock *bb)
Definition LLVMModule.h:301
bool hasLLVMValue(const SVFValue *value) const
Definition LLVMModule.h:258
DominatorTree & getDomTree(const Function *fun)
const Value * getLLVMValue(const SVFValue *value) const
Definition LLVMModule.h:263
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)
const std::vector< std::reference_wrapper< Module > > & getLLVMModules() const
Definition LLVMModule.h:160
bool is_ext(const Function *F)
bool is_memset(const Function *F)
bool is_memcpy(const Function *F)
static Option< bool > ModelArrays
Definition Options.h:178
const ICFGNode * back() const
StInfo * getTypeInfo()
Definition SVFType.h:273
const bool hasLLVMValue() const
Definition LLVMUtil.cpp:770
virtual const std::string getSourceLoc() const
Definition SVFValue.h:194
const std::string valueOnlyToString() const
Definition LLVMUtil.cpp:751
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:649
const Value * getFirstUseViaCastInst(const Value *val)
Definition LLVMUtil.cpp:279
bool isHeapAllocExtCall(const Instruction *inst)
Definition LLVMUtil.h:406
void viewCFGOnly(const Function *fun)
Definition LLVMUtil.cpp:240
const std::string getSourceLocOfFunction(const Function *F)
Definition LLVMUtil.cpp:572
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:231
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:47
bool isStackAllocExtCall(const Instruction *inst)
Definition LLVMUtil.h:413
bool functionDoesNotRet(const Function *fun)
Definition LLVMUtil.cpp:124
std::string dumpType(const Type *type)
Definition LLVMUtil.cpp:627
void getNextInsts(const Instruction *curInst, std::vector< const Instruction * > &instList)
Get the next instructions following control flow.
Definition LLVMUtil.cpp:589
std::string dumpValueAndDbgInfo(const Value *val)
Definition LLVMUtil.cpp:638
bool isConstDataOrAggData(const Value *val)
Return true if the value refers to constant data, e.g., i32 0.
Definition LLVMUtil.h:378
const std::string getSourceLoc(const Value *val)
Definition LLVMUtil.cpp:454
bool isHeapObj(const Value *val)
Definition LLVMUtil.cpp:698
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:720
bool isHeapAllocExtCallViaArg(const Instruction *inst)
Definition LLVMUtil.cpp:664
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:116
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:170
bool isStackAllocExtCallViaRet(const Instruction *inst)
Definition LLVMUtil.cpp:678
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:736
std::string dumpValue(const Value *val)
Definition LLVMUtil.cpp:616
for isBitcode
Definition BasicTypes.h:70
llvm::GlobalVariable GlobalVariable
Definition BasicTypes.h:137
llvm::Type Type
Definition BasicTypes.h:87
llvm::CallBase CallBase
Definition BasicTypes.h:153
llvm::BasicBlock BasicBlock
Definition BasicTypes.h:90
llvm::NamedMDNode NamedMDNode
LLVM metadata and debug information.
Definition BasicTypes.h:115
llvm::succ_const_iterator succ_const_iterator
LLVM Iterators.
Definition BasicTypes.h:287
llvm::Argument Argument
Definition BasicTypes.h:152
llvm::Function Function
Definition BasicTypes.h:89
llvm::Instruction Instruction
Definition BasicTypes.h:91
llvm::DomTreeNode DomTreeNode
Definition BasicTypes.h:141
llvm::Value Value
LLVM Basic classes.
Definition BasicTypes.h:86
llvm::ConstantExpr ConstantExpr
Definition BasicTypes.h:124
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76
llvm::CastInst CastInst
Definition BasicTypes.h:165
llvm::Module Module
Definition BasicTypes.h:88
llvm::MDNode MDNode
Definition BasicTypes.h:116
unsigned u32_t
Definition GeneralType.h:67
llvm::DominatorTree DominatorTree
LLVM Dominators.
Definition BasicTypes.h:140