36#ifndef MEMORYSSAPASS_H_
37#define MEMORYSSAPASS_H_
76 typedef std::vector<const MemRegion*>
MRVector;
93 typedef std::vector<const SVFBasicBlock*>
BBList;
169 assert(!
stack.empty() &&
"stack is empty!!");
191 for (MRSet::iterator iter = mrSet.begin(), eiter = mrSet.end(); iter != eiter; ++iter)
196 for (MRSet::iterator iter = mrSet.begin(), eiter = mrSet.end(); iter != eiter; ++iter)
201 for (MRSet::iterator iter = mrSet.begin(), eiter = mrSet.end(); iter != eiter; ++iter)
206 for (MRSet::iterator iter = mrSet.begin(), eiter = mrSet.end(); iter != eiter; ++iter)
211 for (MRSet::iterator iter = mrSet.begin(), eiter = mrSet.end(); iter != eiter; ++iter)
251 for (MUSet::const_iterator mit = muSet.begin(), emit = muSet.end();
262 for (CHISet::const_iterator cit = chiSet.begin(), ecit = chiSet.end();
268 memRegs.push_back(chi->
getMR());
275 for (PHISet::const_iterator iter = phiSet.begin(), eiter = phiSet.end();
276 iter != eiter; ++iter)
280 memRegs.push_back(phi->
getMR());
287 for (PHISet::const_iterator iter = phiSet.begin(), eiter = phiSet.end();
288 iter != eiter; ++iter)
332 assert(hasMu &&
"not associated with mem region!");
344 assert(has_store &&
"not associated with mem region!");
const SVFBasicBlock * getBasicBlock() const
Return basic block.
OrderedSet< const MemRegion *, MemRegion::equalMemRegion > MRSet
Get typedef from Pointer Analysis.
void setOpVer(MRVer *v)
Set operand ver.
void setResVer(MRVer *v)
Set result operand ver.
const MemRegion * getMR() const
Return memory region.
void setVer(MRVer *v)
Set Ver.
const MemRegion * getMR() const
Return MR.
void setOpVer(const MRVer *v, u32_t pos)
Set operand ver.
PHISet & getPHISet(const SVFBasicBlock *bb)
void AddStoreCHI(const SVFBasicBlock *bb, const StoreStmt *store, const MemRegion *mr)
MemSSA(BVDataPTAImpl *p, std::unique_ptr< MRGenerator > mrGenerator)
std::vector< const SVFBasicBlock * > BBList
For phi insertion.
void RenamePhiOps(const PHISet &phiSet, u32_t pos, MRVector &)
Rename operands (RHS) of phis.
StoreCHI< Condition > STORECHI
u32_t getFunEntryChiNum() const
BBToPhiSetMap bb2PhiSetMap
CallSiteToCHISetMap callsiteToChiSetMap
CHISet & getCHISet(const StoreStmt *st)
MemRegToCounterMap mr2CounterMap
void RenameMuSet(const MUSet &muSet)
Rename mus, chis and phis.
BVDataPTAImpl * getPTA() const
Return PTA.
virtual void createMUCHI(const FunObjVar &fun)
Create mu chi for candidate regions in a function.
LoadToMUSetMap & getLoadToMUSetMap()
u32_t getCallSiteChiNum() const
void collectRegDefs(const SVFBasicBlock *bb, const MemRegion *mr)
MRGenerator::MRSet MRSet
Define mem region set.
static double timeOfGeneratingMemRegions
Statistics.
MRVer * newSSAName(const MemRegion *mr, MSSADEF *def)
Get a new SSA name of a memory region.
void AddStoreCHI(const SVFBasicBlock *bb, const StoreStmt *store, const MRSet &mrSet)
static double timeOfInsertingPHI
Time for inserting phis.
bool hasReturnMu(const FunObjVar *fun) const
void destroy()
Release the memory.
SVFIR * getPAG()
Return SVFIR.
bool hasPHISet(const SVFBasicBlock *bb) const
void AddLoadMU(const SVFBasicBlock *bb, const LoadStmt *load, const MRSet &mrSet)
Add methods for mus/chis/phis.
Map< const CallICFGNode *, CHISet > CallSiteToCHISetMap
SVFIR::SVFStmtList SVFStmtList
SVFIR edge list.
LoadMU< Condition > LOADMU
static double timeOfCreateMUCHI
Time for generating mu/chi for load/store/calls.
CHISet & getFuncEntryChiSet(const FunObjVar *fun)
StoreToChiSetMap & getStoreToChiSetMap()
CallCHI< Condition > CALLCHI
FunToEntryChiSetMap funToEntryChiSetMap
virtual void insertPHI(const FunObjVar &fun)
Insert phi for candidate regions in a function.
LoadToMUSetMap load2MuSetMap
Map< const CallICFGNode *, MUSet > CallSiteToMUSetMap
void RenameChiSet(const CHISet &chiSet, MRVector &memRegs)
Rename chi set.
CallSiteToMUSetMap & getCallSiteToMuSetMap()
void RenamePhiRes(const PHISet &phiSet, MRVector &memRegs)
Rename result (LHS) of phis.
MUSet & getMUSet(const CallICFGNode *cs)
u32_t getFunRetMuNum() const
EntryCHI< Condition > ENTRYCHI
bool hasMU(const CallICFGNode *cs) const
std::vector< std::unique_ptr< MRVer > > usedMRVers
FunToEntryChiSetMap & getFunToEntryChiSetMap()
StoreToChiSetMap store2ChiSetMap
void dumpMSSA(OutStream &Out=SVFUtil::outs())
Print Memory SSA.
Map< const FunObjVar *, MUSet > FunToReturnMuSetMap
CHISet & getCHISet(const CallICFGNode *cs)
CallMU< Condition > CALLMU
void AddMSSAPHI(const SVFBasicBlock *bb, const MemRegion *mr)
std::vector< const MemRegion * > MRVector
void collectRegUses(const MemRegion *mr)
Collect region uses and region defs according to mus/chis, in order to insert phis.
void performStat()
Perform statistics.
Map< const MemRegion *, BBList > MemRegToBBsMap
virtual void buildMemSSA(const FunObjVar &fun)
We start from here.
void AddCallSiteMU(const CallICFGNode *cs, const MRSet &mrSet)
bool hasFuncEntryChi(const FunObjVar *fun) const
Has function entry chi or return mu.
Map< const LoadStmt *, MUSet > LoadToMUSetMap
static double timeOfSSARenaming
Time for SSA rename.
BBToPhiSetMap & getBBToPhiSetMap()
FunToReturnMuSetMap & getFunToRetMuSetMap()
u32_t getBBPhiNum() const
u32_t getCallSiteMuNum() const
u32_t getStoreChiNum() const
Map< const MemRegion *, std::vector< MRVer * > > MemRegToVerStackMap
For SSA renaming.
u32_t getLoadMuNum() const
Stat methods.
MRGenerator * getMRGenerator()
Return MRGenerator (non-owning; MemSSA retains ownership).
std::unique_ptr< MRGenerator > mrGen
CallSiteToMUSetMap callsiteToMuSetMap
FunToReturnMuSetMap funToReturnMuSetMap
bool hasCHI(const PAGEdge *inst) const
MemRegion::Condition Condition
define condition here changes needed if we add new type
virtual void SSARename(const FunObjVar &fun)
SSA rename for a function.
MRSet usedRegs
The following three set are used for prune SSA phi insertion.
Map< const SVFBasicBlock *, MRSet > BBToMRSetMap
Map< const StoreStmt *, CHISet > StoreToChiSetMap
MUSet & getMUSet(const LoadStmt *ld)
Get methods of mu/chi/phi.
void AddCallSiteCHI(const CallICFGNode *cs, const MRSet &mrSet)
void AddCallSiteMU(const CallICFGNode *cs, const MemRegion *mr)
MUSet & getReturnMuSet(const FunObjVar *fun)
CallSiteToCHISetMap & getCallSiteToChiSetMap()
MemRegToBBsMap reg2BBMap
Maps memory region to its basic block.
MRVer * getTopStackVer(const MemRegion *mr)
Get the last version of the SSA ver of memory region.
virtual ~MemSSA()
Destructor.
bool hasCHI(const CallICFGNode *cs) const
Map< const MemRegion *, MRVERSION > MemRegToCounterMap
void AddMSSAPHI(const SVFBasicBlock *bb, const MRSet &mrSet)
MemRegToVerStackMap mr2VerStackMap
Map< const FunObjVar *, CHISet > FunToEntryChiSetMap
Map from fun to its entry chi set and return mu set.
MRSet varKills
Collect memory regions whose definition killed.
virtual void SSARenameBB(const SVFBasicBlock &bb)
SSA rename for a basic block.
void AddLoadMU(const SVFBasicBlock *bb, const LoadStmt *load, const MemRegion *mr)
bool hasMU(const PAGEdge *inst) const
Has mu/chi methods.
void AddCallSiteCHI(const CallICFGNode *cs, const MemRegion *mr)
OrderedMap< const SVFBasicBlock *, PHISet > BBToPhiSetMap
std::vector< const SVFStmt * > SVFStmtList
std::ostream & outs()
Overwrite llvm::outs().
LLVM_NODISCARD std::enable_if_t<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type > dyn_cast(const Y &Val)
std::map< Key, Value, Compare, Allocator > OrderedMap
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map