41#include "llvm/Support/FileSystem.h"
43#include "llvm/Transforms/Utils/Cloning.h"
48#include <llvm/Passes/PassBuilder.h>
76#define SVF_MAIN_FUNC_NAME "svf.main"
77#define SVF_GLOBAL_CTORS "llvm.global_ctors"
78#define SVF_GLOBAL_DTORS "llvm.global_dtors"
106 dt.recalculate(
const_cast<Function&
>(*fun));
116 mset->
modules.emplace_back(mod);
134 if (!moduleNameVec.empty())
191 std::vector<const Function*> candidateDefs, candidateDecls;
196 for (
Function& func : mod.functions())
198 if (func.isDeclaration())
200 candidateDecls.push_back(&func);
204 candidateDefs.push_back(&func);
209 for (
const Function* func: candidateDefs)
213 for (
const Function* func: candidateDecls)
219 for (
const auto& func:
funSet)
221 for (Function::const_iterator bit = func->begin(), ebit = func->end(); bit != ebit; ++bit)
225 if (succ_size(bb) == 0)
231 "last inst must be return inst");
242 "last inst must be return inst");
262 std::unique_ptr<BreakConstantGEPs> p1 = std::make_unique<BreakConstantGEPs>();
269 std::unique_ptr<UnifyFunctionExitNodes> p2 =
270 std::make_unique<UnifyFunctionExitNodes>();
273 for (
auto F = M.begin(), E = M.end(); F != E; ++F)
276 if (fun.isDeclaration())
278 llvm::PassBuilder PB;
279 llvm::LoopAnalysisManager LAM;
280 llvm::FunctionAnalysisManager FAM;
281 llvm::CGSCCAnalysisManager CGAM;
282 llvm::ModuleAnalysisManager MAM;
283 PB.registerModuleAnalyses(MAM);
284 PB.registerCGSCCAnalyses(CGAM);
285 PB.registerFunctionAnalyses(FAM);
286 PB.registerLoopAnalyses(LAM);
287 PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
288 llvm::FunctionPassManager FPM;
289 FPM.addPass(llvm::UnifyFunctionExitNodesPass());
302 std::string preProcessSuffix =
".pre.bc";
304 for (
u32_t i = 0; i < moduleNameVec.size(); i++)
306 u32_t lastIndex = moduleNameVec[i].find_last_of(
".");
307 std::string rawName = moduleNameVec[i].substr(0, lastIndex);
308 moduleNameVec[i] = (rawName + preProcessSuffix);
322 if(moduleNameVec.empty())
360 owned_ctx = std::make_unique<LLVMContext>();
361 for (
const std::string& moduleName : moduleNameVec)
365 SVFUtil::errs() <<
"not an IR file: " << moduleName << std::endl;
370 std::unique_ptr<Module> mod = parseIRFile(moduleName, Err, *
owned_ctx);
373 SVFUtil::errs() <<
"load module: " << moduleName <<
"failed!!\n\n";
374 Err.print(
"SVFModuleLoader", llvm::errs());
395 assert(!
empty() &&
"LLVMModuleSet contains no modules; cannot load ExtAPI module without LLVMContext!");
403 SVFUtil::errs() <<
"not an external IR file: " << extModuleName << std::endl;
407 std::unique_ptr<Module> mod = parseIRFile(extModuleName, Err,
getContext());
410 SVFUtil::errs() <<
"load external module: " << extModuleName <<
"failed!!\n\n";
411 Err.print(
"SVFModuleLoader", llvm::errs());
444 class LLVMGlobalFunction
449 LLVMGlobalFunction() {};
451 : priority(_priority), func(_func) {};
452 bool operator>(
const LLVMGlobalFunction &other)
const
454 if (priority != other.priority)
456 return priority > other.priority;
460 return func > other.func;
465 std::priority_queue<LLVMGlobalFunction, std::vector<LLVMGlobalFunction>,
466 greater<LLVMGlobalFunction>>
468 std::vector<const Function* > result;
477 for (
unsigned int i = 0; i < globalFuncArray->getNumOperands(); ++i)
482 globalFuncArray->getOperand(i)))
487 globalFuncItem->getOperand(0));
489 globalFuncItem->getOperand(1));
491 if (priority && func)
501 while (!queue.empty())
503 result.push_back(queue.top().func);
511 std::vector<const Function*> ctor_funcs;
512 std::vector<const Function*> dtor_funcs;
514 Module* mainMod =
nullptr;
532 for (
auto &func : mod)
534 auto funName = func.getName();
538 if (funName ==
"main")
549 (ctor_funcs.size() > 0 || dtor_funcs.size() > 0))
551 assert(mainMod &&
"Module with main function not found.");
554 Type* ptr = PointerType::getUnqual(M.getContext());
555 Type* i32 = IntegerType::getInt32Ty(M.getContext());
559 Type::getVoidTy(M.getContext()),
563 svfmain->setCallingConv(llvm::CallingConv::C);
564 BasicBlock* block = BasicBlock::Create(M.getContext(),
"entry", svfmain);
568 for (
auto& ctor : ctor_funcs)
570 auto target = M.getOrInsertFunction(
572 Type::getVoidTy(M.getContext())
574 Builder.CreateCall(target);
578 Function::arg_iterator arg_it = svfmain->arg_begin();
579 Value* args[] = {arg_it, arg_it + 1, arg_it + 2};
580 size_t cnt = orgMain->arg_size();
581 assert(cnt <= 3 &&
"Too many arguments for main()");
582 Builder.CreateCall(orgMain, llvm::ArrayRef<Value*>(args, args + cnt));
585 for (
auto& dtor : dtor_funcs)
587 auto target = M.getOrInsertFunction(dtor->getName(), Type::getVoidTy(M.getContext()));
588 Builder.CreateCall(target);
591 Builder.CreateRetVoid();
602 GlobalVariable *glob = mod->getGlobalVariable(
"llvm.global.annotations");
603 if (glob ==
nullptr || !glob->hasInitializer())
610 for (
unsigned i = 0; i < ca->getNumOperands(); ++i)
613 if (structAn ==
nullptr || structAn->getNumOperands() == 0)
626 if (note->getOpcode() != Instruction::GetElementPtr)
638 if (!fun || annotateStr ==
nullptr || !annotateStr->hasInitializer())
642 if (data && data->isString())
644 std::string annotation = data->getAsString().str();
645 if (!annotation.empty())
673 Module* appModule =
nullptr;
674 Module* extModule =
nullptr;
683 for (
const Function& fun : mod.functions())
687 if (fun.getName().str() ==
"main")
689 appFunDecls.insert(&fun);
690 appFuncDeclNames.insert(fun.getName().str());
693 else if (fun.getName().str() ==
"svf__main")
699 extFuncs.insert(&fun);
700 extFunDefNames.insert(fun.getName().str());
708 for (
const Function& fun : mod.functions())
710 if (fun.isDeclaration())
712 appFunDecls.insert(&fun);
713 appFuncDeclNames.insert(fun.getName().str());
717 appFunDefs.insert(&fun);
718 appFuncDefNames.insert(fun.getName().str());
725 std::set_intersection(
726 appFuncDefNames.begin(), appFuncDefNames.end(), extFunDefNames.begin(), extFunDefNames.end(),
727 std::inserter(intersectNames, intersectNames.end()));
731 assert(!(appFunToReplace ==
NULL && appModule ==
NULL) &&
"appFunToReplace and appModule cannot both be NULL");
735 appModule = appFunToReplace->getParent();
737 Function* clonedFunction = Function::Create(extFunToClone->getFunctionType(),
738 Function::ExternalLinkage,
739 extFunToClone->getName());
741 llvm::ValueToValueMapTy valueMap;
742 Function::arg_iterator destArg = clonedFunction->arg_begin();
743 for (Function::const_arg_iterator srcArg = extFunToClone->arg_begin(); srcArg != extFunToClone->arg_end(); ++srcArg)
745 destArg->setName(srcArg->getName());
746 valueMap[&*srcArg] = &*destArg++;
752 std::set<GlobalVariable*> referencedGlobals;
757 for (
const Value* operand : I.operands())
773 GlobalVariable* existingGV = appModule->getGlobalVariable(GV->getName());
777 assert(existingGV->getType() == GV->getType() &&
"Global variable type mismatch in client module!");
779 valueMap[GV] = existingGV;
792 GV->getThreadLocalMode(),
793 GV->getAddressSpace()
797 if (GV->hasInitializer())
799 Constant* init = GV->getInitializer();
800 newGV->setInitializer(init);
804 newGV->copyAttributesFrom(GV);
807 valueMap[GV] = newGV;
812 llvm::SmallVector<ReturnInst*, 8> ignoredReturns;
813 CloneFunctionInto(clonedFunction, extFunToClone, valueMap, llvm::CloneFunctionChangeType::LocalChangesOnly, ignoredReturns,
"",
nullptr);
818 appFunToReplace->replaceAllUsesWith(clonedFunction);
819 std::string oldFunctionName = appFunToReplace->getName().str();
821 appFunToReplace->eraseFromParent();
822 appModule->getFunctionList().push_back(clonedFunction);
823 clonedFunction->setName(oldFunctionName);
827 appModule->getFunctionList().push_back(clonedFunction);
829 return clonedFunction;
833 for (
const Function* appFunDecl : appFunDecls)
836 for (
const Function* extFun : extFuncs)
838 if (extFun->getName().str().compare(appFunDeclName) == 0)
844 Function* clonedFunction = cloneAndReplaceFunction(
const_cast<Function*
>(extFun),
const_cast<Function*
>(appFunDecl),
nullptr,
true);
845 extFuncs2ClonedFuncs[extFun] = clonedFunction;
846 clonedFuncs.insert(clonedFunction);
859 for (
string sameFuncDef: intersectNames)
861 Function* appFuncDef = appModule->getFunction(sameFuncDef);
862 Function* extFuncDef = extModule->getFunction(sameFuncDef);
863 if (appFuncDef ==
nullptr || extFuncDef ==
nullptr)
866 FunctionType *appFuncDefType = appFuncDef->getFunctionType();
867 FunctionType *extFuncDefType = extFuncDef->getFunctionType();
868 if (appFuncDefType != extFuncDefType)
874 std::vector<std::string> annotations = it->second;
875 if (annotations.size() == 1 && annotations[0].find(
"OVERWRITE") != std::string::npos)
877 Function* clonedFunction = cloneAndReplaceFunction(
const_cast<Function*
>(extFuncDef),
const_cast<Function*
>(appFuncDef),
nullptr,
true);
878 extFuncs2ClonedFuncs[extFuncDef] = clonedFunction;
879 clonedFuncs.insert(clonedFunction);
883 if (annotations.size() >= 2)
885 for (
const auto& annotation : annotations)
887 if(annotation.find(
"OVERWRITE") != std::string::npos)
889 assert(
false &&
"overwrite and other annotations cannot co-exist");
899 for (
inst_iterator I = inst_begin(caller), E = inst_end(caller); I != E; ++I)
905 Function *calledFunc = callInst->getCalledFunction();
907 if (calledFunc && calledFunc->getName() == callee->getName())
909 callInst->setCalledFunction(callee);
916 cloneAndLinkFunction = [&](
const Function* extFunToClone,
Function* appClonedFun)
918 if (clonedFuncs.find(extFunToClone) != clonedFuncs.end())
921 Module* appModule = appClonedFun->getParent();
923 if (appModule->getFunction(extFunToClone->getName()))
926 Function* func = appModule->getFunction(extFunToClone->getName());
927 linkFunctions(appClonedFun, func);
931 bool cloneBody =
true;
935 std::vector<std::string> annotations = it->second;
936 if (!(annotations.size() == 1 && annotations[0].find(
"OVERWRITE") != std::string::npos))
942 Function* clonedFunction = cloneAndReplaceFunction(extFunToClone,
nullptr, appModule, cloneBody);
944 clonedFuncs.insert(clonedFunction);
948 linkFunctions(appClonedFun, clonedFunction);
952 for (
const auto& calledFunction : calledFunctions)
954 cloneAndLinkFunction(calledFunction, clonedFunction);
959 for (
const auto& pair : extFuncs2ClonedFuncs)
965 for (
const auto& extCalledFun : extCalledFuns)
967 cloneAndLinkFunction(extCalledFun, clonedExtFun);
979 std::string newKey =
name;
980 if (
name != extFun->getName().str())
982 newKey = extFun->getName().str();
984 newFun2AnnoMap.insert({newKey, it->second});
991 [&extModule](
const std::reference_wrapper<llvm::Module>& moduleRef)
993 return &moduleRef.get() == extModule;
1007 NameToGlobalsMapTy nameToGlobalsMap;
1013 if (global.hasPrivateLinkage())
1015 string name = global.getName().str();
1018 nameToGlobalsMap[std::move(
name)].insert(&global);
1022 for (
const auto& pair : nameToGlobalsMap)
1027 std::find_if(globals.begin(), globals.end(),
1030 return g->hasInitializer();
1033 repIt != globals.end()
1036 : (assert(!globals.empty() &&
"Empty global set"),
1051 std::string moduleName = mod.getName().str();
1052 std::string OutputFilename;
1053 std::size_t pos = moduleName.rfind(
'.');
1054 if (pos != std::string::npos)
1055 OutputFilename = moduleName.substr(0, pos) + suffix;
1057 OutputFilename = moduleName + suffix;
1060 raw_fd_ostream OS(OutputFilename.c_str(), EC, llvm::sys::fs::OF_None);
1061 WriteBitcodeToFile(mod, OS);
1069 return svfir->nullPtrSymID();
1075 return svfir->nullPtrSymID();
1076 return svfir->blkPtrSymID();
1080 ValueToIDMapTy::const_iterator iter =
valSymMap.find(llvm_value);
1081 assert(iter!=
valSymMap.end() &&
"value sym not found");
1082 return iter->second;
1097 ValueToIDMapTy::const_iterator iter =
objSymMap.find(llvm_value);
1098 assert(iter!=
objSymMap.end() &&
"obj sym not found");
1099 return iter->second;
1109 const NodeID i = iter->second;
1110 idmap[i] = iter->first;
1115 const NodeID i = iter->second;
1116 idmap[i] = iter->first;
1118 for (FunToIDMapTy::iterator iter =
retSyms().begin(); iter !=
retSyms().end();
1121 const NodeID i = iter->second;
1122 idmap[i] = iter->first;
1127 const NodeID i = iter->second;
1128 idmap[i] = iter->first;
1135 for (
auto iter : idmap)
1138 llvm::raw_string_ostream rawstr(str);
1139 auto llvmVal = iter.second;
1141 rawstr <<
" " << *llvmVal <<
" ";
1143 rawstr <<
" No llvmVal found";
1145 SVFUtil::outs() << iter.first <<
" " << rawstr.str() <<
"\n";
1155 svfBaseNode->
setName(val->getName().str());
1165 fun = mod->getFunction(
name);
1179 if (it->second == T)
1182 assert(
false &&
"can't find the corresponding LLVM Type");
1191 assert(T &&
"SVFType should not be null");
1214 assert (node!=
nullptr &&
"no ICFGNode for this instruction?");
1228 return node !=
nullptr;
1236 assert (node!=
nullptr &&
"no CallICFGNode for this instruction?");
1245 assert (node!=
nullptr &&
"no RetICFGNode for this instruction?");
1252 assert (node!=
nullptr &&
"no IntraICFGNode for this instruction?");
1273 if (nf >
svfir->maxStSize)
1276 svfir->maxStSize = nf;
1284 svfir->addStInfo(stInfo);
1291 "SVFType has been added before");
1299 Type *mut_T =
const_cast<Type *
>(T);
1300 byteSize = DL.getTypeAllocSize(mut_T);
1313 unsigned signWidth = intT->getBitWidth();
1314 assert(signWidth < INT16_MAX &&
"Integer width too big");
1315 svfIntT->setSignAndWidth(intT->getSignBit() ? -signWidth : signWidth);
1320 std::vector<const SVFType*> paramTypes;
1321 for (
const auto& t: ft->params())
1329 std::vector<const SVFType*> fieldTypes;
1331 for (
const auto& t: st->elements())
1337 svfst->setName(st->getName().str());
1343 svfat->setNumOfElement(at->getNumElements());
1344 svfat->setTypeOfElement(
getSVFType(at->getElementType()));
1350 auto ot =
new SVFOtherType(
id, T->isSingleValueType(), byteSize);
1351 llvm::raw_string_ostream(
buffer) << *T;
1352 ot->setRepr(std::move(
buffer));
1356 svfir->addTypeInfo(svftype);
1367 u64_t totalElemNum = ty->getNumElements();
1368 const Type* elemTy = ty->getElementType();
1371 totalElemNum *= aty->getNumElements();
1372 elemTy = aty->getElementType();
1379 if (totalElemNum == 0)
1393 for (
u32_t j = 0; j < nfF; j++)
1401 u32_t outArrayElemNum = ty->getNumElements();
1402 for (
u32_t i = 0; i < outArrayElemNum; ++i)
1404 auto idx = (i * nfE * totalElemNum) / outArrayElemNum;
1408 for (
u32_t i = 0; i < totalElemNum; ++i)
1410 for (
u32_t j = 0; j < nfE; ++j)
1418 "typeForArray size incorrect!!!");
1437 u32_t strideOffset = 0;
1438 for (
const Type* elemTy : structTy->elements())
1450 for (
u32_t j = 0; j < nfF; ++j)
1456 strideOffset += nfE;
1457 for (
u32_t tpj = 0; tpj < nfE; ++tpj)
1475 "typeForStruct size incorrect!");
1501 assert(fun &&
"Null SVFFunction* pointer");
1507 assert(fun &&
"Null SVFFunction* pointer");
1511 for (
const std::string& annotation : it->second)
1512 if (annotation.find(funcAnnotation) != std::string::npos)
1520 assert(fun &&
"Null Function* pointer");
1524 for (
const std::string& annotation : it->second)
1525 if (annotation.find(funcAnnotation) != std::string::npos)
1533 assert(fun &&
"Null Function* pointer");
1572 assert(!allocArg.empty() &&
"Not an alloc call via argument or incorrect extern function annotation!");
1575 for (
char c : allocArg)
1580 assert(!
number.empty() &&
"Incorrect naming convention for svf external functions(ALLOC_HEAP_ARG + number)?");
1581 return std::stoi(
number);
1595 assert(F &&
"Null SVFFunction* pointer");
1596 if (F->isDeclaration() || F->isIntrinsic())
#define SVF_MAIN_FUNC_NAME
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
const char *const const double number
std::string getExtBcPath()
static ExtAPI * getExtAPI()
bool hasValueNode(const Value *V)
TargetABI targetABI
C++ ABI of the module being analyzed.
NodeID getValueNode(const Value *V)
IntraICFGNode * getIntraBlock(const Instruction *inst)
LLVMType2SVFTypeMap LLVMType2SVFType
bool is_alloc_stack_ret(const Function *F)
std::vector< const Function * > getLLVMGlobalFunctions(const GlobalVariable *global)
void buildSymbolTable() const
Module * getMainLLVMModule() const
const FunObjVar * getFunObjVar(const Function *fun) const
ValueToIDMapTy valSymMap
map a value to its sym id
StInfo * collectTypeInfo(const Type *ty)
Collect a type info.
static LLVMModuleSet * getLLVMModuleSet()
void loadModules(const std::vector< std::string > &moduleNameVec)
ObjTypeInference * typeInference
static void releaseLLVMModuleSet()
static void preProcessBCs(std::vector< std::string > &moduleNameVec)
DominatorTree & getDomTree(const Function *fun)
void addToSVFVar2LLVMValueMap(const Value *val, SVFValue *svfBaseNode)
RetICFGNode * getRetBlock(const Instruction *cs)
Get/Add a return node.
std::unique_ptr< LLVMContext > owned_ctx
void createSVFDataStructure()
StInfo * collectSimpleTypeInfo(const Type *T)
Collect simple type (non-aggregate) info.
bool is_alloc(const Function *F)
const std::vector< std::string > & getExtFuncAnnotations(const Function *fun)
SVFType * getSVFType(const Type *T)
Get or create SVFType and typeinfo.
void setFunExitBB(const Function *fun, const BasicBlock *bb)
const Type * getLLVMType(const SVFType *T) const
Get LLVM Type.
void setExtFuncAnnotations(const Function *fun, const std::vector< std::string > &funcAnnotations)
bool hasICFGNode(const Instruction *inst)
CallICFGNode * getCallBlock(const Instruction *cs)
Get/Add a call node.
ValueToIDMapTy objSymMap
map a obj reference to its sym id
ICFGNode * getICFGNode(const Instruction *inst)
Get a basic block ICFGNode.
const Function * getFunction(const std::string &name)
Get the corresponding Function based on its name.
CallICFGNode * getCallICFGNode(const Instruction *cs)
get a call node
Fun2AnnoMap ExtFun2Annotations
Record annotations of function in extapi.bc.
bool is_arg_alloc(const Function *F)
Map< const Function *, std::vector< std::string > > func2Annotations
const BasicBlock * getFunExitBB(const Function *fun) const
NodeID getObjectNode(const Value *V)
RetICFGNode * getRetICFGNode(const Instruction *cs)
get a return node
void prePassSchedule()
Invoke llvm passes to modify module.
StInfo * collectStructInfo(const StructType *structTy, u32_t &numFields)
Collect the struct info and set the number of fields after flattening.
s32_t get_alloc_arg_pos(const Function *F)
void addFunctionSet(const Function *svfFunc)
const std::vector< std::reference_wrapper< Module > > & getLLVMModules() const
LLVMContext & getContext() const
friend class SymbolTableBuilder
bool is_ext(const Function *F)
Map< const Function *, DominatorTree > FunToDominatorTree
static void buildSVFModule(Module &mod)
SVFBaseNode2LLVMValueMap SVFBaseNode2LLVMValue
StInfo * collectArrayInfo(const ArrayType *T)
Collect the array info.
LLVMModuleSet()
Constructor.
void buildGlobalDefToRepMap()
SVFType * addSVFTypeInfo(const Type *t)
Create SVFTypes.
FunctionSetType ExtFuncsVec
Record some "sse_" function declarations used in other ext function definition, e....
bool hasExtFuncAnnotation(const Function *fun, const std::string &funcAnnotation)
static LLVMModuleSet * llvmModuleSet
IntraICFGNode * getIntraICFGNode(const Instruction *inst)
get a intra node
std::vector< std::reference_wrapper< Module > > modules
std::string getExtFuncAnnotation(const Function *fun, const std::string &funcAnnotation)
Map< std::string, std::vector< std::string > > Fun2AnnoMap
u32_t getModuleNum() const
GlobalDefToRepMapTy GlobalDefToRepMap
Global definition to a rep definition map.
std::vector< std::unique_ptr< Module > > owned_modules
bool is_memset(const Function *F)
FunToIDMapTy & varargSyms()
Type2TypeInfoMap Type2TypeInfo
void dumpModulesToFile(const std::string &suffix)
void collectExtFunAnnotations(const Module *mod)
bool is_memcpy(const Function *F)
ObjTypeInference * getTypeInference()
bool is_realloc(const Function *F)
static NodeIDAllocator * get(void)
Return (singleton) allocator.
NodeID allocateTypeId(void)
Allocate an type ID as determined by the strategy.
static const Option< bool > UndefAsNull
static const Option< std::string > Graphtxt
static Option< bool > SVFMain
static bool pagReadFromTXT()
void setModuleIdentifier(const std::string &moduleIdentifier)
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
static void setPagFromTXT(const std::string &txt)
static double timeOfBuildingLLVMModule
static double getClk(bool mark=false)
static double timeOfBuildingSymbolTable
static SVFType * svfPtrTy
ptr type
static SVFType * svfI8Ty
8-bit int type
void setTypeInfo(StInfo *ti)
virtual void setSourceLoc(const std::string &sourceCodeInfo)
virtual void setName(const std::string &nameInfo)
std::vector< const SVFType * > & getFlattenElementTypes()
void setNumOfFieldsAndElems(u32_t nf, u32_t ne)
Set number of fields and elements of an aggregate.
u32_t getNumOfFlattenElements() const
Return number of elements after flattening (including array elements).
std::vector< const SVFType * > & getFlattenFieldTypes()
void addFldWithType(u32_t fldIdx, const SVFType *type, u32_t elemIdx)
Add field index and element index and their corresponding type.
u32_t getNumOfFlattenFields() const
Return the number of fields after flattening (ignoring array elements).
void buildMemModel()
Start building memory model.
bool isIntrinsicInst(const Instruction *inst)
Return true if it is an intrinsic instruction.
std::vector< const Function * > getCalledFunctions(const Function *F)
Get all called funcions in a parent function.
bool isCallSite(const Instruction *inst)
Whether an instruction is a call or invoke instruction.
bool functionDoesNotRet(const Function *fun)
std::pair< s64_t, u64_t > getIntegerValue(const ConstantInt *intValue)
static TargetABI detectTargetABI(const llvm::Triple &triple)
const std::string getSourceLoc(const Value *val)
const Value * getGlobalRep(const Value *val)
find the unique defined global across multiple modules
bool basicBlockHasRetInst(const BasicBlock *bb)
Return true if the function has a return instruction.
static llvm::Triple getTargetTriple(const Module *mod)
bool isIRFile(const std::string &filename)
Check whether a file is an LLVM IR file.
std::string restoreFuncName(std::string funcName)
bool isNonInstricCallSite(const Instruction *inst)
Whether an instruction is a callsite in the application code, excluding llvm intrinsic calls.
std::string pasMsg(const std::string &msg)
Print each pass/phase message by converting a string into blue string output.
std::enable_if_t<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type > cast(const Y &Val)
LLVM_NODISCARD bool isa(const Y &Val)
std::ostream & errs()
Overwrite llvm::errs().
std::ostream & outs()
Overwrite llvm::outs().
LLVM_NODISCARD std::enable_if_t<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type > dyn_cast(const Y &Val)
std::map< Key, Value, Compare, Allocator > OrderedMap
llvm::GlobalVariable GlobalVariable
llvm::ArrayType ArrayType
llvm::raw_fd_ostream raw_fd_ostream
LLVM outputs.
llvm::BasicBlock BasicBlock
llvm::inst_iterator inst_iterator
llvm::ConstantStruct ConstantStruct
llvm::StructType StructType
LLVM types.
llvm::IntegerType IntegerType
std::set< Key, Compare, Allocator > OrderedSet
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
llvm::ConstantArray ConstantArray
llvm::FunctionType FunctionType
llvm::Instruction Instruction
llvm::SMDiagnostic SMDiagnostic
llvm::ConstantDataSequential ConstantDataSequential
llvm::Value Value
LLVM Basic classes.
llvm::ConstantExpr ConstantExpr
llvm::IRBuilder IRBuilder
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
llvm::FunctionCallee FunctionCallee
llvm::ConstantInt ConstantInt
llvm::DominatorTree DominatorTree
LLVM Dominators.
IntervalValue operator>(const IntervalValue &lhs, const IntervalValue &rhs)