39using namespace SVFUtil;
49 outs() <<
"Writing SVFG analysis to '" <<
filename <<
"'...";
51 std::fstream
f(
filename.c_str(), std::ios_base::out);
54 outs() <<
" error opening file for writing!\n";
66 f <<
"SVFGNodeID: " <<
nodeId <<
" >= " <<
"FormalINSVFGNode";
73 f <<
"SVFGNodeID: " <<
nodeId <<
" >= " <<
"FormalOUTSVFGNode";
75 f << *
formalOut->getMRVer() <<
"} >= ICFGNodeID: " <<
formalOut->getFunExitNode()->getId() <<
"\n";
80 f <<
"SVFGNodeID: " <<
nodeId <<
" >= " <<
"ActualINSVFGNode";
82 f << *
actualIn->getMRVer() <<
"} >= ICFGNodeID: " <<
actualIn->getCallSite()->getId() <<
"\n";
87 f <<
"SVFGNodeID: " <<
nodeId <<
" >= " <<
"ActualOUTSVFGNode" <<
" >= MVER: {";
88 f << *
actualOut->getMRVer() <<
"} >= ICFGNodeID: " <<
actualOut->getCallSite()->getId() <<
"\n";
93 f <<
"SVFGNodeID: " <<
nodeId <<
" >= " <<
"PHISVFGNode";
95 for (MemSSA::PHI::OPVers::const_iterator
it =
phiNode->opVerBegin(),
eit =
phiNode->opVerEnd();
104 f <<
"} >= ICFGNodeID: " << inst->
getId();
105 f <<
" >= OPVers: {";
109 f <<
"{" << *
op <<
"}" <<
",";
115 f <<
"\n\n__Edges__\n";
126 if(
LOADMU*
mu = SVFUtil::dyn_cast<LOADMU>(*
it))
129 f <<
"srcSVFGNodeID: " <<
nodeId <<
" => " <<
"dstSVFGNodeID: " << def <<
" >= LoadNode | MVER: {" << *
mu->getMRVer() <<
"}" <<
"\n";
141 f <<
"srcSVFGNodeID: " <<
nodeId <<
" => " <<
"dstSVFGNodeID: " << def <<
" >= StoreNode | MVER: {" << *
chi->getOpVer() <<
"}" <<
"\n";
158 f <<
"srcSVFGNodeID: " <<
nodeId <<
" => " <<
"dstSVFGNodeID: " <<
actualIn->getId() <<
" >= FormalINSVFGNode" <<
"\n";
169 if(!
mssa->hasCHI(cs))
175 f <<
"srcSVFGNodeID: " <<
nodeId <<
" => " <<
"dstSVFGNodeID: " <<
actualOut->getId() <<
" >= FormalOUTSVFGNode" <<
"\n";
179 f <<
"srcSVFGNodeID: " <<
nodeId <<
" => " <<
"dstSVFGNodeID: " << def <<
" >= FormalOUTSVFGNode | intra" <<
"\n";
184 f <<
"srcSVFGNodeID: " <<
nodeId <<
" => " <<
"dstSVFGNodeID: " << def <<
" >= ActualINSVFGNode" <<
"\n";
189 for (MemSSA::PHI::OPVers::const_iterator
it =
phiNode->opVerBegin(),
eit =
phiNode->opVerEnd();
194 f <<
"srcSVFGNodeID: " <<
nodeId <<
" => " <<
"dstSVFGNodeID: " << def <<
" >= PHISVFGNode | MVER: {" << *
op <<
"}" <<
"\n";
209 outs() <<
"Loading SVFG analysis results from '" <<
filename <<
"'...";
213 outs() <<
" error opening file for reading!\n";
223 for(CHISet::iterator
pi =
mssa->getCHISet(store).begin(),
epi =
mssa->getCHISet(store).end();
pi!=
epi; ++
pi)
235 if (
line.find(
"__Edges__") != std::string::npos)
238 std::string
s =
line;
290 if(
type ==
"FormalINSVFGNode")
296 else if(
type ==
"FormalOUTSVFGNode")
302 else if(
type ==
"ActualINSVFGNode")
308 else if(
type ==
"ActualOUTSVFGNode")
314 else if (
type ==
"PHISVFGNode")
317 next = opVer.find(
"{") + 1;
318 last = opVer.find(
",}");
322 while ((
next =
temp.find(
"{") + 1) != string::npos)
334 next = basicBlock.find(
"ICFGNodeID: ") + 12;
355 std::string
s =
line;
372 next =
edge.find(
"srcSVFGNodeID: ") + 15;
375 next =
edge.find(
"dstSVFGNodeID: ") + 15;
389 if(
type ==
"FormalINSVFGNode")
395 else if(
type ==
"FormalOUTSVFGNode")
398 if (attribute.find(
"intra") != string::npos)
408 else if(
type ==
"ActualINSVFGNode")
413 else if(
type ==
"ActualOUTSVFGNode")
417 else if (
type ==
"StoreNode" ||
type ==
"LoadNode" ||
type ==
"PHISVFGNode")
444 next =
s.find(
"MemRegion: pts{") + 15;
445 last =
s.find(
"} MRVERSION: ");
460 next =
s.find(
"MSSADef: ") + 9;
461 last =
s.find(
"} >=");
470 next =
s.find(
"MRVERSION: ") + 11;
471 last =
s.find(
" MSSADef:");
iterator begin()
Iterators.
virtual const SVFBasicBlock * getBB() const
Return the basic block of this ICFGNode.
ICFGNode * getICFGNode(NodeID id) const
Get a ICFG node.
Set< const CallICFGNode * > CallInstSet
NodeID getId() const
Get ID.
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
virtual SVFStmt::SVFStmtSetTy & getPAGEdgeSet(SVFStmt::PEDGEK kind)
Get PAGEdge set.
VFGNodeIDToNodeMapTy::iterator iterator
CallSiteID getCallSiteID(const CallICFGNode *cs, const SVFFunction *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