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 > 16
467 for (llvm::DbgInfoIntrinsic *DII : llvm::findDbgDeclares(const_cast<Instruction*>(inst)))
468#else
469 for (llvm::DbgInfoIntrinsic *DII : FindDbgDeclareUses(const_cast<Instruction*>(inst)))
470#endif
471 {
472 if (llvm::DbgDeclareInst *DDI = SVFUtil::dyn_cast<llvm::DbgDeclareInst>(DII))
473 {
474 llvm::DIVariable *DIVar = SVFUtil::cast<llvm::DIVariable>(DDI->getVariable());
475 rawstr << "\"ln\": " << DIVar->getLine() << ", \"fl\": \"" << DIVar->getFilename().str() << "\"";
476 break;
477 }
478 }
479 }
480 else if (MDNode *N = inst->getMetadata("dbg")) // Here I is an LLVM instruction
481 {
482 llvm::DILocation* Loc = SVFUtil::cast<llvm::DILocation>(N); // DILocation is in DebugInfo.h
483 unsigned Line = Loc->getLine();
484 unsigned Column = Loc->getColumn();
485 std::string File = Loc->getFilename().str();
486 //StringRef Dir = Loc.getDirectory();
487 if(File.empty() || Line == 0)
488 {
489 auto inlineLoc = Loc->getInlinedAt();
490 if(inlineLoc)
491 {
492 Line = inlineLoc->getLine();
493 Column = inlineLoc->getColumn();
494 File = inlineLoc->getFilename().str();
495 }
496 }
497 rawstr << "\"ln\": " << Line << ", \"cl\": " << Column << ", \"fl\": \"" << File << "\"";
498 }
499 }
500 else if (const Argument* argument = SVFUtil::dyn_cast<Argument>(val))
501 {
502 if (argument->getArgNo()%10 == 1)
503 rawstr << argument->getArgNo() << "st";
504 else if (argument->getArgNo()%10 == 2)
505 rawstr << argument->getArgNo() << "nd";
506 else if (argument->getArgNo()%10 == 3)
507 rawstr << argument->getArgNo() << "rd";
508 else
509 rawstr << argument->getArgNo() << "th";
510 rawstr << " arg " << argument->getParent()->getName().str() << " "
511 << getSourceLocOfFunction(argument->getParent());
512 }
513 else if (const GlobalVariable* gvar = SVFUtil::dyn_cast<GlobalVariable>(val))
514 {
515 rawstr << "Glob ";
516 NamedMDNode* CU_Nodes = gvar->getParent()->getNamedMetadata("llvm.dbg.cu");
517 if(CU_Nodes)
518 {
519 for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i)
520 {
521 llvm::DICompileUnit *CUNode = SVFUtil::cast<llvm::DICompileUnit>(CU_Nodes->getOperand(i));
522 for (llvm::DIGlobalVariableExpression *GV : CUNode->getGlobalVariables())
523 {
524 llvm::DIGlobalVariable * DGV = GV->getVariable();
525
526 if(DGV->getName() == gvar->getName())
527 {
528 rawstr << "\"ln\": " << DGV->getLine() << ", \"fl\": \"" << DGV->getFilename().str() << "\"";
529 }
530
531 }
532 }
533 }
534 }
535 else if (const Function* func = SVFUtil::dyn_cast<Function>(val))
536 {
538 }
539 else if (const BasicBlock* bb = SVFUtil::dyn_cast<BasicBlock>(val))
540 {
541 rawstr << "\"basic block\": " << bb->getName().str() << ", \"location\": " << getSourceLoc(bb->getFirstNonPHI());
542 }
544 {
545 rawstr << "constant data";
546 }
547 else
548 {
549 rawstr << "N/A";
550 }
551 rawstr << " }";
552
553 if(rawstr.str()=="{ }")
554 return "";
555 return rawstr.str();
556}
557
558
563{
564 std::string str;
565 std::stringstream rawstr(str);
566 /*
567 * https://reviews.llvm.org/D18074?id=50385
568 * looks like the relevant
569 */
570 if (llvm::DISubprogram *SP = F->getSubprogram())
571 {
572 if (SP->describes(F))
573 rawstr << "\"ln\": " << SP->getLine() << ", \"file\": \"" << SP->getFilename().str() << "\"";
574 }
575 return rawstr.str();
576}
577
579void LLVMUtil::getNextInsts(const Instruction* curInst, std::vector<const Instruction*>& instList)
580{
581 if (!curInst->isTerminator())
582 {
583 const Instruction* nextInst = curInst->getNextNode();
586 else
587 instList.push_back(nextInst);
588 }
589 else
590 {
591 const BasicBlock *BB = curInst->getParent();
592 // Visit all successors of BB in the CFG
593 for (succ_const_iterator it = succ_begin(BB), ie = succ_end(BB); it != ie; ++it)
594 {
595 const Instruction* nextInst = &((*it)->front());
598 else
599 instList.push_back(nextInst);
600 }
601 }
602}
603
604
605
606std::string LLVMUtil::dumpValue(const Value* val)
607{
608 std::string str;
609 llvm::raw_string_ostream rawstr(str);
610 if (val)
611 rawstr << " " << *val << " ";
612 else
613 rawstr << " llvm Value is null";
614 return rawstr.str();
615}
616
617std::string LLVMUtil::dumpType(const Type* type)
618{
619 std::string str;
620 llvm::raw_string_ostream rawstr(str);
621 if (type)
622 rawstr << " " << *type << " ";
623 else
624 rawstr << " llvm type is null";
625 return rawstr.str();
626}
627
629{
630 std::string str;
631 llvm::raw_string_ostream rawstr(str);
632 if (val)
634 else
635 rawstr << " llvm Value is null";
636 return rawstr.str();
637}
638
640{
642 bool isPtrTy = inst->getType()->isPointerTy();
643 if (const CallBase* call = SVFUtil::dyn_cast<CallBase>(inst))
644 {
645 const Function* fun = call->getCalledFunction();
646 return fun && isPtrTy &&
647 (pSet->is_alloc(fun) ||
648 pSet->is_realloc(fun));
649 }
650 else
651 return false;
652}
653
655{
656 if (const CallBase* call = SVFUtil::dyn_cast<CallBase>(inst))
657 {
658 const Function* fun = call->getCalledFunction();
659 return fun &&
661 }
662 else
663 {
664 return false;
665 }
666}
667
669{
671 bool isPtrTy = inst->getType()->isPointerTy();
672 if (const CallBase* call = SVFUtil::dyn_cast<CallBase>(inst))
673 {
674 const Function* fun = call->getCalledFunction();
675 return fun && isPtrTy &&
676 pSet->is_alloc_stack_ret(fun);
677 }
678 else
679 return false;
680}
681
689{
690 // Check if the value is an argument in the program entry function
692 {
693 // Return true if the value does not have a first use via cast instruction
695 }
696 // Check if the value is an instruction and if it is a heap allocation external call
697 else if (SVFUtil::isa<Instruction>(val) &&
698 LLVMUtil::isHeapAllocExtCall(SVFUtil::cast<Instruction>(val)))
699 {
700 return true;
701 }
702 // Return false if none of the above conditions are met
703 return false;
704}
705
711{
712 if (SVFUtil::isa<AllocaInst>(val))
713 {
714 return true;
715 }
716 // Check if the value is an instruction and if it is a stack allocation external call
717 else if (SVFUtil::isa<Instruction>(val) &&
718 LLVMUtil::isStackAllocExtCall(SVFUtil::cast<Instruction>(val)))
719 {
720 return true;
721 }
722 // Return false if none of the above conditions are met
723 return false;
724}
725
727{
728 bool res = false;
729
730 if(isIntrinsicInst(inst))
731 res = false;
732 else
733 res = isCallSite(inst);
734 return res;
735}
736
737namespace SVF
738{
739
740
741const std::string SVFValue::valueOnlyToString() const
742{
743 std::string str;
744 llvm::raw_string_ostream rawstr(str);
745 assert(
746 !SVFUtil::isa<GepObjVar>(this) && !SVFUtil::isa<GepValVar>(this) &&
747 !SVFUtil::isa<DummyObjVar>(this) &&!SVFUtil::isa<DummyValVar>(this) &&
748 !SVFUtil::isa<BlackHoleValVar>(this) &&
749 "invalid value, refer to their toString method");
750 auto llvmVal =
752 if (llvmVal)
753 rawstr << " " << *llvmVal << " ";
754 else
755 rawstr << "";
756 rawstr << getSourceLoc();
757 return rawstr.str();
758}
759
760const bool SVFValue::hasLLVMValue() const
761{
763
764}
765}// 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:181
const ICFGNode * back() const
StInfo * getTypeInfo()
Definition SVFType.h:273
const bool hasLLVMValue() const
Definition LLVMUtil.cpp:760
virtual const std::string getSourceLoc() const
Definition SVFValue.h:194
const std::string valueOnlyToString() const
Definition LLVMUtil.cpp:741
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:639
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:562
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:617
void getNextInsts(const Instruction *curInst, std::vector< const Instruction * > &instList)
Get the next instructions following control flow.
Definition LLVMUtil.cpp:579
std::string dumpValueAndDbgInfo(const Value *val)
Definition LLVMUtil.cpp:628
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:688
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:710
bool isHeapAllocExtCallViaArg(const Instruction *inst)
Definition LLVMUtil.cpp:654
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:668
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:726
std::string dumpValue(const Value *val)
Definition LLVMUtil.cpp:606
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