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 <algorithm>
35#include <vector>
36
37#include "Util/GeneralType.h"
38
39namespace SVF
40{
41
42class SVFBasicBlock;
43
45{
46
47 friend class GraphDBClient;
48public:
50 typedef std::vector<const SVFBasicBlock*> BBList;
51 typedef BBList LoopBBs;
52
53private:
61
62protected:
67
72
77
82
87
92
94 {
95 return bb2LoopMap;
96 }
97
98public:
100 {
101 }
102
104
106 {
107 return dfBBsMap;
108 }
109
114
115 inline bool hasLoopInfo(const SVFBasicBlock* bb) const
116 {
117 return bb2LoopMap.find(bb) != bb2LoopMap.end();
118 }
119
120 const LoopBBs& getLoopInfo(const SVFBasicBlock* bb) const;
121
122 inline const SVFBasicBlock* getLoopHeader(const LoopBBs& lp) const
123 {
124 assert(!lp.empty() && "this is not a loop, empty basic block");
125 return lp.front();
126 }
127
128 inline bool loopContainsBB(const LoopBBs& lp, const SVFBasicBlock* bb) const
129 {
130 return std::find(lp.begin(), lp.end(), bb) != lp.end();
131 }
132
133 inline void addToBB2LoopMap(const SVFBasicBlock* bb, const SVFBasicBlock* loopBB)
134 {
135 bb2LoopMap[bb].push_back(loopBB);
136 }
137
139 {
140 return pdtBBsMap;
141 }
142
147
149 {
150 return bb2PdomLevel;
151 }
152
157
159 {
160 return bb2PIdom;
161 }
162
167
168
170 {
171 return dtBBsMap;
172 }
173
175 {
176 return dtBBsMap;
177 }
178
179 inline bool isUnreachable(const SVFBasicBlock* bb) const
180 {
181 return std::find(reachableBBs.begin(), reachableBBs.end(), bb) ==
182 reachableBBs.end();
183 }
184
185 inline const BBList& getReachableBBs() const
186 {
187 return reachableBBs;
188 }
189
191 {
193 }
194
195 void getExitBlocksOfLoop(const SVFBasicBlock* bb, BBList& exitbbs) const;
196
197 bool isLoopHeader(const SVFBasicBlock* bb) const;
198
199 bool dominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const;
200
201 bool postDominate(const SVFBasicBlock* bbKey, const SVFBasicBlock* bbValue) const;
202
205};
206}
207
208#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:77
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:103
bool isLoopHeader(const SVFBasicBlock *bb) const
Definition SVFValue.cpp:190
void getExitBlocksOfLoop(const SVFBasicBlock *bb, BBList &exitbbs) const
Definition SVFValue.cpp:84
const SVFBasicBlock * findNearestCommonPDominator(const SVFBasicBlock *A, const SVFBasicBlock *B) const
find nearest common post dominator of two basic blocks
Definition SVFValue.cpp:164
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:134
Map< const SVFBasicBlock *, u32_t > & getBBPDomLevel()
for isBitcode
Definition BasicTypes.h:70
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76