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

#include <MemPartition.h>

Inheritance diagram for SVF::DistinctMRG:
SVF::MRGenerator

Public Member Functions

 DistinctMRG (BVDataPTAImpl *p, bool ptrOnly)
 
 ~DistinctMRG ()
 
- 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)
 Get memory region at a load. More...
 
virtual void getMRsForCallSiteRef (MRSet &aliasMRs, const NodeBS &cpts, const SVFFunction *fun)
 Get memory regions to be inserted at a load statement. 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

void createDistinctMR (const SVFFunction *func, const NodeBS &cpts)
 Create memory regions for each points-to target. More...
 

Additional Inherited Members

- 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...
 
- 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

Distinct memory region generator.

Definition at line 47 of file MemPartition.h.

Constructor & Destructor Documentation

◆ DistinctMRG()

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

Definition at line 50 of file MemPartition.h.

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

◆ ~DistinctMRG()

SVF::DistinctMRG::~DistinctMRG ( )
inline

Definition at line 53 of file MemPartition.h.

53 {}

Member Function Documentation

◆ createDistinctMR()

void DistinctMRG::createDistinctMR ( const SVFFunction func,
const NodeBS pts 
)
private

Create memory regions for each points-to target.

Create memory regions for each points-to target.

  1. collect all points-to targets in a function scope.
  2. create memory region for each point-to target.

Create memory regions for each points-to target.

Definition at line 64 of file MemPartition.cpp.

65 {
67 
68  NodeBS::iterator ptsIt = pts.begin();
69  NodeBS::iterator ptsEit = pts.end();
70  for (; ptsIt != ptsEit; ++ptsIt)
71  {
72  NodeID id = *ptsIt;
73  // create new conditional points-to set with this single element.
74  NodeBS newPts;
75  newPts.set(id);
76 
77  // set the rep cpts as itself.
78  cptsToRepCPtsMap[newPts] = newPts;
79 
80  // add memory region for this points-to target.
81  createMR(func, newPts);
82  }
83 }
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
iterator end() const
void set(unsigned Idx)
iterator begin() const
u32_t NodeID
Definition: GeneralType.h:55

◆ getMRsForCallSiteRef()

void DistinctMRG::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 115 of file MemPartition.cpp.

116 {
117  getMRsForLoad(aliasMRs, cpts, fun);
118 }
virtual void getMRsForLoad(MRSet &aliasMRs, const NodeBS &cpts, const SVFFunction *fun)
Get memory region at a load.

◆ getMRsForLoad()

void DistinctMRG::getMRsForLoad ( MRSet mrs,
const NodeBS pts,
const SVFFunction fun 
)
protectedvirtual

Get memory region at a load.

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.

Get memory regions for each points-to element in cpts.

Reimplemented from SVF::MRGenerator.

Definition at line 91 of file MemPartition.cpp.

92 {
94 
95  NodeBS::iterator ptsIt = pts.begin();
96  NodeBS::iterator ptsEit = pts.end();
97  for (; ptsIt != ptsEit; ++ptsIt)
98  {
99  NodeID id = *ptsIt;
100  // create new conditional points-to set with this single element.
101  NodeBS newPts;
102  newPts.set(id);
103 
104  MemRegion mr(newPts);
105  MRSet::iterator mit = memRegSet.find(&mr);
106  assert(mit!=memRegSet.end() && "memory region not found!!");
107  mrs.insert(*mit);
108  }
109 }
MRSet memRegSet
A set of All memory regions.
Definition: MemRegion.h:278
Memory Region class.
Definition: MemRegion.h:56

◆ partitionMRs()

void DistinctMRG::partitionMRs ( )
protectedvirtual

Partition regions.

Create distinct memory regions.

Collect all points-to target in a function scope.

Reimplemented from SVF::MRGenerator.

Definition at line 42 of file MemPartition.cpp.

43 {
44  for(FunToPointsTosMap::iterator it = getFunToPointsToList().begin(), eit = getFunToPointsToList().end();
45  it!=eit; ++it)
46  {
47  const SVFFunction* fun = it->first;
49  NodeBS mergePts;
50  for(PointsToList::iterator cit = it->second.begin(), ecit = it->second.end(); cit!=ecit; ++cit)
51  {
52  const NodeBS& pts = *cit;
53  mergePts |= pts;
54  }
55  createDistinctMR(fun, mergePts);
56  }
57 }
void createDistinctMR(const SVFFunction *func, const NodeBS &cpts)
Create memory regions for each points-to target.
FunToPointsTosMap & getFunToPointsToList()
Definition: MemRegion.h:371

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