Static Value-Flow Analysis
Loading...
Searching...
No Matches
Steensgaard.cpp
Go to the documentation of this file.
1//===- Steensgaard.cpp -- Steensgaard's field-insensitive
2// analysis--------------//
3//
4// SVF: Static Value-Flow Analysis
5//
6// Copyright (C) <2013-2017> <Yulei Sui>
7//
8
9// This program is free software: you can redistribute it and/or modify
10// it under the terms of the GNU Affero General Public License as published by
11// the Free Software Foundation, either version 3 of the License, or
12// (at your option) any later version.
13
14// This program is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17// GNU Affero General Public License for more details.
18
19// You should have received a copy of the GNU Affero General Public License
20// along with this program. If not, see <http://www.gnu.org/licenses/>.
21//
22//===----------------------------------------------------------------------===//
23
24/*
25 * Steensgaard.cpp
26 *
27 * Created on: 2 Feb. 2021
28 * Author: Yulei Sui
29 */
30
31#include "WPA/Steensgaard.h"
32
33using namespace SVF;
34using namespace SVFUtil;
35
37
43{
44
46
47 // Keep solving until workList is empty.
48 while (!isWorklistEmpty())
49 {
52
54 for (NodeID o : getPts(nodeId))
55 {
56
58 for (ConstraintEdge* edge : node->getStoreInEdges())
59 {
60 ecUnion(edge->getSrcID(), o);
61 }
62 // r = *p : EC(r) == EC(o)
63 for (ConstraintEdge* edge : node->getLoadOutEdges())
64 {
65 ecUnion(o, edge->getDstID());
66 }
67 }
68
70 for (ConstraintEdge* edge : node->getCopyOutEdges())
71 {
72 ecUnion(edge->getSrcID(), edge->getDstID());
73 }
75 for (ConstraintEdge* edge : node->getGepOutEdges())
76 {
77 ecUnion(edge->getSrcID(), edge->getDstID());
78 }
79 }
80}
81
83{
84 rep = getEC(rep);
85 Set<NodeID>& subNodes = getSubNodes(node);
86 for (NodeID sub : subNodes)
87 {
88 nodeToECMap[sub] = rep;
89 addSubNode(rep, sub);
90 }
91 subNodes.clear();
92}
93
96{
97 if (unionPts(ec, node))
99 setEC(node, ec);
100}
101
106{
108 nodeEit = consCG->end();
109 nodeIt != nodeEit; nodeIt++)
110 {
111 ConstraintNode* cgNode = nodeIt->second;
112 for (ConstraintNode::const_iterator it = cgNode->incomingAddrsBegin(),
113 eit = cgNode->incomingAddrsEnd();
114 it != eit; ++it)
115 {
117
119 NodeID dst = addr->getDstID();
120 NodeID src = addr->getSrcID();
121 if (addPts(dst, src))
122 pushIntoWorklist(dst);
123 }
124 }
125}
static u32_t numOfProcessedAddr
Statistics.
Definition Andersen.h:157
ConstraintGraph * consCG
Constraint Graph.
Definition Andersen.h:178
virtual bool addPts(NodeID id, NodeID ptd)
ConstraintNode * getConstraintNode(NodeID id) const
Get/add/remove constraint node.
Definition ConsG.h:109
const ConstraintEdge::ConstraintEdgeSetTy & getStoreInEdges() const
Definition ConsGNode.h:135
const ConstraintEdge::ConstraintEdgeSetTy & getGepOutEdges() const
Definition ConsGNode.h:123
ConstraintEdge::ConstraintEdgeSetTy::const_iterator const_iterator
Definition ConsGNode.h:45
const ConstraintEdge::ConstraintEdgeSetTy & getLoadOutEdges() const
Definition ConsGNode.h:131
const ConstraintEdge::ConstraintEdgeSetTy & getCopyOutEdges() const
Definition ConsGNode.h:115
iterator begin()
Iterators.
static Steensgaard * steens
NodeToEquivClassMap nodeToECMap
void ecUnion(NodeID id, NodeID ec)
merge node into equiv class and merge node's pts into ec's pts
virtual const PointsTo & getPts(NodeID id) override
Operation of points-to set.
Definition Steensgaard.h:71
Set< NodeID > & getSubNodes(NodeID id)
void setEC(NodeID node, NodeID rep)
virtual void solveWorklist() override
virtual bool unionPts(NodeID id, const PointsTo &target) override
pts(id) = pts(id) U target
Definition Steensgaard.h:76
void addSubNode(NodeID node, NodeID sub)
NodeID getEC(NodeID id) const
Definition Steensgaard.h:92
NodeID popFromWorklist()
Worklist operations.
Definition WPASolver.h:151
virtual void pushIntoWorklist(NodeID id)
Definition WPASolver.h:156
bool isWorklistEmpty()
Definition WPASolver.h:160
for isBitcode
Definition BasicTypes.h:68
u32_t NodeID
Definition GeneralType.h:55
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74