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

remove getbasevalvar in getgepval #1356

Merged
merged 3 commits into from
Feb 2, 2024
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 svf-llvm/lib/SVFIRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@ void SVFIRBuilder::sanityCheck()
*/
NodeID SVFIRBuilder::getGepValVar(const Value* val, const AccessPath& ap, const SVFType* elementType)
{
NodeID base = pag->getBaseValVar(getValueNode(val));
NodeID base = getValueNode(val);
NodeID gepval = pag->getGepValVar(curVal, base, ap);
if (gepval==UINT_MAX)
{
Expand Down
14 changes: 12 additions & 2 deletions svf/include/CFL/CFLAlias.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,18 @@ class CFLAlias : public CFLBase
if((*outedge)->getEdgeKind() == graph->getStartKind())
{
// Need to Find dst addr src
CFLNode *vNode = graph->getGNode((*outedge)->getDstID());
addPts(ptr, svfir->getBaseValVar((*outedge)->getDstID()));
SVFVar *vNode = svfir->getGNode((*outedge)->getDstID());
NodeID basevNodeID;
// Remove svfir->getBaseValVar, SVF IR api change
if (vNode->hasIncomingEdges(SVFStmt::Gep))
{
SVFStmt::SVFStmtSetTy& geps = vNode->getIncomingEdges(SVFStmt::Gep);
SVFVar::iterator it = geps.begin();
basevNodeID = (*it)->getSrcID();
}
else
basevNodeID = vNode->getId();
addPts(ptr, basevNodeID);
for(auto inEdge = vNode->getInEdges().begin(); inEdge!=vNode->getInEdges().end(); inEdge++)
{
if((*inEdge)->getEdgeKind() == 0)
Expand Down
1 change: 0 additions & 1 deletion svf/include/SVFIR/SVFIR.h
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,6 @@ class SVFIR : public IRGraph
/// Base and Offset methods for Value and Object node
//@{
/// Get a base pointer node given a field pointer
NodeID getBaseValVar(NodeID nodeId);
inline NodeID getBaseObjVar(NodeID id) const
{
return getBaseObj(id)->getId();
Expand Down
25 changes: 1 addition & 24 deletions svf/lib/SVFIR/SVFIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ GepStmt* SVFIR::addVariantGepStmt(NodeID src, NodeID dst, const AccessPath& ap)
*/
NodeID SVFIR::addGepValNode(const SVFValue* curInst,const SVFValue* gepVal, const AccessPath& ap, NodeID i, const SVFType* type)
{
NodeID base = getBaseValVar(getValueNode(gepVal));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this function if it will never be used later.

NodeID base = getValueNode(gepVal);
//assert(findPAGNode(i) == false && "this node should not be created before");
assert(0==GepValObjMap[curInst].count(std::make_pair(base, ap))
&& "this node should not be created before");
Expand Down Expand Up @@ -511,29 +511,6 @@ NodeBS SVFIR::getFieldsAfterCollapse(NodeID id)
return getAllFieldsObjVars(mem);
}

/*!
* Get a base pointer given a pointer
* Return the source node of its connected gep edge if this pointer has
* Otherwise return the node id itself
*/
NodeID SVFIR::getBaseValVar(NodeID nodeId)
{
SVFVar* node = getGNode(nodeId);
if (node->hasIncomingEdges(SVFStmt::Gep))
{
SVFStmt::SVFStmtSetTy& geps = node->getIncomingEdges(SVFStmt::Gep);

assert((geps.size()==1) && "one node can only be connected by at most one gep edge!");

SVFVar::iterator it = geps.begin();

assert(SVFUtil::isa<GepStmt>(*it) && "not a gep edge??");
return (*it)->getSrcID();
}
else
return nodeId;
}

/*!
* It is used to create a dummy GepValVar during global initialization.
*/
Expand Down
Loading