Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some issues about ExtAPI #1210

Merged
merged 2 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .config.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
#define CONFIG_H_IN

#define PROJECT_PATH "@CMAKE_CURRENT_SOURCE_DIR@"
#define EXTAPI_PATH PROJECT_PATH "/@CMAKE_BUILD_TYPE@-build/svf-llvm"
#define EXTAPI_DIR PROJECT_PATH "/@CMAKE_BUILD_TYPE@-build/svf-llvm"

#endif
2 changes: 1 addition & 1 deletion svf-llvm/include/SVF-LLVM/LLVMModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class LLVMModuleSet
bool isCalledExtFunction(Function* func)
{
/// if this function func defined in extapi.bc but never used in application code (without any corresponding declared functions).
if (func->getParent()->getName().str() == Options::ExtAPIInput()
if (func->getParent()->getName().str() == ExtAPI::getExtAPI()->getExtBcPath()
&& FunDefToDeclsMap.find(func) == FunDefToDeclsMap.end()
&& std::find(ExtFuncsVec.begin(), ExtFuncsVec.end(), func) == ExtFuncsVec.end())
{
Expand Down
8 changes: 4 additions & 4 deletions svf-llvm/lib/LLVMModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,10 @@ void LLVMModuleSet::loadModules(const std::vector<std::string> &moduleNameVec)

void LLVMModuleSet::loadExtAPIModules()
{
// has external bc
if (Options::ExtAPIInput().size() > 0)
// Load external API module (extapi.bc)
if (!ExtAPI::getExtAPI()->getExtBcPath().empty())
{
std::string extModuleName = Options::ExtAPIInput();
std::string extModuleName = ExtAPI::getExtAPI()->getExtBcPath();
if (!LLVMUtil::isIRFile(extModuleName))
{
SVFUtil::errs() << "not an external IR file: " << extModuleName << std::endl;
Expand Down Expand Up @@ -809,7 +809,7 @@ void LLVMModuleSet::buildFunToFunMap()
for (Module& mod : modules)
{
// extapi.bc functions
if (mod.getName().str() == Options::ExtAPIInput())
if (mod.getName().str() == ExtAPI::getExtAPI()->getExtBcPath())
{
for (const Function& fun : mod.functions())
{
Expand Down
2 changes: 1 addition & 1 deletion svf-llvm/lib/LLVMUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ void LLVMUtil::removeUnusedFuncsAndAnnotationsAndGlobalVariables(std::vector<Fun
return;

Module* mod = removedFuncList[0]->getParent();
if (mod->getName().str() != Options::ExtAPIInput())
if (mod->getName().str() != ExtAPI::getExtAPI()->getExtBcPath())
return;

/// Delete unused function annotations
Expand Down
2 changes: 1 addition & 1 deletion svf/include/Util/ExtAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ExtAPI

public:

static ExtAPI *getExtAPI(const std::string& = "");
static ExtAPI *getExtAPI();

static void destory();

Expand Down
1 change: 0 additions & 1 deletion svf/include/Util/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ class Options
static const Option<bool> VtableInSVFIR;

// WPAPass.cpp
static const Option<std::string> ExtAPIInput;
static const Option<bool> AnderSVFG;
static const Option<bool> SABERFULLSVFG;
static const Option<bool> PrintAliases;
Expand Down
6 changes: 3 additions & 3 deletions svf/lib/Util/ExtAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ using namespace SVF;

ExtAPI* ExtAPI::extOp = nullptr;

ExtAPI* ExtAPI::getExtAPI(const std::string& path)
ExtAPI* ExtAPI::getExtAPI()
{
if (extOp == nullptr)
{
Expand Down Expand Up @@ -108,7 +108,7 @@ static std::string getFilePath(const std::string& path)
std::string ExtAPI::getExtBcPath()
{
struct stat statbuf;
std::string bcFilePath = std::string(EXTAPI_PATH) + "/extapi.bc";
std::string bcFilePath = std::string(EXTAPI_DIR) + "/extapi.bc";
if (!stat(bcFilePath.c_str(), &statbuf))
return bcFilePath;

Expand All @@ -120,7 +120,7 @@ std::string ExtAPI::getExtBcPath()
if (!stat(bcFilePath.c_str(), &statbuf))
return bcFilePath;

SVFUtil::errs() << "No extpai.bc found at " << bcFilePath << " for getExtAPI(); set $SVF_DIR first!\n";
SVFUtil::errs() << "No extapi.bc found at " << bcFilePath << " for getExtAPI(); The default path for extapi.bc is: SVF_IR_PATH/CMAKE_BUILD_TYPE-build/svf-llvm/extapi.bc !\n";
abort();
}

Expand Down
6 changes: 0 additions & 6 deletions svf/lib/Util/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,12 +770,6 @@ const Option<bool> Options::VtableInSVFIR(
false
);


//WPAPass.cpp
const Option<std::string> Options::ExtAPIInput(
"extapi", "External API extapi.bc", ExtAPI::getExtAPI()->getExtBcPath()
);

const Option<bool> Options::AnderSVFG(
"svfg",
"Generate SVFG after Andersen's Analysis",
Expand Down