Skip to content

Commit

Permalink
small change
Browse files Browse the repository at this point in the history
  • Loading branch information
hwg committed Oct 11, 2024
1 parent 7c8cd2a commit 68c933c
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 27 deletions.
9 changes: 6 additions & 3 deletions svf/include/Util/CallGraphBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@ class SVFModule;

class CallGraphBuilder
{
public:
typedef SVFModule::FunctionSetType FunctionSetType;

protected:
const SVFModule::FunctionSetType* svfFunctionSet;
const FunctionSetType* svfFunctionSet;
ICFG* icfg;
// CallGraph* callgraph;

public:

CallGraphBuilder(const SVFModule::FunctionSetType* fs, ICFG* i): svfFunctionSet(fs),icfg(i)
{
}
Expand All @@ -58,7 +61,7 @@ class CallGraphBuilder
CallGraph* buildSVFIRCallGraph();

/// Build thread-aware callgraph
CallGraph* buildThreadCallGraph();
ThreadCallGraph* buildThreadCallGraph();
};

} // End namespace SVF
Expand Down
8 changes: 4 additions & 4 deletions svf/include/Util/SVFUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,11 @@ inline bool isProgEntryFunction(const SVFFunction* fun)
return fun && fun->getName() == "main";
}

/// Get program entry function from module.
const SVFFunction* getProgFunction(SVFModule* svfModule, const std::string& funName);
/// Get program entry function from function name.
const SVFFunction* getProgFunction(const std::string& funName);

/// Get program entry function from module.
const SVFFunction* getProgEntryFunction(SVFModule* svfModule);
/// Get program entry function.
const SVFFunction* getProgEntryFunction();

/// Return true if this is a program exit function call
//@{
Expand Down
4 changes: 1 addition & 3 deletions svf/lib/Graphs/SVFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,7 @@ void SVFG::connectIndirectSVFGEdges()
*/
void SVFG::connectFromGlobalToProgEntry()
{
SVFModule* svfModule = mssa->getPTA()->getModule();
const SVFFunction* mainFunc =
SVFUtil::getProgEntryFunction(svfModule);
const SVFFunction* mainFunc = SVFUtil::getProgEntryFunction();
FormalINSVFGNodeSet& formalIns = getFormalINSVFGNodes(mainFunc);
if (formalIns.empty())
return;
Expand Down
3 changes: 2 additions & 1 deletion svf/lib/MSSA/MemRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ SVFIR::SVFStmtList& MRGenerator::getPAGEdgesFromInst(const ICFGNode* node)
void MRGenerator::collectModRefForLoadStore()
{

for (const auto& item: *PAG::getPAG()->getCallGraph())
CallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph();
for (const auto& item: *svfirCallGraph)
{
const SVFFunction& fun = *item.second->getFunction();

Expand Down
3 changes: 2 additions & 1 deletion svf/lib/MSSA/MemSSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,8 @@ u32_t MemSSA::getBBPhiNum() const
void MemSSA::dumpMSSA(OutStream& Out)
{

for (const auto& item: *PAG::getPAG()->getCallGraph())
CallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph();

Check warning on line 578 in svf/lib/MSSA/MemSSA.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/MSSA/MemSSA.cpp#L578

Added line #L578 was not covered by tests
for (const auto& item: *svfirCallGraph)
{
const SVFFunction* fun = item.second->getFunction();

Check warning on line 581 in svf/lib/MSSA/MemSSA.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/MSSA/MemSSA.cpp#L581

Added line #L581 was not covered by tests
if(Options::MSSAFun()!="" && Options::MSSAFun()!=fun->getName())
Expand Down
3 changes: 2 additions & 1 deletion svf/lib/MSSA/SVFGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ std::unique_ptr<MemSSA> SVFGBuilder::buildMSSA(BVDataPTAImpl* pta, bool ptrOnlyM

auto mssa = std::make_unique<MemSSA>(pta, ptrOnlyMSSA);

for (const auto& item: *PAG::getPAG()->getCallGraph())
CallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph();
for (const auto& item: *svfirCallGraph)
{

const SVFFunction *fun = item.second->getFunction();
Expand Down
3 changes: 2 additions & 1 deletion svf/lib/MTA/TCT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ void TCT::markRelProcs(const SVFFunction* svffun)
*/
void TCT::collectEntryFunInCallGraph()
{
for (const auto& item: *PAG::getPAG()->getCallGraph())
CallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph();
for (const auto& item: *svfirCallGraph)
{
const SVFFunction* fun = item.second->getFunction();
if (SVFUtil::isExtCall(fun))
Expand Down
3 changes: 2 additions & 1 deletion svf/lib/SABER/SaberCondAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ void SaberCondAllocator::allocate(const SVFModule *M)
{
DBOUT(DGENERAL, outs() << pasMsg("path condition allocation starts\n"));

for (const auto& item: *PAG::getPAG()->getCallGraph())
CallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph();
for (const auto& item: *svfirCallGraph)
{
const SVFFunction *func = (item.second)->getFunction();
if (!SVFUtil::isExtCall(func))
Expand Down
3 changes: 2 additions & 1 deletion svf/lib/Util/CDGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ s64_t CDGBuilder::getBBSuccessorBranchID(const SVFBasicBlock *BB, const SVFBasic
*/
void CDGBuilder::buildControlDependence(const SVFModule *svfgModule)
{
for (const auto& item: *PAG::getPAG()->getCallGraph())
CallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph();

Check warning on line 126 in svf/lib/Util/CDGBuilder.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/Util/CDGBuilder.cpp#L126

Added line #L126 was not covered by tests
for (const auto& item: *svfirCallGraph)
{
const SVFFunction *svfFun = (item.second)->getFunction();

Check warning on line 129 in svf/lib/Util/CDGBuilder.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/Util/CDGBuilder.cpp#L129

Added line #L129 was not covered by tests
if (SVFUtil::isExtCall(svfFun)) continue;
Expand Down
10 changes: 5 additions & 5 deletions svf/lib/Util/CallGraphBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ CallGraph* CallGraphBuilder::buildSVFIRCallGraph()
return callgraph;
}

CallGraph* CallGraphBuilder::buildThreadCallGraph()
ThreadCallGraph* CallGraphBuilder::buildThreadCallGraph()
{
CallGraph* callgraph = new ThreadCallGraph(*(PAG::getPAG()->getCallGraph()));
ThreadCallGraph* cg = dyn_cast<ThreadCallGraph>(callgraph);
ThreadCallGraph* cg = new ThreadCallGraph(*(PAG::getPAG()->getCallGraph()));
assert(cg && "not a thread callgraph?");

ThreadAPI* tdAPI = ThreadAPI::getThreadAPI();
for (const auto& item: *PAG::getPAG()->getCallGraph())
CallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph();
for (const auto& item: *svfirCallGraph)
{
for (const SVFBasicBlock* svfbb : (item.second)->getFunction()->getBasicBlockList())
{
Expand All @@ -95,7 +95,7 @@ CallGraph* CallGraphBuilder::buildThreadCallGraph()
}
}
// record join sites
for (const auto& item: *PAG::getPAG()->getCallGraph())
for (const auto& item: *svfirCallGraph)
{
for (const SVFBasicBlock* svfbb : (item.second)->getFunction()->getBasicBlockList())
{
Expand Down
3 changes: 2 additions & 1 deletion svf/lib/Util/SVFStat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ void SVFStat::branchStat()
{
u32_t numOfBB_2Succ = 0;
u32_t numOfBB_3Succ = 0;
for (const auto& item: *PAG::getPAG()->getCallGraph())
CallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph();
for (const auto& item: *svfirCallGraph)
{
const SVFFunction* func = item.second->getFunction();
for (SVFFunction::const_iterator bbIt = func->begin(), bbEit = func->end();
Expand Down
10 changes: 6 additions & 4 deletions svf/lib/Util/SVFUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,10 @@ bool SVFUtil::isProgExitCall(const CallICFGNode* cs)
}

/// Get program entry function from module.
const SVFFunction* SVFUtil::getProgFunction(SVFModule* svfModule, const std::string& funName)
const SVFFunction* SVFUtil::getProgFunction(const std::string& funName)

Check warning on line 402 in svf/lib/Util/SVFUtil.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/Util/SVFUtil.cpp#L402

Added line #L402 was not covered by tests
{
for (const auto& item: *PAG::getPAG()->getCallGraph())
CallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph();

Check warning on line 404 in svf/lib/Util/SVFUtil.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/Util/SVFUtil.cpp#L404

Added line #L404 was not covered by tests
for (const auto& item: *svfirCallGraph)
{
const CallGraphNode*fun = item.second;

Check warning on line 407 in svf/lib/Util/SVFUtil.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/Util/SVFUtil.cpp#L407

Added line #L407 was not covered by tests
if (fun->getName()==funName)
Expand All @@ -411,9 +412,10 @@ const SVFFunction* SVFUtil::getProgFunction(SVFModule* svfModule, const std::str
}

/// Get program entry function from module.
const SVFFunction* SVFUtil::getProgEntryFunction(SVFModule* svfModule)
const SVFFunction* SVFUtil::getProgEntryFunction()
{
for (const auto& item: *PAG::getPAG()->getCallGraph())
CallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph();
for (const auto& item: *svfirCallGraph)
{
const CallGraphNode*fun = item.second;
if (isProgEntryFunction(fun->getFunction()))
Expand Down
3 changes: 2 additions & 1 deletion svf/lib/Util/ThreadAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ void ThreadAPI::performAPIStat(SVFModule* module)

statInit(tdAPIStatMap);

for (const auto& item: *PAG::getPAG()->getCallGraph())
CallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph();

Check warning on line 273 in svf/lib/Util/ThreadAPI.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/Util/ThreadAPI.cpp#L273

Added line #L273 was not covered by tests
for (const auto& item: *svfirCallGraph)
{
for (SVFFunction::const_iterator bit = (item.second)->getFunction()->begin(), ebit = (item.second)->getFunction()->end(); bit != ebit; ++bit)
{
Expand Down

0 comments on commit 68c933c

Please sign in to comment.