36 #ifndef MEMORYSSAPASS_H_
37 #define MEMORYSSAPASS_H_
47 class PointerAnalysis;
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)
327 if (
const LoadStmt* load = SVFUtil::dyn_cast<LoadStmt>(inst))
330 assert(hasMu &&
"not associated with mem region!");
338 if (
const StoreStmt* store = SVFUtil::dyn_cast<StoreStmt>(
342 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 setOpVer(const MRVer *v, u32_t pos)
Set operand ver.
CallSiteToMUSetMap & getCallSiteToMuSetMap()
void AddStoreCHI(const SVFBasicBlock *bb, const StoreStmt *store, const MemRegion *mr)
std::vector< const SVFBasicBlock * > BBList
For phi insertion.
void RenamePhiOps(const PHISet &phiSet, u32_t pos, MRVector &)
Rename operands (RHS) of phis.
CHISet & getFuncEntryChiSet(const SVFFunction *fun)
StoreCHI< Condition > STORECHI
u32_t getFunEntryChiNum() const
virtual void SSARename(const SVFFunction &fun)
SSA rename for a function.
BBToPhiSetMap bb2PhiSetMap
CallSiteToCHISetMap callsiteToChiSetMap
MemRegToCounterMap mr2CounterMap
void RenameMuSet(const MUSet &muSet)
Rename mus, chis and phis.
u32_t getCallSiteChiNum() const
CHISet & getCHISet(const StoreStmt *st)
bool hasReturnMu(const SVFFunction *fun) 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.
Map< const SVFFunction *, MUSet > FunToReturnMuSetMap
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.
FunToReturnMuSetMap & getFunToRetMuSetMap()
LoadMU< Condition > LOADMU
static double timeOfCreateMUCHI
Time for generating mu/chi for load/store/calls.
virtual void buildMemSSA(const SVFFunction &fun)
We start from here.
CallCHI< Condition > CALLCHI
FunToEntryChiSetMap funToEntryChiSetMap
LoadToMUSetMap load2MuSetMap
Map< const CallICFGNode *, MUSet > CallSiteToMUSetMap
void RenameChiSet(const CHISet &chiSet, MRVector &memRegs)
Rename chi set.
void RenamePhiRes(const PHISet &phiSet, MRVector &memRegs)
Rename result (LHS) of phis.
u32_t getFunRetMuNum() const
virtual void createMUCHI(const SVFFunction &fun)
Create mu chi for candidate regions in a function.
EntryCHI< Condition > ENTRYCHI
MemSSA(BVDataPTAImpl *p, bool ptrOnlyMSSA)
Constructor.
bool hasMU(const CallICFGNode *cs) const
std::vector< std::unique_ptr< MRVer > > usedMRVers
LoadToMUSetMap & getLoadToMUSetMap()
StoreToChiSetMap store2ChiSetMap
void dumpMSSA(OutStream &Out=SVFUtil::outs())
Print Memory SSA.
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.
PHISet & getPHISet(const SVFBasicBlock *bb)
void performStat()
Perform statistics.
Map< const MemRegion *, BBList > MemRegToBBsMap
void AddCallSiteMU(const CallICFGNode *cs, const MRSet &mrSet)
CallSiteToCHISetMap & getCallSiteToChiSetMap()
Map< const LoadStmt *, MUSet > LoadToMUSetMap
CHISet & getCHISet(const CallICFGNode *cs)
BBToPhiSetMap & getBBToPhiSetMap()
StoreToChiSetMap & getStoreToChiSetMap()
static double timeOfSSARenaming
Time for SSA rename.
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.
CallSiteToMUSetMap callsiteToMuSetMap
FunToReturnMuSetMap funToReturnMuSetMap
bool hasCHI(const PAGEdge *inst) const
MemRegion::Condition Condition
define condition here changes needed if we add new type
Map< const SVFFunction *, CHISet > FunToEntryChiSetMap
Map from fun to its entry chi set and return mu set.
virtual void insertPHI(const SVFFunction &fun)
Insert phi for candidate regions in 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
BVDataPTAImpl * getPTA() const
Return PTA.
MRVer * getTopStackVer(const MemRegion *mr)
Get the last version of the SSA ver of memory region.
void AddCallSiteCHI(const CallICFGNode *cs, const MRSet &mrSet)
void AddCallSiteMU(const CallICFGNode *cs, const MemRegion *mr)
MemRegToBBsMap reg2BBMap
Maps memory region to its basic block.
virtual ~MemSSA()
Destructor.
bool hasCHI(const CallICFGNode *cs) const
Map< const MemRegion *, MRVERSION > MemRegToCounterMap
void AddMSSAPHI(const SVFBasicBlock *bb, const MRSet &mrSet)
MemRegToVerStackMap mr2VerStackMap
MRSet varKills
Collect memory regions whose definition killed.
virtual void SSARenameBB(const SVFBasicBlock &bb)
SSA rename for a basic block.
bool hasFuncEntryChi(const SVFFunction *fun) const
Has function entry chi or return mu.
MUSet & getMUSet(const CallICFGNode *cs)
void AddLoadMU(const SVFBasicBlock *bb, const LoadStmt *load, const MemRegion *mr)
MUSet & getMUSet(const LoadStmt *ld)
Get methods of mu/chi/phi.
bool hasMU(const PAGEdge *inst) const
Has mu/chi methods.
void AddCallSiteCHI(const CallICFGNode *cs, const MemRegion *mr)
MUSet & getReturnMuSet(const SVFFunction *fun)
OrderedMap< const SVFBasicBlock *, PHISet > BBToPhiSetMap
FunToEntryChiSetMap & getFunToEntryChiSetMap()
std::vector< const SVFStmt * > SVFStmtList
std::ostream & outs()
Overwrite llvm::outs()
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
std::map< Key, Value, Compare, Allocator > OrderedMap
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set