Static Value-Flow Analysis
MemPartition.h
Go to the documentation of this file.
1 //===- MemPartition.h -- Memory region partition-----------------------------//
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  * @file: DisnctMRGenerator.h
25  * @author: yesen
26  * @date: 07/12/2013
27  * @version: 1.0
28  *
29  * @section LICENSE
30  *
31  * @section DESCRIPTION
32  *
33  */
34 
35 
36 #ifndef DISNCTMRGENERATOR_H_
37 #define DISNCTMRGENERATOR_H_
38 
39 #include "MSSA/MemRegion.h"
40 
41 namespace SVF
42 {
43 
47 class DistinctMRG : public MRGenerator
48 {
49 public:
50  DistinctMRG(BVDataPTAImpl* p, bool ptrOnly) : MRGenerator(p, ptrOnly)
51  {}
52 
54 
55 protected:
57  virtual void partitionMRs();
58 
60  virtual void getMRsForLoad(MRSet& aliasMRs, const NodeBS& cpts, const SVFFunction* fun);
61 
63  virtual void getMRsForCallSiteRef(MRSet& aliasMRs, const NodeBS& cpts, const SVFFunction* fun);
64 private:
66  void createDistinctMR(const SVFFunction* func, const NodeBS& cpts);
67 
68 };
69 
74 {
75 public:
79 
80  IntraDisjointMRG(BVDataPTAImpl* p, bool ptrOnly) : MRGenerator(p, ptrOnly)
81  {}
82 
84 
85 protected:
86 
88  virtual void partitionMRs();
89 
96  virtual inline void getMRsForLoad(MRSet& aliasMRs, const NodeBS& cpts,
97  const SVFFunction* fun)
98  {
99  const PointsToList& inters = getIntersList(fun);
100  getMRsForLoadFromInterList(aliasMRs, cpts, inters);
101  }
102 
103  void getMRsForLoadFromInterList(MRSet& mrs, const NodeBS& cpts, const PointsToList& inters);
104 
106  virtual void getMRsForCallSiteRef(MRSet& aliasMRs, const NodeBS& cpts, const SVFFunction* fun);
107 
109  void createDisjointMR(const SVFFunction* func, const NodeBS& cpts);
110 
112  void computeIntersections(const NodeBS& cpts, PointsToList& inters);
113 
114 private:
116  {
117  return funcToPtsMap[func];
118  }
119 
121  {
122  return funcToInterMap[func];
123  }
124 
125  inline const PtsToSubPtsMap& getPtsSubSetMap(const SVFFunction* func) const
126  {
127  FunToPtsMap::const_iterator it = funcToPtsMap.find(func);
128  assert(it != funcToPtsMap.end() && "can not find pts map for specified function");
129  return it->second;
130  }
131 
134 };
135 
140 {
141 public:
142  InterDisjointMRG(BVDataPTAImpl* p, bool ptrOnly) : IntraDisjointMRG(p, ptrOnly)
143  {}
144 
146 
147 protected:
149  virtual void partitionMRs();
150 
157  virtual inline void getMRsForLoad(MRSet& aliasMRs, const NodeBS& cpts,
158  const SVFFunction*)
159  {
160  getMRsForLoadFromInterList(aliasMRs, cpts, inters);
161  }
162 
163 private:
165 };
166 
167 } // End namespace SVF
168 
169 #endif /* DISNCTMRGENERATOR_H_ */
cJSON * p
Definition: cJSON.cpp:2559
virtual void getMRsForLoad(MRSet &aliasMRs, const NodeBS &cpts, const SVFFunction *fun)
Get memory region at a load.
virtual void partitionMRs()
Partition regions.
virtual void getMRsForCallSiteRef(MRSet &aliasMRs, const NodeBS &cpts, const SVFFunction *fun)
Get memory regions to be inserted at a load statement.
void createDistinctMR(const SVFFunction *func, const NodeBS &cpts)
Create memory regions for each points-to target.
DistinctMRG(BVDataPTAImpl *p, bool ptrOnly)
Definition: MemPartition.h:50
virtual void partitionMRs()
Partition regions.
InterDisjointMRG(BVDataPTAImpl *p, bool ptrOnly)
Definition: MemPartition.h:142
virtual void getMRsForLoad(MRSet &aliasMRs, const NodeBS &cpts, const SVFFunction *)
Definition: MemPartition.h:157
void createDisjointMR(const SVFFunction *func, const NodeBS &cpts)
Create disjoint memory region.
FunToPtsMap funcToPtsMap
Definition: MemPartition.h:132
OrderedMap< NodeBS, PointsToList > PtsToSubPtsMap
Definition: MemPartition.h:76
virtual void partitionMRs()
Partition regions.
Map< const SVFFunction *, PtsToSubPtsMap > FunToPtsMap
Definition: MemPartition.h:77
virtual void getMRsForCallSiteRef(MRSet &aliasMRs, const NodeBS &cpts, const SVFFunction *fun)
Get memory regions to be inserted at a load statement.
void getMRsForLoadFromInterList(MRSet &mrs, const NodeBS &cpts, const PointsToList &inters)
PointsToList & getIntersList(const SVFFunction *func)
Definition: MemPartition.h:120
FunToInterMap funcToInterMap
Definition: MemPartition.h:133
const PtsToSubPtsMap & getPtsSubSetMap(const SVFFunction *func) const
Definition: MemPartition.h:125
Map< const SVFFunction *, PointsToList > FunToInterMap
Definition: MemPartition.h:78
void computeIntersections(const NodeBS &cpts, PointsToList &inters)
Compute intersections between cpts and computed cpts intersections before.
PtsToSubPtsMap & getPtsSubSetMap(const SVFFunction *func)
Definition: MemPartition.h:115
IntraDisjointMRG(BVDataPTAImpl *p, bool ptrOnly)
Definition: MemPartition.h:80
virtual void getMRsForLoad(MRSet &aliasMRs, const NodeBS &cpts, const SVFFunction *fun)
Definition: MemPartition.h:96
OrderedSet< NodeBS, SVFUtil::equalNodeBS > PointsToList
Definition: MemRegion.h:143
OrderedSet< const MemRegion *, MemRegion::equalMemRegion > MRSet
Get typedef from Pointer Analysis.
Definition: MemRegion.h:141
for isBitcode
Definition: BasicTypes.h:68
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
Definition: GeneralType.h:101
std::map< Key, Value, Compare, Allocator > OrderedMap
Definition: GeneralType.h:109