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())
94 for (SVFStmt::SVFStmtSetTy::iterator
iter =
rets.begin(),
eiter =
102 for (SVFStmt::SVFStmtSetTy::iterator
iter =
tdfks.begin(),
eiter =
110 for (SVFStmt::SVFStmtSetTy::iterator
iter =
tdjns.begin(),
eiter =
118 for (SVFStmt::SVFStmtSetTy::iterator
iter =
ngeps.begin(),
eiter =
122 if(
edge->isVariantFieldGep())
129 for (SVFStmt::SVFStmtSetTy::iterator
iter =
loads.begin(),
eiter =
164 if (
it->second->hasIncomingEdge() ||
it->second->hasOutgoingEdge())
195 assert(!SVFUtil::isa<DummyValVar>(node) &&
"a dummy node??");
370 assert(
false &&
"no other edge type!!");
414 assert(
false &&
"no other edge type!!");
426 assert(
num &&
"edge not in the set, can not remove!!!");
439 assert(
num &&
"edge not in the set, can not remove!!!");
452 assert(
num &&
"edge not in the set, can not remove!!!");
466 assert(
num &&
"edge not in the set, can not remove!!!");
476 std::vector<ConstraintEdge*>
sccEdges;
504 if(SVFUtil::isa<CopyCGEdge>(
edge))
506 else if (SVFUtil::isa<GepCGEdge>(
edge))
516 else if(SVFUtil::isa<LoadCGEdge, StoreCGEdge>(
edge))
523 assert(
false &&
"no such edge");
535 std::vector<ConstraintEdge*>
sccEdges;
563 if(SVFUtil::isa<CopyCGEdge>(
edge))
565 else if (SVFUtil::isa<GepCGEdge>(
edge))
575 else if(SVFUtil::isa<LoadCGEdge, StoreCGEdge>(
edge))
582 assert(
false &&
"no such edge");
602 outs() <<
"-----------------ConstraintGraph--------------------------------------\n";
605 for (ConstraintEdge::ConstraintEdgeSetTy::iterator
iter = addrs.begin(),
608 outs() << (*iter)->getSrcID() <<
" -- Addr --> " << (*iter)->getDstID()
613 for (ConstraintEdge::ConstraintEdgeSetTy::iterator
iter =
directs.begin(),
618 outs() <<
copy->getSrcID() <<
" -- Copy --> " <<
copy->getDstID()
623 outs() <<
ngep->getSrcID() <<
" -- NormalGep (" <<
ngep->getConstantFieldIdx()
624 <<
") --> " <<
ngep->getDstID() <<
"\n";
628 outs() <<
vgep->getSrcID() <<
" -- VarintGep --> "
629 <<
vgep->getDstID() <<
"\n";
632 assert(
false &&
"wrong constraint edge kind!");
636 for (ConstraintEdge::ConstraintEdgeSetTy::iterator
iter =
loads.begin(),
639 outs() << (*iter)->getSrcID() <<
" -- Load --> " << (*iter)->getDstID()
644 for (ConstraintEdge::ConstraintEdgeSetTy::iterator
iter =
stores.begin(),
647 outs() << (*iter)->getSrcID() <<
" -- Store --> " << (*iter)->getDstID()
652 <<
"--------------------------------------------------------------\n";
754 return "ConstraintG";
760 else return (
n->getInEdges().empty() &&
n->getOutEdges().empty());
775 if (SVFUtil::isa<ValVar>(node))
788 if (!SVFUtil::isa<DummyValVar>(node) && !SVFUtil::isa<DummyObjVar>(node))
801 if (SVFUtil::isa<ValVar>(node))
803 if(SVFUtil::isa<GepValVar>(node))
804 return "shape=hexagon";
805 else if (SVFUtil::isa<DummyValVar>(node))
806 return "shape=diamond";
810 else if (SVFUtil::isa<ObjVar>(node))
812 if(SVFUtil::isa<GepObjVar>(node))
813 return "shape=doubleoctagon";
814 else if(SVFUtil::isa<BaseObjVar>(node))
815 return "shape=box3d";
816 else if (SVFUtil::isa<DummyObjVar>(node))
819 return "shape=component";
821 else if (SVFUtil::isa<RetPN>(node))
823 return "shape=Mrecord";
825 else if (SVFUtil::isa<VarArgPN>(node))
827 return "shape=octagon";
831 assert(0 &&
"no such kind!!");
836 template<
class EdgeIter>
843 return "color=green";
847 return "color=black";
852 return "color=purple";
864 assert(0 &&
"No such kind edge!!");
869 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.
SVFStmt::SVFStmtSetTy & getPAGEdgeSet(SVFStmt::PEDGEK kind)
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)
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.
NodeType * getGNode(NodeID id) const
Get a node.
iterator OutEdgeBegin()
iterators
static void WriteGraphToFile(SVF::OutStream &O, const std::string &GraphName, const GraphType >, bool simple=false)
static const Option< bool > BriefConsCGDotGraph
static Option< bool > DetectPWC
static const Option< bool > ShowHiddenNode
NodeID getId() const
Get ID.
const CallSiteToFunPtrMap & getIndirectCallsites() const
Add/get indirect callsites.
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.
const SVFVar * getCallSiteRet(const RetICFGNode *cs) const
Get callsite return.
static bool pagReadFromTXT()
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy
virtual const std::string getValueName() const =0
Get name of the LLVM value.
virtual const std::string toString() const
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)