Static Value-Flow Analysis
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
SVF::IntraDisjointMRG Class Reference

#include <MemPartition.h>

Inheritance diagram for SVF::IntraDisjointMRG:
SVF::MRGenerator SVF::InterDisjointMRG

Public Types

typedef OrderedMap< NodeBS, PointsToListPtsToSubPtsMap
 
typedef Map< const SVFFunction *, PtsToSubPtsMapFunToPtsMap
 
typedef Map< const SVFFunction *, PointsToListFunToInterMap
 
- Public Types inherited from SVF::MRGenerator
typedef FIFOWorkList< NodeIDWorkList
 
typedef OrderedSet< const MemRegion *, MemRegion::equalMemRegionMRSet
 Get typedef from Pointer Analysis. More...
 
typedef Map< const PAGEdge *, const SVFFunction * > PAGEdgeToFunMap
 
typedef OrderedSet< NodeBS, SVFUtil::equalNodeBSPointsToList
 
typedef Map< const SVFFunction *, NodeBSFunToPointsToMap
 
typedef Map< const SVFFunction *, PointsToListFunToPointsTosMap
 
typedef OrderedMap< NodeBS, NodeBS, SVFUtil::equalNodeBSPtsToRepPtsSetMap
 
typedef Map< const SVFFunction *, MRSetFunToMRsMap
 Map a function to its region set. More...
 
typedef Map< const LoadStmt *, MRSetLoadsToMRsMap
 
typedef Map< const StoreStmt *, MRSetStoresToMRsMap
 
typedef Map< const CallICFGNode *, MRSetCallSiteToMRsMap
 
typedef Map< const LoadStmt *, NodeBSLoadsToPointsToMap
 Map loads/stores/callsites to their cpts set. More...
 
typedef Map< const StoreStmt *, NodeBSStoresToPointsToMap
 
typedef Map< const CallICFGNode *, NodeBSCallSiteToPointsToMap
 
typedef Map< const SVFFunction *, NodeBSFunToNodeBSMap
 Maps Mod-Ref analysis. More...
 
typedef Map< const CallICFGNode *, NodeBSCallSiteToNodeBSMap
 Map a callsite to its indirect refs/mods of memory objects. More...
 
typedef Map< NodeID, NodeBSNodeToPTSSMap
 
typedef SVFIR::SVFStmtList SVFStmtList
 SVFIR edge list. More...
 
typedef SCCDetection< PTACallGraph * > SCC
 Call Graph SCC. More...
 

Public Member Functions

 IntraDisjointMRG (BVDataPTAImpl *p, bool ptrOnly)
 
 ~IntraDisjointMRG ()
 
- Public Member Functions inherited from SVF::MRGenerator
MRSetgetMRSet ()
 
const NodeBSgetRepPointsTo (const NodeBS &cpts) const
 Get superset cpts set. More...
 
const MemRegiongetMR (const NodeBS &cpts) const
 Get a memory region according to cpts. More...
 
u32_t getMRNum () const
 
virtual ~MRGenerator ()
 Destructor. More...
 
virtual void generateMRs ()
 Start generating memory regions. More...
 
const SVFFunctiongetFunction (const PAGEdge *pagEdge) const
 Get the function which SVFIR Edge located. More...
 
MRSetgetFunMRSet (const SVFFunction *fun)
 Get Memory Region set. More...
 
MRSetgetLoadMRSet (const LoadStmt *load)
 
MRSetgetStoreMRSet (const StoreStmt *store)
 
bool hasRefMRSet (const CallICFGNode *cs)
 
bool hasModMRSet (const CallICFGNode *cs)
 
MRSetgetCallSiteRefMRSet (const CallICFGNode *cs)
 
MRSetgetCallSiteModMRSet (const CallICFGNode *cs)
 
bool hasSVFStmtList (const ICFGNode *icfgNode)
 Whether this instruction has SVFIR Edge. More...
 
SVFStmtListgetPAGEdgesFromInst (const ICFGNode *node)
 Given an instruction, get all its the PAGEdge (statement) in sequence. More...
 
NodeBS getModInfoForCall (const CallICFGNode *cs)
 getModRefInfo APIs More...
 
NodeBS getRefInfoForCall (const CallICFGNode *cs)
 
ModRefInfo getModRefInfo (const CallICFGNode *cs)
 
ModRefInfo getModRefInfo (const CallICFGNode *cs, const SVFValue *V)
 
ModRefInfo getModRefInfo (const CallICFGNode *cs1, const CallICFGNode *cs2)
 

Protected Member Functions

virtual void partitionMRs ()
 Partition regions. More...
 
virtual void getMRsForLoad (MRSet &aliasMRs, const NodeBS &cpts, const SVFFunction *fun)
 
void getMRsForLoadFromInterList (MRSet &mrs, const NodeBS &cpts, const PointsToList &inters)
 
virtual void getMRsForCallSiteRef (MRSet &aliasMRs, const NodeBS &cpts, const SVFFunction *fun)
 Get memory regions to be inserted at a load statement. More...
 
void createDisjointMR (const SVFFunction *func, const NodeBS &cpts)
 Create disjoint memory region. More...
 
void computeIntersections (const NodeBS &cpts, PointsToList &inters)
 Compute intersections between cpts and computed cpts intersections before. More...
 
- Protected Member Functions inherited from SVF::MRGenerator
 MRGenerator (BVDataPTAImpl *p, bool ptrOnly)
 
void createMR (const SVFFunction *fun, const NodeBS &cpts)
 Generate a memory region and put in into functions which use it. More...
 
void collectGlobals ()
 Collect all global variables for later escape analysis. More...
 
virtual void collectModRefForLoadStore ()
 Generate regions for loads/stores. More...
 
virtual void collectModRefForCall ()
 Generate regions for calls/rets. More...
 
virtual void updateAliasMRs ()
 Update aliased regions for loads/stores/callsites. More...
 
virtual void sortPointsTo (const NodeBS &cpts)
 Given a condition pts, insert into cptsToRepCPtsMap for region generation. More...
 
virtual bool isAliasedMR (const NodeBS &cpts, const MemRegion *mr)
 Whether a region is aliased with a conditional points-to. More...
 
virtual void getAliasMemRegions (MRSet &aliasMRs, const NodeBS &cpts, const SVFFunction *fun)
 Get all aliased mem regions from function fun according to cpts. More...
 
virtual void modRefAnalysis (PTACallGraphNode *callGraphNode, WorkList &worklist)
 Mod-Ref analysis for callsite invoking this callGraphNode. More...
 
virtual bool handleCallsiteModRef (NodeBS &mod, NodeBS &ref, const CallICFGNode *cs, const SVFFunction *fun)
 Get Mod-Ref of a callee function. More...
 
void addCPtsToStore (NodeBS &cpts, const StoreStmt *st, const SVFFunction *fun)
 Add cpts to store/load. More...
 
void addCPtsToLoad (NodeBS &cpts, const LoadStmt *ld, const SVFFunction *fun)
 
void addCPtsToCallSiteRefs (NodeBS &cpts, const CallICFGNode *cs)
 
void addCPtsToCallSiteMods (NodeBS &cpts, const CallICFGNode *cs)
 
bool hasCPtsList (const SVFFunction *fun) const
 
PointsToListgetPointsToList (const SVFFunction *fun)
 
FunToPointsTosMapgetFunToPointsToList ()
 
void addRefSideEffectOfFunction (const SVFFunction *fun, const NodeBS &refs)
 Add/Get methods for side-effect of functions and callsites. More...
 
void addModSideEffectOfFunction (const SVFFunction *fun, const NodeBS &mods)
 Add indirect def an memory object in the function. More...
 
bool addRefSideEffectOfCallSite (const CallICFGNode *cs, const NodeBS &refs)
 Add indirect uses an memory object in the function. More...
 
bool addModSideEffectOfCallSite (const CallICFGNode *cs, const NodeBS &mods)
 Add indirect def an memory object in the function. More...
 
const NodeBSgetRefSideEffectOfFunction (const SVFFunction *fun)
 Get indirect refs of a function. More...
 
const NodeBSgetModSideEffectOfFunction (const SVFFunction *fun)
 Get indirect mods of a function. More...
 
const NodeBSgetRefSideEffectOfCallSite (const CallICFGNode *cs)
 Get indirect refs of a callsite. More...
 
const NodeBSgetModSideEffectOfCallSite (const CallICFGNode *cs)
 Get indirect mods of a callsite. More...
 
bool hasRefSideEffectOfCallSite (const CallICFGNode *cs)
 Has indirect refs of a callsite. More...
 
bool hasModSideEffectOfCallSite (const CallICFGNode *cs)
 Has indirect mods of a callsite. More...
 

Private Member Functions

PtsToSubPtsMapgetPtsSubSetMap (const SVFFunction *func)
 
PointsToListgetIntersList (const SVFFunction *func)
 
const PtsToSubPtsMapgetPtsSubSetMap (const SVFFunction *func) const
 

Private Attributes

FunToPtsMap funcToPtsMap
 
FunToInterMap funcToInterMap
 

Additional Inherited Members

- Protected Attributes inherited from SVF::MRGenerator
MRSet memRegSet
 A set of All memory regions. More...
 
PtsToRepPtsSetMap cptsToRepCPtsMap
 Map a condition pts to its rep conditional pts (super set points-to) More...
 

Detailed Description

Create memory regions which don't have intersections with each other in the same function scope.

Definition at line 73 of file MemPartition.h.

Member Typedef Documentation

◆ FunToInterMap

Definition at line 78 of file MemPartition.h.

◆ FunToPtsMap

Definition at line 77 of file MemPartition.h.

◆ PtsToSubPtsMap

Definition at line 76 of file MemPartition.h.

Constructor & Destructor Documentation

◆ IntraDisjointMRG()

SVF::IntraDisjointMRG::IntraDisjointMRG ( BVDataPTAImpl p,
bool  ptrOnly 
)
inline

Definition at line 80 of file MemPartition.h.

80  : MRGenerator(p, ptrOnly)
81  {}
cJSON * p
Definition: cJSON.cpp:2559
MRGenerator(BVDataPTAImpl *p, bool ptrOnly)
Definition: MemRegion.cpp:41

◆ ~IntraDisjointMRG()

SVF::IntraDisjointMRG::~IntraDisjointMRG ( )
inline

Definition at line 83 of file MemPartition.h.

83 {}

Member Function Documentation

◆ computeIntersections()

void IntraDisjointMRG::computeIntersections ( const NodeBS cpts,
PointsToList inters 
)
protected

Compute intersections between cpts and computed cpts intersections before.

Compute intersections between cpts and computed cpts intersections before.

Definition at line 152 of file MemPartition.cpp.

153 {
154  if (inters.find(cpts) != inters.end())
155  {
156  // Skip this cpts if it is already in the map.
157  return;
158  }
159  else if (cpts.count() == 1)
160  {
161  // If this cpts has only one element, it will not intersect with any cpts in inters,
162  // just add it into intersection set.
163  inters.insert(cpts);
164  return;
165  }
166  else
167  {
168  PointsToList toBeDeleted;
169  PointsToList newInters;
170 
171  NodeBS cpts_copy = cpts; // make a copy since cpts may be changed.
172 
173  // check intersections with existing cpts in subSetMap
174  for (PointsToList::const_iterator interIt = inters.begin(), interEit = inters.end();
175  interIt != interEit; ++interIt)
176  {
177  const NodeBS& inter = *interIt;
178 
179  if (cpts_copy.intersects(inter))
180  {
181  // compute intersection between cpts and inter
182  NodeBS new_inter = inter;
183  new_inter &= cpts_copy;
184 
185  // remove old intersection and add new one if possible
186  if (new_inter != inter)
187  {
188  toBeDeleted.insert(inter);
189  newInters.insert(new_inter);
190 
191  // compute complement after intersection
192  NodeBS complement = inter;
193  complement.intersectWithComplement(new_inter);
194  if (complement.empty() == false)
195  {
196  newInters.insert(complement);
197  }
198  }
199 
200  cpts_copy.intersectWithComplement(new_inter);
201 
202  if (cpts_copy.empty())
203  break;
204  }
205  }
206 
207  // remove old intersections
208  for (PointsToList::const_iterator it = toBeDeleted.begin(), eit = toBeDeleted.end();
209  it != eit; ++it)
210  {
211  const NodeBS& temp_cpts = *it;
212  inters.erase(temp_cpts);
213  }
214 
215  // add new intersections
216  for (PointsToList::const_iterator it = newInters.begin(), eit = newInters.end();
217  it != eit; ++it)
218  {
219  const NodeBS& temp_cpts = *it;
220  inters.insert(temp_cpts);
221  }
222 
223  // add remaining set into inters
224  if (cpts_copy.empty() == false)
225  inters.insert(cpts_copy);
226  }
227 }
OrderedSet< NodeBS, SVFUtil::equalNodeBS > PointsToList
Definition: MemRegion.h:143
bool intersects(const SparseBitVector< ElementSize > *RHS) const
bool intersectWithComplement(const SparseBitVector &RHS)
unsigned count() const

◆ createDisjointMR()

void IntraDisjointMRG::createDisjointMR ( const SVFFunction func,
const NodeBS cpts 
)
protected

Create disjoint memory region.

Create memory regions for each points-to target.

Definition at line 232 of file MemPartition.cpp.

233 {
234  // set the rep cpts as itself.
235  cptsToRepCPtsMap[cpts] = cpts;
236 
237  // add memory region for this points-to target.
238  createMR(func, cpts);
239 }
PtsToRepPtsSetMap cptsToRepCPtsMap
Map a condition pts to its rep conditional pts (super set points-to)
Definition: MemRegion.h:280
void createMR(const SVFFunction *fun, const NodeBS &cpts)
Generate a memory region and put in into functions which use it.
Definition: MemRegion.cpp:69

◆ getIntersList()

PointsToList& SVF::IntraDisjointMRG::getIntersList ( const SVFFunction func)
inlineprivate

Definition at line 120 of file MemPartition.h.

121  {
122  return funcToInterMap[func];
123  }
FunToInterMap funcToInterMap
Definition: MemPartition.h:133

◆ getMRsForCallSiteRef()

void IntraDisjointMRG::getMRsForCallSiteRef ( MRSet aliasMRs,
const NodeBS cpts,
const SVFFunction fun 
)
protectedvirtual

Get memory regions to be inserted at a load statement.

Get memory regions to be inserted at a load statement. Just process as getMRsForLoad().

Reimplemented from SVF::MRGenerator.

Definition at line 262 of file MemPartition.cpp.

263 {
264  getMRsForLoad(aliasMRs, cpts, fun);
265 }
virtual void getMRsForLoad(MRSet &aliasMRs, const NodeBS &cpts, const SVFFunction *fun)
Definition: MemPartition.h:96

◆ getMRsForLoad()

virtual void SVF::IntraDisjointMRG::getMRsForLoad ( MRSet aliasMRs,
const NodeBS cpts,
const SVFFunction fun 
)
inlineprotectedvirtual

Get memory regions to be inserted at a load statement.

Parameters
cptsThe conditional points-to set of load statement.
funThe function being analyzed.
mrsMemory region set contains all possible target memory regions.

Reimplemented from SVF::MRGenerator.

Reimplemented in SVF::InterDisjointMRG.

Definition at line 96 of file MemPartition.h.

98  {
99  const PointsToList& inters = getIntersList(fun);
100  getMRsForLoadFromInterList(aliasMRs, cpts, inters);
101  }
void getMRsForLoadFromInterList(MRSet &mrs, const NodeBS &cpts, const PointsToList &inters)
PointsToList & getIntersList(const SVFFunction *func)
Definition: MemPartition.h:120

◆ getMRsForLoadFromInterList()

void IntraDisjointMRG::getMRsForLoadFromInterList ( MRSet mrs,
const NodeBS cpts,
const PointsToList inters 
)
protected

Definition at line 241 of file MemPartition.cpp.

242 {
243  PointsToList::const_iterator it = inters.begin();
244  PointsToList::const_iterator eit = inters.end();
245  for (; it != eit; ++it)
246  {
247  const NodeBS& inter = *it;
248  if (cpts.contains(inter))
249  {
250  MemRegion mr(inter);
251  MRSet::iterator mit = memRegSet.find(&mr);
252  assert(mit!=memRegSet.end() && "memory region not found!!");
253  mrs.insert(*mit);
254  }
255  }
256 }
MRSet memRegSet
A set of All memory regions.
Definition: MemRegion.h:278
Memory Region class.
Definition: MemRegion.h:56
bool contains(const SparseBitVector< ElementSize > &RHS) const

◆ getPtsSubSetMap() [1/2]

PtsToSubPtsMap& SVF::IntraDisjointMRG::getPtsSubSetMap ( const SVFFunction func)
inlineprivate

Definition at line 115 of file MemPartition.h.

116  {
117  return funcToPtsMap[func];
118  }
FunToPtsMap funcToPtsMap
Definition: MemPartition.h:132

◆ getPtsSubSetMap() [2/2]

const PtsToSubPtsMap& SVF::IntraDisjointMRG::getPtsSubSetMap ( const SVFFunction func) const
inlineprivate

Definition at line 125 of file MemPartition.h.

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  }

◆ partitionMRs()

void IntraDisjointMRG::partitionMRs ( )
protectedvirtual

Partition regions.

Create memory regions.

Reimplemented from SVF::MRGenerator.

Reimplemented in SVF::InterDisjointMRG.

Definition at line 122 of file MemPartition.cpp.

123 {
124  for(FunToPointsTosMap::iterator it = getFunToPointsToList().begin(),
125  eit = getFunToPointsToList().end(); it!=eit; ++it)
126  {
127  const SVFFunction* fun = it->first;
128 
129  for(PointsToList::iterator cit = it->second.begin(), ecit = it->second.end();
130  cit!=ecit; ++cit)
131  {
132  const NodeBS& cpts = *cit;
133 
134  PointsToList& inters = getIntersList(fun);
135  computeIntersections(cpts, inters);
136  }
137 
139  const PointsToList& inters = getIntersList(fun);
140  for (PointsToList::const_iterator interIt = inters.begin(), interEit = inters.end();
141  interIt != interEit; ++interIt)
142  {
143  const NodeBS& inter = *interIt;
144  createDisjointMR(fun, inter);
145  }
146  }
147 }
void createDisjointMR(const SVFFunction *func, const NodeBS &cpts)
Create disjoint memory region.
void computeIntersections(const NodeBS &cpts, PointsToList &inters)
Compute intersections between cpts and computed cpts intersections before.
FunToPointsTosMap & getFunToPointsToList()
Definition: MemRegion.h:371

Member Data Documentation

◆ funcToInterMap

FunToInterMap SVF::IntraDisjointMRG::funcToInterMap
private

Definition at line 133 of file MemPartition.h.

◆ funcToPtsMap

FunToPtsMap SVF::IntraDisjointMRG::funcToPtsMap
private

Definition at line 132 of file MemPartition.h.


The documentation for this class was generated from the following files: