Skip to content

Commit

Permalink
Merge pull request #1258 from shuangxiangkan/master
Browse files Browse the repository at this point in the history
Load extapi module in buildSVFModule(Module& mod)
  • Loading branch information
yuleisui authored Nov 25, 2023
2 parents d470e6f + 1bbb734 commit b36c455
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions svf-llvm/include/SVF-LLVM/LLVMModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ class LLVMModuleSet
llvmModuleSet = nullptr;
}

static SVFModule* buildSVFModule(Module& mod);
// The parameter of context should be the llvm context of the mod, the llvm context of mod and extapi module should be the same
static SVFModule* buildSVFModule(Module& mod, std::unique_ptr<LLVMContext> context);
static SVFModule* buildSVFModule(const std::vector<std::string>& moduleNameVec);

inline SVFModule* getSVFModule()
Expand Down Expand Up @@ -356,7 +357,8 @@ class LLVMModuleSet
std::vector<const Function*> getLLVMGlobalFunctions(const GlobalVariable* global);

void loadModules(const std::vector<std::string>& moduleNameVec);
void loadExtAPIModules();
// The llvm context of app module and extapi module should be the same
void loadExtAPIModules(std::unique_ptr<LLVMContext> context = nullptr);
void addSVFMain();

void createSVFDataStructure();
Expand Down
8 changes: 6 additions & 2 deletions svf-llvm/lib/LLVMModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,14 @@ LLVMModuleSet::LLVMModuleSet()
{
}

SVFModule* LLVMModuleSet::buildSVFModule(Module &mod)
SVFModule* LLVMModuleSet::buildSVFModule(Module &mod, std::unique_ptr<LLVMContext> context)
{
LLVMModuleSet* mset = getLLVMModuleSet();

double startSVFModuleTime = SVFStat::getClk(true);
SVFModule::getSVFModule()->setModuleIdentifier(mod.getModuleIdentifier());
mset->modules.emplace_back(mod);
mset->loadExtAPIModules(std::move(context));

mset->build();
double endSVFModuleTime = SVFStat::getClk(true);
Expand Down Expand Up @@ -528,7 +529,7 @@ void LLVMModuleSet::loadModules(const std::vector<std::string> &moduleNameVec)
}
}

void LLVMModuleSet::loadExtAPIModules()
void LLVMModuleSet::loadExtAPIModules(std::unique_ptr<LLVMContext> context)
{
// Load external API module (extapi.bc)
if (!ExtAPI::getExtAPI()->getExtBcPath().empty())
Expand All @@ -540,6 +541,9 @@ void LLVMModuleSet::loadExtAPIModules()
abort();
}
SMDiagnostic Err;
assert(!(cxts == nullptr && context == nullptr) && "Before loading extapi module, at least one LLVMContext should be initialized !!!");
if (context != nullptr)
cxts = std::move(context);
std::unique_ptr<Module> mod = parseIRFile(extModuleName, Err, *cxts);
if (mod == nullptr)
{
Expand Down

0 comments on commit b36c455

Please sign in to comment.