42using namespace SVFUtil;
110 rawstr <<
"MR_" <<
it->second->getMR()->getMRID() <<
"V_" <<
it->second->getSSAVersion() <<
", ";
265 for(CHISet::iterator
pi =
mssa->getCHISet(store).begin(),
epi =
mssa->getCHISet(store).end();
pi!=
epi; ++
pi)
272 for(MemSSA::BBToPhiSetMap::iterator
it =
mssa->getBBToPhiSetMap().begin(),
275 for(PHISet::iterator
pi =
it->second.begin(),
epi =
it->second.end();
pi!=
epi; ++
pi)
278 const ICFGNode* inst =
phi->getBasicBlock()->front();
283 for(MemSSA::FunToEntryChiSetMap::iterator
it =
mssa->getFunToEntryChiSetMap().begin(),
286 for(CHISet::iterator
pi =
it->second.begin(),
epi =
it->second.end();
pi!=
epi; ++
pi)
293 for(MemSSA::FunToReturnMuSetMap::iterator
it =
mssa->getFunToRetMuSetMap().begin(),
296 for(MUSet::iterator
pi =
it->second.begin(),
epi =
it->second.end();
pi!=
epi; ++
pi)
303 for(MemSSA::CallSiteToMUSetMap::iterator
it =
mssa->getCallSiteToMuSetMap().begin(),
304 eit =
mssa->getCallSiteToMuSetMap().end();
307 for(MUSet::iterator
pi =
it->second.begin(),
epi =
it->second.end();
pi!=
epi; ++
pi)
314 for(MemSSA::CallSiteToCHISetMap::iterator
it =
mssa->getCallSiteToChiSetMap().begin(),
315 eit =
mssa->getCallSiteToChiSetMap().end();
318 for(CHISet::iterator
pi =
it->second.begin(),
epi =
it->second.end();
pi!=
epi; ++
pi)
342 if(
LOADMU*
mu = SVFUtil::dyn_cast<LOADMU>(*
it))
386 if(!
mssa->hasCHI(cs))
404 else if(SVFUtil::isa<ActualOUTSVFGNode>(node))
410 for (MemSSA::PHI::OPVers::const_iterator
it =
phiNode->opVerBegin(),
eit =
phiNode->opVerEnd();
470 assert(SVFUtil::isa<IndirectSVFGEdge>(
edge) &&
"this should be a indirect value flow edge!");
471 return (SVFUtil::cast<IndirectSVFGEdge>(
edge)->addPointsTo(cpts) ?
edge :
nullptr);
491 assert(SVFUtil::isa<IndirectSVFGEdge>(
edge) &&
"this should be a indirect value flow edge!");
492 return (SVFUtil::cast<IndirectSVFGEdge>(
edge)->addPointsTo(cpts) ?
edge :
nullptr);
511 assert(SVFUtil::isa<CallIndSVFGEdge>(
edge) &&
"this should be a indirect value flow edge!");
512 return (SVFUtil::cast<CallIndSVFGEdge>(
edge)->addPointsTo(cpts) ?
edge :
nullptr);
531 assert(SVFUtil::isa<RetIndSVFGEdge>(
edge) &&
"this should be a indirect value flow edge!");
532 return (SVFUtil::cast<RetIndSVFGEdge>(
edge)->addPointsTo(cpts) ?
edge :
nullptr);
714 if(
phi->isFormalParmPHI())
715 return phi->getFun();
723 if(
mphi->isFormalINPHI())
724 return mphi->getFun();
736 return ar->getCallSite();
740 if(
phi->isActualRetPHI())
741 return phi->getCallSite();
745 return ao->getCallSite();
749 if(
mphi->isActualOUTPHI())
750 return mphi->getCallSite();
784 assert(
defSite ==
nullptr &&
"ObjVar should have a unique indirect definition!");
802 if (
edge->isDirectVFGEdge())
804 if (
const ICFGNode* icfgNode =
edge->getDstNode()->getICFGNode())
807 assert(
false &&
"The destination node of a direct VFG edge should have an ICFG node!");
830 assert(
false &&
"The destination node of an indirect SVFG edge should have an ICFG node!");
870 return getSimpleNodeLabel(node, graph);
872 return getCompleteNodeLabel(node, graph);
924 else if(SVFUtil::isa<NullPtrSVFGNode>(node))
936 else if(
CmpVFGNode*
cmp = SVFUtil::dyn_cast<CmpVFGNode>(node))
941 assert(
false &&
"what else kinds of nodes do we have??");
964 else if(
CmpVFGNode*
cmp = SVFUtil::dyn_cast<CmpVFGNode>(node))
1017 assert(
false &&
"what else kinds of nodes do we have??");
1030 if (SVFUtil::isa<AddrStmt>(
edge))
1034 else if (SVFUtil::isa<CopyStmt>(
edge))
1038 else if (SVFUtil::isa<RetPE>(
edge))
1040 rawstr <<
"color=black,style=dotted";
1042 else if (SVFUtil::isa<GepStmt>(
edge))
1044 rawstr <<
"color=purple";
1046 else if (SVFUtil::isa<StoreStmt>(
edge))
1050 else if (SVFUtil::isa<LoadStmt>(
edge))
1056 assert(0 &&
"No such kind edge!!");
1060 else if(SVFUtil::isa<MSSAPHISVFGNode>(node))
1064 else if(SVFUtil::isa<PHISVFGNode>(node))
1068 else if(SVFUtil::isa<NullPtrSVFGNode>(node))
1072 else if(SVFUtil::isa<FormalINSVFGNode>(node))
1074 rawstr <<
"color=yellow,penwidth=2";
1076 else if(SVFUtil::isa<FormalOUTSVFGNode>(node))
1078 rawstr <<
"color=yellow,penwidth=2";
1080 else if(SVFUtil::isa<FormalParmSVFGNode>(node))
1082 rawstr <<
"color=yellow,penwidth=2";
1084 else if(SVFUtil::isa<ActualINSVFGNode>(node))
1086 rawstr <<
"color=yellow,penwidth=2";
1088 else if(SVFUtil::isa<ActualOUTSVFGNode>(node))
1090 rawstr <<
"color=yellow,penwidth=2";
1092 else if(SVFUtil::isa<ActualParmSVFGNode>(node))
1094 rawstr <<
"color=yellow,penwidth=2";
1096 else if (SVFUtil::isa<ActualRetSVFGNode>(node))
1098 rawstr <<
"color=yellow,penwidth=2";
1100 else if (SVFUtil::isa<FormalRetSVFGNode>(node))
1102 rawstr <<
"color=yellow,penwidth=2";
1104 else if (SVFUtil::isa<BinaryOPVFGNode>(node))
1106 rawstr <<
"color=black,penwidth=2";
1108 else if (SVFUtil::isa<CmpVFGNode>(node))
1110 rawstr <<
"color=black,penwidth=2";
1112 else if (SVFUtil::isa<UnaryOPVFGNode>(node))
1114 rawstr <<
"color=black,penwidth=2";
1116 else if (SVFUtil::isa<BranchVFGNode>(node))
1118 rawstr <<
"color=gold,penwidth=2";
1121 assert(
false &&
"no such kind of node!!");
1126 rawstr <<
",style=filled, fillcolor=red";
1130 rawstr <<
",style=filled, fillcolor=blue";
1134 rawstr <<
",style=filled, fillcolor=yellow";
1137 rawstr <<
",style=filled, fillcolor=gray";
1144 template<
class EdgeIter>
1149 if (SVFUtil::isa<DirectSVFGEdge>(
edge))
1151 if (SVFUtil::isa<CallDirSVFGEdge>(
edge))
1152 return "style=solid,color=red";
1153 else if (SVFUtil::isa<RetDirSVFGEdge>(
edge))
1154 return "style=solid,color=blue";
1156 return "style=solid";
1158 else if (SVFUtil::isa<IndirectSVFGEdge>(
edge))
1160 if (SVFUtil::isa<CallIndSVFGEdge>(
edge))
1161 return "style=dashed,color=red";
1162 else if (SVFUtil::isa<RetIndSVFGEdge>(
edge))
1163 return "style=dashed,color=blue";
1165 return "style=dashed";
1170 template<
class EdgeIter>
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
const MRVer * getMRVer() const
Ver.
virtual const std::string toString() const
const CallICFGNode * getCallSite() const
Callsite.
const CallICFGNode * getCallSite() const
Callsite.
virtual const std::string toString() const
const MRVer * getMRVer() const
Ver.
Set< const CallICFGNode * > CallInstSet
const std::string getSourceLoc() const override
virtual const std::string toString() const
CallSiteID getCallSiteId() const
const NodeBS getDefSVFVars() const override
Return the left hand side SVF Vars.
NodeID getSrcID() const
get methods of the components
iterator begin()
Iterators.
const GEdgeSetTy & getOutEdges() const
const GEdgeSetTy & getInEdges() const
static void WriteGraphToFile(SVF::OutStream &O, const std::string &GraphName, const GraphType >, bool simple=false)
virtual const FunObjVar * getFun() const
Return the function of this ICFGNode.
const VFGNodeList & getVFGNodes() const
FunExitICFGNode * getFunExitICFGNode(const FunObjVar *fun)
Add a function exit node.
FunEntryICFGNode * getFunEntryICFGNode(const FunObjVar *fun)
Add a function entry node.
NodeID getVarargNode(const FunObjVar *func) const
getVarargNode - Return the unique node representing the variadic argument of a variadic function.
virtual const std::string toString() const
virtual const std::string toString() const
bool isFormalINPHI() const
const FunObjVar * getFun() const
Get the function of this SVFGNode.
const CallICFGNode * getCallSite() const
virtual const std::string toString() const
virtual const std::string toString() const
virtual const std::string toString() const override
const NodeBS & getPointsTo() const
Return points-to of the MR.
const NodeBS getDefSVFVars() const override
Return the left hand side SVF Vars.
MRVERSION getSSAVersion() const
Return SSA version.
const MemRegion * getMR() const
Return the memory region.
virtual const std::string toString() const
OPVers::const_iterator opVerEnd() const
const MRVer * getResVer() const
Ver.
OPVers::const_iterator opVerBegin() const
MRID getMRID() const
Return memory region ID.
const NodeBS & getPointsTo() const
Return points-to.
std::string dumpStr() const
Dump string.
CallCHI< Condition > CALLCHI
EntryCHI< Condition > ENTRYCHI
CallMU< Condition > CALLMU
static const Option< std::string > ReadSVFG
static const Option< std::string > WriteSVFG
static const Option< bool > ShowHiddenNode
CallSiteID getCallSiteId() const
virtual const std::string toString() const
virtual void performStat() override
bool inBackwardSlice(const SVFGNode *node) const
bool isSource(const SVFGNode *node) const
bool inForwardSlice(const SVFGNode *node) const
bool isSink(const SVFGNode *node) const
virtual void getInterVFEdgeAtIndCSFromFOutToAOut(ActualOUTSVFGNode *actualOut, const FunObjVar *callee, SVFGEdgeSetTy &edges)
SVFG(std::unique_ptr< MemSSA > mssa, VFGK k)
Constructor.
virtual void buildSVFG()
Start building SVFG.
void connectIndirectSVFGEdges()
Connect direct SVFG edges between two SVFG nodes (value-flow of top address-taken variables)
SVFGEdge * addThreadMHPIndirectVFEdge(NodeID srcId, NodeID dstId, const NodeBS &cpts)
ActualOUTSVFGNodeSet & getActualOUTSVFGNodes(const CallICFGNode *cs)
FormalOUTSVFGNodeSet & getFormalOUTSVFGNodes(const FunObjVar *fun)
FormalINSVFGNodeSet & getFormalINSVFGNodes(const FunObjVar *fun)
SVFGStat * getStat() const
Return statistics.
virtual void connectFOutAndAOut(const FormalOUTSVFGNode *formalOut, const ActualOUTSVFGNode *actualOut, CallSiteID csId, SVFGEdgeSetTy &edges)
Connect formal-out and actual-out.
virtual void getInterVFEdgeAtIndCSFromAPToFP(const ValVar *cs_arg, const ValVar *fun_arg, const CallICFGNode *, CallSiteID csId, SVFGEdgeSetTy &edges)
Get inter value flow edges between indirect call site and callee.
const ICFGNode * getDefSiteOfValVar(const ValVar *var) const
SVFGEdge * addInterIndirectVFCallEdge(const ActualINSVFGNode *src, const FormalINSVFGNode *dst, CallSiteID csId)
Add inter VF edge from callsite mu to function entry chi.
virtual void getInterVFEdgeAtIndCSFromAInToFIn(ActualINSVFGNode *actualIn, const FunObjVar *callee, SVFGEdgeSetTy &edges)
void connectFromGlobalToProgEntry()
Connect indirect SVFG edges from global initializers (store) to main function entry.
SVFGNode * getSVFGNode(NodeID id) const
Get a SVFG node.
void getInterVFEdgesForIndirectCallSite(const CallICFGNode *cs, const FunObjVar *callee, SVFGEdgeSetTy &edges)
Get all inter value flow edges of a indirect call site.
void dump(const std::string &file, bool simple=false)
Dump graph into dot file.
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.
bool addSVFGEdge(SVFGEdge *edge)
Add SVFG edge.
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.
void destroy()
Clean up memory.
virtual void connectCallerAndCallee(const CallICFGNode *cs, const FunObjVar *callee, SVFGEdgeSetTy &edges)
Connect SVFG nodes between caller and callee for indirect call site.
bool hasCallSiteMu(const CallICFGNode *cs) const
void setDef(const ValVar *valVar, const SVFGNode *node)
Given a ValVar, set/get its def SVFG node (definition of top level pointers)
SVFGEdge * addRetIndirectVFEdge(NodeID srcId, NodeID dstId, const NodeBS &cpts, CallSiteID csId)
const Set< const ICFGNode * > getUseSitesOfValVar(const ValVar *var) const
void addActualINSVFGNode(const CallICFGNode *callsite, const MRVer *ver, const NodeID nodeId)
Add memory callsite mu SVFG node.
bool hasFuncRetMu(const FunObjVar *func) const
NodeID getDef(const ValVar *valVar) const
virtual void readFile(const std::string &filename)
std::unique_ptr< MemSSA > mssa
const ICFGNode * getDefSiteOfObjVar(const ObjVar *obj, const ICFGNode *node) const
void addFormalINSVFGNode(const FunEntryICFGNode *funEntry, const MRVer *resVer, const NodeID nodeId)
Add memory Function entry chi SVFG node.
void addSVFGNodesForAddrTakenVars()
Create SVFG nodes for address-taken variables.
virtual void getInterVFEdgeAtIndCSFromFRToAR(const ValVar *fun_ret, const ValVar *cs_ret, CallSiteID csId, SVFGEdgeSetTy &edges)
SVFGEdge * addInterIndirectVFRetEdge(const FormalOUTSVFGNode *src, const ActualOUTSVFGNode *dst, CallSiteID csId)
Add inter VF edge from function exit mu to callsite chi.
virtual void connectAInAndFIn(const ActualINSVFGNode *actualIn, const FormalINSVFGNode *formalIn, CallSiteID csId, SVFGEdgeSetTy &edges)
Connect SVFG nodes between caller and callee for indirect call site.
SVFGEdge * addIntraIndirectVFEdge(NodeID srcId, NodeID dstId, const NodeBS &cpts)
Add indirect def-use edges of a memory region between two statements,.
MemSSA::STORECHI STORECHI
const CallICFGNode * isCallSiteRetSVFGNode(const SVFGNode *node) const
Whether a node is callsite return SVFGNode.
bool hasCallSiteChi(const CallICFGNode *cs) const
bool hasFuncEntryChi(const FunObjVar *func) const
Has function for EntryCHI/RetMU/CallCHI/CallMU.
void performStat()
Perform statistics.
const FunObjVar * isFunEntrySVFGNode(const SVFGNode *node) const
Whether a node is function entry SVFGNode.
const Set< const ICFGNode * > getUseSitesOfObjVar(const ObjVar *obj, const ICFGNode *node) const
void clearMSSA()
Clear MSSA.
const SVFGNode * getDefSVFGNode(const ValVar *valVar) const
Given a valVar, return its definition site.
SVFGEdge * addCallIndirectVFEdge(NodeID srcId, NodeID dstId, const NodeBS &cpts, CallSiteID csId)
bool funHasRet(const FunObjVar *func) const
bool hasFunArgsList(const FunObjVar *func) const
Function has arguments list.
const ValVar * getCallSiteRet(const RetICFGNode *cs) const
Get callsite return.
const ValVarList & getFunArgsList(const FunObjVar *func) const
Get function arguments list.
std::vector< const ValVar * > ValVarList
bool hasCallSiteArgsMap(const CallICFGNode *cs) const
Callsite has argument list.
bool callsiteHasRet(const RetICFGNode *cs) const
const ValVar * getFunRet(const FunObjVar *func) const
Get function return list.
const ValVarList & getCallSiteArgsList(const CallICFGNode *cs) const
Get callsite argument list.
const ValVar * getValVar(NodeID id) const
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy
NodeID getId() const
Get ID.
virtual const std::string & getName() const
const std::string valueOnlyToString() const
virtual const std::string toString() const
virtual const FunObjVar * getFun() const
Get the function of this SVFGNode.
virtual const ICFGNode * getICFGNode() const
Return corresponding ICFG node.
VFGNodeIDToNodeMapTy::iterator iterator
CallSiteID getCallSiteID(const CallICFGNode *cs, const FunObjVar *func) const
Get callsite given a callsiteID.
void checkIntraEdgeParents(const VFGNode *srcNode, const VFGNode *dstNode)
sanitize Intra edges, verify that both nodes belong to the same function.
GlobalVFGNodeSet globalVFGNodes
set of global store VFG nodes
StmtVFGNode * getStmtVFGNode(const SVFStmt *svfStmt) const
Get an VFGNode.
virtual SVFStmt::SVFStmtSetTy & getSVFStmtSet(SVFStmt::PEDGEK kind)
Get SVFStmt set.
VFGEdge * hasIntraVFGEdge(VFGNode *src, VFGNode *dst, VFGEdge::VFGEdgeK kind)
Whether we has a SVFG edge.
VFGEdge::SVFGEdgeSetTy SVFGEdgeSetTy
VFGEdge * hasInterVFGEdge(VFGNode *src, VFGNode *dst, VFGEdge::VFGEdgeK kind, CallSiteID csId)
virtual bool isInterestedSVFVar(const SVFVar *node) const
VFGEdge * hasThreadVFGEdge(VFGNode *src, VFGNode *dst, VFGEdge::VFGEdgeK kind)
virtual void connectCallerAndCallee(const CallICFGNode *cs, const FunObjVar *callee, VFGEdgeSetTy &edges)
Connect VFG nodes between caller and callee for indirect call site.
const FunObjVar * getProgEntryFunction()
Get program entry function.
std::string pasMsg(const std::string &msg)
Print each pass/phase message by converting a string into blue string output.
std::ostream & outs()
Overwrite llvm::outs()
constexpr std::remove_reference< T >::type && move(T &&t) noexcept
llvm::IRBuilder IRBuilder
static std::string getGraphName(SVFG *)
Return name of the graph.
std::string getNodeLabel(NodeType *node, SVFG *graph)
static std::string getEdgeSourceLabel(NodeType *, EdgeIter EI)
static std::string getSimpleNodeLabel(NodeType *node, SVFG *)
Return label of a VFG node without MemSSA information.
static bool isNodeHidden(SVFGNode *node, SVFG *)
DOTGraphTraits(bool isSimple=false)
static std::string getNodeAttributes(NodeType *node, SVFG *graph)
static std::string getCompleteNodeLabel(NodeType *node, SVFG *)
Return label of a VFG node with MemSSA information.
static std::string getEdgeAttributes(NodeType *, EdgeIter EI, SVFG *)