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