Static Value-Flow Analysis
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
SVF::LLVMModuleSet Class Reference

#include <LLVMModule.h>

Public Types

typedef std::vector< const Function * > FunctionSetType
 
typedef Map< const Function *, const Function * > FunDeclToDefMapTy
 
typedef Map< const Function *, FunctionSetType > FunDefToDeclsMapTy
 
typedef Map< const GlobalVariable *, GlobalVariable * > GlobalDefToRepMapTy
 
typedef Map< const Function *, FunObjVar * > LLVMFun2FunObjVarMap
 
typedef Map< const BasicBlock *, SVFBasicBlock * > LLVMBB2SVFBBMap
 
typedef Map< const SVFValue *, const Value * > SVFBaseNode2LLVMValueMap
 
typedef Map< const Type *, SVFType * > LLVMType2SVFTypeMap
 
typedef Map< const Type *, StInfo * > Type2TypeInfoMap
 
typedef Map< std::string, std::vector< std::string > > Fun2AnnoMap
 
typedef Map< const Instruction *, CallICFGNode * > CSToCallNodeMapTy
 
typedef Map< const Instruction *, RetICFGNode * > CSToRetNodeMapTy
 
typedef Map< const Instruction *, IntraICFGNode * > InstToBlockNodeMapTy
 
typedef Map< const Function *, FunEntryICFGNode * > FunToFunEntryNodeMapTy
 
typedef Map< const Function *, FunExitICFGNode * > FunToFunExitNodeMapTy
 
typedef OrderedMap< const Value *, NodeID > ValueToIDMapTy
 
typedef OrderedMap< const Function *, NodeID > FunToIDMapTy
 
typedef std::vector< const Function * > FunctionSet
 
typedef Map< const Function *, const BasicBlock * > FunToExitBBMap
 
typedef Map< const Function *, const Function * > FunToRealDefFunMap
 

Public Member Functions

 ~LLVMModuleSet ()
 
u32_t getModuleNum () const
 
const std::vector< std::reference_wrapper< Module > > & getLLVMModules () const
 
Module * getModule (u32_t idx) const
 
Module & getModuleRef (u32_t idx) const
 
void dumpModulesToFile (const std::string &suffix)
 
const BasicBlock * getFunExitBB (const Function *fun) const
 
const Function * getRealDefFun (const Function *fun) const
 
const FunctionSet & getFunctionSet () const
 
u32_t getValueNodeNum () const
 
u32_t getObjNodeNum () const
 
ValueToIDMapTy & valSyms ()
 
ValueToIDMapTy & objSyms ()
 
NodeID getValueNode (const Value *V)
 
bool hasValueNode (const Value *V)
 
NodeID getObjectNode (const Value *V)
 
void dumpSymTable ()
 
void addBasicBlock (FunObjVar *fun, const BasicBlock *bb)
 
void addInstructionMap (const Instruction *inst, CallICFGNode *svfInst)
 
void addInstructionMap (const Instruction *inst, RetICFGNode *svfInst)
 
void addInstructionMap (const Instruction *inst, IntraICFGNode *svfInst)
 
bool hasLLVMValue (const SVFValue *value) const
 
const Value * getLLVMValue (const SVFValue *value) const
 
const FunObjVar * getFunObjVar (const Function *fun) const
 
FunToIDMapTy & retSyms ()
 
FunToIDMapTy & varargSyms ()
 
NodeID getReturnNode (const Function *func) const
 
NodeID getVarargNode (const Function *func) const
 
SVFBasicBlock * getSVFBasicBlock (const BasicBlock *bb)
 
const Function * getFunction (const std::string &name)
 Get the corresponding Function based on its name.
 
const FunObjVar * getFunObjVar (const std::string &name)
 Get the corresponding Function based on its name.
 
ICFGNode * getICFGNode (const Instruction *inst)
 Get a basic block ICFGNode.
 
bool hasICFGNode (const Instruction *inst)
 
CallICFGNode * getCallICFGNode (const Instruction *cs)
 get a call node
 
RetICFGNode * getRetICFGNode (const Instruction *cs)
 get a return node
 
IntraICFGNode * getIntraICFGNode (const Instruction *inst)
 get a intra node
 
FunEntryICFGNode * getFunEntryICFGNode (const Function *fun)
 Add a function entry node.
 
FunExitICFGNode * getFunExitICFGNode (const Function *fun)
 Add a function exit node.
 
bool hasGlobalRep (const GlobalVariable *val) const
 Global to rep.
 
GlobalVariable * getGlobalRep (const GlobalVariable *val) const
 
Module * getMainLLVMModule () const
 
TargetABI getTargetABI () const
 
LLVMContext & getContext () const
 
bool empty () const
 
SVFType * getSVFType (const Type *T)
 Get or create SVFType and typeinfo.
 
const Type * getLLVMType (const SVFType *T) const
 Get LLVM Type.
 
ObjTypeInference * getTypeInference ()
 
DominatorTree & getDomTree (const Function *fun)
 
std::string getExtFuncAnnotation (const Function *fun, const std::string &funcAnnotation)
 
const std::vector< std::string > & getExtFuncAnnotations (const Function *fun)
 
bool hasExtFuncAnnotation (const Function *fun, const std::string &funcAnnotation)
 
bool has_static (const Function *F)
 
bool is_memcpy (const Function *F)
 
bool is_memset (const Function *F)
 
bool is_alloc (const Function *F)
 
bool is_arg_alloc (const Function *F)
 
bool is_alloc_stack_ret (const Function *F)
 
s32_t get_alloc_arg_pos (const Function *F)
 
bool is_realloc (const Function *F)
 
bool is_ext (const Function *F)
 
void setExtFuncAnnotations (const Function *fun, const std::vector< std::string > &funcAnnotations)
 

Static Public Member Functions

static LLVMModuleSet * getLLVMModuleSet ()
 
static void releaseLLVMModuleSet ()
 
static void buildSVFModule (Module &mod)
 
static void buildSVFModule (const std::vector< std::string > &moduleNameVec)
 
static void preProcessBCs (std::vector< std::string > &moduleNameVec)
 

Private Member Functions

 LLVMModuleSet ()
 Constructor.
 
void build ()
 
void addFunctionSet (const Function *svfFunc)
 
void setFunExitBB (const Function *fun, const BasicBlock *bb)
 
void setFunRealDefFun (const Function *fun, const Function *realDefFun)
 
SVFType * addSVFTypeInfo (const Type *t)
 Create SVFTypes.
 
StInfo * collectTypeInfo (const Type *ty)
 Collect a type info.
 
StInfo * collectStructInfo (const StructType *structTy, u32_t &numFields)
 Collect the struct info and set the number of fields after flattening.
 
StInfo * collectArrayInfo (const ArrayType *T)
 Collect the array info.
 
StInfo * collectSimpleTypeInfo (const Type *T)
 Collect simple type (non-aggregate) info.
 
std::vector< const Function * > getLLVMGlobalFunctions (const GlobalVariable *global)
 
void loadModules (const std::vector< std::string > &moduleNameVec)
 
void loadExtAPIModules ()
 
void addSVFMain ()
 
void createSVFDataStructure ()
 
void addToSVFVar2LLVMValueMap (const Value *val, SVFValue *svfBaseNode)
 
void buildFunToFunMap ()
 
void buildGlobalDefToRepMap ()
 
void prePassSchedule ()
 Invoke llvm passes to modify module.
 
void buildSymbolTable () const
 
void collectExtFunAnnotations (const Module *mod)
 
CallICFGNode * getCallBlock (const Instruction *cs)
 Get/Add a call node.
 
RetICFGNode * getRetBlock (const Instruction *cs)
 Get/Add a return node.
 
IntraICFGNode * getIntraBlock (const Instruction *inst)
 
FunEntryICFGNode * getFunEntryBlock (const Function *fun)
 Get/Add a function entry node.
 
FunExitICFGNode * getFunExitBlock (const Function *fun)
 Get/Add a function exit node.
 

Private Attributes

SVFIR * svfir
 
std::unique_ptr< LLVMContext > owned_ctx
 
std::vector< std::unique_ptr< Module > > owned_modules
 
std::vector< std::reference_wrapper< Module > > modules
 
TargetABI targetABI = TargetABI::Itanium
 C++ ABI of the module being analyzed.
 
FunctionSetType ExtFuncsVec
 Record some "sse_" function declarations used in other ext function definition, e.g., svf_ext_foo(), and svf_ext_foo() used in app functions.
 
Fun2AnnoMap ExtFun2Annotations
 Record annotations of function in extapi.bc.
 
Map< const Function *, std::vector< std::string > > func2Annotations
 
GlobalDefToRepMapTy GlobalDefToRepMap
 Global definition to a rep definition map.
 
LLVMFun2FunObjVarMap LLVMFun2FunObjVar
 Map an LLVM Function to an SVF Funobjvar.
 
LLVMBB2SVFBBMap LLVMBB2SVFBB
 
LLVMType2SVFTypeMap LLVMType2SVFType
 
Type2TypeInfoMap Type2TypeInfo
 
ObjTypeInference * typeInference
 
SVFBaseNode2LLVMValueMap SVFBaseNode2LLVMValue
 
CSToCallNodeMapTy CSToCallNodeMap
 map a callsite to its CallICFGNode
 
CSToRetNodeMapTy CSToRetNodeMap
 map a callsite to its RetICFGNode
 
InstToBlockNodeMapTy InstToBlockNodeMap
 map a basic block to its ICFGNode
 
FunToFunEntryNodeMapTy FunToFunEntryNodeMap
 map a function to its FunExitICFGNode
 
FunToFunExitNodeMapTy FunToFunExitNodeMap
 map a function to its FunEntryICFGNode
 
Map< const Function *, DominatorTree > FunToDominatorTree
 
ValueToIDMapTy valSymMap
 map a value to its sym id
 
ValueToIDMapTy objSymMap
 map a obj reference to its sym id
 
FunToIDMapTy returnSymMap
 return map
 
FunToIDMapTy varargSymMap
 vararg map
 
FunctionSet funSet
 
FunToExitBBMap funToExitBB
 
FunToRealDefFunMap funToRealDefFun
 

Static Private Attributes

static LLVMModuleSet * llvmModuleSet = nullptr
 
static bool preProcessed = false
 

Friends

class SVFIRBuilder
 
class ICFGBuilder
 
class SymbolTableBuilder
 

Detailed Description

Definition at line 47 of file LLVMModule.h.

Member Typedef Documentation

◆ CSToCallNodeMapTy

Definition at line 67 of file LLVMModule.h.

◆ CSToRetNodeMapTy

Definition at line 68 of file LLVMModule.h.

◆ Fun2AnnoMap

typedef Map<std::string, std::vector<std::string> > SVF::LLVMModuleSet::Fun2AnnoMap

Definition at line 65 of file LLVMModule.h.

◆ FunctionSet

Definition at line 79 of file LLVMModule.h.

◆ FunctionSetType

Definition at line 55 of file LLVMModule.h.

◆ FunDeclToDefMapTy

Definition at line 56 of file LLVMModule.h.

◆ FunDefToDeclsMapTy

Definition at line 57 of file LLVMModule.h.

◆ FunToExitBBMap

Definition at line 80 of file LLVMModule.h.

◆ FunToFunEntryNodeMapTy

Definition at line 70 of file LLVMModule.h.

◆ FunToFunExitNodeMapTy

Definition at line 71 of file LLVMModule.h.

◆ FunToIDMapTy

Definition at line 77 of file LLVMModule.h.

◆ FunToRealDefFunMap

Definition at line 81 of file LLVMModule.h.

◆ GlobalDefToRepMapTy

Definition at line 58 of file LLVMModule.h.

◆ InstToBlockNodeMapTy

Definition at line 69 of file LLVMModule.h.

◆ LLVMBB2SVFBBMap

Definition at line 61 of file LLVMModule.h.

◆ LLVMFun2FunObjVarMap

Definition at line 60 of file LLVMModule.h.

◆ LLVMType2SVFTypeMap

Definition at line 63 of file LLVMModule.h.

◆ SVFBaseNode2LLVMValueMap

Definition at line 62 of file LLVMModule.h.

◆ Type2TypeInfoMap

Definition at line 64 of file LLVMModule.h.

◆ ValueToIDMapTy

llvm value to sym id map local (%) and global (@) identifiers are pointer types which have a value node id.

Definition at line 75 of file LLVMModule.h.

Constructor & Destructor Documentation

◆ LLVMModuleSet()

LLVMModuleSet::LLVMModuleSet ( )
private

Constructor.

Definition at line 85 of file LLVMModule.cpp.

87{
88}
ObjTypeInference * typeInference
Definition LLVMModule.h:109
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
Definition SVFIR.h:121

◆ ~LLVMModuleSet()

LLVMModuleSet::~LLVMModuleSet ( )

Definition at line 90 of file LLVMModule.cpp.

91{
92
93 delete typeInference;
94 typeInference = nullptr;
95
96}

Member Function Documentation

◆ addBasicBlock()

void SVF::LLVMModuleSet::addBasicBlock ( FunObjVar *  fun,
const BasicBlock *  bb 
)
inline

Definition at line 239 of file LLVMModule.h.

240 {
241 SVFBasicBlock* svfBB = fun->getBasicBlockGraph()->addBasicBlock(bb->getName().str());
242 LLVMBB2SVFBB[bb] = svfBB;
244 }
LLVMBB2SVFBBMap LLVMBB2SVFBB
Definition LLVMModule.h:106
SVFBaseNode2LLVMValueMap SVFBaseNode2LLVMValue
Definition LLVMModule.h:111
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

◆ addFunctionSet()

void SVF::LLVMModuleSet::addFunctionSet ( const Function *  svfFunc)
inlineprivate

Definition at line 452 of file LLVMModule.h.

453 {
454 funSet.push_back(svfFunc);
455 }
FunctionSet funSet
Definition LLVMModule.h:125

◆ addInstructionMap() [1/3]

void SVF::LLVMModuleSet::addInstructionMap ( const Instruction *  inst,
CallICFGNode *  svfInst 
)
inline

Definition at line 246 of file LLVMModule.h.

247 {
248 CSToCallNodeMap[inst] = svfInst;
250 }
void addToSVFVar2LLVMValueMap(const Value *val, SVFValue *svfBaseNode)
CSToCallNodeMapTy CSToCallNodeMap
map a callsite to its CallICFGNode
Definition LLVMModule.h:112

◆ addInstructionMap() [2/3]

void SVF::LLVMModuleSet::addInstructionMap ( const Instruction *  inst,
IntraICFGNode *  svfInst 
)
inline

Definition at line 256 of file LLVMModule.h.

257 {
260 }
InstToBlockNodeMapTy InstToBlockNodeMap
map a basic block to its ICFGNode
Definition LLVMModule.h:114

◆ addInstructionMap() [3/3]

void SVF::LLVMModuleSet::addInstructionMap ( const Instruction *  inst,
RetICFGNode *  svfInst 
)
inline

Definition at line 251 of file LLVMModule.h.

252 {
253 CSToRetNodeMap[inst] = svfInst;
255 }
CSToRetNodeMapTy CSToRetNodeMap
map a callsite to its RetICFGNode
Definition LLVMModule.h:113

◆ addSVFMain()

void LLVMModuleSet::addSVFMain ( )
private

Definition at line 515 of file LLVMModule.cpp.

516{
517 std::vector<const Function*> ctor_funcs;
518 std::vector<const Function*> dtor_funcs;
519 Function* orgMain = 0;
520 Module* mainMod = nullptr;
521
522 for (Module &mod : modules)
523 {
524 // Collect ctor and dtor functions
525 for (const GlobalVariable& global : mod.globals())
526 {
527 if (global.getName() == SVF_GLOBAL_CTORS && global.hasInitializer())
528 {
530 }
531 else if (global.getName() == SVF_GLOBAL_DTORS && global.hasInitializer())
532 {
534 }
535 }
536
537 // Find main function
538 for (auto &func : mod)
539 {
540 auto funName = func.getName();
541
542 assert(!(funName == SVF_MAIN_FUNC_NAME) && SVF_MAIN_FUNC_NAME " already defined");
543
544 if (funName == "main")
545 {
546 orgMain = &func;
547 mainMod = &mod;
548 }
549 }
550 }
551
552 // Only create svf.main when the original main function is found, and also
553 // there are global constructor or destructor functions.
554 if (orgMain && getModuleNum() > 0 &&
555 (ctor_funcs.size() > 0 || dtor_funcs.size() > 0))
556 {
557 assert(mainMod && "Module with main function not found.");
558 Module& M = *mainMod;
559 // char **
560 Type* ptr = PointerType::getUnqual(M.getContext());
561 Type* i32 = IntegerType::getInt32Ty(M.getContext());
562 // define void @svf.main(i32, i8**, i8**)
563#if (LLVM_VERSION_MAJOR >= 9)
564 FunctionCallee svfmainFn = M.getOrInsertFunction(
566 Type::getVoidTy(M.getContext()),
567 i32,ptr,ptr
568 );
569 Function* svfmain = SVFUtil::dyn_cast<Function>(svfmainFn.getCallee());
570#else
571 Function* svfmain = SVFUtil::dyn_cast<Function>(M.getOrInsertFunction(
573 Type::getVoidTy(M.getContext()),
575 ));
576#endif
577 svfmain->setCallingConv(llvm::CallingConv::C);
578 BasicBlock* block = BasicBlock::Create(M.getContext(), "entry", svfmain);
580 // emit "call void @ctor()". ctor_funcs is sorted so the functions are
581 // emitted in the order of priority
582 for (auto& ctor : ctor_funcs)
583 {
584 auto target = M.getOrInsertFunction(
585 ctor->getName(),
586 Type::getVoidTy(M.getContext())
587 );
588 Builder.CreateCall(target);
589 }
590 // main() should be called after all ctor functions and before dtor
591 // functions.
592 Function::arg_iterator arg_it = svfmain->arg_begin();
593 Value* args[] = {arg_it, arg_it + 1, arg_it + 2};
594 size_t cnt = orgMain->arg_size();
595 assert(cnt <= 3 && "Too many arguments for main()");
596 Builder.CreateCall(orgMain, llvm::ArrayRef<Value*>(args, args + cnt));
597 // emit "call void @dtor()". dtor_funcs is sorted so the functions are
598 // emitted in the order of priority
599 for (auto& dtor : dtor_funcs)
600 {
601 auto target = M.getOrInsertFunction(dtor->getName(), Type::getVoidTy(M.getContext()));
602 Builder.CreateCall(target);
603 }
604 // return;
605 Builder.CreateRetVoid();
606 }
607 else
608 {
609 // use SVF::Options to record whether svf.main is added or not
611 }
612}
#define SVF_MAIN_FUNC_NAME
#define SVF_GLOBAL_DTORS
#define SVF_GLOBAL_CTORS
void setValue(T v)
std::vector< const Function * > getLLVMGlobalFunctions(const GlobalVariable *global)
std::vector< std::reference_wrapper< Module > > modules
Definition LLVMModule.h:89
u32_t getModuleNum() const
Definition LLVMModule.h:159
static Option< bool > SVFMain
Definition Options.h:174
llvm::GlobalVariable GlobalVariable
Definition BasicTypes.h:137
llvm::Type Type
Definition BasicTypes.h:87
llvm::BasicBlock BasicBlock
Definition BasicTypes.h:90
llvm::Function Function
Definition BasicTypes.h:89
llvm::Value Value
LLVM Basic classes.
Definition BasicTypes.h:86
llvm::Module Module
Definition BasicTypes.h:88

◆ addSVFTypeInfo()

SVFType * LLVMModuleSet::addSVFTypeInfo ( const Type *  t)
private

Create SVFTypes.

Definition at line 1308 of file LLVMModule.cpp.

1309{
1310 assert(LLVMType2SVFType.find(T) == LLVMType2SVFType.end() &&
1311 "SVFType has been added before");
1312
1313 // add SVFType's LLVM byte size iff T isSized(), otherwise byteSize is 1 (default value)
1314 u32_t byteSize = 1;
1315 if (T->isSized())
1316 {
1317 const llvm::DataLayout &DL = LLVMModuleSet::getLLVMModuleSet()->
1318 getMainLLVMModule()->getDataLayout();
1319 Type *mut_T = const_cast<Type *>(T);
1320 byteSize = DL.getTypeAllocSize(mut_T);
1321 }
1322
1324
1326 if (SVFUtil::isa<PointerType>(T))
1327 {
1328 svftype = new SVFPointerType(id, byteSize);
1329 }
1330 else if (const IntegerType* intT = SVFUtil::dyn_cast<IntegerType>(T))
1331 {
1332 auto svfIntT = new SVFIntegerType(id, byteSize);
1333 unsigned signWidth = intT->getBitWidth();
1334 assert(signWidth < INT16_MAX && "Integer width too big");
1335 svfIntT->setSignAndWidth(intT->getSignBit() ? -signWidth : signWidth);
1336 svftype = svfIntT;
1337 }
1338 else if (const FunctionType* ft = SVFUtil::dyn_cast<FunctionType>(T))
1339 {
1340 std::vector<const SVFType*> paramTypes;
1341 for (const auto& t: ft->params())
1342 {
1343 paramTypes.push_back(getSVFType(t));
1344 }
1345 svftype = new SVFFunctionType(id, getSVFType(ft->getReturnType()), paramTypes, ft->isVarArg());
1346 }
1347 else if (const StructType* st = SVFUtil::dyn_cast<StructType>(T))
1348 {
1349 std::vector<const SVFType*> fieldTypes;
1350
1351 for (const auto& t: st->elements())
1352 {
1353 fieldTypes.push_back(getSVFType(t));
1354 }
1355 auto svfst = new SVFStructType(id, fieldTypes, byteSize);
1356 if (st->hasName())
1357 svfst->setName(st->getName().str());
1358 svftype = svfst;
1359 }
1360 else if (const auto at = SVFUtil::dyn_cast<ArrayType>(T))
1361 {
1362 auto svfat = new SVFArrayType(id, byteSize);
1363 svfat->setNumOfElement(at->getNumElements());
1364 svfat->setTypeOfElement(getSVFType(at->getElementType()));
1365 svftype = svfat;
1366 }
1367 else
1368 {
1369 std::string buffer;
1370 auto ot = new SVFOtherType(id, T->isSingleValueType(), byteSize);
1371 llvm::raw_string_ostream(buffer) << *T;
1372 ot->setRepr(std::move(buffer));
1373 svftype = ot;
1374 }
1375
1378
1379 return svftype;
1380}
unsigned u32_t
Definition CommandLine.h:18
char * buffer
Definition cJSON.h:163
void addTypeInfo(const SVFType *ty)
Definition IRGraph.h:368
LLVMType2SVFTypeMap LLVMType2SVFType
Definition LLVMModule.h:107
Module * getMainLLVMModule() const
Definition LLVMModule.h:373
static LLVMModuleSet * getLLVMModuleSet()
Definition LLVMModule.h:137
SVFType * getSVFType(const Type *T)
Get or create SVFType and typeinfo.
static NodeIDAllocator * get(void)
Return (singleton) allocator.
NodeID allocateTypeId(void)
Allocate an type ID as determined by the strategy.
llvm::StructType StructType
LLVM types.
Definition BasicTypes.h:98
llvm::IntegerType IntegerType
Definition BasicTypes.h:101
llvm::FunctionType FunctionType
Definition BasicTypes.h:102

◆ addToSVFVar2LLVMValueMap()

void LLVMModuleSet::addToSVFVar2LLVMValueMap ( const Value *  val,
SVFValue *  svfBaseNode 
)
private

Definition at line 1170 of file LLVMModule.cpp.

1172{
1174 svfBaseNode->setSourceLoc(LLVMUtil::getSourceLoc(val));
1175 svfBaseNode->setName(val->getName().str());
1176}
const std::string getSourceLoc(const Value *val)
Definition LLVMUtil.cpp:454

◆ build()

void LLVMModuleSet::build ( )
private

Definition at line 165 of file LLVMModule.cpp.

166{
167 if (!empty())
168 {
171 }
172
173 if(preProcessed==false)
175
178
179 if (Options::SVFMain())
180 addSVFMain();
181
183
184}
TargetABI targetABI
C++ ABI of the module being analyzed.
Definition LLVMModule.h:92
static bool preProcessed
Definition LLVMModule.h:85
void createSVFDataStructure()
void prePassSchedule()
Invoke llvm passes to modify module.
bool empty() const
Definition LLVMModule.h:399
static TargetABI detectTargetABI(const llvm::Triple &triple)
Definition LLVMUtil.h:355
static llvm::Triple getTargetTriple(const Module *mod)
Definition LLVMUtil.h:345

◆ buildFunToFunMap()

void LLVMModuleSet::buildFunToFunMap ( )
private

Keep svf_main() function and all the functions called in svf_main()

app functions

App Func decl -> SVF extern Func def

Overwrite App Func def -> SVF extern Func def

Definition at line 682 of file LLVMModule.cpp.

683{
687 Module* appModule = nullptr;
688 Module* extModule = nullptr;
689
690 for (Module& mod : modules)
691 {
692 // extapi.bc functions
693 if (mod.getName().str() == ExtAPI::getExtAPI()->getExtBcPath())
694 {
696 extModule = &mod;
697 for (const Function& fun : mod.functions())
698 {
699 // there is main declaration in ext bc, it should be mapped to
700 // main definition in app bc.
701 if (fun.getName().str() == "main")
702 {
703 appFunDecls.insert(&fun);
704 appFuncDeclNames.insert(fun.getName().str());
705 }
707 else if (fun.getName().str() == "svf__main")
708 {
709 ExtFuncsVec.push_back(&fun);
710 }
711 else
712 {
713 extFuncs.insert(&fun);
714 extFunDefNames.insert(fun.getName().str());
715 }
716 }
717 }
718 else
719 {
720 appModule = &mod;
722 for (const Function& fun : mod.functions())
723 {
724 if (fun.isDeclaration())
725 {
726 appFunDecls.insert(&fun);
727 appFuncDeclNames.insert(fun.getName().str());
728 }
729 else
730 {
731 appFunDefs.insert(&fun);
732 appFuncDefNames.insert(fun.getName().str());
733 }
734 }
735 }
736 }
737
738 // Find the intersectNames between appFuncDefNames and externalFunDefNames
739 std::set_intersection(
740 appFuncDefNames.begin(), appFuncDefNames.end(), extFunDefNames.begin(), extFunDefNames.end(),
741 std::inserter(intersectNames, intersectNames.end()));
742
744 {
745 assert(!(appFunToReplace == NULL && appModule == NULL) && "appFunToReplace and appModule cannot both be NULL");
746
747 if (appFunToReplace)
748 {
749 appModule = appFunToReplace->getParent();
750 }
751 Function* clonedFunction = Function::Create(extFunToClone->getFunctionType(),
752 Function::ExternalLinkage,
753 extFunToClone->getName());
754 // Map the arguments of the new function to the arguments of extFunToClone
755 llvm::ValueToValueMapTy valueMap;
756 Function::arg_iterator destArg = clonedFunction->arg_begin();
757 for (Function::const_arg_iterator srcArg = extFunToClone->arg_begin(); srcArg != extFunToClone->arg_end(); ++srcArg)
758 {
759 destArg->setName(srcArg->getName()); // Copy the name of the original argument
760 valueMap[&*srcArg] = &*destArg++; // Add a mapping from the old arg to the new arg
761 }
762 if (cloneBody)
763 {
764 // Collect global variables referenced by extFunToClone
765 // This step identifies all global variables used within the function to be cloned
766 std::set<GlobalVariable*> referencedGlobals;
767 for (const BasicBlock& BB : *extFunToClone)
768 {
769 for (const Instruction& I : BB)
770 {
771 for (const Value* operand : I.operands())
772 {
773 // Check if the operand is a global variable
774 if (const GlobalVariable* GV = SVFUtil::dyn_cast<GlobalVariable>(operand))
775 {
776 referencedGlobals.insert(const_cast<GlobalVariable*>(GV));
777 }
778 }
779 }
780 }
781
782 // Copy global variables to target module and update valueMap
783 // When cloning a function, we need to ensure all global variables it references are available in the target module
785 {
786 // Check if the global variable already exists in the target module
787 GlobalVariable* existingGV = appModule->getGlobalVariable(GV->getName());
788 if (existingGV)
789 {
790 // If the global variable already exists, ensure type consistency
791 assert(existingGV->getType() == GV->getType() && "Global variable type mismatch in client module!");
792 // Map the original global to the existing one in the target module
793 valueMap[GV] = existingGV; // Map to existing global variable
794 }
795 else
796 {
797 // If the global variable doesn't exist in the target module, create a new one with the same properties
799 *appModule, // Target module
800 GV->getValueType(), // Type of the global variable
801 GV->isConstant(), // Whether it's constant
802 GV->getLinkage(), // Linkage type
803 nullptr, // No initializer yet
804 GV->getName(), // Same name
805 nullptr, // No insert before instruction
806 GV->getThreadLocalMode(), // Thread local mode
807 GV->getAddressSpace() // Address space
808 );
809
810 // Copy initializer if present to maintain the global's value
811 if (GV->hasInitializer())
812 {
813 Constant* init = GV->getInitializer();
814 newGV->setInitializer(init); // Simple case: direct copy
815 }
816
817 // Copy other attributes like alignment to ensure identical behavior
818 newGV->copyAttributesFrom(GV);
819
820 // Add mapping from original global to the new one for use during function cloning
821 valueMap[GV] = newGV;
822 }
823 }
824
825 // Clone function body with updated valueMap
826 llvm::SmallVector<ReturnInst*, 8> ignoredReturns;
827 CloneFunctionInto(clonedFunction, extFunToClone, valueMap, llvm::CloneFunctionChangeType::LocalChangesOnly, ignoredReturns, "", nullptr);
828 }
829 if (appFunToReplace)
830 {
831 // Replace all uses of appFunToReplace with clonedFunction
832 appFunToReplace->replaceAllUsesWith(clonedFunction);
833 std::string oldFunctionName = appFunToReplace->getName().str();
834 // Delete the old function
835 appFunToReplace->eraseFromParent();
836 appModule->getFunctionList().push_back(clonedFunction);
838 }
839 else
840 {
841 appModule->getFunctionList().push_back(clonedFunction);
842 }
843 return clonedFunction;
844 };
845
847 for (const Function* appFunDecl : appFunDecls)
848 {
849 std::string appFunDeclName = LLVMUtil::restoreFuncName(appFunDecl->getName().str());
850 for (const Function* extFun : extFuncs)
851 {
852 if (extFun->getName().str().compare(appFunDeclName) == 0)
853 {
854 auto it = ExtFun2Annotations.find(extFun->getName().str());
855 // Without annotations, this function is normal function with useful function body
856 if (it == ExtFun2Annotations.end())
857 {
858 Function* clonedFunction = cloneAndReplaceFunction(const_cast<Function*>(extFun), const_cast<Function*>(appFunDecl), nullptr, true);
861 }
862 else
863 {
864 ExtFuncsVec.push_back(appFunDecl);
865 }
866 break;
867 }
868 }
869 }
870
873 for (string sameFuncDef: intersectNames)
874 {
875 Function* appFuncDef = appModule->getFunction(sameFuncDef);
876 Function* extFuncDef = extModule->getFunction(sameFuncDef);
877 if (appFuncDef == nullptr || extFuncDef == nullptr)
878 continue;
879
880 FunctionType *appFuncDefType = appFuncDef->getFunctionType();
881 FunctionType *extFuncDefType = extFuncDef->getFunctionType();
883 continue;
884
885 auto it = ExtFun2Annotations.find(sameFuncDef);
886 if (it != ExtFun2Annotations.end())
887 {
888 std::vector<std::string> annotations = it->second;
889 if (annotations.size() == 1 && annotations[0].find("OVERWRITE") != std::string::npos)
890 {
891 Function* clonedFunction = cloneAndReplaceFunction(const_cast<Function*>(extFuncDef), const_cast<Function*>(appFuncDef), nullptr, true);
894 }
895 else
896 {
897 if (annotations.size() >= 2)
898 {
899 for (const auto& annotation : annotations)
900 {
901 if(annotation.find("OVERWRITE") != std::string::npos)
902 {
903 assert(false && "overwrite and other annotations cannot co-exist");
904 }
905 }
906 }
907 }
908 }
909 }
910
912 {
913 for (inst_iterator I = inst_begin(caller), E = inst_end(caller); I != E; ++I)
914 {
915 Instruction *inst = &*I;
916
917 if (CallInst *callInst = SVFUtil::dyn_cast<CallInst>(inst))
918 {
919 Function *calledFunc = callInst->getCalledFunction();
920
921 if (calledFunc && calledFunc->getName() == callee->getName())
922 {
923 callInst->setCalledFunction(callee);
924 }
925 }
926 }
927 };
928
929 std::function<void(const Function*, Function*)> cloneAndLinkFunction;
931 {
932 if (clonedFuncs.find(extFunToClone) != clonedFuncs.end())
933 return;
934
935 Module* appModule = appClonedFun->getParent();
936 // Check if the function already exists in the parent module
937 if (appModule->getFunction(extFunToClone->getName()))
938 {
939 // The function already exists, no need to clone, but need to link it with the caller
940 Function* func = appModule->getFunction(extFunToClone->getName());
942 return;
943 }
944 // Decide whether to clone the function body based on ExtFun2Annotations
945 bool cloneBody = true;
946 auto it = ExtFun2Annotations.find(extFunToClone->getName().str());
947 if (it != ExtFun2Annotations.end())
948 {
949 std::vector<std::string> annotations = it->second;
950 if (!(annotations.size() == 1 && annotations[0].find("OVERWRITE") != std::string::npos))
951 {
952 cloneBody = false;
953 }
954 }
955
957
959 // Add the cloned function to ExtFuncsVec for further processing
960 ExtFuncsVec.push_back(clonedFunction);
961
963
964 std::vector<const Function*> calledFunctions = LLVMUtil::getCalledFunctions(extFunToClone);
965
966 for (const auto& calledFunction : calledFunctions)
967 {
969 }
970 };
971
972 // Recursive clone called functions
973 for (const auto& pair : extFuncs2ClonedFuncs)
974 {
975 Function* extFun = const_cast<Function*>(pair.first);
976 Function* clonedExtFun = const_cast<Function*>(pair.second);
977 std::vector<const Function*> extCalledFuns = LLVMUtil::getCalledFunctions(extFun);
978
979 for (const auto& extCalledFun : extCalledFuns)
980 {
982 }
983 }
984
985 // Remove unused annotations in ExtFun2Annotations according to the functions in ExtFuncsVec
987 for (const Function* extFun : ExtFuncsVec)
988 {
989 std::string name = LLVMUtil::restoreFuncName(extFun->getName().str());
990 auto it = ExtFun2Annotations.find(name);
991 if (it != ExtFun2Annotations.end())
992 {
993 std::string newKey = name;
994 if (name != extFun->getName().str())
995 {
996 newKey = extFun->getName().str();
997 }
998 newFun2AnnoMap.insert({newKey, it->second});
999 }
1000 }
1002
1003 // Remove ExtAPI module from modules
1004 auto it = std::find_if(modules.begin(), modules.end(),
1005 [&extModule](const std::reference_wrapper<llvm::Module>& moduleRef)
1006 {
1007 return &moduleRef.get() == extModule;
1008 });
1009
1010 if (it != modules.end())
1011 {
1012 size_t index = std::distance(modules.begin(), it);
1013 modules.erase(it);
1014 owned_modules.erase(owned_modules.begin() + index);
1015 }
1016}
const char *const name
Definition cJSON.h:264
int index
Definition cJSON.h:170
std::string getExtBcPath()
Definition ExtAPI.cpp:111
static ExtAPI * getExtAPI()
Definition ExtAPI.cpp:43
Fun2AnnoMap ExtFun2Annotations
Record annotations of function in extapi.bc.
Definition LLVMModule.h:97
FunctionSetType ExtFuncsVec
Record some "sse_" function declarations used in other ext function definition, e....
Definition LLVMModule.h:95
Map< std::string, std::vector< std::string > > Fun2AnnoMap
Definition LLVMModule.h:65
std::vector< std::unique_ptr< Module > > owned_modules
Definition LLVMModule.h:88
void collectExtFunAnnotations(const Module *mod)
#define NULL
Definition extapi.c:5
std::vector< const Function * > getCalledFunctions(const Function *F)
Get all called funcions in a parent function.
Definition LLVMUtil.cpp:365
std::string restoreFuncName(std::string funcName)
Definition LLVMUtil.cpp:408
llvm::inst_iterator inst_iterator
Definition BasicTypes.h:260
llvm::Instruction Instruction
Definition BasicTypes.h:91
llvm::Constant Constant
Definition BasicTypes.h:128
llvm::CallInst CallInst
Definition BasicTypes.h:154

◆ buildGlobalDefToRepMap()

void LLVMModuleSet::buildGlobalDefToRepMap ( )
private

Definition at line 1018 of file LLVMModule.cpp.

1019{
1022 for (Module &mod : modules)
1023 {
1024 // Collect ctor and dtor functions
1025 for (GlobalVariable& global : mod.globals())
1026 {
1027 if (global.hasPrivateLinkage())
1028 continue;
1029 string name = global.getName().str();
1030 if (name.empty())
1031 continue;
1032 nameToGlobalsMap[std::move(name)].insert(&global);
1033 }
1034 }
1035
1036 for (const auto& pair : nameToGlobalsMap)
1037 {
1038 const Set<GlobalVariable*> &globals = pair.second;
1039
1040 const auto repIt =
1041 std::find_if(globals.begin(), globals.end(),
1042 [](GlobalVariable* g)
1043 {
1044 return g->hasInitializer();
1045 });
1046 GlobalVariable* rep =
1047 repIt != globals.end()
1048 ? *repIt
1049 // When there is no initializer, just pick the first one.
1050 : (assert(!globals.empty() && "Empty global set"),
1051 *globals.begin());
1052
1053 for (const GlobalVariable* cur : globals)
1054 {
1055 GlobalDefToRepMap[cur] = rep;
1056 }
1057 }
1058}
GlobalDefToRepMapTy GlobalDefToRepMap
Global definition to a rep definition map.
Definition LLVMModule.h:103

◆ buildSVFModule() [1/2]

void LLVMModuleSet::buildSVFModule ( const std::vector< std::string > &  moduleNameVec)
static

Definition at line 127 of file LLVMModule.cpp.

128{
129 double startSVFModuleTime = SVFStat::getClk(true);
130
132
133 mset->loadModules(moduleNameVec); // Populates `modules`; can get context via `this->getContext()`
134 mset->loadExtAPIModules(); // Uses context from first module through `this->getContext()`
135
136 if (!moduleNameVec.empty())
137 {
139 }
140
141 mset->build();
142
143 double endSVFModuleTime = SVFStat::getClk(true);
146
147 mset->buildSymbolTable();
148}
#define TIMEINTERVAL
Definition SVFType.h:604
void setModuleIdentifier(const std::string &moduleIdentifier)
Definition SVFIR.h:291
static double timeOfBuildingLLVMModule
Definition SVFStat.h:96
static double getClk(bool mark=false)
Definition SVFStat.cpp:52

◆ buildSVFModule() [2/2]

void LLVMModuleSet::buildSVFModule ( Module &  mod)
static

Definition at line 112 of file LLVMModule.cpp.

113{
115
116 double startSVFModuleTime = SVFStat::getClk(true);
117 PAG::getPAG()->setModuleIdentifier(mod.getModuleIdentifier());
118 mset->modules.emplace_back(mod); // Populates `modules`; can get context via `this->getContext()`
119 mset->loadExtAPIModules(); // Uses context from module through `this->getContext()`
120 mset->build();
121 double endSVFModuleTime = SVFStat::getClk(true);
123
124 mset->buildSymbolTable();
125}

◆ buildSymbolTable()

void LLVMModuleSet::buildSymbolTable ( ) const
private

building symbol table

Definition at line 150 of file LLVMModule.cpp.

151{
152 double startSymInfoTime = SVFStat::getClk(true);
154 {
156 DBOUT(DGENERAL, SVFUtil::outs() << SVFUtil::pasMsg("Building Symbol table ...\n"));
158 builder.buildMemModel();
159 }
160 double endSymInfoTime = SVFStat::getClk(true);
163}
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
Definition SVFType.h:576
#define DGENERAL
Definition SVFType.h:582
static bool pagReadFromTXT()
Definition SVFIR.h:281
static double timeOfBuildingSymbolTable
Definition SVFStat.h:97
std::string pasMsg(const std::string &msg)
Print each pass/phase message by converting a string into blue string output.
Definition SVFUtil.cpp:121
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:58

◆ collectArrayInfo()

StInfo * LLVMModuleSet::collectArrayInfo ( const ArrayType *  ty)
private

Collect the array info.

Fill in StInfo for an array type.

array without any element (this is not true in C/C++ arrays) we assume there is an empty dummy element

Array's flatten field infor is the same as its element's flatten infor.

Flatten arrays, map each array element index i to flattened index (i * nfE * totalElemNum)/outArrayElemNum nfE>1 if the array element is a struct with more than one field.

Definition at line 1385 of file LLVMModule.cpp.

1386{
1387 u64_t totalElemNum = ty->getNumElements();
1388 const Type* elemTy = ty->getElementType();
1389 while (const ArrayType* aty = SVFUtil::dyn_cast<ArrayType>(elemTy))
1390 {
1391 totalElemNum *= aty->getNumElements();
1392 elemTy = aty->getElementType();
1393 }
1394
1397
1399 if (totalElemNum == 0)
1400 {
1401 stInfo->addFldWithType(0, elemSvfType, 0);
1402 stInfo->setNumOfFieldsAndElems(1, 1);
1403 stInfo->getFlattenFieldTypes().push_back(elemSvfType);
1404 stInfo->getFlattenElementTypes().push_back(elemSvfType);
1405 return stInfo;
1406 }
1407
1411 u32_t nfF = elemStInfo->getNumOfFlattenFields();
1412 u32_t nfE = elemStInfo->getNumOfFlattenElements();
1413 for (u32_t j = 0; j < nfF; j++)
1414 {
1415 const SVFType* fieldTy = elemStInfo->getFlattenFieldTypes()[j];
1416 stInfo->getFlattenFieldTypes().push_back(fieldTy);
1417 }
1418
1421 u32_t outArrayElemNum = ty->getNumElements();
1422 for (u32_t i = 0; i < outArrayElemNum; ++i)
1423 {
1424 auto idx = (i * nfE * totalElemNum) / outArrayElemNum;
1425 stInfo->addFldWithType(0, elemSvfType, idx);
1426 }
1427
1428 for (u32_t i = 0; i < totalElemNum; ++i)
1429 {
1430 for (u32_t j = 0; j < nfE; ++j)
1431 {
1432 const SVFType* et = elemStInfo->getFlattenElementTypes()[j];
1433 stInfo->getFlattenElementTypes().push_back(et);
1434 }
1435 }
1436
1437 assert(stInfo->getFlattenElementTypes().size() == nfE * totalElemNum &&
1438 "typeForArray size incorrect!!!");
1439 stInfo->setNumOfFieldsAndElems(nfF, nfE * totalElemNum);
1440
1441 return stInfo;
1442}
StInfo * collectTypeInfo(const Type *ty)
Collect a type info.
llvm::ArrayType ArrayType
Definition BasicTypes.h:99
unsigned long long u64_t
Definition GeneralType.h:69

◆ collectExtFunAnnotations()

void LLVMModuleSet::collectExtFunAnnotations ( const Module *  mod)
private

Non-opaque pointer

Opaque pointer

Definition at line 614 of file LLVMModule.cpp.

615{
616 GlobalVariable *glob = mod->getGlobalVariable("llvm.global.annotations");
617 if (glob == nullptr || !glob->hasInitializer())
618 return;
619
620 ConstantArray *ca = SVFUtil::dyn_cast<ConstantArray>(glob->getInitializer());
621 if (ca == nullptr)
622 return;
623
624 for (unsigned i = 0; i < ca->getNumOperands(); ++i)
625 {
626 ConstantStruct *structAn = SVFUtil::dyn_cast<ConstantStruct>(ca->getOperand(i));
627 if (structAn == nullptr || structAn->getNumOperands() == 0)
628 continue;
629
630 // Check if the annotation is for a function
631 Function* fun = nullptr;
632 GlobalVariable *annotateStr = nullptr;
634 if (ConstantExpr *expr = SVFUtil::dyn_cast<ConstantExpr>(structAn->getOperand(0)))
635 {
636 if (expr->getOpcode() == Instruction::BitCast && SVFUtil::isa<Function>(expr->getOperand(0)))
637 fun = SVFUtil::cast<Function>(expr->getOperand(0));
638
639 ConstantExpr *note = SVFUtil::cast<ConstantExpr>(structAn->getOperand(1));
640 if (note->getOpcode() != Instruction::GetElementPtr)
641 continue;
642
643 annotateStr = SVFUtil::dyn_cast<GlobalVariable>(note->getOperand(0));
644 }
646 else
647 {
648 fun = SVFUtil::dyn_cast<Function>(structAn->getOperand(0));
649 annotateStr = SVFUtil::dyn_cast<GlobalVariable>(structAn->getOperand(1));
650 }
651
652 if (!fun || annotateStr == nullptr || !annotateStr->hasInitializer())
653 continue;;
654
655 ConstantDataSequential *data = SVFUtil::dyn_cast<ConstantDataSequential>(annotateStr->getInitializer());
656 if (data && data->isString())
657 {
658 std::string annotation = data->getAsString().str();
659 if (!annotation.empty())
660 ExtFun2Annotations[fun->getName().str()].push_back(annotation);
661 }
662 }
663}
llvm::ConstantStruct ConstantStruct
Definition BasicTypes.h:110
llvm::ConstantArray ConstantArray
Definition BasicTypes.h:127
llvm::ConstantDataSequential ConstantDataSequential
Definition BasicTypes.h:123
llvm::ConstantExpr ConstantExpr
Definition BasicTypes.h:124

◆ collectSimpleTypeInfo()

StInfo * LLVMModuleSet::collectSimpleTypeInfo ( const Type *  ty)
private

Collect simple type (non-aggregate) info.

Collect simple type (non-aggregate) info

Only one field

Definition at line 1505 of file LLVMModule.cpp.

1506{
1508 StInfo* stInfo = new StInfo(1);
1510 stInfo->addFldWithType(0, svfType, 0);
1511
1512 stInfo->getFlattenFieldTypes().push_back(svfType);
1513 stInfo->getFlattenElementTypes().push_back(svfType);
1514 stInfo->setNumOfFieldsAndElems(1,1);
1515
1516 return stInfo;
1517}

◆ collectStructInfo()

StInfo * LLVMModuleSet::collectStructInfo ( const StructType *  structTy,
u32_t &  numFields 
)
private

Collect the struct info and set the number of fields after flattening.

Fill in struct_info for T. Given a Struct type, we recursively extend and record its fields and types.

The struct info should not be processed before

Definition at line 1448 of file LLVMModule.cpp.

1450{
1452 StInfo* stInfo = new StInfo(1);
1453
1454 // Number of fields after flattening the struct
1455 numFields = 0;
1456 // The offset when considering array stride info
1457 u32_t strideOffset = 0;
1458 for (const Type* elemTy : structTy->elements())
1459 {
1461 // offset with int_32 (s32_t) is large enough and won't overflow
1462 stInfo->addFldWithType(numFields, elemSvfTy, strideOffset);
1463
1464 if (SVFUtil::isa<StructType, ArrayType>(elemTy))
1465 {
1467 u32_t nfF = subStInfo->getNumOfFlattenFields();
1468 u32_t nfE = subStInfo->getNumOfFlattenElements();
1469 // Copy ST's info, whose element 0 is the size of ST itself.
1470 for (u32_t j = 0; j < nfF; ++j)
1471 {
1472 const SVFType* elemTy = subStInfo->getFlattenFieldTypes()[j];
1473 stInfo->getFlattenFieldTypes().push_back(elemTy);
1474 }
1475 numFields += nfF;
1476 strideOffset += nfE;
1477 for (u32_t tpj = 0; tpj < nfE; ++tpj)
1478 {
1479 const SVFType* ty = subStInfo->getFlattenElementTypes()[tpj];
1480 stInfo->getFlattenElementTypes().push_back(ty);
1481 }
1482
1483 }
1484 else
1485 {
1486 // Simple type
1487 numFields += 1;
1488 strideOffset += 1;
1489 stInfo->getFlattenFieldTypes().push_back(elemSvfTy);
1490 stInfo->getFlattenElementTypes().push_back(elemSvfTy);
1491 }
1492 }
1493
1494 assert(stInfo->getFlattenElementTypes().size() == strideOffset &&
1495 "typeForStruct size incorrect!");
1496 stInfo->setNumOfFieldsAndElems(numFields,strideOffset);
1497
1498 return stInfo;
1499}

◆ collectTypeInfo()

StInfo * LLVMModuleSet::collectTypeInfo ( const Type *  ty)
private

Collect a type info.

Definition at line 1276 of file LLVMModule.cpp.

1277{
1278 Type2TypeInfoMap::iterator tit = Type2TypeInfo.find(T);
1279 if (tit != Type2TypeInfo.end())
1280 {
1281 return tit->second;
1282 }
1283 // No such StInfo for T, create it now.
1284 StInfo* stInfo;
1285 if (const ArrayType* aty = SVFUtil::dyn_cast<ArrayType>(T))
1286 {
1288 }
1289 else if (const StructType* sty = SVFUtil::dyn_cast<StructType>(T))
1290 {
1291 u32_t nf;
1293 if (nf > svfir->maxStSize)
1294 {
1296 svfir->maxStSize = nf;
1297 }
1298 }
1299 else
1300 {
1302 }
1303 Type2TypeInfo.emplace(T, stInfo);
1305 return stInfo;
1306}
const SVFType * maxStruct
The struct type with the most fields.
Definition IRGraph.h:363
void addStInfo(StInfo *stInfo)
Definition IRGraph.h:375
u32_t maxStSize
The number of fields in max_struct.
Definition IRGraph.h:366
StInfo * collectSimpleTypeInfo(const Type *T)
Collect simple type (non-aggregate) info.
StInfo * collectStructInfo(const StructType *structTy, u32_t &numFields)
Collect the struct info and set the number of fields after flattening.
StInfo * collectArrayInfo(const ArrayType *T)
Collect the array info.
Type2TypeInfoMap Type2TypeInfo
Definition LLVMModule.h:108

◆ createSVFDataStructure()

void LLVMModuleSet::createSVFDataStructure ( )
private

Function

set exit block: exit basic block must have no successors and have a return instruction

Definition at line 186 of file LLVMModule.cpp.

187{
190 // Functions need to be retrieved in the order of insertion
191 // candidateDefs is the vector for all used defined functions
192 // candidateDecls is the vector for all used declared functions
193 std::vector<const Function*> candidateDefs, candidateDecls;
194
195 for (Module& mod : modules)
196 {
198 for (Function& func : mod.functions())
199 {
200 if (func.isDeclaration())
201 {
202 candidateDecls.push_back(&func);
203 }
204 else
205 {
206 candidateDefs.push_back(&func);
207 }
208 }
209 }
210
211 for (const Function* func: candidateDefs)
212 {
214 }
215 for (const Function* func: candidateDecls)
216 {
218 }
219
220 // set function exit block
221 for (const auto& func: funSet)
222 {
223 for (Function::const_iterator bit = func->begin(), ebit = func->end(); bit != ebit; ++bit)
224 {
225 const BasicBlock* bb = &*bit;
227 if (succ_size(bb) == 0)
228 {
230 {
232 SVFUtil::isa<ReturnInst>(bb->back())) &&
233 "last inst must be return inst");
234 setFunExitBB(func, bb);
235 }
236 }
237 }
238 // For no return functions, we set the last block as exit BB
239 // This ensures that each function that has definition must have an exit BB
240 if (func->size() != 0 && !getFunExitBB(func))
241 {
243 SVFUtil::isa<ReturnInst>(&func->back().back())) &&
244 "last inst must be return inst");
245 setFunExitBB(func, &func->back());
246 }
247 }
248
249 // Store annotations of functions in extapi.bc
250 for (const auto& pair : ExtFun2Annotations)
251 {
252 const Function* fun = getFunction(pair.first);
253 setExtFuncAnnotations(fun, pair.second);
254 }
255
256}
void setFunExitBB(const Function *fun, const BasicBlock *bb)
Definition LLVMModule.h:457
void setExtFuncAnnotations(const Function *fun, const std::vector< std::string > &funcAnnotations)
const Function * getFunction(const std::string &name)
Get the corresponding Function based on its name.
Definition LLVMModule.h:313
const BasicBlock * getFunExitBB(const Function *fun) const
Definition LLVMModule.h:185
void addFunctionSet(const Function *svfFunc)
Definition LLVMModule.h:452
ObjTypeInference * getTypeInference()
static SVFType * svfPtrTy
ptr type
Definition SVFType.h:230
static SVFType * svfI8Ty
8-bit int type
Definition SVFType.h:231
bool functionDoesNotRet(const Function *fun)
Definition LLVMUtil.cpp:124
bool basicBlockHasRetInst(const BasicBlock *bb)
Return true if the function has a return instruction.
Definition LLVMUtil.cpp:110

◆ dumpModulesToFile()

void LLVMModuleSet::dumpModulesToFile ( const std::string &  suffix)

Definition at line 1061 of file LLVMModule.cpp.

1062{
1063 for (Module& mod : modules)
1064 {
1065 std::string moduleName = mod.getName().str();
1066 std::string OutputFilename;
1067 std::size_t pos = moduleName.rfind('.');
1068 if (pos != std::string::npos)
1069 OutputFilename = moduleName.substr(0, pos) + suffix;
1070 else
1071 OutputFilename = moduleName + suffix;
1072
1073 std::error_code EC;
1074 raw_fd_ostream OS(OutputFilename.c_str(), EC, llvm::sys::fs::OF_None);
1075
1076#if (LLVM_VERSION_MAJOR >= 7)
1078#else
1080#endif
1081
1082 OS.flush();
1083 }
1084}
llvm::raw_fd_ostream raw_fd_ostream
LLVM outputs.
Definition BasicTypes.h:275

◆ dumpSymTable()

void LLVMModuleSet::dumpSymTable ( )

Definition at line 1123 of file LLVMModule.cpp.

1124{
1126 for (ValueToIDMapTy::iterator iter = valSymMap.begin(); iter != valSymMap.end();
1127 ++iter)
1128 {
1129 const NodeID i = iter->second;
1130 idmap[i] = iter->first;
1131 }
1132 for (ValueToIDMapTy::iterator iter = objSymMap.begin(); iter != objSymMap.end();
1133 ++iter)
1134 {
1135 const NodeID i = iter->second;
1136 idmap[i] = iter->first;
1137 }
1138 for (FunToIDMapTy::iterator iter = retSyms().begin(); iter != retSyms().end();
1139 ++iter)
1140 {
1141 const NodeID i = iter->second;
1142 idmap[i] = iter->first;
1143 }
1144 for (FunToIDMapTy::iterator iter = varargSyms().begin(); iter != varargSyms().end();
1145 ++iter)
1146 {
1147 const NodeID i = iter->second;
1148 idmap[i] = iter->first;
1149 }
1150 SVFUtil::outs() << "{SymbolTableInfo \n";
1151
1152
1153
1154
1155 for (auto iter : idmap)
1156 {
1157 std::string str;
1158 llvm::raw_string_ostream rawstr(str);
1159 auto llvmVal = iter.second;
1160 if (llvmVal)
1161 rawstr << " " << *llvmVal << " ";
1162 else
1163 rawstr << " No llvmVal found";
1165 SVFUtil::outs() << iter.first << " " << rawstr.str() << "\n";
1166 }
1167 SVFUtil::outs() << "}\n";
1168}
FunToIDMapTy & retSyms()
Definition LLVMModule.h:281
ValueToIDMapTy valSymMap
map a value to its sym id
Definition LLVMModule.h:120
ValueToIDMapTy objSymMap
map a obj reference to its sym id
Definition LLVMModule.h:121
FunToIDMapTy & varargSyms()
Definition LLVMModule.h:286
u32_t NodeID
Definition GeneralType.h:76

◆ empty()

bool SVF::LLVMModuleSet::empty ( ) const
inline

Definition at line 399 of file LLVMModule.h.

400 {
401 return getModuleNum() == 0;
402 }

◆ get_alloc_arg_pos()

s32_t LLVMModuleSet::get_alloc_arg_pos ( const Function *  F)

Definition at line 1589 of file LLVMModule.cpp.

1590{
1591 std::string allocArg = getExtFuncAnnotation(F, "ALLOC_HEAP_ARG");
1592 assert(!allocArg.empty() && "Not an alloc call via argument or incorrect extern function annotation!");
1593
1594 std::string number;
1595 for (char c : allocArg)
1596 {
1597 if (isdigit(c))
1598 number.push_back(c);
1599 }
1600 assert(!number.empty() && "Incorrect naming convention for svf external functions(ALLOC_HEAP_ARG + number)?");
1601 return std::stoi(number);
1602}
const char *const const double number
Definition cJSON.h:268
std::string getExtFuncAnnotation(const Function *fun, const std::string &funcAnnotation)
int isdigit(int c)
Definition extapi.c:1031

◆ getCallBlock()

CallICFGNode * SVF::LLVMModuleSet::getCallBlock ( const Instruction *  cs)
inlineprivate

Get/Add a call node.

Definition at line 495 of file LLVMModule.h.

496 {
497 CSToCallNodeMapTy::const_iterator it = CSToCallNodeMap.find(cs);
498 if (it == CSToCallNodeMap.end())
499 return nullptr;
500 return it->second;
501 }

◆ getCallICFGNode()

CallICFGNode * LLVMModuleSet::getCallICFGNode ( const Instruction *  cs)

get a call node

Definition at line 1251 of file LLVMModule.cpp.

1252{
1253 assert(LLVMUtil::isCallSite(inst) && "not a call instruction?");
1254 assert(LLVMUtil::isNonInstricCallSite(inst) && "associating an intrinsic debug instruction with an ICFGNode!");
1255 CallICFGNode* node = getCallBlock(inst);
1256 assert (node!=nullptr && "no CallICFGNode for this instruction?");
1257 return node;
1258}
CallICFGNode * getCallBlock(const Instruction *cs)
Get/Add a call node.
Definition LLVMModule.h:495
bool isCallSite(const Instruction *inst)
Whether an instruction is a call or invoke instruction.
Definition LLVMUtil.h:61
bool isNonInstricCallSite(const Instruction *inst)
Whether an instruction is a callsite in the application code, excluding llvm intrinsic calls.
Definition LLVMUtil.cpp:736

◆ getContext()

LLVMContext & SVF::LLVMModuleSet::getContext ( ) const
inline

Definition at line 393 of file LLVMModule.h.

394 {
395 assert(!empty() && "empty LLVM module!!");
396 return getMainLLVMModule()->getContext();
397 }

◆ getDomTree()

DominatorTree & LLVMModuleSet::getDomTree ( const Function *  fun)

Definition at line 103 of file LLVMModule.cpp.

104{
105 auto it = FunToDominatorTree.find(fun);
106 if(it != FunToDominatorTree.end()) return it->second;
108 dt.recalculate(const_cast<Function&>(*fun));
109 return dt;
110}
Map< const Function *, DominatorTree > FunToDominatorTree
Definition LLVMModule.h:118
llvm::DominatorTree DominatorTree
LLVM Dominators.
Definition BasicTypes.h:140

◆ getExtFuncAnnotation()

std::string LLVMModuleSet::getExtFuncAnnotation ( const Function *  fun,
const std::string &  funcAnnotation 
)

Definition at line 1538 of file LLVMModule.cpp.

1539{
1540 assert(fun && "Null Function* pointer");
1541 auto it = func2Annotations.find(fun);
1542 if (it != func2Annotations.end())
1543 {
1544 for (const std::string& annotation : it->second)
1545 if (annotation.find(funcAnnotation) != std::string::npos)
1547 }
1548 return "";
1549}
if(prebuffer< 0)
Definition cJSON.cpp:1269
return(char *) p.buffer
const char *const string
Definition cJSON.h:172
Map< const Function *, std::vector< std::string > > func2Annotations
Definition LLVMModule.h:100

◆ getExtFuncAnnotations()

const std::vector< std::string > & LLVMModuleSet::getExtFuncAnnotations ( const Function *  fun)

Definition at line 1551 of file LLVMModule.cpp.

1552{
1553 assert(fun && "Null Function* pointer");
1554 auto it = func2Annotations.find(fun);
1555 if (it != func2Annotations.end())
1556 return it->second;
1557 return func2Annotations[fun];
1558}

◆ getFunction()

const Function * SVF::LLVMModuleSet::getFunction ( const std::string &  name)
inline

Get the corresponding Function based on its name.

Definition at line 313 of file LLVMModule.h.

314 {
315 Function* fun = nullptr;
316
317 for (u32_t i = 0; i < llvmModuleSet->getModuleNum(); ++i)
318 {
320 fun = mod->getFunction(name);
321 if (fun)
322 {
323 return fun;
324 }
325 }
326 return nullptr;
327 }
Module * getModule(u32_t idx) const
Definition LLVMModule.h:169
static LLVMModuleSet * llvmModuleSet
Definition LLVMModule.h:84

◆ getFunctionSet()

const FunctionSet & SVF::LLVMModuleSet::getFunctionSet ( ) const
inline

Definition at line 199 of file LLVMModule.h.

200 {
201 return funSet;
202 }

◆ getFunEntryBlock()

FunEntryICFGNode * SVF::LLVMModuleSet::getFunEntryBlock ( const Function *  fun)
inlineprivate

Get/Add a function entry node.

Definition at line 521 of file LLVMModule.h.

522 {
523 FunToFunEntryNodeMapTy::const_iterator it = FunToFunEntryNodeMap.find(fun);
524 if (it == FunToFunEntryNodeMap.end())
525 return nullptr;
526 return it->second;
527 }
FunToFunEntryNodeMapTy FunToFunEntryNodeMap
map a function to its FunExitICFGNode
Definition LLVMModule.h:115

◆ getFunEntryICFGNode()

FunEntryICFGNode * SVF::LLVMModuleSet::getFunEntryICFGNode ( const Function *  fun)
inline

Add a function entry node.

Definition at line 344 of file LLVMModule.h.

345 {
346 FunEntryICFGNode* b = getFunEntryBlock(fun);
347 assert(b && "Function entry not created?");
348 return b;
349 }
const cJSON *const b
Definition cJSON.h:255
FunEntryICFGNode * getFunEntryBlock(const Function *fun)
Get/Add a function entry node.
Definition LLVMModule.h:521

◆ getFunExitBB()

const BasicBlock * SVF::LLVMModuleSet::getFunExitBB ( const Function *  fun) const
inline

Definition at line 185 of file LLVMModule.h.

186 {
187 auto it = funToExitBB.find(fun);
188 if (it == funToExitBB.end()) return nullptr;
189 else return it->second;
190 }
FunToExitBBMap funToExitBB
Definition LLVMModule.h:126

◆ getFunExitBlock()

FunExitICFGNode * SVF::LLVMModuleSet::getFunExitBlock ( const Function *  fun)
inlineprivate

Get/Add a function exit node.

Definition at line 530 of file LLVMModule.h.

531 {
532 FunToFunExitNodeMapTy::const_iterator it = FunToFunExitNodeMap.find(fun);
533 if (it == FunToFunExitNodeMap.end())
534 return nullptr;
535 return it->second;
536 }
FunToFunExitNodeMapTy FunToFunExitNodeMap
map a function to its FunEntryICFGNode
Definition LLVMModule.h:116

◆ getFunExitICFGNode()

FunExitICFGNode * SVF::LLVMModuleSet::getFunExitICFGNode ( const Function *  fun)
inline

Add a function exit node.

Definition at line 351 of file LLVMModule.h.

352 {
353 FunExitICFGNode* b = getFunExitBlock(fun);
354 assert(b && "Function exit not created?");
355 return b;
356 }
FunExitICFGNode * getFunExitBlock(const Function *fun)
Get/Add a function exit node.
Definition LLVMModule.h:530

◆ getFunObjVar() [1/2]

const FunObjVar * SVF::LLVMModuleSet::getFunObjVar ( const Function *  fun) const
inline

Definition at line 274 of file LLVMModule.h.

275 {
276 LLVMFun2FunObjVarMap::const_iterator it = LLVMFun2FunObjVar.find(fun);
277 assert(it!=LLVMFun2FunObjVar.end() && "SVF Function not found!");
278 return it->second;
279 }
LLVMFun2FunObjVarMap LLVMFun2FunObjVar
Map an LLVM Function to an SVF Funobjvar.
Definition LLVMModule.h:105

◆ getFunObjVar() [2/2]

const FunObjVar * LLVMModuleSet::getFunObjVar ( const std::string &  name)

Get the corresponding Function based on its name.

Definition at line 1178 of file LLVMModule.cpp.

1179{
1180 Function* fun = nullptr;
1181
1182 for (u32_t i = 0; i < llvmModuleSet->getModuleNum(); ++i)
1183 {
1185 fun = mod->getFunction(name);
1186 if (fun)
1187 {
1188 return llvmModuleSet->getFunObjVar(fun);
1189 }
1190 }
1191 return nullptr;
1192}
const FunObjVar * getFunObjVar(const Function *fun) const
Definition LLVMModule.h:274

◆ getGlobalRep()

GlobalVariable * SVF::LLVMModuleSet::getGlobalRep ( const GlobalVariable *  val) const
inline

Definition at line 366 of file LLVMModule.h.

367 {
368 GlobalDefToRepMapTy::const_iterator it = GlobalDefToRepMap.find(val);
369 assert(it != GlobalDefToRepMap.end() && "has no rep?");
370 return it->second;
371 }

◆ getICFGNode()

ICFGNode * LLVMModuleSet::getICFGNode ( const Instruction *  inst)

Get a basic block ICFGNode.

Definition at line 1224 of file LLVMModule.cpp.

1225{
1226 ICFGNode* node;
1228 node = getCallICFGNode(inst);
1229 else if(LLVMUtil::isIntrinsicInst(inst))
1230 node = getIntraICFGNode(inst);
1231 else
1232 node = getIntraICFGNode(inst);
1233
1234 assert (node!=nullptr && "no ICFGNode for this instruction?");
1235 return node;
1236}
CallICFGNode * getCallICFGNode(const Instruction *cs)
get a call node
IntraICFGNode * getIntraICFGNode(const Instruction *inst)
get a intra node
bool isIntrinsicInst(const Instruction *inst)
Return true if it is an intrinsic instruction.
Definition LLVMUtil.cpp:204

◆ getIntraBlock()

IntraICFGNode * SVF::LLVMModuleSet::getIntraBlock ( const Instruction *  inst)
inlineprivate

Definition at line 512 of file LLVMModule.h.

513 {
514 InstToBlockNodeMapTy::const_iterator it = InstToBlockNodeMap.find(inst);
515 if (it == InstToBlockNodeMap.end())
516 return nullptr;
517 return it->second;
518 }

◆ getIntraICFGNode()

IntraICFGNode * LLVMModuleSet::getIntraICFGNode ( const Instruction *  inst)

get a intra node

Definition at line 1269 of file LLVMModule.cpp.

1270{
1271 IntraICFGNode* node = getIntraBlock(inst);
1272 assert (node!=nullptr && "no IntraICFGNode for this instruction?");
1273 return node;
1274}
IntraICFGNode * getIntraBlock(const Instruction *inst)
Definition LLVMModule.h:512

◆ getLLVMGlobalFunctions()

std::vector< const Function * > LLVMModuleSet::getLLVMGlobalFunctions ( const GlobalVariable *  global)
private

Definition at line 427 of file LLVMModule.cpp.

428{
429 // This function is used to extract constructor and destructor functions
430 // sorted by their priority from @llvm.global_ctors or @llvm.global_dtors.
431 // For example, given following @llvm.global_ctors, the returning sorted
432 // function list should be [ctor3, ctor1, ctor2].
433 // ------------------------------------------------------------------
434 // ; Each struct in the array is {priority, function, associated data}
435 //
436 // @llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }]
437 // [{ i32, void ()*, i8* } { i32 1234, void ()* @ctor1.cpp, i8* null },
438 // { i32, void ()*, i8* } { i32 2345, void ()* @ctor2.cpp, i8* null },
439 // { i32, void ()*, i8* } { i32 345, void ()* @ctor3.cpp, i8* null }]
440 // ------------------------------------------------------------------
441 // TODO: According to LLVM language reference, if the third field is
442 // non-null, and points to a global variable or function, the initializer
443 // function will only run if the associated data from the current module is
444 // not discarded. However the associated data is currently ignored.
445
446
447 // This class is used for the priority queue that sorts the functions by
448 // their priority. Each object of this class stands for an item in the
449 // function array.
451 {
452 public:
454 const Function* func;
458 bool operator>(const LLVMGlobalFunction &other) const
459 {
460 if (priority != other.priority)
461 {
462 return priority > other.priority;
463 }
464 else
465 {
466 return func > other.func;
467 }
468 }
469 };
470
471 std::priority_queue<LLVMGlobalFunction, std::vector<LLVMGlobalFunction>,
473 queue;
474 std::vector<const Function* > result;
475
476 // The @llvm.global_ctors/dtors global variable is an array of struct. Each
477 // struct has three fields: {i32 priority, void ()* @ctor/dtor, i8* @data}.
478 // First get the array here.
480 SVFUtil::dyn_cast<ConstantArray>(global->getInitializer()))
481 {
482 // Get each struct in the array.
483 for (unsigned int i = 0; i < globalFuncArray->getNumOperands(); ++i)
484 {
485 if (
487 SVFUtil::dyn_cast<ConstantStruct>(
488 globalFuncArray->getOperand(i)))
489 {
490
491 // Extract priority and function from the struct
492 const ConstantInt* priority = SVFUtil::dyn_cast<ConstantInt>(
493 globalFuncItem->getOperand(0));
494 const Function* func = SVFUtil::dyn_cast<Function>(
495 globalFuncItem->getOperand(1));
496
497 if (priority && func)
498 {
500 func));
501 }
502 }
503 }
504 }
505
506 // Generate a sorted vector of functions from the priority queue.
507 while (!queue.empty())
508 {
509 result.push_back(queue.top().func);
510 queue.pop();
511 }
512 return result;
513}
std::pair< s64_t, u64_t > getIntegerValue(const ConstantInt *intValue)
Definition LLVMUtil.h:99
llvm::ConstantInt ConstantInt
Definition BasicTypes.h:129
IntervalValue operator>(const IntervalValue &lhs, const IntervalValue &rhs)

◆ getLLVMModules()

const std::vector< std::reference_wrapper< Module > > & SVF::LLVMModuleSet::getLLVMModules ( ) const
inline

Definition at line 164 of file LLVMModule.h.

165 {
166 return modules;
167 }

◆ getLLVMModuleSet()

static LLVMModuleSet * SVF::LLVMModuleSet::getLLVMModuleSet ( )
inlinestatic

Definition at line 137 of file LLVMModule.h.

138 {
139 if (!llvmModuleSet)
141 return llvmModuleSet;
142 }
LLVMModuleSet()
Constructor.

◆ getLLVMType()

const Type * LLVMModuleSet::getLLVMType ( const SVFType *  T) const

Get LLVM Type.

Definition at line 1195 of file LLVMModule.cpp.

1196{
1197 for(LLVMType2SVFTypeMap::const_iterator it = LLVMType2SVFType.begin(), eit = LLVMType2SVFType.end(); it!=eit; ++it)
1198 {
1199 if (it->second == T)
1200 return it->first;
1201 }
1202 assert(false && "can't find the corresponding LLVM Type");
1203 abort();
1204}

◆ getLLVMValue()

const Value * SVF::LLVMModuleSet::getLLVMValue ( const SVFValue *  value) const
inline

Definition at line 267 of file LLVMModule.h.

268 {
269 SVFBaseNode2LLVMValueMap ::const_iterator it = SVFBaseNode2LLVMValue.find(value);
270 assert(it != SVFBaseNode2LLVMValue.end() && "can't find corresponding llvm value!");
271 return it->second;
272 }

◆ getMainLLVMModule()

Module * SVF::LLVMModuleSet::getMainLLVMModule ( ) const
inline

Definition at line 373 of file LLVMModule.h.

374 {
375 assert(!empty() && "empty LLVM module!!");
376 for (size_t i = 0; i < getModuleNum(); ++i)
377 {
378 Module& module = getModuleRef(i);
379 if (module.getName().str() != ExtAPI::getExtAPI()->getExtBcPath())
380 {
381 return &module;
382 }
383 }
384 assert(false && "no main module found!");
385 return nullptr;
386 }

◆ getModule()

Module * SVF::LLVMModuleSet::getModule ( u32_t  idx) const
inline

Definition at line 169 of file LLVMModule.h.

170 {
171 return &getModuleRef(idx);
172 }
Module & getModuleRef(u32_t idx) const
Definition LLVMModule.h:174

◆ getModuleNum()

u32_t SVF::LLVMModuleSet::getModuleNum ( ) const
inline

Definition at line 159 of file LLVMModule.h.

160 {
161 return modules.size();
162 }

◆ getModuleRef()

Module & SVF::LLVMModuleSet::getModuleRef ( u32_t  idx) const
inline

Definition at line 174 of file LLVMModule.h.

175 {
176 assert(idx < getModuleNum() && "Out of range.");
177 return modules[idx];
178 }

◆ getObjectNode()

NodeID LLVMModuleSet::getObjectNode ( const Value *  V)

getObject - Return the obj node id refer to the memory object for the specified global, heap or alloca instruction according to llvm value.

Definition at line 1113 of file LLVMModule.cpp.

1114{
1115 if (const GlobalVariable* glob = SVFUtil::dyn_cast<GlobalVariable>(llvm_value))
1117 ValueToIDMapTy::const_iterator iter = objSymMap.find(llvm_value);
1118 assert(iter!=objSymMap.end() && "obj sym not found");
1119 return iter->second;
1120}
const Value * getGlobalRep(const Value *val)
find the unique defined global across multiple modules
Definition LLVMUtil.cpp:441

◆ getObjNodeNum()

u32_t SVF::LLVMModuleSet::getObjNodeNum ( ) const
inline

Definition at line 209 of file LLVMModule.h.

210 {
211 return objSymMap.size();
212 }

◆ getRealDefFun()

const Function * SVF::LLVMModuleSet::getRealDefFun ( const Function *  fun) const
inline

Definition at line 192 of file LLVMModule.h.

193 {
194 auto it = funToRealDefFun.find(fun);
195 if (it == funToRealDefFun.end()) return nullptr;
196 else return it->second;
197 }
FunToRealDefFunMap funToRealDefFun
Definition LLVMModule.h:127

◆ getRetBlock()

RetICFGNode * SVF::LLVMModuleSet::getRetBlock ( const Instruction *  cs)
inlineprivate

Get/Add a return node.

Definition at line 504 of file LLVMModule.h.

505 {
506 CSToRetNodeMapTy::const_iterator it = CSToRetNodeMap.find(cs);
507 if (it == CSToRetNodeMap.end())
508 return nullptr;
509 return it->second;
510 }

◆ getRetICFGNode()

RetICFGNode * LLVMModuleSet::getRetICFGNode ( const Instruction *  cs)

get a return node

Definition at line 1260 of file LLVMModule.cpp.

1261{
1262 assert(LLVMUtil::isCallSite(inst) && "not a call instruction?");
1263 assert(LLVMUtil::isNonInstricCallSite(inst) && "associating an intrinsic debug instruction with an ICFGNode!");
1264 RetICFGNode* node = getRetBlock(inst);
1265 assert (node!=nullptr && "no RetICFGNode for this instruction?");
1266 return node;
1267}
RetICFGNode * getRetBlock(const Instruction *cs)
Get/Add a return node.
Definition LLVMModule.h:504

◆ getReturnNode()

NodeID SVF::LLVMModuleSet::getReturnNode ( const Function *  func) const
inline

Definition at line 291 of file LLVMModule.h.

292 {
293 FunToIDMapTy::const_iterator iter = returnSymMap.find(func);
294 assert(iter!=returnSymMap.end() && "ret sym not found");
295 return iter->second;
296 }
FunToIDMapTy returnSymMap
return map
Definition LLVMModule.h:122

◆ getSVFBasicBlock()

SVFBasicBlock * SVF::LLVMModuleSet::getSVFBasicBlock ( const BasicBlock *  bb)
inline

Definition at line 305 of file LLVMModule.h.

306 {
307 LLVMBB2SVFBBMap::const_iterator it = LLVMBB2SVFBB.find(bb);
308 assert(it!=LLVMBB2SVFBB.end() && "SVF BasicBlock not found!");
309 return it->second;
310 }

◆ getSVFType()

SVFType * LLVMModuleSet::getSVFType ( const Type *  T)

Get or create SVFType and typeinfo.

Get or create SVFType and typeinfo

Definition at line 1209 of file LLVMModule.cpp.

1210{
1211 assert(T && "SVFType should not be null");
1212 LLVMType2SVFTypeMap::const_iterator it = LLVMType2SVFType.find(T);
1213 if (it != LLVMType2SVFType.end())
1214 return it->second;
1215
1218 svfType->setTypeInfo(stinfo);
1219 return svfType;
1220}
SVFType * addSVFTypeInfo(const Type *t)
Create SVFTypes.

◆ getTargetABI()

TargetABI SVF::LLVMModuleSet::getTargetABI ( ) const
inline

Definition at line 388 of file LLVMModule.h.

389 {
390 return targetABI;
391 }

◆ getTypeInference()

ObjTypeInference * LLVMModuleSet::getTypeInference ( )

Definition at line 98 of file LLVMModule.cpp.

99{
100 return typeInference;
101}

◆ getValueNode()

NodeID LLVMModuleSet::getValueNode ( const Value *  V)

Get SVFIR Node according to LLVM value getNode - Return the node corresponding to the specified pointer.

Definition at line 1086 of file LLVMModule.cpp.

1087{
1088 if (SVFUtil::isa<ConstantPointerNull>(llvm_value))
1089 return svfir->nullPtrSymID();
1090 else if (SVFUtil::isa<UndefValue>(llvm_value))
1091 {
1092 // For phi ptr [ @x, ... ], [ undef, ... ], keep @x without adding
1093 // a black-hole target. Integer and aggregate undef keep their model.
1094 if (Options::UndefAsNull() && llvm_value->getType()->isPointerTy())
1095 return svfir->nullPtrSymID();
1096 return svfir->blkPtrSymID();
1097 }
1098 else
1099 {
1100 ValueToIDMapTy::const_iterator iter = valSymMap.find(llvm_value);
1101 assert(iter!=valSymMap.end() &&"value sym not found");
1102 return iter->second;
1103 }
1104}
NodeID blkPtrSymID() const
Definition IRGraph.h:182
NodeID nullPtrSymID() const
Definition IRGraph.h:187
static const Option< bool > UndefAsNull
Definition Options.h:99

◆ getValueNodeNum()

u32_t SVF::LLVMModuleSet::getValueNodeNum ( ) const
inline

Definition at line 204 of file LLVMModule.h.

205 {
206 return valSymMap.size();
207 }

◆ getVarargNode()

NodeID SVF::LLVMModuleSet::getVarargNode ( const Function *  func) const
inline

Definition at line 298 of file LLVMModule.h.

299 {
300 FunToIDMapTy::const_iterator iter = varargSymMap.find(func);
301 assert(iter!=varargSymMap.end() && "vararg sym not found");
302 return iter->second;
303 }
FunToIDMapTy varargSymMap
vararg map
Definition LLVMModule.h:123

◆ has_static()

bool SVF::LLVMModuleSet::has_static ( const Function *  F)

◆ hasExtFuncAnnotation()

bool LLVMModuleSet::hasExtFuncAnnotation ( const Function *  fun,
const std::string &  funcAnnotation 
)

Definition at line 1525 of file LLVMModule.cpp.

1526{
1527 assert(fun && "Null SVFFunction* pointer");
1528 auto it = func2Annotations.find(fun);
1529 if (it != func2Annotations.end())
1530 {
1531 for (const std::string& annotation : it->second)
1532 if (annotation.find(funcAnnotation) != std::string::npos)
1533 return true;
1534 }
1535 return false;
1536}
#define true
Definition cJSON.cpp:65

◆ hasGlobalRep()

bool SVF::LLVMModuleSet::hasGlobalRep ( const GlobalVariable *  val) const
inline

Global to rep.

Definition at line 360 of file LLVMModule.h.

361 {
362 GlobalDefToRepMapTy::const_iterator it = GlobalDefToRepMap.find(val);
363 return it != GlobalDefToRepMap.end();
364 }

◆ hasICFGNode()

bool LLVMModuleSet::hasICFGNode ( const Instruction *  inst)

Definition at line 1238 of file LLVMModule.cpp.

1239{
1240 ICFGNode* node;
1242 node = getCallBlock(inst);
1243 else if(LLVMUtil::isIntrinsicInst(inst))
1244 node = getIntraBlock(inst);
1245 else
1246 node = getIntraBlock(inst);
1247
1248 return node != nullptr;
1249}

◆ hasLLVMValue()

bool SVF::LLVMModuleSet::hasLLVMValue ( const SVFValue *  value) const
inline

Definition at line 262 of file LLVMModule.h.

263 {
264 return SVFBaseNode2LLVMValue.find(value) != SVFBaseNode2LLVMValue.end();
265 }

◆ hasValueNode()

bool LLVMModuleSet::hasValueNode ( const Value *  V)

Definition at line 1105 of file LLVMModule.cpp.

1106{
1107 if (SVFUtil::isa<ConstantPointerNull, UndefValue>(val))
1108 return true;
1109 else
1110 return (valSymMap.find(val) != valSymMap.end());
1111}

◆ is_alloc()

bool LLVMModuleSet::is_alloc ( const Function *  F)

Definition at line 1572 of file LLVMModule.cpp.

1573{
1574 return F && hasExtFuncAnnotation(F, "ALLOC_HEAP_RET");
1575}
bool hasExtFuncAnnotation(const Function *fun, const std::string &funcAnnotation)

◆ is_alloc_stack_ret()

bool LLVMModuleSet::is_alloc_stack_ret ( const Function *  F)

Definition at line 1583 of file LLVMModule.cpp.

1584{
1585 return F && hasExtFuncAnnotation(F, "ALLOC_STACK_RET");
1586}

◆ is_arg_alloc()

bool LLVMModuleSet::is_arg_alloc ( const Function *  F)

Definition at line 1578 of file LLVMModule.cpp.

1579{
1580 return F && hasExtFuncAnnotation(F, "ALLOC_HEAP_ARG");
1581}

◆ is_ext()

bool LLVMModuleSet::is_ext ( const Function *  F)

Definition at line 1613 of file LLVMModule.cpp.

1614{
1615 assert(F && "Null SVFFunction* pointer");
1616 if (F->isDeclaration() || F->isIntrinsic())
1617 return true;
1618 else if (hasExtFuncAnnotation(F, "OVERWRITE") && getExtFuncAnnotations(F).size() == 1)
1619 return false;
1620 else
1621 return !getExtFuncAnnotations(F).empty();
1622}
const std::vector< std::string > & getExtFuncAnnotations(const Function *fun)

◆ is_memcpy()

bool LLVMModuleSet::is_memcpy ( const Function *  F)

Definition at line 1560 of file LLVMModule.cpp.

1561{
1562 return F &&
1563 (hasExtFuncAnnotation(F, "MEMCPY") || hasExtFuncAnnotation(F, "STRCPY")
1564 || hasExtFuncAnnotation(F, "STRCAT"));
1565}

◆ is_memset()

bool LLVMModuleSet::is_memset ( const Function *  F)

Definition at line 1567 of file LLVMModule.cpp.

1568{
1569 return F && hasExtFuncAnnotation(F, "MEMSET");
1570}

◆ is_realloc()

bool LLVMModuleSet::is_realloc ( const Function *  F)

Definition at line 1605 of file LLVMModule.cpp.

1606{
1607 return F && hasExtFuncAnnotation(F, "REALLOC_HEAP_RET");
1608}

◆ loadExtAPIModules()

void LLVMModuleSet::loadExtAPIModules ( )
private

Definition at line 388 of file LLVMModule.cpp.

389{
390 // This function loads the ExtAPI bitcode file as an LLVM module. Note that it is important that
391 // the same LLVMContext object is used to load this bitcode file as is used by the other modules
392 // being analysed.
393 // When the modules are loaded from bitcode files (i.e. passing filenames to files containing
394 // LLVM IR to `buildSVFModule({file1.bc, file2.bc, ...})) the context is created while loading
395 // the modules in `loadModules()`, which populates this->modules and this->owned_modules.
396 // If, however, an LLVM Module object is passed to `buildSVFModule` (e.g. from an LLVM pass),
397 // the context should be retrieved from the module itself (note that the garbage collection from
398 // `std::unique_ptr<LLVMContext> LLVMModuleSet::owned_ctx` should be avoided in this case). This
399 // function populates only this->modules.
400 // In both cases, fetching the context from the main LLVM module (through `getContext`) works
401 assert(!empty() && "LLVMModuleSet contains no modules; cannot load ExtAPI module without LLVMContext!");
402
403 // Load external API module (extapi.bc)
404 if (!ExtAPI::getExtAPI()->getExtBcPath().empty())
405 {
408 {
409 SVFUtil::errs() << "not an external IR file: " << extModuleName << std::endl;
410 abort();
411 }
413 std::unique_ptr<Module> mod = parseIRFile(extModuleName, Err, getContext());
414 if (mod == nullptr)
415 {
416 SVFUtil::errs() << "load external module: " << extModuleName << "failed!!\n\n";
417 Err.print("SVFModuleLoader", llvm::errs());
418 abort();
419 }
420 // The module of extapi.bc needs to be inserted before applications modules, like std::vector<std::reference_wrapper<Module>> modules{extapi_module, app_module}.
421 // Otherwise, when overwriting the app function with SVF extern function, the corresponding SVFFunction of the extern function will not be found.
422 modules.insert(modules.begin(), *mod);
423 owned_modules.insert(owned_modules.begin(),std::move(mod));
424 }
425}
LLVMContext & getContext() const
Definition LLVMModule.h:393
bool isIRFile(const std::string &filename)
Check whether a file is an LLVM IR file.
Definition LLVMUtil.cpp:316
std::ostream & errs()
Overwrite llvm::errs()
Definition SVFUtil.h:64
llvm::SMDiagnostic SMDiagnostic
Definition BasicTypes.h:94

◆ loadModules()

void LLVMModuleSet::loadModules ( const std::vector< std::string > &  moduleNameVec)
private

Definition at line 322 of file LLVMModule.cpp.

323{
324
325 // We read SVFIR from LLVM IR
327 {
328 if(moduleNameVec.empty())
329 {
330 SVFUtil::outs() << "no LLVM bc file is found!\n";
331 exit(0);
332 }
333 //assert(!moduleNameVec.empty() && "no LLVM bc file is found!");
334 }
335 // We read SVFIR from a user-defined txt instead of parsing SVFIR from LLVM IR
336 else
337 {
339 }
340 //
341 // LLVMContext objects separate global LLVM settings (from which e.g. types are
342 // derived); multiple LLVMContext objects can coexist and each context can "own"
343 // multiple modules (modules can only have one context). Mixing contexts can lead
344 // to unintended inequalities, such as the following:
345 //
346 // ------------------------------------------------------------------
347 // LLVMContext ctxa,ctxb;
348 // IntegerType * t1 = IntegerType::get(ctxa,32);
349 // IntegerType * t2 = IntegerType::get(ctxa,32);
350 // assert(t1 == t2);
351 // IntegerType * t3 = IntegerType::get(ctxb,32);
352 // IntegerType * t4 = IntegerType::get(ctxb,32);
353 // assert(t3 == t4);
354 // assert(t1 != t3);
355 // ------------------------------------------------------------------
356 //
357 // When loading bytecode files, SVF will use the same LLVMContext object for all
358 // modules (i.e. the context owns all loaded modules). This applies to ExtAPI as
359 // well, which *must* be loaded using the same LLVMContext object. Hence, when
360 // loading modules from bitcode files, a new LLVMContext is created (using a
361 // `std::unique_ptr<LLVMContext>` type to ensure automatic garbage collection).
362 //
363 // This garbage collection should be avoided when building an SVF module from an LLVM
364 // module instance; see the comment(s) in `buildSVFModule` and `loadExtAPIModules()`
365
366 owned_ctx = std::make_unique<LLVMContext>();
367 for (const std::string& moduleName : moduleNameVec)
368 {
369 if (!LLVMUtil::isIRFile(moduleName))
370 {
371 SVFUtil::errs() << "not an IR file: " << moduleName << std::endl;
372 abort();
373 }
374
376 std::unique_ptr<Module> mod = parseIRFile(moduleName, Err, *owned_ctx);
377 if (mod == nullptr)
378 {
379 SVFUtil::errs() << "load module: " << moduleName << "failed!!\n\n";
380 Err.print("SVFModuleLoader", llvm::errs());
381 abort();
382 }
383 modules.emplace_back(*mod);
384 owned_modules.emplace_back(std::move(mod));
385 }
386}
std::unique_ptr< LLVMContext > owned_ctx
Definition LLVMModule.h:87
static const Option< std::string > Graphtxt
Definition Options.h:173
static void setPagFromTXT(const std::string &txt)
Definition SVFIR.h:286

◆ objSyms()

ValueToIDMapTy & SVF::LLVMModuleSet::objSyms ( )
inline

Definition at line 219 of file LLVMModule.h.

220 {
221 return objSymMap;
222 }

◆ prePassSchedule()

void LLVMModuleSet::prePassSchedule ( )
private

Invoke llvm passes to modify module.

Invoke llvm passes to modify module

BreakConstantGEPs Pass

MergeFunctionRets Pass

Definition at line 261 of file LLVMModule.cpp.

262{
264 std::unique_ptr<BreakConstantGEPs> p1 = std::make_unique<BreakConstantGEPs>();
265 for (Module &M : getLLVMModules())
266 {
267 p1->runOnModule(M);
268 }
269
271 std::unique_ptr<UnifyFunctionExitNodes> p2 =
272 std::make_unique<UnifyFunctionExitNodes>();
273 for (Module &M : getLLVMModules())
274 {
275 for (auto F = M.begin(), E = M.end(); F != E; ++F)
276 {
277 Function &fun = *F;
278 if (fun.isDeclaration())
279 continue;
280#if LLVM_VERSION_MAJOR <= 16
281 p2->runOnFunction(fun);
282#else
283 llvm::PassBuilder PB;
284 llvm::LoopAnalysisManager LAM;
285 llvm::FunctionAnalysisManager FAM;
286 llvm::CGSCCAnalysisManager CGAM;
287 llvm::ModuleAnalysisManager MAM;
288 PB.registerModuleAnalyses(MAM);
289 PB.registerCGSCCAnalyses(CGAM);
290 PB.registerFunctionAnalyses(FAM);
291 PB.registerLoopAnalyses(LAM);
292 PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
293 llvm::FunctionPassManager FPM;
294 FPM.addPass(llvm::UnifyFunctionExitNodesPass());
295 FPM.run(fun, FAM);
296#endif
297 }
298 }
299}
const std::vector< std::reference_wrapper< Module > > & getLLVMModules() const
Definition LLVMModule.h:164

◆ preProcessBCs()

void LLVMModuleSet::preProcessBCs ( std::vector< std::string > &  moduleNameVec)
static

Definition at line 301 of file LLVMModule.cpp.

302{
304 mset->loadModules(moduleNameVec);
305 mset->loadExtAPIModules();
306 mset->prePassSchedule();
307
308 std::string preProcessSuffix = ".pre.bc";
309 // Get the existing module names, remove old extension, add preProcessSuffix
310 for (u32_t i = 0; i < moduleNameVec.size(); i++)
311 {
312 u32_t lastIndex = moduleNameVec[i].find_last_of(".");
313 std::string rawName = moduleNameVec[i].substr(0, lastIndex);
315 }
316
317 mset->dumpModulesToFile(preProcessSuffix);
318 preProcessed = true;
320}
static void releaseLLVMModuleSet()
Definition LLVMModule.h:144

◆ releaseLLVMModuleSet()

static void SVF::LLVMModuleSet::releaseLLVMModuleSet ( )
inlinestatic

Definition at line 144 of file LLVMModule.h.

145 {
146 delete llvmModuleSet;
147 llvmModuleSet = nullptr;
149 }
static void unset(void)
Deletes the (singleton) allocator.

◆ retSyms()

FunToIDMapTy & SVF::LLVMModuleSet::retSyms ( )
inline

Definition at line 281 of file LLVMModule.h.

282 {
283 return returnSymMap;
284 }

◆ setExtFuncAnnotations()

void LLVMModuleSet::setExtFuncAnnotations ( const Function *  fun,
const std::vector< std::string > &  funcAnnotations 
)

Definition at line 1519 of file LLVMModule.cpp.

1520{
1521 assert(fun && "Null SVFFunction* pointer");
1523}

◆ setFunExitBB()

void SVF::LLVMModuleSet::setFunExitBB ( const Function *  fun,
const BasicBlock *  bb 
)
inlineprivate

Definition at line 457 of file LLVMModule.h.

458 {
459 funToExitBB[fun] = bb;
460 }

◆ setFunRealDefFun()

void SVF::LLVMModuleSet::setFunRealDefFun ( const Function *  fun,
const Function *  realDefFun 
)
inlineprivate

Definition at line 462 of file LLVMModule.h.

463 {
464 funToRealDefFun[fun] = realDefFun;
465 }

◆ valSyms()

ValueToIDMapTy & SVF::LLVMModuleSet::valSyms ( )
inline

Definition at line 214 of file LLVMModule.h.

215 {
216 return valSymMap;
217 }

◆ varargSyms()

FunToIDMapTy & SVF::LLVMModuleSet::varargSyms ( )
inline

Definition at line 286 of file LLVMModule.h.

287 {
288 return varargSymMap;
289 }

Friends And Related Symbol Documentation

◆ ICFGBuilder

Definition at line 50 of file LLVMModule.h.

◆ SVFIRBuilder

Definition at line 49 of file LLVMModule.h.

◆ SymbolTableBuilder

Definition at line 51 of file LLVMModule.h.

Member Data Documentation

◆ CSToCallNodeMap

CSToCallNodeMapTy SVF::LLVMModuleSet::CSToCallNodeMap
private

map a callsite to its CallICFGNode

Definition at line 112 of file LLVMModule.h.

◆ CSToRetNodeMap

CSToRetNodeMapTy SVF::LLVMModuleSet::CSToRetNodeMap
private

map a callsite to its RetICFGNode

Definition at line 113 of file LLVMModule.h.

◆ ExtFun2Annotations

Fun2AnnoMap SVF::LLVMModuleSet::ExtFun2Annotations
private

Record annotations of function in extapi.bc.

Definition at line 97 of file LLVMModule.h.

◆ ExtFuncsVec

FunctionSetType SVF::LLVMModuleSet::ExtFuncsVec
private

Record some "sse_" function declarations used in other ext function definition, e.g., svf_ext_foo(), and svf_ext_foo() used in app functions.

Definition at line 95 of file LLVMModule.h.

◆ func2Annotations

Map<const Function*, std::vector<std::string> > SVF::LLVMModuleSet::func2Annotations
private

Definition at line 100 of file LLVMModule.h.

◆ funSet

FunctionSet SVF::LLVMModuleSet::funSet
private

Definition at line 125 of file LLVMModule.h.

◆ FunToDominatorTree

Map<const Function*, DominatorTree> SVF::LLVMModuleSet::FunToDominatorTree
private

Definition at line 118 of file LLVMModule.h.

◆ funToExitBB

FunToExitBBMap SVF::LLVMModuleSet::funToExitBB
private

Definition at line 126 of file LLVMModule.h.

◆ FunToFunEntryNodeMap

FunToFunEntryNodeMapTy SVF::LLVMModuleSet::FunToFunEntryNodeMap
private

map a function to its FunExitICFGNode

Definition at line 115 of file LLVMModule.h.

◆ FunToFunExitNodeMap

FunToFunExitNodeMapTy SVF::LLVMModuleSet::FunToFunExitNodeMap
private

map a function to its FunEntryICFGNode

Definition at line 116 of file LLVMModule.h.

◆ funToRealDefFun

FunToRealDefFunMap SVF::LLVMModuleSet::funToRealDefFun
private

Definition at line 127 of file LLVMModule.h.

◆ GlobalDefToRepMap

GlobalDefToRepMapTy SVF::LLVMModuleSet::GlobalDefToRepMap
private

Global definition to a rep definition map.

Definition at line 103 of file LLVMModule.h.

◆ InstToBlockNodeMap

InstToBlockNodeMapTy SVF::LLVMModuleSet::InstToBlockNodeMap
private

map a basic block to its ICFGNode

Definition at line 114 of file LLVMModule.h.

◆ LLVMBB2SVFBB

LLVMBB2SVFBBMap SVF::LLVMModuleSet::LLVMBB2SVFBB
private

Definition at line 106 of file LLVMModule.h.

◆ LLVMFun2FunObjVar

LLVMFun2FunObjVarMap SVF::LLVMModuleSet::LLVMFun2FunObjVar
private

Map an LLVM Function to an SVF Funobjvar.

Definition at line 105 of file LLVMModule.h.

◆ llvmModuleSet

LLVMModuleSet * LLVMModuleSet::llvmModuleSet = nullptr
staticprivate

Definition at line 84 of file LLVMModule.h.

◆ LLVMType2SVFType

LLVMType2SVFTypeMap SVF::LLVMModuleSet::LLVMType2SVFType
private

Definition at line 107 of file LLVMModule.h.

◆ modules

std::vector<std::reference_wrapper<Module> > SVF::LLVMModuleSet::modules
private

Definition at line 89 of file LLVMModule.h.

◆ objSymMap

ValueToIDMapTy SVF::LLVMModuleSet::objSymMap
private

map a obj reference to its sym id

Definition at line 121 of file LLVMModule.h.

◆ owned_ctx

std::unique_ptr<LLVMContext> SVF::LLVMModuleSet::owned_ctx
private

Definition at line 87 of file LLVMModule.h.

◆ owned_modules

std::vector<std::unique_ptr<Module> > SVF::LLVMModuleSet::owned_modules
private

Definition at line 88 of file LLVMModule.h.

◆ preProcessed

bool LLVMModuleSet::preProcessed = false
staticprivate

Definition at line 85 of file LLVMModule.h.

◆ returnSymMap

FunToIDMapTy SVF::LLVMModuleSet::returnSymMap
private

return map

Definition at line 122 of file LLVMModule.h.

◆ SVFBaseNode2LLVMValue

SVFBaseNode2LLVMValueMap SVF::LLVMModuleSet::SVFBaseNode2LLVMValue
private

Definition at line 111 of file LLVMModule.h.

◆ svfir

SVFIR* SVF::LLVMModuleSet::svfir
private

Definition at line 86 of file LLVMModule.h.

◆ targetABI

TargetABI SVF::LLVMModuleSet::targetABI = TargetABI::Itanium
private

C++ ABI of the module being analyzed.

Definition at line 92 of file LLVMModule.h.

◆ Type2TypeInfo

Type2TypeInfoMap SVF::LLVMModuleSet::Type2TypeInfo
private

Definition at line 108 of file LLVMModule.h.

◆ typeInference

ObjTypeInference* SVF::LLVMModuleSet::typeInference
private

Definition at line 109 of file LLVMModule.h.

◆ valSymMap

ValueToIDMapTy SVF::LLVMModuleSet::valSymMap
private

map a value to its sym id

Definition at line 120 of file LLVMModule.h.

◆ varargSymMap

FunToIDMapTy SVF::LLVMModuleSet::varargSymMap
private

vararg map

Definition at line 123 of file LLVMModule.h.


The documentation for this class was generated from the following files: