Static Value-Flow Analysis
Loading...
Searching...
No Matches
AndersenPWC.h
Go to the documentation of this file.
1//===- AndersenSFR.h -- SFR based field-sensitive Andersen's analysis-------------//
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 * AndersenSFR.h
25 *
26 * Created on: 09, Feb, 2019
27 * Author: Yuxiang Lei
28 */
29
30#ifndef PROJECT_ANDERSENSFR_H
31#define PROJECT_ANDERSENSFR_H
32
33
34#include "WPA/Andersen.h"
35#include "WPA/CSC.h"
37
38namespace SVF
39{
40
44class AndersenSCD : public Andersen
45{
46public:
48
49protected:
53
54public:
56 Andersen(_pag,type)
57 {
58 }
59
62 {
63 if (scdAndersen == nullptr)
64 {
65 scdAndersen = new AndersenSCD(_pag);
67 return scdAndersen;
68 }
69 return scdAndersen;
70 }
71
72 static void releaseAndersenSCD()
73 {
74 if (scdAndersen)
75 delete scdAndersen;
76 scdAndersen = nullptr;
77 }
78
79protected:
81 {
83 }
84
85 virtual NodeStack& SCCDetect();
86 virtual void PWCDetect();
87 virtual void solveWorklist();
88 virtual void handleLoadStore(ConstraintNode* node);
89 virtual void processAddr(const AddrCGEdge* addr);
90 virtual bool addCopyEdge(NodeID src, NodeID dst);
92 virtual void processPWC(ConstraintNode* rep);
93 virtual void handleCopyGep(ConstraintNode* node);
94
95};
96
97
98
103{
104public:
108
109private:
111
115
116public:
118 AndersenSCD(_pag, type), csc(nullptr)
119 {
120 }
121
124 {
125 if (sfrAndersen == nullptr)
126 {
127 sfrAndersen = new AndersenSFR(_pag);
129 return sfrAndersen;
130 }
131 return sfrAndersen;
132 }
133
134 static void releaseAndersenSFR()
135 {
136 if (sfrAndersen)
137 delete sfrAndersen;
138 }
139
141 {
142 if (csc != nullptr)
143 {
144 delete(csc);
145 csc = nullptr;
146 }
147 }
148
149protected:
150 void initialize();
151 void PWCDetect();
153 bool processGepPts(const PointsTo& pts, const GepCGEdge* edge);
155
156};
157
158} // End namespace SVF
159
160#endif //PROJECT_ANDERSENSFR_H
newitem type
Definition cJSON.cpp:2739
buffer offset
Definition cJSON.cpp:1113
virtual void analyze() override
Andersen analysis.
Definition Andersen.cpp:133
NodeID sccRepNode(NodeID id) const override
SCC methods.
Definition Andersen.h:129
static AndersenSCD * createAndersenSCD(SVFIR *_pag)
Create an singleton instance directly instead of invoking llvm pass manager.
Definition AndersenPWC.h:61
virtual bool addCopyEdge(NodeID src, NodeID dst)
static AndersenSCD * scdAndersen
Definition AndersenPWC.h:50
virtual bool updateCallGraph(const CallSiteToFunPtrMap &callsites)
virtual void processAddr(const AddrCGEdge *addr)
AndersenSCD(SVFIR *_pag, PTATY type=AndersenSCD_WPA)
Definition AndersenPWC.h:55
virtual NodeStack & SCCDetect()
virtual void handleLoadStore(ConstraintNode *node)
Map< NodeID, NodeID > NodeToNodeMap
Definition AndersenPWC.h:47
virtual void solveWorklist()
virtual void handleCopyGep(ConstraintNode *node)
virtual void processPWC(ConstraintNode *rep)
static void releaseAndersenSCD()
Definition AndersenPWC.h:72
NodeToNodeMap pwcReps
Definition AndersenPWC.h:52
void addSccCandidate(NodeID nodeId)
Definition AndersenPWC.h:80
NodeSet sccCandidates
Definition AndersenPWC.h:51
virtual void PWCDetect()
Map< NodeID, std::pair< NodeID, NodeSet > > SFRTrait
void initialize()
Initialize analysis.
static void releaseAndersenSFR()
Map< NodeID, NodeSet > FieldReps
AndersenSFR(SVFIR *_pag, PTATY type=AndersenSFR_WPA)
bool processGepPts(const PointsTo &pts, const GepCGEdge *edge)
void fieldExpand(NodeSet &initials, APOffset offset, NodeBS &strides, PointsTo &expandPts)
FieldReps fieldReps
static AndersenSFR * sfrAndersen
bool mergeSrcToTgt(NodeID nodeId, NodeID newRepId)
Map< NodeID, NodeBS > NodeStrides
static AndersenSFR * createAndersenSFR(SVFIR *_pag)
Create an singleton instance directly instead of invoking llvm pass manager.
Definition CSC.h:50
PTATY
Pointer analysis type list.
@ AndersenSCD_WPA
Selective cycle detection andersen-style WPA.
@ AndersenSFR_WPA
Stride-based field representation.
SVFIR::CallSiteToFunPtrMap CallSiteToFunPtrMap
for isBitcode
Definition BasicTypes.h:68
std::stack< NodeID > NodeStack
Set< NodeID > NodeSet
u32_t NodeID
Definition GeneralType.h:55
s64_t APOffset
Definition GeneralType.h:60
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74