Static Value-Flow Analysis
Loading...
Searching...
No Matches
AndersenWaveDiff.cpp
Go to the documentation of this file.
1//===- AndersenWaveDiff.cpp -- Wave propagation based Andersen's analysis with caching--//
2//
3// SVF: Static Value-Flow Analysis
4//
5// Copyright (C) <2013-2017> <Yulei Sui>
6//
7
8// This program is free software: you can redistribute it and/or modify
9// it under the terms of the GNU Affero General Public License as published by
10// the Free Software Foundation, either version 3 of the License, or
11// (at your option) any later version.
12
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU Affero General Public License for more details.
17
18// You should have received a copy of the GNU Affero General Public License
19// along with this program. If not, see <http://www.gnu.org/licenses/>.
20//
21//===--------------------------------------------------------------------------------===//
22
23/*
24 * AndersenWaveDiff.cpp
25 *
26 * Created on: 23/11/2013
27 * Author: yesen
28 */
29
30#include "WPA/Andersen.h"
32
33using namespace SVF;
34using namespace SVFUtil;
35using namespace std;
36
38
43{
45 setDetectPWC(true); // Standard wave propagation always collapses PWCs
46}
47
52{
53 // Initialize the nodeStack via a whole SCC detection
54 // Nodes in nodeStack are in topological order by default.
55 NodeStack& nodeStack = SCCDetect();
56
57 // Process nodeStack and put the changed nodes into workList.
58 while (!nodeStack.empty())
59 {
60 NodeID nodeId = nodeStack.top();
61 nodeStack.pop();
63 // process nodes in nodeStack
66 }
67
68 // New nodes will be inserted into workList during processing.
69 while (!isWorklistEmpty())
70 {
72 // process nodes in worklist
74 }
75}
76
81{
82 // This node may be merged during collapseNodePts() which means it is no longer a rep node
83 // in the graph. Only rep node needs to be handled.
84 if (sccRepNode(nodeId) != nodeId)
85 return;
86
87 double propStart = stat->getClk();
89 handleCopyGep(node);
90 double propEnd = stat->getClk();
92}
93
98{
99 double insertStart = stat->getClk();
100
102
103 // handle load
105 it != eit; ++it)
106 {
107 if (handleLoad(nodeId, *it))
108 reanalyze = true;
109 }
110 // handle store
112 it != eit; ++it)
113 {
114 if (handleStore(nodeId, *it))
115 reanalyze = true;
116 }
117
118 double insertEnd = stat->getClk();
120}
121
126{
127 bool changed = false;
128 for (PointsTo::iterator piter = getPts(nodeId).begin(), epiter = getPts(nodeId).end();
129 piter != epiter; ++piter)
130 {
131 if (processLoad(*piter, edge))
132 {
133 changed = true;
134 }
135 }
136 return changed;
137}
138
143{
144 bool changed = false;
145 for (PointsTo::iterator piter = getPts(nodeId).begin(), epiter = getPts(nodeId).end();
146 piter != epiter; ++piter)
147 {
148 if (processStore(*piter, edge))
149 {
150 changed = true;
151 }
152 }
153 return changed;
154}
#define TIMEINTERVAL
Definition SVFType.h:512
static double timeOfProcessLoadStore
Definition Andersen.h:172
static double timeOfProcessCopyGep
Definition Andersen.h:171
ConstraintGraph * consCG
Constraint Graph.
Definition Andersen.h:178
NodeID sccRepNode(NodeID id) const override
SCC methods.
Definition Andersen.h:129
virtual bool handleStore(NodeID id, const ConstraintEdge *store)
virtual bool handleLoad(NodeID id, const ConstraintEdge *load)
virtual void postProcessNode(NodeID nodeId)
static AndersenWaveDiff * diffWave
Definition Andersen.h:402
virtual void processNode(NodeID nodeId)
void setDetectPWC(bool flag)
Definition Andersen.h:258
virtual void initialize()
Initialize analysis.
Definition Andersen.cpp:418
virtual NodeStack & SCCDetect()
SCC detection.
Definition Andersen.cpp:834
virtual void handleCopyGep(ConstraintNode *node)
Definition Andersen.cpp:476
virtual bool processLoad(NodeID node, const ConstraintEdge *load)
Definition Andersen.cpp:553
virtual const PointsTo & getPts(NodeID id)
Operation of points-to set.
Definition Andersen.h:239
void collapseFields()
collapse positive weight cycles of a graph
Definition Andersen.cpp:695
virtual bool processStore(NodeID node, const ConstraintEdge *load)
Definition Andersen.cpp:573
virtual void collapsePWCNode(NodeID nodeId)
Collapse a field object into its base for field insensitive analysis.
Definition Andersen.cpp:686
ConstraintNode * getConstraintNode(NodeID id) const
Get/add/remove constraint node.
Definition ConsG.h:109
const_iterator outgoingLoadsEnd() const
Definition ConsGNode.h:194
const_iterator incomingStoresBegin() const
Definition ConsGNode.h:215
const_iterator incomingStoresEnd() const
Definition ConsGNode.h:219
ConstraintEdge::ConstraintEdgeSetTy::const_iterator const_iterator
Definition ConsGNode.h:45
const_iterator outgoingLoadsBegin() const
Definition ConsGNode.h:190
PTAStat * stat
Statistics.
static double getClk(bool mark=false)
Definition SVFStat.cpp:48
NodeID popFromWorklist()
Worklist operations.
Definition WPASolver.h:151
bool isWorklistEmpty()
Definition WPASolver.h:160
bool reanalyze
Reanalyze if any constraint value changed.
Definition WPASolver.h:171
for isBitcode
Definition BasicTypes.h:68
std::stack< NodeID > NodeStack
u32_t NodeID
Definition GeneralType.h:55
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74