Static Value-Flow Analysis
Loading...
Searching...
No Matches
SVFLoopAndDomInfo.h
Go to the documentation of this file.
1//===- SVFLoopAndDomInfo.h -- ------------------------------//
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* SVFLoopAndDomInfo.h
25*
26* Created on: Feb 7, 2025
27* Author: Xiao Cheng
28*
29*/
30
31#ifndef SVFLOOPANDDOMINFO_H
32#define SVFLOOPANDDOMINFO_H
33
34#include "SVFIR/SVFType.h"
35#include "Graphs/GraphPrinter.h"
36#include "Util/Casting.h"
37#include "Graphs/BasicBlockG.h"
38
39namespace SVF
40{
42{
43
44 friend class GraphDBClient;
45public:
47 typedef std::vector<const SVFBasicBlock*> BBList;
48 typedef BBList LoopBBs;
49
50private:
58
59protected:
64
69
74
79
84
89
91 {
92 return bb2LoopMap;
93 }
94
95public:
97 {
98 }
99
101
103 {
104 return dfBBsMap;
105 }
106
111
112 inline bool hasLoopInfo(const SVFBasicBlock* bb) const
113 {
114 return bb2LoopMap.find(bb) != bb2LoopMap.end();
115 }
116
117 const LoopBBs& getLoopInfo(const SVFBasicBlock* bb) const;
118
119 inline const SVFBasicBlock* getLoopHeader(const LoopBBs& lp) const
120 {
121 assert(!lp.empty() && "this is not a loop, empty basic block");
122 return lp.front();
123 }
124
125 inline bool loopContainsBB(const LoopBBs& lp, const SVFBasicBlock* bb) const
126 {
127 return std::find(lp.begin(), lp.end(), bb) != lp.end();
128 }
129
130 inline void addToBB2LoopMap(const SVFBasicBlock* bb, const SVFBasicBlock* loopBB)
131 {
132 bb2LoopMap[bb].push_back(loopBB);
133 }
134
136 {
137 return pdtBBsMap;
138 }
139
144
146 {
147 return bb2PdomLevel;
148 }
149
154
156 {
157 return bb2PIdom;
158 }
159
164
165
167 {
168 return dtBBsMap;
169 }
170
172 {
173 return dtBBsMap;
174 }
175
176 inline bool isUnreachable(const SVFBasicBlock* bb) const
177 {
178 return std::find(reachableBBs.begin(), reachableBBs.end(), bb) ==
179 reachableBBs.end();
180 }
181
182 inline const BBList& getReachableBBs() const
183 {
184 return reachableBBs;
185 }
186
188 {
190 }
191
192 void getExitBlocksOfLoop(const SVFBasicBlock* bb, BBList& exitbbs) const;
193
194 bool isLoopHeader(const SVFBasicBlock* bb) const;
195
196 bool dominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const;
197
198 bool postDominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const;
199
202};
203}
204
205#endif //SVFLOOPANDDOMINFO_H
void setDomTreeMap(Map< const SVFBasicBlock *, BBSet > &dtMap)
const Map< const SVFBasicBlock *, BBSet > & getPostDomTreeMap() const
const LoopBBs & getLoopInfo(const SVFBasicBlock *bb) const
Definition SVFValue.cpp:76
const Map< const SVFBasicBlock *, BBSet > & getDomFrontierMap() const
Map< const SVFBasicBlock *, BBSet > & getDomTreeMap()
const Map< const SVFBasicBlock *, LoopBBs > & getBB2LoopMap() const
std::vector< const SVFBasicBlock * > BBList
Map< const SVFBasicBlock *, BBSet > dtBBsMap
map a BasicBlock to BasicBlocks it Dominates
bool dominate(const SVFBasicBlock *bbKey, const SVFBasicBlock *bbValue) const
Definition SVFValue.cpp:102
bool isLoopHeader(const SVFBasicBlock *bb) const
Definition SVFValue.cpp:189
void getExitBlocksOfLoop(const SVFBasicBlock *bb, BBList &exitbbs) const
Definition SVFValue.cpp:83
const SVFBasicBlock * findNearestCommonPDominator(const SVFBasicBlock *A, const SVFBasicBlock *B) const
find nearest common post dominator of two basic blocks
Definition SVFValue.cpp:163
Map< const SVFBasicBlock *, BBSet > pdtBBsMap
map a BasicBlock to BasicBlocks it PostDominates
const Map< const SVFBasicBlock *, u32_t > & getBBPDomLevel() const
void setPostDomTreeMap(Map< const SVFBasicBlock *, BBSet > &pdtMap)
const BBList & getReachableBBs() const
Map< const SVFBasicBlock *, BBSet > & getPostDomTreeMap()
void setDomFrontierMap(Map< const SVFBasicBlock *, BBSet > &dfMap)
Map< const SVFBasicBlock *, u32_t > bb2PdomLevel
map a BasicBlock to its level in pdom tree, used in findNearestCommonPDominator
const Map< const SVFBasicBlock *, const SVFBasicBlock * > & getBB2PIdom() const
const Map< const SVFBasicBlock *, BBSet > & getDomTreeMap() const
Map< const SVFBasicBlock *, BBSet > & getDomFrontierMap()
bool isUnreachable(const SVFBasicBlock *bb) const
const SVFBasicBlock * getLoopHeader(const LoopBBs &lp) const
void setBB2PdomLevel(Map< const SVFBasicBlock *, u32_t > &bb2Pdom)
Map< const SVFBasicBlock *, const SVFBasicBlock * > bb2PIdom
map a BasicBlock to its immediate dominator in pdom tree, used in findNearestCommonPDominator
bool hasLoopInfo(const SVFBasicBlock *bb) const
void setReachableBBs(BBList &bbs)
Set< const SVFBasicBlock * > BBSet
Map< const SVFBasicBlock *, LoopBBs > bb2LoopMap
map a BasicBlock (if it is in a loop) to all the BasicBlocks in this loop
bool loopContainsBB(const LoopBBs &lp, const SVFBasicBlock *bb) const
void setBB2LoopMap(Map< const SVFBasicBlock *, LoopBBs > &bb2Loop)
Map< const SVFBasicBlock *, BBSet > dfBBsMap
map a BasicBlock to its Dominate Frontier BasicBlocks
void addToBB2LoopMap(const SVFBasicBlock *bb, const SVFBasicBlock *loopBB)
void setBB2PIdom(Map< const SVFBasicBlock *, const SVFBasicBlock * > &bb2PIdomMap)
Map< const SVFBasicBlock *, const SVFBasicBlock * > & getBB2PIdom()
BBList reachableBBs
reachable BasicBlocks from the function entry.
bool postDominate(const SVFBasicBlock *bbKey, const SVFBasicBlock *bbValue) const
Definition SVFValue.cpp:133
Map< const SVFBasicBlock *, u32_t > & getBBPDomLevel()
for isBitcode
Definition BasicTypes.h:68
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74