Static Value-Flow Analysis
Loading...
Searching...
No Matches
CDGBuilder.h
Go to the documentation of this file.
1//===----- CDGBuilder.h -- Control Dependence Graph Builder -------------//
2//
3// SVF: Static Value-Flow Analysis
4//
5// Copyright (C) <2013-> <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 * CDGBuilder.h
25 *
26 * Created on: Sep 27, 2023
27 * Author: Xiao Cheng
28 */
29#ifndef SVF_CDGBUILDER_H
30#define SVF_CDGBUILDER_H
31
32#include "Graphs/CDG.h"
33#include "SVFIR/SVFValue.h"
34
35// control dependence builder
36namespace SVF
37{
39{
40public:
41
43 CDGBuilder() : _controlDG(CDG::getCDG())
44 {
45
46 }
47
50 {
51
52 }
53
55 void build();
56
59
62
63
64
65private:
66
67
69 static void
70 extractBBS(const SVFFunction *func,
71 Map<const SVFBasicBlock *, std::vector<const SVFBasicBlock *>> &res);
72
74 void
76 std::vector<const SVFBasicBlock *> &tgtNodes);
77
78
80 const SVFBasicBlock *tgt,
81 std::vector<const SVFBasicBlock *> &path,
82 std::vector<const SVFBasicBlock *> &tgtNodes,
84
85
87
88
90 inline void updateMap(const SVFBasicBlock *pred, const SVFBasicBlock *bb, s32_t pos)
91 {
92 _svfcontrolMap[pred][bb].insert(pos);
93 _svfdependentOnMap[bb][pred].insert(pos);
94 }
95
96
97private:
103};
104}
105
106
107#endif //SVF_CDGBUILDER_H
Map< const ICFGNode *, Map< const ICFGNode *, Set< s32_t > > > _nodeControlMap
map an ICFG node to its controlling ICFG nodes (position, set of Nodes)
Definition CDGBuilder.h:101
Map< const SVFBasicBlock *, Map< const SVFBasicBlock *, Set< s32_t > > > _svfdependentOnMap
map a basicblock to its dependent on BBs (position, set of BBs)
Definition CDGBuilder.h:100
void updateMap(const SVFBasicBlock *pred, const SVFBasicBlock *bb, s32_t pos)
update map
Definition CDGBuilder.h:90
void extractNodesBetweenPdomNodes(const SVFBasicBlock *succ, const SVFBasicBlock *LCA, std::vector< const SVFBasicBlock * > &tgtNodes)
extract nodes between two nodes in pdom tree
static void extractBBS(const SVFFunction *func, Map< const SVFBasicBlock *, std::vector< const SVFBasicBlock * > > &res)
extract basic block edges to be processed
void dfsNodesBetweenPdomNodes(const SVFBasicBlock *cur, const SVFBasicBlock *tgt, std::vector< const SVFBasicBlock * > &path, std::vector< const SVFBasicBlock * > &tgtNodes, SVFLoopAndDomInfo *ld)
CDGBuilder()
constructor
Definition CDGBuilder.h:43
void buildControlDependence(const SVFModule *svfgModule)
build control dependence for each function
~CDGBuilder()
destructor
Definition CDGBuilder.h:49
Map< const SVFBasicBlock *, Map< const SVFBasicBlock *, Set< s32_t > > > _svfcontrolMap
map a basicblock to its controlling BBs (position, set of BBs)
Definition CDGBuilder.h:99
void buildICFGNodeControlMap()
build map at icfg node level
Map< const ICFGNode *, Map< const ICFGNode *, Set< s32_t > > > _nodeDependentOnMap
map an ICFG node to its dependent on ICFG nodes (position, set of Nodes)
Definition CDGBuilder.h:102
void build()
start here
s64_t getBBSuccessorBranchID(const SVFBasicBlock *BB, const SVFBasicBlock *Succ)
for isBitcode
Definition BasicTypes.h:68
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74
signed s32_t
Definition GeneralType.h:47
signed long long s64_t
Definition GeneralType.h:49