37using namespace SVFUtil;
51 &&
"please specify a pointer analysis");
60 assert(
false &&
"unrecognised memory partition strategy");
83 assert(!
isExtCall(&fun) &&
"we do not build memory ssa for external functions");
120 outs() <<
"\t creating mu chi for function " << fun.
getName()
140 for (BBList::const_iterator
iter = reachableBBs.begin(),
eiter = reachableBBs.end();
150 for (SVFStmtList::const_iterator bit =
pagEdgeList.begin(),
154 if (
const LoadStmt* load = SVFUtil::dyn_cast<LoadStmt>(inst))
156 else if (
const StoreStmt* store = SVFUtil::dyn_cast<StoreStmt>(inst))
205 outs() <<
"\t insert phi for function " << fun.
getName() <<
"\n");
225 writeWrnMsg(
"bb not in the dominance frontier map??");
253 outs() <<
"\t ssa rename for function " << fun.
getName() <<
"\n");
291 if (
const LoadStmt* load = SVFUtil::dyn_cast<LoadStmt>(inst))
294 else if (
const StoreStmt* store = SVFUtil::dyn_cast<StoreStmt>(inst))
350 &&
"did not find initial version in map? ");
352 &&
"did not find initial stack in map? ");
356 auto mrVer = std::make_unique<MRVer>(mr, version, def);
372 for (MUSet::iterator
it =
iter->second.begin(),
eit =
382 for (CHISet::iterator
it =
iter->second.begin(),
eit =
392 for (MUSet::iterator
it =
iter->second.begin(),
eit =
402 for (CHISet::iterator
it =
iter->second.begin(),
eit =
412 for (CHISet::iterator
it =
iter->second.begin(),
eit =
422 for (MUSet::iterator
it =
iter->second.begin(),
eit =
432 for (PHISet::iterator
it =
iter->second.begin(),
eit =
586 Out <<
"==========FUNCTION: " << fun->
getName() <<
"==========\n";
628 Out << inst->toString() <<
"\n";
651 if (
const LoadStmt* load = SVFUtil::dyn_cast<LoadStmt>(
edge))
666 Out << inst->toString() <<
"\n";
673 if (
const StoreStmt* store = SVFUtil::dyn_cast<StoreStmt>(
edge))
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
MRSet & getStoreMRSet(const StoreStmt *store)
MRSet & getCallSiteRefMRSet(const CallICFGNode *cs)
SVFStmtList & getPAGEdgesFromInst(const ICFGNode *node)
Given an instruction, get all its the PAGEdge (statement) in sequence.
virtual void generateMRs()
Start generating memory regions.
bool hasModMRSet(const CallICFGNode *cs)
bool hasSVFStmtList(const ICFGNode *icfgNode)
Whether this instruction has SVFIR Edge.
MRSet & getLoadMRSet(const LoadStmt *load)
MRSet & getCallSiteModMRSet(const CallICFGNode *cs)
bool hasRefMRSet(const CallICFGNode *cs)
virtual void performStat() override
PHISet & getPHISet(const SVFBasicBlock *bb)
std::vector< const SVFBasicBlock * > BBList
For phi insertion.
void RenamePhiOps(const PHISet &phiSet, u32_t pos, MRVector &)
Rename operands (RHS) of phis.
u32_t getFunEntryChiNum() const
virtual void SSARename(const SVFFunction &fun)
SSA rename for a function.
BBToPhiSetMap bb2PhiSetMap
CallSiteToCHISetMap callsiteToChiSetMap
CHISet & getCHISet(const StoreStmt *st)
MemRegToCounterMap mr2CounterMap
void RenameMuSet(const MUSet &muSet)
Rename mus, chis and phis.
u32_t getCallSiteChiNum() const
bool hasReturnMu(const SVFFunction *fun) const
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.
void destroy()
Release the memory.
MUSet & getReturnMuSet(const SVFFunction *fun)
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.
SVFIR::SVFStmtList SVFStmtList
SVFIR edge list.
static double timeOfCreateMUCHI
Time for generating mu/chi for load/store/calls.
virtual void buildMemSSA(const SVFFunction &fun)
We start from here.
FunToEntryChiSetMap funToEntryChiSetMap
LoadToMUSetMap load2MuSetMap
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.
std::vector< std::unique_ptr< MRVer > > usedMRVers
StoreToChiSetMap store2ChiSetMap
void dumpMSSA(OutStream &Out=SVFUtil::outs())
Print Memory SSA.
std::vector< const MemRegion * > MRVector
void performStat()
Perform statistics.
void AddCallSiteMU(const CallICFGNode *cs, const MRSet &mrSet)
static double timeOfSSARenaming
Time for SSA rename.
u32_t getBBPhiNum() const
u32_t getCallSiteMuNum() const
u32_t getStoreChiNum() const
u32_t getLoadMuNum() const
Stat methods.
CallSiteToMUSetMap callsiteToMuSetMap
FunToReturnMuSetMap funToReturnMuSetMap
CHISet & getFuncEntryChiSet(const SVFFunction *fun)
bool hasCHI(const PAGEdge *inst) const
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
MUSet & getMUSet(const LoadStmt *ld)
Get methods of mu/chi/phi.
void AddCallSiteCHI(const CallICFGNode *cs, const MRSet &mrSet)
MemRegToBBsMap reg2BBMap
Maps memory region to its basic block.
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.
bool hasMU(const PAGEdge *inst) const
Has mu/chi methods.
static const OptionMap< MemSSA::MemPartition > MemPar
static const Option< std::string > MSSAFun
@ Default_PTA
default pta without any analysis
bool printStat()
Whether print statistics.
PTATY getAnalysisTy() const
Type of pointer analysis.
const SVFFunction * getParent() const
const std::vector< const ICFGNode * > & getICFGNodeList() const
const std::vector< const SVFBasicBlock * > & getSuccessors() const
u32_t getBBPredecessorPos(const SVFBasicBlock *succbb)
const ICFGNode * back() const
const_iterator end() const
const std::vector< const SVFBasicBlock * > & getReachableBBs() const
const_iterator begin() const
std::vector< constSVFBasicBlock * >::const_iterator const_iterator
const SVFBasicBlock * getEntryBlock() const
const Map< const SVFBasicBlock *, BBSet > & getDomFrontierMap() const
const Map< const SVFBasicBlock *, BBSet > & getDomTreeMap() const
CallGraph * getCallGraph()
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
static double getClk(bool mark=false)
const std::string & getName() const
bool isExtCall(const SVFFunction *fun)
bool isHeapAllocExtCall(const ICFGNode *cs)
bool isNonInstricCallSite(const ICFGNode *inst)
Whether an instruction is a callsite in the application code, excluding llvm intrinsic calls.
void writeWrnMsg(const std::string &msg)
Writes a message run through wrnMsg.
bool isRetInstNode(const ICFGNode *node)
std::ostream & outs()
Overwrite llvm::outs()
llvm::IRBuilder IRBuilder