Skip to content

Commit

Permalink
Merge pull request #1356 from jumormt/memcpy
Browse files Browse the repository at this point in the history
remove getbasevalvar in getgepval
  • Loading branch information
yuleisui authored Feb 2, 2024
2 parents dad29e9 + 614b659 commit e1ab2d6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 28 deletions.
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));
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

0 comments on commit e1ab2d6

Please sign in to comment.