38using namespace SVFUtil;
48 outs() <<
"Writing SVFG analysis to '" <<
filename <<
"'...";
50 std::fstream
f(
filename.c_str(), std::ios_base::out);
53 outs() <<
" error opening file for writing!\n";
65 f <<
"SVFGNodeID: " <<
nodeId <<
" >= " <<
"FormalINSVFGNode";
72 f <<
"SVFGNodeID: " <<
nodeId <<
" >= " <<
"FormalOUTSVFGNode";
74 f << *
formalOut->getMRVer() <<
"} >= ICFGNodeID: " <<
formalOut->getFunExitNode()->getId() <<
"\n";
79 f <<
"SVFGNodeID: " <<
nodeId <<
" >= " <<
"ActualINSVFGNode";
81 f << *
actualIn->getMRVer() <<
"} >= ICFGNodeID: " <<
actualIn->getCallSite()->getId() <<
"\n";
86 f <<
"SVFGNodeID: " <<
nodeId <<
" >= " <<
"ActualOUTSVFGNode" <<
" >= MVER: {";
87 f << *
actualOut->getMRVer() <<
"} >= ICFGNodeID: " <<
actualOut->getCallSite()->getId() <<
"\n";
92 f <<
"SVFGNodeID: " <<
nodeId <<
" >= " <<
"PHISVFGNode";
94 for (MemSSA::PHI::OPVers::const_iterator
it =
phiNode->opVerBegin(),
eit =
phiNode->opVerEnd();
103 f <<
"} >= ICFGNodeID: " << inst->
getId();
104 f <<
" >= OPVers: {";
108 f <<
"{" << *
op <<
"}" <<
",";
114 f <<
"\n\n__Edges__\n";
125 if(
LOADMU*
mu = SVFUtil::dyn_cast<LOADMU>(*
it))
128 f <<
"srcSVFGNodeID: " <<
nodeId <<
" => " <<
"dstSVFGNodeID: " << def <<
" >= LoadNode | MVER: {" << *
mu->getMRVer() <<
"}" <<
"\n";
140 f <<
"srcSVFGNodeID: " <<
nodeId <<
" => " <<
"dstSVFGNodeID: " << def <<
" >= StoreNode | MVER: {" << *
chi->getOpVer() <<
"}" <<
"\n";
157 f <<
"srcSVFGNodeID: " <<
nodeId <<
" => " <<
"dstSVFGNodeID: " <<
actualIn->getId() <<
" >= FormalINSVFGNode" <<
"\n";
168 if(!
mssa->hasCHI(cs))
174 f <<
"srcSVFGNodeID: " <<
nodeId <<
" => " <<
"dstSVFGNodeID: " <<
actualOut->getId() <<
" >= FormalOUTSVFGNode" <<
"\n";
178 f <<
"srcSVFGNodeID: " <<
nodeId <<
" => " <<
"dstSVFGNodeID: " << def <<
" >= FormalOUTSVFGNode | intra" <<
"\n";
183 f <<
"srcSVFGNodeID: " <<
nodeId <<
" => " <<
"dstSVFGNodeID: " << def <<
" >= ActualINSVFGNode" <<
"\n";
188 for (MemSSA::PHI::OPVers::const_iterator
it =
phiNode->opVerBegin(),
eit =
phiNode->opVerEnd();
193 f <<
"srcSVFGNodeID: " <<
nodeId <<
" => " <<
"dstSVFGNodeID: " << def <<
" >= PHISVFGNode | MVER: {" << *
op <<
"}" <<
"\n";
208 outs() <<
"Loading SVFG analysis results from '" <<
filename <<
"'...";
212 outs() <<
" error opening file for reading!\n";
222 for(CHISet::iterator
pi =
mssa->getCHISet(store).begin(),
epi =
mssa->getCHISet(store).end();
pi!=
epi; ++
pi)
234 if (
line.find(
"__Edges__") != std::string::npos)
237 std::string
s =
line;
289 if(
type ==
"FormalINSVFGNode")
295 else if(
type ==
"FormalOUTSVFGNode")
301 else if(
type ==
"ActualINSVFGNode")
307 else if(
type ==
"ActualOUTSVFGNode")
313 else if (
type ==
"PHISVFGNode")
316 next = opVer.find(
"{") + 1;
317 last = opVer.find(
",}");
321 while ((
next =
temp.find(
"{") + 1) != string::npos)
333 next = basicBlock.find(
"ICFGNodeID: ") + 12;
354 std::string
s =
line;
371 next =
edge.find(
"srcSVFGNodeID: ") + 15;
374 next =
edge.find(
"dstSVFGNodeID: ") + 15;
388 if(
type ==
"FormalINSVFGNode")
394 else if(
type ==
"FormalOUTSVFGNode")
397 if (attribute.find(
"intra") != string::npos)
407 else if(
type ==
"ActualINSVFGNode")
412 else if(
type ==
"ActualOUTSVFGNode")
416 else if (
type ==
"StoreNode" ||
type ==
"LoadNode" ||
type ==
"PHISVFGNode")
443 next =
s.find(
"MemRegion: pts{") + 15;
444 last =
s.find(
"} MRVERSION: ");
459 next =
s.find(
"MSSADef: ") + 9;
460 last =
s.find(
"} >=");
469 next =
s.find(
"MRVERSION: ") + 11;
470 last =
s.find(
" MSSADef:");
Set< const CallICFGNode * > CallInstSet
iterator begin()
Iterators.
virtual const SVFBasicBlock * getBB() const
Return the basic block of this ICFGNode.
ICFGNode * getICFGNode(NodeID id) const
Get a ICFG node.
const ICFGNode * front() const
ActualOUTSVFGNodeSet & getActualOUTSVFGNodes(const CallICFGNode *cs)
SVFGEdge * addInterIndirectVFCallEdge(const ActualINSVFGNode *src, const FormalINSVFGNode *dst, CallSiteID csId)
Add inter VF edge from callsite mu to function entry chi.
void connectFromGlobalToProgEntry()
Connect indirect SVFG edges from global initializers (store) to main function entry.
SVFGNode * getSVFGNode(NodeID id) const
Get a SVFG node.
void addIntraMSSAPHISVFGNode(ICFGNode *BlockICFGNode, const Map< u32_t, const MRVer * >::const_iterator opVerBegin, const Map< u32_t, const MRVer * >::const_iterator opVerEnd, const MRVer *resVer, const NodeID nodeId)
Add memory SSA PHI SVFG node.
ActualINSVFGNodeSet & getActualINSVFGNodes(const CallICFGNode *cs)
Get SVFGNode set.
void addActualOUTSVFGNode(const CallICFGNode *callsite, const MRVer *resVer, const NodeID nodeId)
Add memory callsite chi SVFG node.
virtual void writeToFile(const std::string &filename)
void addFormalOUTSVFGNode(const FunExitICFGNode *funExit, const MRVer *ver, const NodeID nodeId)
Add memory Function return mu SVFG node.
virtual MRVer * getMRVERFromString(const std::string &input)
void addActualINSVFGNode(const CallICFGNode *callsite, const MRVer *ver, const NodeID nodeId)
Add memory callsite mu SVFG node.
virtual void readFile(const std::string &filename)
std::unique_ptr< MemSSA > mssa
void addFormalINSVFGNode(const FunEntryICFGNode *funEntry, const MRVer *resVer, const NodeID nodeId)
Add memory Function entry chi SVFG node.
NodeID getDef(const PAGNode *pagNode) const
SVFGEdge * addInterIndirectVFRetEdge(const FormalOUTSVFGNode *src, const ActualOUTSVFGNode *dst, CallSiteID csId)
Add inter VF edge from function exit mu to callsite chi.
void setDef(const PAGNode *pagNode, const SVFGNode *node)
Given a PAGNode, set/get its def SVFG node (definition of top level pointers)
SVFGEdge * addIntraIndirectVFEdge(NodeID srcId, NodeID dstId, const NodeBS &cpts)
Add indirect def-use edges of a memory region between two statements,.
MemSSA::STORECHI STORECHI
SVFStmtSetTy PAGEdgeSetTy
NodeID getId() const
Get ID.
virtual SVFStmt::SVFStmtSetTy & getPAGEdgeSet(SVFStmt::PEDGEK kind)
Get PAGEdge set.
VFGNodeIDToNodeMapTy::iterator iterator
CallSiteID getCallSiteID(const CallICFGNode *cs, const FunObjVar *func) const
Get callsite given a callsiteID.
StmtVFGNode * getStmtVFGNode(const PAGEdge *pagEdge) const
Get an VFGNode.
std::ostream & outs()
Overwrite llvm::outs()
llvm::IRBuilder IRBuilder