8000 remove callgraph by jumormt · Pull Request #1647 · SVF-tools/SVF · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

remove callgraph #1647

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

Merged
merged 1 commit into from
Feb 3, 2025
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
13 changes: 1 addition & 12 deletions svf-llvm/include/SVF-LLVM/LLVMModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class LLVMModuleSet
typedef Map<const GlobalVariable*, GlobalVariable*> GlobalDefToRepMapTy;

typedef Map<const Function*, SVFFunction*> LLVMFun2SVFFunMap;
typedef Map<const Function*, CallGraphNode*> LLVMFun2CallGraphNodeMap;
typedef Map<const BasicBlock*, SVFBasicBlock*> LLVMBB2SVFBBMap;
typedef Map<const Instruction*, SVFInstruction*> LLVMInst2SVFInstMap;
typedef Map<const Argument*, SVFArgument*> LLVMArgument2SVFArgumentMap;
Expand Down Expand Up @@ -95,7 +94,6 @@ class LLVMModuleSet
GlobalDefToRepMapTy GlobalDefToRepMap;

LLVMFun2SVFFunMap LLVMFunc2SVFFunc; ///< Map an LLVM Function to an SVF Function
LLVMFun2CallGraphNodeMap LLVMFunc2CallGraphNode; ///< Map an LLVM Function to an CallGraph Node
LLVMBB2SVFBBMap LLVMBB2SVFBB;
LLVMInst2SVFInstMap LLVMInst2SVFInst;
LLVMArgument2SVFArgumentMap LLVMArgument2SVFArgument;
Expand All @@ -112,7 +110,7 @@ class LLVMModuleSet
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
CallGraph* callgraph;
PTACallGraph* callgraph;

Map<const Function*, DominatorTree> FunToDominatorTree;

Expand Down Expand Up @@ -218,8 +216,6 @@ class LLVMModuleSet
setValueAttr(func,svfFunc);
}

void addFunctionMap(const Function* func, CallGraphNode* svfFunc);

// create a SVFBasicBlock according to LLVM BasicBlock, then add it to SVFFunction's BasicBlockGraph
inline void addBasicBlock(SVFFunction* fun, const BasicBlock* bb)
{
Expand Down Expand Up @@ -296,13 +292,6 @@ class LLVMModuleSet
return it->second;
}

inline CallGraphNode* getCallGraphNode(const Function* fun) const
{
LLVMFun2CallGraphNodeMap::const_iterator it = LLVMFunc2CallGraphNode.find(fun);
assert(it!=LLVMFunc2CallGraphNode.end() && "SVF Function not found!");
return it->second;
}

inline SVFFunction* getSVFFunction(const Function* fun) const
{
LLVMFun2SVFFunMap::const_iterator it = LLVMFunc2SVFFunc.find(fun);
Expand Down
20 changes: 1 addition & 19 deletions svf-llvm/lib/LLVMModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include "SVF-LLVM/ObjTypeInference.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "SVF-LLVM/ICFGBuilder.h"
#include "Graphs/CallGraph.h"
#include "Graphs/PTACallGraph.h"
#include "Util/CallGraphBuilder.h"

using namespace std;
Expand Down Expand Up @@ -191,18 +191,6 @@ void LLVMModuleSet::build()

CallGraphBuilder callGraphBuilder;
callgraph = callGraphBuilder.buildSVFIRCallGraph(svfModule);
for (const auto& func : svfModule->getFunctionSet())
{
SVFFunction* svffunc = const_cast<SVFFunction*>(func);
svffunc->setCallGraphNode(callgraph->getCallGraphNode(func));
}

for (const auto& it : *callgraph)
{
addFunctionMap(
SVFUtil::cast<Function>(getLLVMValue(it.second->getFunction())),
it.second);
}
}

void LLVMModuleSet::createSVFDataStructure()
Expand Down Expand Up @@ -1294,12 +1282,6 @@ void LLVMModuleSet::dumpSymTable()
SVFUtil::outs() << "}\n";
}

void LLVMModuleSet::addFunctionMap(const Function* func, CallGraphNode* svfFunc)
{
LLVMFunc2CallGraphNode[func] = svfFunc;
addToSVFVar2LLVMValueMap(func, svfFunc);
}

void LLVMModuleSet::setValueAttr(const Value* val, SVFValue* svfvalue)
{
SVFValue2LLVMValue[svfvalue] = val;
Expand Down
14 changes: 7 additions & 7 deletions svf-llvm/lib/SVFIRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "SVFIR/SVFModule.h"
#include "SVFIR/SVFValue.h"
#include "Util/CallGraphBuilder.h"
#include "Graphs/CallGraph.h"
#include "Graphs/PTACallGraph.h"
#include "Util/Options.h"
#include "Util/SVFUtil.h"

Expand Down Expand Up @@ -220,15 +220,15 @@ void SVFIRBuilder::initialiseNodes()
if (const Function* func =
SVFUtil::dyn_cast<Function>(llvmValue))
{
const CallGraphNode* cgn = llvmModuleSet()->getCallGraphNode(func);
const SVFFunction* cgn = llvmModuleSet()->getSVFFunction(func);
// add value node representing the function
pag->addFunValNode(iter->second, icfgNode, cgn, iter->first->getType());
}
else if (auto argval = SVFUtil::dyn_cast<Argument>(llvmValue))
{
pag->addArgValNode(
iter->second, argval->getArgNo(), icfgNode,
llvmModuleSet()->getCallGraphNode(argval->getParent()),iter->first->getType());
llvmModuleSet()->getSVFFunction(argval->getParent()),iter->first->getType());
if (!argval->hasName())
pag->getGNode(iter->second)->setName("arg_" + std::to_string(argval->getArgNo()));
}
Expand Down Expand Up @@ -291,8 +291,8 @@ void SVFIRBuilder::initialiseNodes()
// Check if the value is a function and add a function object node
if (const Function* func = SVFUtil::dyn_cast<Function>(llvmValue))
{
NodeID id = llvmModuleSet()->getObjectNode(llvmModuleSet()->getCallGraphNode(func)->getFunction());
pag->addFunObjNode(iter->second, pag->getObjTypeInfo(id), llvmModuleSet()->getCallGraphNode(func), iter->first->getType(), icfgNode);
NodeID id = llvmModuleSet()->getObjectNode(llvmModuleSet()->getSVFFunction(func));
pag->addFunObjNode(iter->second, pag->getObjTypeInfo(id), llvmModuleSet()->getSVFFunction(func), iter->first->getType(), icfgNode);
}
// Check if the value is a heap object and add a heap object node
else if (LLVMUtil::isHeapObj(llvmValue))
Expand Down Expand Up @@ -361,7 +361,7 @@ void SVFIRBuilder::initialiseNodes()
}
DBOUT(DPAGBuild, outs() << "add ret node " << iter->second << "\n");
pag->addRetNode(iter->second,
llvmModuleSet()->getCallGraphNode(SVFUtil::cast<Function>(llvmValue)), iter->first->getType(), icfgNode);
llvmModuleSet()->getSVFFunction(SVFUtil::cast<Function>(llvmValue)), iter->first->getType(), icfgNode);
llvmModuleSet()->addToSVFVar2LLVMValueMap(llvmValue, pag->getGNode(iter->second));
}

Expand All @@ -379,7 +379,7 @@ void SVFIRBuilder::initialiseNodes()
}
DBOUT(DPAGBuild, outs() << "add vararg node " << iter->second << "\n");
pag->addVarargNode(iter->second,
llvmModuleSet()->getCallGraphNode(SVFUtil::cast<Function>(llvmValue)), iter->first->getType(), icfgNode);
llvmModuleSet()->getSVFFunction(SVFUtil::cast<Function>(llvmValue)), iter->first->getType(), icfgNode);
llvmModuleSet()->addToSVFVar2LLVMValueMap(llvmValue, pag->getGNode(iter->second));

}
Expand Down
5 changes: 2 additions & 3 deletions svf-llvm/lib/SVFIRExtAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "Util/SVFUtil.h"
#include "SVF-LLVM/SymbolTableBuilder.h"
#include "SVF-LLVM/ObjTypeInference.h"
#include "Graphs/CallGraph.h"
#include "Graphs/PTACallGraph.h"

using namespace std;
using namespace SVF;
Expand Down Expand Up @@ -264,8 +264,7 @@ void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCalle
const ValVar* valVar = getForkedFun(callICFGNode);
if (const FunValVar* funcValVar = SVFUtil::dyn_cast<FunValVar>(valVar))
{
const SVFFunction* forkedFun = funcValVar->getCallGraphNode()->getFunction()
->getDefFunForMultipleModule();
const SVFFunction* forkedFun = funcValVar->getFunction()->getDefFunForMultipleModule();
const SVFVar* actualParm = getActualParmAtForkSite(callICFGNode);
/// pthread_create has 1 arg.
/// apr_thread_create has 2 arg.
Expand Down
4 changes: 2 additions & 2 deletions svf/include/AE/Svfexe/AbstractInterpretation.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ class AbstractInterpretation
AEStat* stat;

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


AbstractState& getAbsStateFromTrace(const ICFGNode* node)
Expand Down
Loading
Loading
0