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

svfargument->argvalvar #1644

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 3 commits into from
Jan 31, 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
7 changes: 6 additions & 1 deletion svf-llvm/lib/LLVMModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ LLVMModuleSet::~LLVMModuleSet()
delete item.second;
item.second = nullptr;
}

for (auto& item: LLVMArgument2SVFArgument)
{
delete item.second;
item.second = nullptr;
}
delete typeInference;
typeInference = nullptr;
}
Expand Down Expand Up @@ -294,7 +300,6 @@ void LLVMModuleSet::createSVFFunction(const Function* func)
if (!arg.hasName())
svfarg->setName(std::to_string(arg.getArgNo()));

svfFunc->addArgument(svfarg);
addArgumentMap(&arg, svfarg);
}

Expand Down
16 changes: 14 additions & 2 deletions svf-llvm/lib/SVFIRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,9 @@ void SVFIRBuilder::initialiseNodes()
{
pag->addArgValNode(
iter->second, argval->getArgNo(), icfgNode,
llvmModuleSet()->getCallGraphNode(argval->getParent()),iter->first->getType(),
LLVMUtil::isArgOf 8000 UncalledFunction(argval));
llvmModuleSet()->getCallGraphNode(argval->getParent()),iter->first->getType());
if (!argval->hasName())
pag->getGNode(iter->second)->setName("arg_" + std::to_string(argval->getArgNo()));
}
else if (auto fpValue = SVFUtil::dyn_cast<ConstantFP>(llvmValue))
{
Expand Down Expand Up @@ -403,6 +404,17 @@ void SVFIRBuilder::initialiseNodes()
assert(pag->getTotalNodeNum() >= pag->getTotalSymNum()
&& "not all node have been initialized!!!");

/// add argvalvar for svffunctions
for (auto& fun: svfModule->getFunctionSet()) {
const Function* llvmFun = SVFUtil::cast<Function>(llvmModuleSet()->getLLVMValue(fun));
for (const Argument& arg : llvmFun->args())
{
const_cast<SVFFunction *>(fun)->addArgument(
SVFUtil::cast<ArgValVar>(
pag->getGNode(llvmModuleSet()->getValueNode(llvmModuleSet()->getSVFArgument(&arg)))));
}
}

}

/*
Expand Down
4 changes: 2 additions & 2 deletions svf-llvm/lib/SVFIRExtAPI.cpp
Original file line number Diff 8000 line number Diff line change
Expand Up @@ -272,12 +272,12 @@ void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCalle
assert((forkedFun->arg_size() <= 2) && "Size of formal parameter of start routine should be one");
if (forkedFun->arg_size() <= 2 && forkedFun->arg_size() >= 1)
{
const SVFArgument* formalParm = forkedFun->getArg(0);
const ArgValVar* formalParm = forkedFun->getArg(0);
/// Connect actual parameter to formal parameter of the start routine
if (actualParm->isPointer() && formalParm->getType()->isPointerTy())
{
FunEntryICFGNode *entry = pag->getICFG()->getFunEntryICFGNode(forkedFun);
addThreadForkEdge(actualParm->getId(), llvmModuleSet()->getValueNode(formalParm), callICFGNode, entry);
addThreadForkEdge(actualParm->getId(), formalParm->getId(), callICFGNode, entry);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions svf/include/SVFIR/SVFIR.h
Original file line number Diff line number Diff line change
Expand Up @@ -553,10 +553,10 @@ class SVFIR : public IRGraph
return addValNode(node);
}

NodeID addArgValNode(NodeID i, u32_t argNo, const ICFGNode* icfgNode, const CallGraphNode* callGraphNode, const SVFType* type, bool isUncalled = false)
NodeID addArgValNode(NodeID i, u32_t argNo, const ICFGNode* icfgNode, const CallGraphNode* callGraphNode, const SVFType* type)
{
ArgValVar* node =
new ArgValVar(i, argNo, icfgNode, callGraphNode, type, isUncalled);
new ArgValVar(i, argNo, icfgNode, callGraphNode, type);
return addValNode(node);
}

Expand Down
8 changes: 5 additions & 3 deletions svf/include/SVFIR/SVFValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ class SVFValue
//@}
};

class ArgValVar;

class SVFFunction : public SVFValue
{
friend class LLVMModuleSet;
Expand All @@ -316,7 +318,7 @@ class SVFFunction : public SVFValue
const SVFFunctionType* funcType; /// FunctionType, which is different from the type (PointerType) of this SVFFunction
SVFLoopAndDomInfo* loopAndDom; /// the loop and dominate information
const SVFFunction* realDefFun; /// the definition of a function across multiple modules
std::vector<const SVFArgument*> allArgs; /// all formal arguments of this function
std::vector<const ArgValVar*> allArgs; /// all formal arguments of this function
SVFBasicBlock *exitBlock; /// a 'single' basic block having no successors and containing return instruction in a function
const CallGraphNode *callGraphNode; /// call graph node for this function
BasicBlockGraph* bbGraph; /// the basic block graph of this function
Expand All @@ -327,7 +329,7 @@ class SVFFunction : public SVFValue
callGraphNode = cgn;
}

inline void addArgument(SVFArgument* arg)
inline void addArgument(const ArgValVar* arg)
{
allArgs.push_back(arg);
}
Expand Down Expand Up @@ -417,7 +419,7 @@ class SVFFunction : public SVFValue
}

u32_t arg_size() const;
const SVFArgument* getArg(u32_t idx) const;
const ArgValVar* getArg(u32_t idx) const;
bool isVarArg() const;

inline bool hasBasicBlock() const
Expand Down
5 changes: 2 additions & 3 deletions svf/include/SVFIR/SVFVariables.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ class ArgValVar: public ValVar
private:
const CallGraphNode* cgNode;
u32_t argNo;
bool uncalled;

protected:
/// Constructor to create function argument (for SVFIRReader/deserialization)
Expand Down Expand Up @@ -401,7 +400,7 @@ class ArgValVar: public ValVar

/// Constructor
ArgValVar(NodeID i, u32_t argNo, const ICFGNode* icn, const CallGraphNode* callGraphNode,
const SVFType* svfType, bool isUncalled = false);
const SVFType* svfType);

/// Return name of a LLVM value
inline const std::string getValueName() const
Expand All @@ -422,7 +421,7 @@ class ArgValVar: public ValVar

inline bool isArgOfUncalledFunction() const
{
return uncalled;
return getFunction()->isUncalledFunction();
}

virtual bool isPointer() const;
Expand Down
4 changes: 1 addition & 3 deletions svf/lib/SVFIR/SVFValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ SVFFunction::SVFFunction(const SVFType* ty, const SVFFunctionType* ft,

SVFFunction::~SVFFunction()
{
for(const SVFArgument* arg : allArgs)
delete arg;
delete loopAndDom;
delete bbGraph;
}
Expand All @@ -171,7 +169,7 @@ u32_t SVFFunction::arg_size() const
return allArgs.size();
}

const SVFArgument* SVFFunction::getArg(u32_t idx) const
const ArgValVar* SVFFunction::getArg(u32_t idx) const
{
assert (idx < allArgs.size() && "getArg() out of range!");
return allArgs[idx];
Expand Down
4 changes: 2 additions & 2 deletions svf/lib/SVFIR/SVFVariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ const std::string ObjVar::toString() const
}

ArgValVar::ArgValVar(NodeID i, u32_t argNo, const ICFGNode* icn,
const SVF::CallGraphNode* callGraphNode, const SVFType* svfType, bool isUncalled)
const SVF::CallGraphNode* callGraphNode, const SVFType* svfType)
: ValVar(i, svfType, icn, ArgValNode),
cgNode(callGraphNode), argNo(argNo), uncalled(isUncalled)
cgNode(callGraphNode), argNo(argNo)
{

}
Expand Down
Loading
0