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#include "Util/PTAStat.h"
33#include "Util/GeneralType.h"
34#include "Util/SVFUtil.h"
35
36using namespace SVF;
37using namespace SVFUtil;
38using namespace std;
39
41
46{
48 setDetectPWC(true); // Standard wave propagation always collapses PWCs
49}
50
55{
56 // Initialize the nodeStack via a whole SCC detection
57 // Nodes in nodeStack are in topological order by default.
58 NodeStack& nodeStack = SCCDetect();
59
60 // Process nodeStack and put the changed nodes into workList.
61 while (!nodeStack.empty())
62 {
63 NodeID nodeId = nodeStack.top();
64 nodeStack.pop();
66 // process nodes in nodeStack
69 }
70
71 // New nodes will be inserted into workList during processing.
72 while (!isWorklistEmpty())
73 {
75 // process nodes in worklist
77 }
78}
79
84{
85 // This node may be merged during collapseNodePts() which means it is no longer a rep node
86 // in the graph. Only rep node needs to be handled.
87 if (sccRepNode(nodeId) != nodeId)
88 return;
89
90 double propStart = stat->getClk();
92 handleCopyGep(node);
93 double propEnd = stat->getClk();
95}
96
101{
102 double insertStart = stat->getClk();
103
105
106 // handle load
108 it != eit; ++it)
109 {
110 if (handleLoad(nodeId, *it))
111 reanalyze = true;
112 }
113 // handle store
115 it != eit; ++it)
116 {
117 if (handleStore(nodeId, *it))
118 reanalyze = true;
119 }
120
121 double insertEnd = stat->getClk();
123}
124
129{
130 bool changed = false;
131 for (PointsTo::iterator piter = getPts(nodeId).begin(), epiter = getPts(nodeId).end();
132 piter != epiter; ++piter)
133 {
134 if (processLoad(*piter, edge))
135 {
136 changed = true;
137 }
138 }
139 return changed;
140}
141
146{
147 bool changed = false;
148 for (PointsTo::iterator piter = getPts(nodeId).begin(), epiter = getPts(nodeId).end();
149 piter != epiter; ++piter)
150 {
151 if (processStore(*piter, edge))
152 {
153 changed = true;
154 }
155 }
156 return changed;
157}
#define TIMEINTERVAL
Definition SVFType.h:604
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:420
virtual NodeStack & SCCDetect()
SCC detection.
Definition Andersen.cpp:834
virtual void handleCopyGep(ConstraintNode *node)
Definition Andersen.cpp:480
virtual bool processLoad(NodeID node, const ConstraintEdge *load)
Definition Andersen.cpp:557
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:699
virtual bool processStore(NodeID node, const ConstraintEdge *load)
Definition Andersen.cpp:577
virtual void collapsePWCNode(NodeID nodeId)
Collapse a field object into its base for field insensitive analysis.
Definition Andersen.cpp:690
ConstraintNode * getConstraintNode(NodeID id) const
Get/add/remove constraint node.
Definition ConsG.h:104
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:51
NodeID popFromWorklist()
Worklist operations.
Definition WPASolver.h:152
bool isWorklistEmpty()
Definition WPASolver.h:161
bool reanalyze
Reanalyze if any constraint value changed.
Definition WPASolver.h:172
for isBitcode
Definition BasicTypes.h:70
std::stack< NodeID > NodeStack
Definition GeneralType.h:92
u32_t NodeID
Definition GeneralType.h:76
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76