Static Value-Flow Analysis
Loading...
Searching...
No Matches
Steensgaard.h
Go to the documentation of this file.
1/*
2 * Steensgaard.h
3 *
4 * Created on: 2 Feb. 2021
5 * Author: Yulei Sui
6 */
7
8#ifndef INCLUDE_WPA_STEENSGAARD_H_
9#define INCLUDE_WPA_STEENSGAARD_H_
10
11#include "WPA/Andersen.h"
12
13namespace SVF
14{
19
21{
22
23public:
26
29
32 {
33 if (steens == nullptr)
34 {
35 steens = new Steensgaard(_pag);
36 steens->analyze();
37 return steens;
38 }
39 return steens;
40 }
41 static void releaseSteensgaard()
42 {
43 if (steens)
44 delete steens;
45 steens = nullptr;
46 }
47
48 virtual void solveWorklist() override;
49
50 void processAllAddr();
51
52 void ecUnion(NodeID id, NodeID ec);
53
55
56 static inline bool classof(const Steensgaard*)
57 {
58 return true;
59 }
60 static inline bool classof(const AndersenBase* pta)
61 {
62 return (pta->getAnalysisTy() == Steensgaard_WPA);
63 }
64 static inline bool classof(const PointerAnalysis* pta)
65 {
66 return (pta->getAnalysisTy() == Steensgaard_WPA);
67 }
69
71 virtual inline const PointsTo& getPts(NodeID id) override
72 {
73 return getPTDataTy()->getPts(getEC(id));
74 }
76 virtual inline bool unionPts(NodeID id, const PointsTo& target) override
77 {
78 id = getEC(id);
79 return getPTDataTy()->unionPts(id, target);
80 }
82 virtual inline bool unionPts(NodeID id, NodeID ptd) override
83 {
84 id = getEC(id);
85 ptd = getEC(ptd);
86 return getPTDataTy()->unionPts(id, ptd);
87 }
88
92 inline NodeID getEC(NodeID id) const
93 {
94 NodeToEquivClassMap::const_iterator it = nodeToECMap.find(id);
95 if (it == nodeToECMap.end())
96 return id;
97 else
98 return it->second;
99 }
101 inline NodeID sccRepNode(NodeID id) const override
102 {
103 return getEC(id);
104 }
105 void setEC(NodeID node, NodeID rep);
106
108 {
109 nodeToSubsMap[id].insert(id);
110 return nodeToSubsMap[id];
111 }
112 inline void addSubNode(NodeID node, NodeID sub)
113 {
114 nodeToSubsMap[node].insert(sub);
115 }
116
118 virtual inline bool addCopyEdge(NodeID src, NodeID dst) override
119 {
120 return consCG->addCopyCGEdge(src, dst);
121 }
122
123private:
124 static Steensgaard* steens; // static instance
127};
128
129} // namespace SVF
130
131#endif /* INCLUDE_WPA_STEENSGAARD_H_ */
#define true
Definition cJSON.cpp:65
virtual void analyze() override
Andersen analysis.
Definition Andersen.cpp:133
ConstraintGraph * consCG
Constraint Graph.
Definition Andersen.h:178
PTDataTy * getPTDataTy() const
Get points-to data structure.
CopyCGEdge * addCopyCGEdge(NodeID src, NodeID dst)
Add Copy edge.
Definition ConsG.cpp:222
@ Steensgaard_WPA
Steensgaard PTA.
PTATY getAnalysisTy() const
Type of pointer analysis.
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 bool addCopyEdge(NodeID src, NodeID dst) override
Add copy edge on constraint graph.
static void releaseSteensgaard()
Definition Steensgaard.h:41
Map< NodeID, Set< NodeID > > NodeToSubsMap
Definition Steensgaard.h:25
static Steensgaard * createSteensgaard(SVFIR *_pag)
Create an singleton instance.
Definition Steensgaard.h:31
static bool classof(const PointerAnalysis *pta)
Definition Steensgaard.h:64
static bool classof(const Steensgaard *)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition Steensgaard.h:56
Map< NodeID, NodeID > NodeToEquivClassMap
Definition Steensgaard.h:24
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)
Steensgaard(SVFIR *_pag)
Constructor.
Definition Steensgaard.h:28
NodeToSubsMap nodeToSubsMap
static bool classof(const AndersenBase *pta)
Definition Steensgaard.h:60
virtual bool unionPts(NodeID id, NodeID ptd) override
pts(id) = pts(id) U pts(ptd)
Definition Steensgaard.h:82
NodeID getEC(NodeID id) const
Definition Steensgaard.h:92
NodeID sccRepNode(NodeID id) const override
Return getEC(id)
for isBitcode
Definition BasicTypes.h:68
u32_t NodeID
Definition GeneralType.h:55
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74
WPASolver< ConstraintGraph * > WPAConstraintSolver
Definition Andersen.h:55