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();
779 if (
indEdge->getPointsTo().test(
obj->getId()))
797 if (
edge->isDirectVFGEdge())
814 if (
indEdge->getPointsTo().test(
obj->getId()))
856 return getSimpleNodeLabel(node, graph);
858 return getCompleteNodeLabel(node, graph);
910 else if(SVFUtil::isa<NullPtrSVFGNode>(node))
922 else if(
CmpVFGNode*
cmp = SVFUtil::dyn_cast<CmpVFGNode>(node))
927 assert(
false &&
"what else kinds of nodes do we have??");
950 else if(
CmpVFGNode*
cmp = SVFUtil::dyn_cast<CmpVFGNode>(node))
1003 assert(
false &&
"what else kinds of nodes do we have??");
1016 if (SVFUtil::isa<AddrStmt>(
edge))
1020 else if (SVFUtil::isa<CopyStmt>(
edge))
1024 else if (SVFUtil::isa<RetPE>(
edge))
1026 rawstr <<
"color=black,style=dotted";
1028 else if (SVFUtil::isa<GepStmt>(
edge))
1030 rawstr <<
"color=purple";
1032 else if (SVFUtil::isa<StoreStmt>(
edge))
1036 else if (SVFUtil::isa<LoadStmt>(
edge))
1042 assert(0 &&
"No such kind edge!!");
1046 else if(SVFUtil::isa<MSSAPHISVFGNode>(node))
1050 else if(SVFUtil::isa<PHISVFGNode>(node))
1054 else if(SVFUtil::isa<NullPtrSVFGNode>(node))
1058 else if(SVFUtil::isa<FormalINSVFGNode>(node))
1060 rawstr <<
"color=yellow,penwidth=2";
1062 else if(SVFUtil::isa<FormalOUTSVFGNode>(node))
1064 rawstr <<
"color=yellow,penwidth=2";
1066 else if(SVFUtil::isa<FormalParmSVFGNode>(node))
1068 rawstr <<
"color=yellow,penwidth=2";
1070 else if(SVFUtil::isa<ActualINSVFGNode>(node))
1072 rawstr <<
"color=yellow,penwidth=2";
1074 else if(SVFUtil::isa<ActualOUTSVFGNode>(node))
1076 rawstr <<
"color=yellow,penwidth=2";
1078 else if(SVFUtil::isa<ActualParmSVFGNode>(node))
1080 rawstr <<
"color=yellow,penwidth=2";
1082 else if (SVFUtil::isa<ActualRetSVFGNode>(node))
1084 rawstr <<
"color=yellow,penwidth=2";
1086 else if (SVFUtil::isa<FormalRetSVFGNode>(node))
1088 rawstr <<
"color=yellow,penwidth=2";
1090 else if (SVFUtil::isa<BinaryOPVFGNode>(node))
1092 rawstr <<
"color=black,penwidth=2";
1094 else if (SVFUtil::isa<CmpVFGNode>(node))
1096 rawstr <<
"color=black,penwidth=2";
1098 else if (SVFUtil::isa<UnaryOPVFGNode>(node))
1100 rawstr <<
"color=black,penwidth=2";
1102 else if (SVFUtil::isa<BranchVFGNode>(node))
1104 rawstr <<
"color=gold,penwidth=2";
1107 assert(
false &&
"no such kind of node!!");
1112 rawstr <<
",style=filled, fillcolor=red";
1116 rawstr <<
",style=filled, fillcolor=blue";
1120 rawstr <<
",style=filled, fillcolor=yellow";
1123 rawstr <<
",style=filled, fillcolor=gray";
1130 template<
class EdgeIter>
1135 if (SVFUtil::isa<DirectSVFGEdge>(
edge))
1137 if (SVFUtil::isa<CallDirSVFGEdge>(
edge))
1138 return "style=solid,color=red";
1139 else if (SVFUtil::isa<RetDirSVFGEdge>(
edge))
1140 return "style=solid,color=blue";
1142 return "style=solid";
1144 else if (SVFUtil::isa<IndirectSVFGEdge>(
edge))
1146 if (SVFUtil::isa<CallIndSVFGEdge>(
edge))
1147 return "style=dashed,color=red";
1148 else if (SVFUtil::isa<RetIndSVFGEdge>(
edge))
1149 return "style=dashed,color=blue";
1151 return "style=dashed";
1156 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.
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.
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)
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
const Set< const SVFGNode * > getDefSiteOfObjVar(const ObjVar *obj, const SVFGNode *node) const
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.
const Set< const SVFGNode * > getUseSitesOfObjVar(const ObjVar *obj, const SVFGNode *node) const
void addSVFGNodesForAddrTakenVars()
Create SVFG nodes for address-taken variables.
const Set< const SVFGNode * > getUseSitesOfValVar(const ValVar *var) const
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.
const SVFGNode * getDefSiteOfValVar(const ValVar *var) const
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.
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 *)