diff --git a/svf/lib/WPA/Andersen.cpp b/svf/lib/WPA/Andersen.cpp index 7b9a413a5..5ca6705f4 100644 --- a/svf/lib/WPA/Andersen.cpp +++ b/svf/lib/WPA/Andersen.cpp @@ -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++; @@ -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++; diff --git a/svf/lib/WPA/FlowSensitive.cpp b/svf/lib/WPA/FlowSensitive.cpp index 9731fc742..b3c69f0c7 100644 --- a/svf/lib/WPA/FlowSensitive.cpp +++ b/svf/lib/WPA/FlowSensitive.cpp @@ -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; @@ -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)) diff --git a/svf/lib/WPA/VersionedFlowSensitive.cpp b/svf/lib/WPA/VersionedFlowSensitive.cpp index 009aaf4aa..5502a4937 100644 --- a/svf/lib/WPA/VersionedFlowSensitive.cpp +++ b/svf/lib/WPA/VersionedFlowSensitive.cpp @@ -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; @@ -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); + } } } }