Skip to content

Commit

Permalink
Merge pull request SVF-tools#20 from jumormt/1.3
Browse files Browse the repository at this point in the history
remove isnonpointer obj in pta
  • Loading branch information
yuleisui authored Jan 3, 2024
2 parents 21ba463 + d5f9f8e commit 79c3c0b
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 49 deletions.
8 changes: 4 additions & 4 deletions svf/lib/WPA/Andersen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ bool Andersen::processLoad(NodeID node, const ConstraintEdge* load)
/// TODO: New copy edges are also added for black hole obj node to
/// make gcc in spec 2000 pass the flow-sensitive analysis.
/// Try to handle black hole obj in an appropriate way.
// if (pag->isBlkObjOrConstantObj(node))
if (pag->isConstantObj(node) || pag->getGNode(load->getDstID())->isPointer())
// if (pag->isBlkObjOrConstantObj(node) || isNonPointerObj(node))
if (pag->isConstantObj(node) || pag->getGNode(load->getDstID())->isPointer() == false)
return false;

numOfProcessedLoad++;
Expand All @@ -371,8 +371,8 @@ bool Andersen::processStore(NodeID node, const ConstraintEdge* store)
/// TODO: New copy edges are also added for black hole obj node to
/// make gcc in spec 2000 pass the flow-sensitive analysis.
/// Try to handle black hole obj in an appropriate way
// if (pag->isBlkObjOrConstantObj(node))
if (pag->isConstantObj(node) || pag->getGNode(store->getSrcID())->isPointer())
// if (pag->isBlkObjOrConstantObj(node) || isNonPointerObj(node))
if (pag->isConstantObj(node) || pag->getGNode(store->getSrcID())->isPointer() == false)
return false;

numOfProcessedStore++;
Expand Down
42 changes: 23 additions & 19 deletions svf/lib/WPA/FlowSensitive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,30 +557,33 @@ bool FlowSensitive::processLoad(const LoadSVFGNode* load)
NodeID dstVar = load->getPAGDstNodeID();

const PointsTo& srcPts = getPts(load->getPAGSrcNodeID());
for (PointsTo::iterator ptdIt = srcPts.begin(); ptdIt != srcPts.end(); ++ptdIt)
{
NodeID ptd = *ptdIt;

if (pag->isConstantObj(ptd) || pag->getGNode(load->getPAGDstNodeID())->isPointer()==false)
continue;
// p = *q, the type of p must be a pointer
if(pag->getGNode(load->getPAGDstNodeID())->isPointer()) {
for (PointsTo::iterator ptdIt = srcPts.begin(); ptdIt != srcPts.end(); ++ptdIt)
{
NodeID ptd = *ptdIt;

if (unionPtsFromIn(load, ptd, dstVar))
changed = true;
if (pag->isConstantObj(ptd))
continue;

if (isFieldInsensitive(ptd))
{
/// If the ptd is a field-insensitive node, we should also get all field nodes'
/// points-to sets and pass them to pagDst.
const NodeBS& allFields = getAllFieldsObjVars(ptd);
for (NodeBS::iterator fieldIt = allFields.begin(), fieldEit = allFields.end();
fieldIt != fieldEit; ++fieldIt)
if (unionPtsFromIn(load, ptd, dstVar))
changed = true;

if (isFieldInsensitive(ptd))
{
if (unionPtsFromIn(load, *fieldIt, dstVar))
changed = true;
/// If the ptd is a field-insensitive node, we should also get all field nodes'
/// points-to sets and pass them to pagDst.
const NodeBS& allFields = getAllFieldsObjVars(ptd);
for (NodeBS::iterator fieldIt = allFields.begin(), fieldEit = allFields.end();
fieldIt != fieldEit; ++fieldIt)
{
if (unionPtsFromIn(load, *fieldIt, dstVar))
changed = true;
}
}
}
}

double end = stat->getClk();
loadTime += (end - start) / TIMEINTERVAL;
return changed;
Expand Down Expand Up @@ -609,13 +612,14 @@ bool FlowSensitive::processStore(const StoreSVFGNode* store)
double start = stat->getClk();
bool changed = false;

if(getPts(store->getPAGSrcNodeID()).empty() == false)
// *p = q, the type of q must be a pointer
if(getPts(store->getPAGSrcNodeID()).empty() == false && pag->getGNode(store->getPAGSrcNodeID())->isPointer())
{
for (PointsTo::iterator it = dstPts.begin(), eit = dstPts.end(); it != eit; ++it)
{
NodeID ptd = *it;

if (pag->isConstantObj(ptd) || pag->getGNode(store->getPAGSrcNodeID())->isPointer()==false)
if (pag->isConstantObj(ptd))
continue;

if (unionPtsFromTop(store, store->getPAGSrcNodeID(), ptd))
Expand Down
57 changes: 31 additions & 26 deletions svf/lib/WPA/VersionedFlowSensitive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,32 +656,34 @@ bool VersionedFlowSensitive::processLoad(const LoadSVFGNode* load)
NodeID q = load->getPAGSrcNodeID();

const PointsTo& qpt = getPts(q);
for (NodeID o : qpt)
{
if (pag->isConstantObj(o) || pag->getGNode(load->getPAGDstNodeID())->isPointer()==false) continue;

const Version c = getConsume(l, o);
if (c != invalidVersion && vPtD->unionPts(p, atKey(o, c)))
// p = *q, the type of p must be a pointer
if (pag->getGNode(load->getPAGDstNodeID())->isPointer()) {
for (NodeID o : qpt)
{
changed = true;
}
if (pag->isConstantObj(o)) continue;

if (isFieldInsensitive(o))
{
/// If o is a field-insensitive object, we should also get all field nodes'
/// points-to sets and pass them to p.
const NodeBS& fields = getAllFieldsObjVars(o);
for (NodeID of : fields)
const Version c = getConsume(l, o);
if (c != invalidVersion && vPtD->unionPts(p, atKey(o, c)))
{
const Version c = getConsume(l, of);
if (c != invalidVersion && vPtD->unionPts(p, atKey(of, c)))
changed = true;
}

if (isFieldInsensitive(o))
{
/// If o is a field-insensitive object, we should also get all field nodes'
/// points-to sets and pass them to p.
const NodeBS& fields = getAllFieldsObjVars(o);
for (NodeID of : fields)
{
changed = true;
const Version c = getConsume(l, of);
if (c != invalidVersion && vPtD->unionPts(p, atKey(of, c)))
{
changed = true;
}
}
}
}
}

double end = stat->getClk();
loadTime += (end - start) / TIMEINTERVAL;
return changed;
Expand All @@ -707,15 +709,18 @@ bool VersionedFlowSensitive::processStore(const StoreSVFGNode* store)

if (!qpt.empty())
{
for (NodeID o : ppt)
{
if (pag->isConstantObj(o) || pag->getGNode(store->getPAGSrcNodeID())->isPointer()==false) continue;

const Version y = getYield(l, o);
if (y != invalidVersion && vPtD->unionPts(atKey(o, y), q))
// *p = q, the type of q must be a pointer
if (pag->getGNode(store->getPAGSrcNodeID())->isPointer()) {
for (NodeID o : ppt)
{
changed = true;
changedObjects.set(o);
if (pag->isConstantObj(o) || pag->isNonPointerObj(o)) continue;

const Version y = getYield(l, o);
if (y != invalidVersion && vPtD->unionPts(atKey(o, y), q))
{
changed = true;
changedObjects.set(o);
}
}
}
}
Expand Down

0 comments on commit 79c3c0b

Please sign in to comment.