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

Hwg change SVFFunction to CallGraphNode in AE #1536

Closed
wants to merge 6 commits into from
Closed
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
5 changes: 3 additions & 2 deletions svf/include/AE/Svfexe/AbstractInterpretation.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,11 @@ class AbstractInterpretation

ICFG* icfg;
AEStat* stat;
CallGraph* callGraph;

std::vector<const CallICFGNode*> callSiteStack;
Map<const SVFFunction*, ICFGWTO*> funcToWTO;
Set<const SVFFunction*> recursiveFuns;
Map<const CallGraphNode*, ICFGWTO*> funcToWTO;
Set<const CallGraphNode*> recursiveFuns;

private:
// helper functions in handleCallSite
Expand Down
26 changes: 17 additions & 9 deletions svf/lib/AE/Svfexe/AbstractInterpretation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ void AbstractInterpretation::runOnModule(ICFG *_icfg)
AbstractInterpretation::AbstractInterpretation()
{
stat = new AEStat(this);
callGraph = nullptr;
initExtFunMap();
}
/// Destructor
Expand All @@ -130,22 +131,22 @@ void AbstractInterpretation::initWTO()
// Detect if the call graph has cycles by finding its strongly connected components (SCC)
Andersen::CallGraphSCC* callGraphScc = ander->getCallGraphSCC();
callGraphScc->find();
auto callGraph = ander->getCallGraph();
callGraph = ander->getCallGraph();

// Iterate through the call graph
for (auto it = callGraph->begin(); it != callGraph->end(); it++)
{
// Check if the current function is part of a cycle
if (callGraphScc->isInCycle(it->second->getId()))
recursiveFuns.insert(it->second->getFunction()); // Mark the function as recursive
recursiveFuns.insert(it->second); // Mark the function as recursive
}

// Initialize WTO for each function in the module
for (const SVFFunction* fun : svfir->getModule()->getFunctionSet())
{
auto* wto = new ICFGWTO(icfg, icfg->getFunEntryICFGNode(fun));
wto->init();
funcToWTO[fun] = wto;
funcToWTO[callGraph->getCallGraphNode(fun)] = wto;
}
}
/// Program entry
Expand All @@ -158,7 +159,7 @@ void AbstractInterpretation::analyse()
icfg->getGlobalICFGNode())[PAG::getPAG()->getBlkPtr()] = IntervalValue::top();
if (const SVFFunction* fun = svfir->getModule()->getSVFFunction("main"))
{
ICFGWTO* wto = funcToWTO[fun];
ICFGWTO* wto = funcToWTO[callGraph->getCallGraphNode(fun)];
handleWTOComponents(wto->getWTOComponents());
}
}
Expand Down Expand Up @@ -630,7 +631,11 @@ void AbstractInterpretation::extCallPass(const SVF::CallICFGNode *callNode)
bool AbstractInterpretation::isRecursiveCall(const SVF::CallICFGNode *callNode)
{
const SVFFunction *callfun = SVFUtil::getCallee(callNode->getCallSite());
return recursiveFuns.find(callfun) != recursiveFuns.end();
if (!callfun)
return false;
else
return recursiveFuns.find(callGraph->getCallGraphNode(callfun)) != recursiveFuns.end();

}

void AbstractInterpretation::recursiveCallPass(const SVF::CallICFGNode *callNode)
Expand All @@ -654,8 +659,11 @@ void AbstractInterpretation::recursiveCallPass(const SVF::CallICFGNode *callNode

bool AbstractInterpretation::isDirectCall(const SVF::CallICFGNode *callNode)
{
const SVFFunction *callfun = SVFUtil::getCallee(callNode->getCallSite());
return funcToWTO.find(callfun) != funcToWTO.end();
const SVFFunction *callfun = SVFUtil::getCallee(callNode->getCallSite());
if (!callfun)
return false;
else
return funcToWTO.find(callGraph->getCallGraphNode(callfun)) != funcToWTO.end();
}
void AbstractInterpretation::directCallFunPass(const SVF::CallICFGNode *callNode)
{
Expand All @@ -665,7 +673,7 @@ void AbstractInterpretation::directCallFunPass(const SVF::CallICFGNode *callNode

abstractTrace[callNode] = as;

ICFGWTO* wto = funcToWTO[callfun];
ICFGWTO* wto = funcToWTO[callGraph->getCallGraphNode(callfun)];
handleWTOComponents(wto->getWTOComponents());

callSiteStack.pop_back();
Expand Down Expand Up @@ -699,7 +707,7 @@ void AbstractInterpretation::indirectCallFunPass(const SVF::CallICFGNode *callNo
callSiteStack.push_back(callNode);
abstractTrace[callNode] = as;

ICFGWTO* wto = funcToWTO[callfun];
ICFGWTO* wto = funcToWTO[callGraph->getCallGraphNode(callfun)];
handleWTOComponents(wto->getWTOComponents());
callSiteStack.pop_back();
// handle Ret node
Expand Down