34using namespace SVFUtil;
51 for (SVFStmt::SVFStmtSetTy::iterator
iter = addrs.begin(),
eiter =
63 if(
edge->isBitCast() ||
edge->isValueCopy())
68 for (SVFStmt::SVFStmtSetTy::iterator
iter =
phis.begin(),
eiter =
72 for(
const auto opVar :
edge->getOpndVars())
81 for(
const auto opVar :
edge->getOpndVars())
89 const CallPE* callPE = SVFUtil::cast<CallPE>(*
iter);
95 for (SVFStmt::SVFStmtSetTy::iterator
iter =
rets.begin(),
eiter =
103 for (SVFStmt::SVFStmtSetTy::iterator
iter =
tdfks.begin(),
eiter =
112 for (SVFStmt::SVFStmtSetTy::iterator
iter =
tdjns.begin(),
eiter =
120 for (SVFStmt::SVFStmtSetTy::iterator
iter =
ngeps.begin(),
eiter =
124 if(
edge->isVariantFieldGep())
131 for (SVFStmt::SVFStmtSetTy::iterator
iter =
loads.begin(),
eiter =
166 if (
it->second->hasIncomingEdge() ||
it->second->hasOutgoingEdge())
196 assert(!SVFUtil::isa<DummyValVar>(node) &&
"a dummy node??");
371 assert(
false &&
"no other edge type!!");
415 assert(
false &&
"no other edge type!!");
427 assert(
num &&
"edge not in the set, can not remove!!!");
440 assert(
num &&
"edge not in the set, can not remove!!!");
453 assert(
num &&
"edge not in the set, can not remove!!!");
467 assert(
num &&
"edge not in the set, can not remove!!!");
477 std::vector<ConstraintEdge*>
sccEdges;
505 if(SVFUtil::isa<CopyCGEdge>(
edge))
507 else if (SVFUtil::isa<GepCGEdge>(
edge))
517 else if(SVFUtil::isa<LoadCGEdge, StoreCGEdge>(
edge))
524 assert(
false &&
"no such edge");
536 std::vector<ConstraintEdge*>
sccEdges;
564 if(SVFUtil::isa<CopyCGEdge>(
edge))
566 else if (SVFUtil::isa<GepCGEdge>(
edge))
576 else if(SVFUtil::isa<LoadCGEdge, StoreCGEdge>(
edge))
583 assert(
false &&
"no such edge");
603 outs() <<
"-----------------ConstraintGraph--------------------------------------\n";
606 for (ConstraintEdge::ConstraintEdgeSetTy::iterator
iter = addrs.begin(),
609 outs() << (*iter)->getSrcID() <<
" -- Addr --> " << (*iter)->getDstID()
614 for (ConstraintEdge::ConstraintEdgeSetTy::iterator
iter =
directs.begin(),
619 outs() <<
copy->getSrcID() <<
" -- Copy --> " <<
copy->getDstID()
624 outs() <<
ngep->getSrcID() <<
" -- NormalGep (" <<
ngep->getConstantFieldIdx()
625 <<
") --> " <<
ngep->getDstID() <<
"\n";
629 outs() <<
vgep->getSrcID() <<
" -- VarintGep --> "
630 <<
vgep->getDstID() <<
"\n";
633 assert(
false &&
"wrong constraint edge kind!");
637 for (ConstraintEdge::ConstraintEdgeSetTy::iterator
iter =
loads.begin(),
640 outs() << (*iter)->getSrcID() <<
" -- Load --> " << (*iter)->getDstID()
645 for (ConstraintEdge::ConstraintEdgeSetTy::iterator
iter =
stores.begin(),
648 outs() << (*iter)->getSrcID() <<
" -- Store --> " << (*iter)->getDstID()
653 <<
"--------------------------------------------------------------\n";
755 return "ConstraintG";
761 else return (
n->getInEdges().empty() &&
n->getOutEdges().empty());
776 if (SVFUtil::isa<ValVar>(node))
789 if (!SVFUtil::isa<DummyValVar>(node) && !SVFUtil::isa<DummyObjVar>(node))
802 if (SVFUtil::isa<ValVar>(node))
804 if(SVFUtil::isa<GepValVar>(node))
805 return "shape=hexagon";
806 else if (SVFUtil::isa<DummyValVar>(node))
807 return "shape=diamond";
811 else if (SVFUtil::isa<ObjVar>(node))
813 if(SVFUtil::isa<GepObjVar>(node))
814 return "shape=doubleoctagon";
815 else if(SVFUtil::isa<BaseObjVar>(node))
816 return "shape=box3d";
817 else if (SVFUtil::isa<DummyObjVar>(node))
820 return "shape=component";
822 else if (SVFUtil::isa<RetValPN>(node))
824 return "shape=Mrecord";
826 else if (SVFUtil::isa<VarArgValPN>(node))
828 return "shape=octagon";
832 assert(0 &&
"no such kind!!");
837 template<
class EdgeIter>
844 return "color=green";
848 return "color=black";
853 return "color=purple";
865 assert(0 &&
"No such kind edge!!");
870 template<
class EdgeIter>
GenericNode< ConstraintNode, ConstraintEdge >::GEdgeSetTy ConstraintEdgeSetTy
Constraint edge type.
bool moveInEdgesToRepNode(ConstraintNode *node, ConstraintNode *rep)
ConstraintEdge::ConstraintEdgeSetTy StoreCGEdgeSet
ConstraintEdge::ConstraintEdgeSetTy directEdgeSet
ConstraintEdge::ConstraintEdgeSetTy LoadCGEdgeSet
LoadCGEdge * addLoadCGEdge(NodeID src, NodeID dst)
Add Load edge.
void view()
View graph from the debugger.
NodeID sccRepNode(NodeID id) const
SCC rep/sub nodes methods.
ConstraintEdge::ConstraintEdgeSetTy & getStoreCGEdges()
Get Store edges.
ConstraintEdge::ConstraintEdgeSetTy & getDirectCGEdges()
Get Copy/call/ret/gep edges.
void reTargetDstOfEdge(ConstraintEdge *edge, ConstraintNode *newDstNode)
Used for cycle elimination.
AddrCGEdge * addAddrCGEdge(NodeID src, NodeID dst)
Add a SVFIR edge into Edge map.
ConstraintEdge::ConstraintEdgeSetTy AddrCGEdgeSet
void addConstraintNode(ConstraintNode *node, NodeID id)
bool hasEdge(ConstraintNode *src, ConstraintNode *dst, ConstraintEdge::ConstraintEdgeK kind)
ConstraintEdge::ConstraintEdgeSetTy & getLoadCGEdges()
Get Load edges.
CopyCGEdge * addCopyCGEdge(NodeID src, NodeID dst)
Add Copy edge.
StoreCGEdge * addStoreCGEdge(NodeID src, NodeID dst)
Add Store edge.
VariantGepCGEdge * addVariantGepCGEdge(NodeID src, NodeID dst)
SVFStmt::SVFStmtSetTy & getSVFStmtSet(SVFStmt::PEDGEK kind)
void removeConstraintNode(ConstraintNode *node)
void removeDirectEdge(ConstraintEdge *edge)
Remove direct edge from their src and dst edge sets.
bool moveOutEdgesToRepNode(ConstraintNode *node, ConstraintNode *rep)
void removeLoadEdge(LoadCGEdge *edge)
Remove load edge from their src and dst edge sets.
ConstraintNode * getConstraintNode(NodeID id) const
Get/add/remove constraint node.
void print()
Print CG into terminal.
void reTargetSrcOfEdge(ConstraintEdge *edge, ConstraintNode *newSrcNode)
Remove edge from old src target, change edge dst id and add modified edge into new src.
void removeStoreEdge(StoreCGEdge *edge)
Remove store edge from their src and dst edge sets.
NormalGepCGEdge * addNormalGepCGEdge(NodeID src, NodeID dst, const AccessPath &ap)
Add Gep edge.
ConstraintEdge::ConstraintEdgeSetTy & getAddrCGEdges()
Get SVFIR edge.
void removeAddrEdge(AddrCGEdge *edge)
Remove addr edge from their src and dst edge sets.
bool isZeroOffsettedGepCGEdge(ConstraintEdge *edge) const
Check if a given edge is a NormalGepCGEdge with 0 offset.
void dump(std::string name)
Dump graph into dot file.
ConstraintEdge::ConstraintEdgeSetTy copyOutEdges
ConstraintEdge::ConstraintEdgeSetTy::iterator iterator
iterator directInEdgeEnd()
bool removeOutgoingStoreEdge(StoreCGEdge *outEdge)
bool removeIncomingStoreEdge(StoreCGEdge *inEdge)
ConstraintEdge::ConstraintEdgeSetTy copyInEdges
ConstraintEdge::ConstraintEdgeSetTy directInEdges
bool removeIncomingAddrEdge(AddrCGEdge *inEdge)
virtual const std::string toString() const
bool removeOutgoingDirectEdge(ConstraintEdge *outEdge)
bool removeIncomingDirectEdge(ConstraintEdge *inEdge)
bool removeOutgoingLoadEdge(LoadCGEdge *outEdge)
iterator directInEdgeBegin()
bool removeIncomingLoadEdge(LoadCGEdge *inEdge)
iterator directOutEdgeEnd()
ConstraintEdge::ConstraintEdgeSetTy::const_iterator const_iterator
bool removeOutgoingAddrEdge(AddrCGEdge *outEdge)
Remove constraint graph edges.
iterator directOutEdgeBegin()
Iterators.
ConstraintEdge::ConstraintEdgeSetTy directOutEdges
iterator begin()
Iterators.
IDToNodeMapTy::iterator iterator
Node Iterators.
iterator OutEdgeBegin()
iterators
static void WriteGraphToFile(SVF::OutStream &O, const std::string &GraphName, const GraphType >, bool simple=false)
NodeID getOpVarID(u32_t pos) const
u32_t getOpVarNum() const
static const Option< bool > BriefConsCGDotGraph
static Option< bool > DetectPWC
static const Option< bool > ShowHiddenNode
const ValVar * getCallSiteRet(const RetICFGNode *cs) const
Get callsite return.
static bool pagReadFromTXT()
const CallSiteToFunPtrMap & getIndirectCallsites() const
Add/get indirect callsites.
const SVFVar * getSVFVar(NodeID id) const
ObjVar/GepObjVar/BaseObjVar.
bool callsiteHasRet(const RetICFGNode *cs) const
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy
NodeID getId() const
Get ID.
virtual const std::string & getName() const
virtual bool isPointer() const
Check if this variable represents a pointer.
virtual const std::string toString() const
Get string representation.
std::ostream & outs()
Overwrite llvm::outs()
void ViewGraph(const GraphType &G, const std::string &name, bool ShortNames=false, GraphProgram::Name Program=GraphProgram::DOT)
llvm::IRBuilder IRBuilder
static std::string getNodeAttributes(NodeType *n, ConstraintGraph *)
static std::string getEdgeSourceLabel(NodeType *, EdgeIter)
static std::string getGraphName(ConstraintGraph *)
Return name of the graph.
static std::string getEdgeAttributes(NodeType *, EdgeIter EI, ConstraintGraph *)
static std::string getNodeLabel(NodeType *n, ConstraintGraph *)
static bool isNodeHidden(NodeType *n, ConstraintGraph *)
DOTGraphTraits(bool isSimple=false)