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();
795 return getSimpleNodeLabel(node, graph);
797 return getCompleteNodeLabel(node, graph);
849 else if(SVFUtil::isa<NullPtrSVFGNode>(node))
861 else if(
CmpVFGNode*
cmp = SVFUtil::dyn_cast<CmpVFGNode>(node))
866 assert(
false &&
"what else kinds of nodes do we have??");
889 else if(
CmpVFGNode*
cmp = SVFUtil::dyn_cast<CmpVFGNode>(node))
942 assert(
false &&
"what else kinds of nodes do we have??");
955 if (SVFUtil::isa<AddrStmt>(
edge))
959 else if (SVFUtil::isa<CopyStmt>(
edge))
963 else if (SVFUtil::isa<RetPE>(
edge))
965 rawstr <<
"color=black,style=dotted";
967 else if (SVFUtil::isa<GepStmt>(
edge))
971 else if (SVFUtil::isa<StoreStmt>(
edge))
975 else if (SVFUtil::isa<LoadStmt>(
edge))
981 assert(0 &&
"No such kind edge!!");
985 else if(SVFUtil::isa<MSSAPHISVFGNode>(node))
989 else if(SVFUtil::isa<PHISVFGNode>(node))
993 else if(SVFUtil::isa<NullPtrSVFGNode>(node))
997 else if(SVFUtil::isa<FormalINSVFGNode>(node))
999 rawstr <<
"color=yellow,penwidth=2";
1001 else if(SVFUtil::isa<FormalOUTSVFGNode>(node))
1003 rawstr <<
"color=yellow,penwidth=2";
1005 else if(SVFUtil::isa<FormalParmSVFGNode>(node))
1007 rawstr <<
"color=yellow,penwidth=2";
1009 else if(SVFUtil::isa<ActualINSVFGNode>(node))
1011 rawstr <<
"color=yellow,penwidth=2";
1013 else if(SVFUtil::isa<ActualOUTSVFGNode>(node))
1015 rawstr <<
"color=yellow,penwidth=2";
1017 else if(SVFUtil::isa<ActualParmSVFGNode>(node))
1019 rawstr <<
"color=yellow,penwidth=2";
1021 else if (SVFUtil::isa<ActualRetSVFGNode>(node))
1023 rawstr <<
"color=yellow,penwidth=2";
1025 else if (SVFUtil::isa<FormalRetSVFGNode>(node))
1027 rawstr <<
"color=yellow,penwidth=2";
1029 else if (SVFUtil::isa<BinaryOPVFGNode>(node))
1031 rawstr <<
"color=black,penwidth=2";
1033 else if (SVFUtil::isa<CmpVFGNode>(node))
1035 rawstr <<
"color=black,penwidth=2";
1037 else if (SVFUtil::isa<UnaryOPVFGNode>(node))
1039 rawstr <<
"color=black,penwidth=2";
1041 else if (SVFUtil::isa<BranchVFGNode>(node))
1043 rawstr <<
"color=gold,penwidth=2";
1046 assert(
false &&
"no such kind of node!!");
1051 rawstr <<
",style=filled, fillcolor=red";
1055 rawstr <<
",style=filled, fillcolor=blue";
1059 rawstr <<
",style=filled, fillcolor=yellow";
1062 rawstr <<
",style=filled, fillcolor=gray";
1069 template<
class EdgeIter>
1074 if (SVFUtil::isa<DirectSVFGEdge>(
edge))
1076 if (SVFUtil::isa<CallDirSVFGEdge>(
edge))
1077 return "style=solid,color=red";
1078 else if (SVFUtil::isa<RetDirSVFGEdge>(
edge))
1079 return "style=solid,color=blue";
1081 return "style=solid";
1083 else if (SVFUtil::isa<IndirectSVFGEdge>(
edge))
1085 if (SVFUtil::isa<CallIndSVFGEdge>(
edge))
1086 return "style=dashed,color=red";
1087 else if (SVFUtil::isa<RetIndSVFGEdge>(
edge))
1088 return "style=dashed,color=blue";
1090 return "style=dashed";
1095 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.
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.
NodeType * getGNode(NodeID id) const
Get a node.
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 SVFFunction * getFun() const
Return the function of this ICFGNode.
FunEntryICFGNode * getFunEntryICFGNode(const SVFFunction *fun)
Add a function entry node.
FunExitICFGNode * getFunExitICFGNode(const SVFFunction *fun)
Add a function exit node.
NodeID getVarargNode(const SVFFunction *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 CallICFGNode * getCallSite() const
const SVFFunction * getFun() const
Get the function of this SVFGNode.
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
Set< const CallICFGNode * > CallInstSet
CallSiteID getCallSiteId() const
virtual const std::string toString() const
NodeID getId() const
Get ID.
const std::string valueOnlyToString() 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
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)
bool hasFuncEntryChi(const SVFFunction *func) const
Has function for EntryCHI/RetMU/CallCHI/CallMU.
bool hasFuncRetMu(const SVFFunction *func) const
SVFGStat * getStat() const
Return statistics.
virtual void connectFOutAndAOut(const FormalOUTSVFGNode *formalOut, const ActualOUTSVFGNode *actualOut, CallSiteID csId, SVFGEdgeSetTy &edges)
Connect formal-out and actual-out.
void getInterVFEdgesForIndirectCallSite(const CallICFGNode *cs, const SVFFunction *callee, SVFGEdgeSetTy &edges)
Get all inter value flow edges of a indirect call site.
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 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.
FormalINSVFGNodeSet & getFormalINSVFGNodes(const SVFFunction *fun)
virtual void getInterVFEdgeAtIndCSFromFOutToAOut(ActualOUTSVFGNode *actualOut, const SVFFunction *callee, SVFGEdgeSetTy &edges)
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.
bool hasCallSiteMu(const CallICFGNode *cs) const
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.
virtual void readFile(const std::string &filename)
std::unique_ptr< MemSSA > mssa
virtual void getInterVFEdgeAtIndCSFromFRToAR(const PAGNode *fun_ret, const PAGNode *cs_ret, CallSiteID csId, SVFGEdgeSetTy &edges)
void addFormalINSVFGNode(const FunEntryICFGNode *funEntry, const MRVer *resVer, const NodeID nodeId)
Add memory Function entry chi SVFG node.
NodeID getDef(const PAGNode *pagNode) const
void addSVFGNodesForAddrTakenVars()
Create SVFG nodes for address-taken variables.
virtual void getInterVFEdgeAtIndCSFromAPToFP(const PAGNode *cs_arg, const PAGNode *fun_arg, const CallICFGNode *, CallSiteID csId, SVFGEdgeSetTy &edges)
Get inter value flow edges between indirect call site and callee.
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.
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
const CallICFGNode * isCallSiteRetSVFGNode(const SVFGNode *node) const
Whether a node is callsite return SVFGNode.
bool hasCallSiteChi(const CallICFGNode *cs) const
void performStat()
Perform statistics.
FormalOUTSVFGNodeSet & getFormalOUTSVFGNodes(const SVFFunction *fun)
const SVFFunction * isFunEntrySVFGNode(const SVFGNode *node) const
Whether a node is function entry SVFGNode.
void clearMSSA()
Clear MSSA.
virtual void connectCallerAndCallee(const CallICFGNode *cs, const SVFFunction *callee, SVFGEdgeSetTy &edges)
Connect SVFG nodes between caller and callee for indirect call site.
SVFGEdge * addCallIndirectVFEdge(NodeID srcId, NodeID dstId, const NodeBS &cpts, CallSiteID csId)
virtual void getInterVFEdgeAtIndCSFromAInToFIn(ActualINSVFGNode *actualIn, const SVFFunction *callee, SVFGEdgeSetTy &edges)
std::vector< const SVFVar * > SVFVarList
const SVFVarList & getFunArgsList(const SVFFunction *func) const
Get function arguments list.
const SVFVar * getFunRet(const SVFFunction *func) const
Get function return list.
bool hasCallSiteArgsMap(const CallICFGNode *cs) const
Callsite has argument list.
bool callsiteHasRet(const RetICFGNode *cs) const
bool hasFunArgsList(const SVFFunction *func) const
Function has arguments list.
const SVFVarList & getCallSiteArgsList(const CallICFGNode *cs) const
Get callsite argument list.
const SVFVar * getCallSiteRet(const RetICFGNode *cs) const
Get callsite return.
bool funHasRet(const SVFFunction *func) const
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy
const std::string & getName() const
virtual const std::string toString() const
virtual const SVFFunction * getFun() const
Get the function of this SVFGNode.
virtual const ICFGNode * getICFGNode() const
Return corresponding ICFG node.
virtual SVFStmt::SVFStmtSetTy & getPAGEdgeSet(SVFStmt::PEDGEK kind)
Get PAGEdge set.
VFGNodeIDToNodeMapTy::iterator iterator
void checkIntraEdgeParents(const VFGNode *srcNode, const VFGNode *dstNode)
sanitize Intra edges, verify that both nodes belong to the same function.
CallSiteID getCallSiteID(const CallICFGNode *cs, const SVFFunction *func) const
Get callsite given a callsiteID.
GlobalVFGNodeSet globalVFGNodes
set of global store VFG nodes
virtual bool isInterestedPAGNode(const SVFVar *node) const
StmtVFGNode * getStmtVFGNode(const PAGEdge *pagEdge) const
Get an VFGNode.
virtual void connectCallerAndCallee(const CallICFGNode *cs, const SVFFunction *callee, VFGEdgeSetTy &edges)
Connect VFG nodes between caller and callee for indirect call site.
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)
VFGEdge * hasThreadVFGEdge(VFGNode *src, VFGNode *dst, VFGEdge::VFGEdgeK kind)
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
const SVFFunction * getProgEntryFunction()
Get program entry function.
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 *)