Static Value-Flow Analysis
Loading...
Searching...
No Matches
SVF::ConstraintGraph Class Reference

#include <ConsG.h>

Inheritance diagram for SVF::ConstraintGraph:
SVF::GenericGraph< ConstraintNode, ConstraintEdge >

Public Types

typedef OrderedMap< NodeID, ConstraintNode * > ConstraintNodeIDToNodeMapTy
typedef ConstraintEdge::ConstraintEdgeSetTy::iterator ConstraintNodeIter
typedef Map< NodeID, NodeID > NodeToRepMap
typedef Map< NodeID, NodeBS > NodeToSubsMap
typedef FIFOWorkList< NodeID > WorkList
Public Types inherited from SVF::GenericGraph< ConstraintNode, ConstraintEdge >
typedef ConstraintNode NodeType
typedef ConstraintEdge EdgeType
typedef OrderedMap< NodeID, NodeType * > IDToNodeMapTy
 NodeID to GenericNode map.
typedef IDToNodeMapTy::iterator iterator
 Node Iterators.
typedef IDToNodeMapTy::const_iterator const_iterator

Public Member Functions

 ConstraintGraph (SVFIR *p)
 Constructor.
virtual ~ConstraintGraph ()
 Destructor.
ConstraintNode * getConstraintNode (NodeID id) const
 Get/add/remove constraint node.
void addConstraintNode (ConstraintNode *node, NodeID id)
bool hasConstraintNode (NodeID id) const
void removeConstraintNode (ConstraintNode *node)
bool hasEdge (ConstraintNode *src, ConstraintNode *dst, ConstraintEdge::ConstraintEdgeK kind)
ConstraintEdge * getEdge (ConstraintNode *src, ConstraintNode *dst, ConstraintEdge::ConstraintEdgeK kind)
 Get an edge via its src and dst nodes and kind.
AddrCGEdge * addAddrCGEdge (NodeID src, NodeID dst)
 Add a SVFIR edge into Edge map.
CopyCGEdge * addCopyCGEdge (NodeID src, NodeID dst)
 Add Copy edge.
NormalGepCGEdge * addNormalGepCGEdge (NodeID src, NodeID dst, const AccessPath &ap)
 Add Gep edge.
VariantGepCGEdge * addVariantGepCGEdge (NodeID src, NodeID dst)
LoadCGEdge * addLoadCGEdge (NodeID src, NodeID dst)
 Add Load edge.
StoreCGEdge * addStoreCGEdge (NodeID src, NodeID dst)
 Add Store edge.
ConstraintEdge::ConstraintEdgeSetTy & getAddrCGEdges ()
 Get SVFIR edge.
ConstraintEdge::ConstraintEdgeSetTy & getDirectCGEdges ()
 Get Copy/call/ret/gep edges.
ConstraintEdge::ConstraintEdgeSetTy & getLoadCGEdges ()
 Get Load edges.
ConstraintEdge::ConstraintEdgeSetTy & getStoreCGEdges ()
 Get Store edges.
void reTargetDstOfEdge (ConstraintEdge *edge, ConstraintNode *newDstNode)
 Used for cycle elimination.
void reTargetSrcOfEdge (ConstraintEdge *edge, ConstraintNode *newSrcNode)
 Remove edge from old src target, change edge dst id and add modified edge into new src.
void removeAddrEdge (AddrCGEdge *edge)
 Remove addr edge from their src and dst edge sets.
void removeDirectEdge (ConstraintEdge *edge)
 Remove direct edge from their src and dst edge sets.
void removeLoadEdge (LoadCGEdge *edge)
 Remove load edge from their src and dst edge sets.
void removeStoreEdge (StoreCGEdge *edge)
 Remove store edge from their src and dst edge sets.
NodeID sccRepNode (NodeID id) const
 SCC rep/sub nodes methods.
NodeBS & sccSubNodes (NodeID id)
void setRep (NodeID node, NodeID rep)
void setSubs (NodeID node, NodeBS &subs)
void resetSubs (NodeID node)
NodeBS & getSubs (NodeID node)
NodeID getRep (NodeID node)
void resetRep (NodeID node)
bool moveInEdgesToRepNode (ConstraintNode *node, ConstraintNode *rep)
bool moveOutEdgesToRepNode (ConstraintNode *node, ConstraintNode *rep)
bool moveEdgesToRepNode (ConstraintNode *node, ConstraintNode *rep)
bool isZeroOffsettedGepCGEdge (ConstraintEdge *edge) const
 Check if a given edge is a NormalGepCGEdge with 0 offset.
const SVFIR::CallSiteToFunPtrMap & getIndirectCallsites () const
 Wrappers for invoking SVFIR methods.
NodeID getBlackHoleNode ()
bool isBlkObjOrConstantObj (NodeID id)
NodeBS & getAllFieldsObjVars (NodeID id)
NodeID getBaseObjVarID (NodeID id)
bool isSingleFieldObj (NodeID id) const
NodeID getGepObjVar (NodeID id, const APOffset &apOffset)
 Get a field of a memory object.
NodeID getFIObjVar (NodeID id)
 Get a field-insensitive node of a memory object.
bool isPWCNode (NodeID nodeId)
 Check/Set PWC (positive weight cycle) flag.
void setPWCNode (NodeID nodeId)
bool hasNodesToBeCollapsed () const
 Add/get nodes to be collapsed.
void addNodeToBeCollapsed (NodeID id)
NodeID getNextCollapseNode ()
void dump (std::string name)
 Dump graph into dot file.
void print ()
 Print CG into terminal.
void view ()
 View graph from the debugger.
Public Member Functions inherited from SVF::GenericGraph< ConstraintNode, ConstraintEdge >
 GenericGraph ()
 Constructor.
virtual ~GenericGraph ()
 Destructor.
void destroy ()
 Release memory.
iterator begin ()
 Iterators.
iterator end ()
void addGNode (NodeID id, NodeType *node)
 Add a Node.
NodeType * getGNode (NodeID id) const
 Get a node.
bool hasGNode (NodeID id) const
 Has a node.
void removeGNode (NodeType *node)
 Delete a node.
u32_t getTotalNodeNum () const
 Get total number of node/edge.
u32_t getTotalEdgeNum () const
void incNodeNum ()
 Increase number of node/edge.
void incEdgeNum ()

Protected Member Functions

void buildCG ()
void destroy ()
void clearSolitaries ()
SVFStmt::SVFStmtSetTy & getSVFStmtSet (SVFStmt::PEDGEK kind)
NodeID getReturnNode (const FunObjVar *value) const
 Wrappers used internally, not expose to Andersen Pass.
NodeID getVarargNode (const FunObjVar *value) const

Protected Attributes

SVFIR * pag
NodeToRepMap nodeToRepMap
NodeToSubsMap nodeToSubsMap
WorkList nodesToBeCollapsed
EdgeID edgeIndex
ConstraintEdge::ConstraintEdgeSetTy AddrCGEdgeSet
ConstraintEdge::ConstraintEdgeSetTy directEdgeSet
ConstraintEdge::ConstraintEdgeSetTy LoadCGEdgeSet
ConstraintEdge::ConstraintEdgeSetTy StoreCGEdgeSet
Protected Attributes inherited from SVF::GenericGraph< ConstraintNode, ConstraintEdge >
IDToNodeMapTy IDToNodeMap
 node map

Additional Inherited Members

Public Attributes inherited from SVF::GenericGraph< ConstraintNode, ConstraintEdge >
u32_t edgeNum
 total num of node
u32_t nodeNum
 total num of edge

Detailed Description

Constraint graph for Andersen's analysis ConstraintNodes are same as PAGNodes ConstraintEdges are self-defined edges (initialized with ConstraintEdges)

Definition at line 44 of file ConsG.h.

Member Typedef Documentation

◆ ConstraintNodeIDToNodeMapTy

◆ ConstraintNodeIter

typedef ConstraintEdge::ConstraintEdgeSetTy::iterator SVF::ConstraintGraph::ConstraintNodeIter

Definition at line 49 of file ConsG.h.

◆ NodeToRepMap

Definition at line 50 of file ConsG.h.

◆ NodeToSubsMap

Definition at line 51 of file ConsG.h.

◆ WorkList

Definition at line 52 of file ConsG.h.

Constructor & Destructor Documentation

◆ ConstraintGraph()

SVF::ConstraintGraph::ConstraintGraph ( SVFIR * p)
inline

Constructor.

Definition at line 92 of file ConsG.h.

92 : pag(p), edgeIndex(0)
93 {
94 buildCG();
95 }
cJSON * p
Definition cJSON.cpp:2559

◆ ~ConstraintGraph()

virtual SVF::ConstraintGraph::~ConstraintGraph ( )
inlinevirtual

Destructor.

Definition at line 97 of file ConsG.h.

98 {
99 destroy();
100 }

Member Function Documentation

◆ addAddrCGEdge()

AddrCGEdge * ConstraintGraph::addAddrCGEdge ( NodeID src,
NodeID dst )

Add a SVFIR edge into Edge map.

Add Address edge

Add an address edge

Definition at line 206 of file ConsG.cpp.

207{
208 ConstraintNode* srcNode = getConstraintNode(src);
209 ConstraintNode* dstNode = getConstraintNode(dst);
210 if (hasEdge(srcNode, dstNode, ConstraintEdge::Addr))
211 return nullptr;
212 AddrCGEdge* edge = new AddrCGEdge(srcNode, dstNode, edgeIndex++);
213
214 bool inserted = AddrCGEdgeSet.insert(edge).second;
215 (void)inserted; // Suppress warning of unused variable under release build
216 assert(inserted && "new AddrCGEdge not added??");
217
218 srcNode->addOutgoingAddrEdge(edge);
219 dstNode->addIncomingAddrEdge(edge);
220 return edge;
221}
ConstraintEdge::ConstraintEdgeSetTy AddrCGEdgeSet
Definition ConsG.h:61
bool hasEdge(ConstraintNode *src, ConstraintNode *dst, ConstraintEdge::ConstraintEdgeK kind)
Definition ConsG.h:125
ConstraintNode * getConstraintNode(NodeID id) const
Get/add/remove constraint node.
Definition ConsG.h:104
void addIncomingAddrEdge(AddrCGEdge *inEdge)
Definition ConsGNode.h:247
void addOutgoingAddrEdge(AddrCGEdge *outEdge)
Definition ConsGNode.h:271

◆ addConstraintNode()

void SVF::ConstraintGraph::addConstraintNode ( ConstraintNode * node,
NodeID id )
inline

Definition at line 109 of file ConsG.h.

110 {
111 addGNode(id,node);
112 }

◆ addCopyCGEdge()

CopyCGEdge * ConstraintGraph::addCopyCGEdge ( NodeID src,
NodeID dst )

Add Copy edge.

Add Copy edge

Definition at line 226 of file ConsG.cpp.

227{
228
229 ConstraintNode* srcNode = getConstraintNode(src);
230 ConstraintNode* dstNode = getConstraintNode(dst);
231 if (hasEdge(srcNode, dstNode, ConstraintEdge::Copy) || srcNode == dstNode)
232 return nullptr;
233
234 CopyCGEdge* edge = new CopyCGEdge(srcNode, dstNode, edgeIndex++);
235
236 bool inserted = directEdgeSet.insert(edge).second;
237 (void)inserted; // Suppress warning of unused variable under release build
238 assert(inserted && "new CopyCGEdge not added??");
239
240 srcNode->addOutgoingCopyEdge(edge);
241 dstNode->addIncomingCopyEdge(edge);
242 return edge;
243}
ConstraintEdge::ConstraintEdgeSetTy directEdgeSet
Definition ConsG.h:62
void addOutgoingCopyEdge(CopyCGEdge *outEdge)
Definition ConsGNode.h:237
void addIncomingCopyEdge(CopyCGEdge *inEdge)
Add constraint graph edges.
Definition ConsGNode.h:227

◆ addLoadCGEdge()

LoadCGEdge * ConstraintGraph::addLoadCGEdge ( NodeID src,
NodeID dst )

Add Load edge.

Add Load edge

Definition at line 292 of file ConsG.cpp.

293{
294 ConstraintNode* srcNode = getConstraintNode(src);
295 ConstraintNode* dstNode = getConstraintNode(dst);
296 if (hasEdge(srcNode, dstNode, ConstraintEdge::Load))
297 return nullptr;
298
299 LoadCGEdge* edge = new LoadCGEdge(srcNode, dstNode, edgeIndex++);
300
301 bool inserted = LoadCGEdgeSet.insert(edge).second;
302 (void)inserted; // Suppress warning of unused variable under release build
303 assert(inserted && "new LoadCGEdge not added??");
304
305 srcNode->addOutgoingLoadEdge(edge);
306 dstNode->addIncomingLoadEdge(edge);
307 return edge;
308}
ConstraintEdge::ConstraintEdgeSetTy LoadCGEdgeSet
Definition ConsG.h:63
void addIncomingLoadEdge(LoadCGEdge *inEdge)
Definition ConsGNode.h:252
bool addOutgoingLoadEdge(LoadCGEdge *outEdge)
Definition ConsGNode.h:276

◆ addNodeToBeCollapsed()

void SVF::ConstraintGraph::addNodeToBeCollapsed ( NodeID id)
inline

Definition at line 361 of file ConsG.h.

362 {
363 nodesToBeCollapsed.push(id);
364 }
WorkList nodesToBeCollapsed
Definition ConsG.h:58

◆ addNormalGepCGEdge()

NormalGepCGEdge * ConstraintGraph::addNormalGepCGEdge ( NodeID src,
NodeID dst,
const AccessPath & ap )

Add Gep edge.

Add Gep edge

Definition at line 249 of file ConsG.cpp.

250{
251 ConstraintNode* srcNode = getConstraintNode(src);
252 ConstraintNode* dstNode = getConstraintNode(dst);
253 if (hasEdge(srcNode, dstNode, ConstraintEdge::NormalGep))
254 return nullptr;
255
256 NormalGepCGEdge* edge =
257 new NormalGepCGEdge(srcNode, dstNode, ap, edgeIndex++);
258
259 bool inserted = directEdgeSet.insert(edge).second;
260 (void)inserted; // Suppress warning of unused variable under release build
261 assert(inserted && "new NormalGepCGEdge not added??");
262
263 srcNode->addOutgoingGepEdge(edge);
264 dstNode->addIncomingGepEdge(edge);
265 return edge;
266}
void addIncomingGepEdge(GepCGEdge *inEdge)
Definition ConsGNode.h:232
void addOutgoingGepEdge(GepCGEdge *outEdge)
Definition ConsGNode.h:242

◆ addStoreCGEdge()

StoreCGEdge * ConstraintGraph::addStoreCGEdge ( NodeID src,
NodeID dst )

Add Store edge.

Add Store edge

Definition at line 313 of file ConsG.cpp.

314{
315 ConstraintNode* srcNode = getConstraintNode(src);
316 ConstraintNode* dstNode = getConstraintNode(dst);
317 if (hasEdge(srcNode, dstNode, ConstraintEdge::Store))
318 return nullptr;
319
320 StoreCGEdge* edge = new StoreCGEdge(srcNode, dstNode, edgeIndex++);
321
322 bool inserted = StoreCGEdgeSet.insert(edge).second;
323 (void)inserted; // Suppress warning of unused variable under release build
324 assert(inserted && "new StoreCGEdge not added??");
325
326 srcNode->addOutgoingStoreEdge(edge);
327 dstNode->addIncomingStoreEdge(edge);
328 return edge;
329}
ConstraintEdge::ConstraintEdgeSetTy StoreCGEdgeSet
Definition ConsG.h:64
bool addOutgoingStoreEdge(StoreCGEdge *outEdge)
Definition ConsGNode.h:284
void addIncomingStoreEdge(StoreCGEdge *inEdge)
Definition ConsGNode.h:257

◆ addVariantGepCGEdge()

VariantGepCGEdge * ConstraintGraph::addVariantGepCGEdge ( NodeID src,
NodeID dst )

Add variant gep edge

Definition at line 271 of file ConsG.cpp.

272{
273 ConstraintNode* srcNode = getConstraintNode(src);
274 ConstraintNode* dstNode = getConstraintNode(dst);
275 if (hasEdge(srcNode, dstNode, ConstraintEdge::VariantGep))
276 return nullptr;
277
278 VariantGepCGEdge* edge = new VariantGepCGEdge(srcNode, dstNode, edgeIndex++);
279
280 bool inserted = directEdgeSet.insert(edge).second;
281 (void)inserted; // Suppress warning of unused variable under release build
282 assert(inserted && "new VariantGepCGEdge not added??");
283
284 srcNode->addOutgoingGepEdge(edge);
285 dstNode->addIncomingGepEdge(edge);
286 return edge;
287}

◆ buildCG()

void ConstraintGraph::buildCG ( )
protected

Start building constraint graph

Definition at line 42 of file ConsG.cpp.

43{
44
45 // initialize nodes
46 for(SVFIR::iterator it = pag->begin(), eit = pag->end(); it!=eit; ++it)
47 {
48 addConstraintNode(new ConstraintNode(it->first), it->first);
49 }
50
51 // initialize edges
53 for (SVFStmt::SVFStmtSetTy::iterator iter = addrs.begin(), eiter =
54 addrs.end(); iter != eiter; ++iter)
55 {
56 const AddrStmt* edge = SVFUtil::cast<AddrStmt>(*iter);
57 addAddrCGEdge(edge->getRHSVarID(),edge->getLHSVarID());
58 }
59
61 for (SVFStmt::SVFStmtSetTy::iterator iter = copys.begin(), eiter =
62 copys.end(); iter != eiter; ++iter)
63 {
64 const CopyStmt* edge = SVFUtil::cast<CopyStmt>(*iter);
65 if(edge->isBitCast() || edge->isValueCopy())
66 addCopyCGEdge(edge->getRHSVarID(),edge->getLHSVarID());
67 }
68
70 for (SVFStmt::SVFStmtSetTy::iterator iter = phis.begin(), eiter =
71 phis.end(); iter != eiter; ++iter)
72 {
73 const PhiStmt* edge = SVFUtil::cast<PhiStmt>(*iter);
74 for(const auto opVar : edge->getOpndVars())
75 addCopyCGEdge(opVar->getId(),edge->getResID());
76 }
77
79 for (SVFStmt::SVFStmtSetTy::iterator iter = selects.begin(), eiter =
80 selects.end(); iter != eiter; ++iter)
81 {
82 const SelectStmt* edge = SVFUtil::cast<SelectStmt>(*iter);
83 for(const auto opVar : edge->getOpndVars())
84 addCopyCGEdge(opVar->getId(),edge->getResID());
85 }
86
88 for (SVFStmt::SVFStmtSetTy::iterator iter = calls.begin(), eiter =
89 calls.end(); iter != eiter; ++iter)
90 {
91 const CallPE* callPE = SVFUtil::cast<CallPE>(*iter);
92 for(u32_t i = 0; i < callPE->getOpVarNum(); i++)
93 addCopyCGEdge(callPE->getOpVarID(i), callPE->getResID());
94 }
95
97 for (SVFStmt::SVFStmtSetTy::iterator iter = rets.begin(), eiter =
98 rets.end(); iter != eiter; ++iter)
99 {
100 const RetPE* edge = SVFUtil::cast<RetPE>(*iter);
101 addCopyCGEdge(edge->getRHSVarID(),edge->getLHSVarID());
102 }
103
105 for (SVFStmt::SVFStmtSetTy::iterator iter = tdfks.begin(), eiter =
106 tdfks.end(); iter != eiter; ++iter)
107 {
108 const TDForkPE* forkPE = SVFUtil::cast<TDForkPE>(*iter);
109 for(u32_t i = 0; i < forkPE->getOpVarNum(); i++)
110 addCopyCGEdge(forkPE->getOpVarID(i), forkPE->getResID());
111 }
112
114 for (SVFStmt::SVFStmtSetTy::iterator iter = tdjns.begin(), eiter =
115 tdjns.end(); iter != eiter; ++iter)
116 {
117 const TDJoinPE* edge = SVFUtil::cast<TDJoinPE>(*iter);
118 addCopyCGEdge(edge->getRHSVarID(),edge->getLHSVarID());
119 }
120
122 for (SVFStmt::SVFStmtSetTy::iterator iter = ngeps.begin(), eiter =
123 ngeps.end(); iter != eiter; ++iter)
124 {
125 GepStmt* edge = SVFUtil::cast<GepStmt>(*iter);
126 if(edge->isVariantFieldGep())
128 else
130 }
131
133 for (SVFStmt::SVFStmtSetTy::iterator iter = loads.begin(), eiter =
134 loads.end(); iter != eiter; ++iter)
135 {
136 LoadStmt* edge = SVFUtil::cast<LoadStmt>(*iter);
137 addLoadCGEdge(edge->getRHSVarID(),edge->getLHSVarID());
138 }
139
141 for (SVFStmt::SVFStmtSetTy::iterator iter = stores.begin(), eiter =
142 stores.end(); iter != eiter; ++iter)
143 {
144 StoreStmt* edge = SVFUtil::cast<StoreStmt>(*iter);
145 addStoreCGEdge(edge->getRHSVarID(),edge->getLHSVarID());
146 }
147
149}
NodeID getRHSVarID() const
NodeID getLHSVarID() const
LoadCGEdge * addLoadCGEdge(NodeID src, NodeID dst)
Add Load edge.
Definition ConsG.cpp:292
AddrCGEdge * addAddrCGEdge(NodeID src, NodeID dst)
Add a SVFIR edge into Edge map.
Definition ConsG.cpp:206
void addConstraintNode(ConstraintNode *node, NodeID id)
Definition ConsG.h:109
CopyCGEdge * addCopyCGEdge(NodeID src, NodeID dst)
Add Copy edge.
Definition ConsG.cpp:226
StoreCGEdge * addStoreCGEdge(NodeID src, NodeID dst)
Add Store edge.
Definition ConsG.cpp:313
VariantGepCGEdge * addVariantGepCGEdge(NodeID src, NodeID dst)
Definition ConsG.cpp:271
SVFStmt::SVFStmtSetTy & getSVFStmtSet(SVFStmt::PEDGEK kind)
Definition ConsG.h:72
NormalGepCGEdge * addNormalGepCGEdge(NodeID src, NodeID dst, const AccessPath &ap)
Add Gep edge.
Definition ConsG.cpp:249
bool isBitCast() const
bool isValueCopy() const
IDToNodeMapTy::iterator iterator
bool isVariantFieldGep() const
Gep statement with a variant field index (pointer arithmetic) for struct field access.
const AccessPath & getAccessPath() const
const OPVars & getOpndVars() const
NodeID getOpVarID(u32_t pos) const
NodeID getResID() const
u32_t getOpVarNum() const
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy
std::enable_if_t<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type > cast(const Y &Val)
Definition Casting.h:360
unsigned u32_t
Definition GeneralType.h:67

◆ clearSolitaries()

void ConstraintGraph::clearSolitaries ( )
protected

Remove nodes that are neither pointers nor connected with any edge

We don't remove return SVFVar from an indirect callsite

Definition at line 154 of file ConsG.cpp.

155{
157 NodeSet retFromIndCalls;
158 for(auto cs_pair : pag->getIndirectCallsites())
159 {
160 const RetICFGNode* retBlockNode = cs_pair.first->getRetICFGNode();
161 if(pag->callsiteHasRet(retBlockNode))
162 retFromIndCalls.insert(pag->getCallSiteRet(retBlockNode)->getId());
163 }
164
165 Set<ConstraintNode*> nodesToRemove;
166 for (auto it = this->begin(); it != this->end(); ++it)
167 {
168 if (it->second->hasIncomingEdge() || it->second->hasOutgoingEdge())
169 continue;
170 if (pag->getSVFVar(it->first)->isPointer())
171 continue;
172 if (retFromIndCalls.find(it->first)!=retFromIndCalls.end())
173 continue;
174 nodesToRemove.insert(it->second);
175 }
176
177 for (auto node : nodesToRemove)
179}
void removeConstraintNode(ConstraintNode *node)
Definition ConsG.h:118
Set< NodeID > NodeSet
Definition GeneralType.h:87
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
Definition GeneralType.h:51

◆ destroy()

void ConstraintGraph::destroy ( )
protected

Memory has been cleaned up at GenericGraph

Definition at line 184 of file ConsG.cpp.

185{
186}

◆ dump()

void ConstraintGraph::dump ( std::string name)

Dump graph into dot file.

Dump constraint graph

Definition at line 595 of file ConsG.cpp.

596{
598}
const char *const name
Definition cJSON.h:264
static void WriteGraphToFile(SVF::OutStream &O, const std::string &GraphName, const GraphType &GT, bool simple=false)
std::ostream & outs()
Overwrite llvm::outs().
Definition SVFUtil.h:58

◆ getAddrCGEdges()

ConstraintEdge::ConstraintEdgeSetTy & SVF::ConstraintGraph::getAddrCGEdges ( )
inline

Get SVFIR edge.

Get Address edges

Definition at line 191 of file ConsG.h.

192 {
193 return AddrCGEdgeSet;
194 }

◆ getAllFieldsObjVars()

NodeBS & SVF::ConstraintGraph::getAllFieldsObjVars ( NodeID id)
inline

Definition at line 311 of file ConsG.h.

312 {
313 return pag->getAllFieldsObjVars(id);
314 }

◆ getBaseObjVarID()

NodeID SVF::ConstraintGraph::getBaseObjVarID ( NodeID id)
inline

Definition at line 315 of file ConsG.h.

316 {
317 return pag->getBaseObjVarID(id);
318 }

◆ getBlackHoleNode()

NodeID SVF::ConstraintGraph::getBlackHoleNode ( )
inline

Definition at line 303 of file ConsG.h.

304 {
305 return pag->getBlackHoleNode();
306 }

◆ getConstraintNode()

ConstraintNode * SVF::ConstraintGraph::getConstraintNode ( NodeID id) const
inline

Get/add/remove constraint node.

Definition at line 104 of file ConsG.h.

105 {
106 id = sccRepNode(id);
107 return getGNode(id);
108 }
NodeID sccRepNode(NodeID id) const
SCC rep/sub nodes methods.
Definition ConsG.h:230

◆ getDirectCGEdges()

ConstraintEdge::ConstraintEdgeSetTy & SVF::ConstraintGraph::getDirectCGEdges ( )
inline

Get Copy/call/ret/gep edges.

Definition at line 196 of file ConsG.h.

197 {
198 return directEdgeSet;
199 }

◆ getEdge()

ConstraintEdge * SVF::ConstraintGraph::getEdge ( ConstraintNode * src,
ConstraintNode * dst,
ConstraintEdge::ConstraintEdgeK kind )
inline

Get an edge via its src and dst nodes and kind.

Definition at line 143 of file ConsG.h.

144 {
145 ConstraintEdge edge(src,dst,kind);
147 {
148 auto eit = directEdgeSet.find(&edge);
149 return *eit;
150 }
151 else if(kind == ConstraintEdge::Addr)
152 {
153 auto eit = AddrCGEdgeSet.find(&edge);
154 return *eit;
155 }
156 else if(kind == ConstraintEdge::Store)
157 {
158 auto eit = StoreCGEdgeSet.find(&edge);
159 return *eit;
160 }
161 else if(kind == ConstraintEdge::Load)
162 {
163 auto eit = LoadCGEdgeSet.find(&edge);
164 return *eit;
165 }
166 else
167 {
168 assert(false && "no other kind!");
169 return nullptr;
170 }
171 }

◆ getFIObjVar()

NodeID SVF::ConstraintGraph::getFIObjVar ( NodeID id)
inline

Get a field-insensitive node of a memory object.

The fi obj in PAG must be either an existing node or merged to another rep node in ConsG

Definition at line 334 of file ConsG.h.

335 {
336 NodeID fi = pag->getFIObjVar(id);
338 assert((hasConstraintNode(fi) || sccRepNode(fi) != fi) && "non-existing fi obj??");
339 return fi;
340 }
bool hasConstraintNode(NodeID id) const
Definition ConsG.h:113
u32_t NodeID
Definition GeneralType.h:76

◆ getGepObjVar()

NodeID SVF::ConstraintGraph::getGepObjVar ( NodeID id,
const APOffset & apOffset )
inline

Get a field of a memory object.

Create a node when it is (1) not exist on graph and (2) not merged

Definition at line 325 of file ConsG.h.

326 {
327 NodeID gep = pag->getGepObjVar(id, apOffset);
329 if(sccRepNode(gep)==gep && hasConstraintNode(gep)==false)
330 addConstraintNode(new ConstraintNode(gep),gep);
331 return gep;
332 }

◆ getIndirectCallsites()

const SVFIR::CallSiteToFunPtrMap & SVF::ConstraintGraph::getIndirectCallsites ( ) const
inline

Wrappers for invoking SVFIR methods.

Definition at line 299 of file ConsG.h.

300 {
301 return pag->getIndirectCallsites();
302 }

◆ getLoadCGEdges()

ConstraintEdge::ConstraintEdgeSetTy & SVF::ConstraintGraph::getLoadCGEdges ( )
inline

Get Load edges.

Definition at line 201 of file ConsG.h.

202 {
203 return LoadCGEdgeSet;
204 }

◆ getNextCollapseNode()

NodeID SVF::ConstraintGraph::getNextCollapseNode ( )
inline

Definition at line 365 of file ConsG.h.

366 {
367 return nodesToBeCollapsed.pop();
368 }

◆ getRep()

NodeID SVF::ConstraintGraph::getRep ( NodeID node)
inline

Definition at line 259 of file ConsG.h.

260 {
261 return nodeToRepMap[node];
262 }
NodeToRepMap nodeToRepMap
Definition ConsG.h:56

◆ getReturnNode()

NodeID SVF::ConstraintGraph::getReturnNode ( const FunObjVar * value) const
inlineprotected

Wrappers used internally, not expose to Andersen Pass.

Definition at line 79 of file ConsG.h.

80 {
81 return pag->getReturnNode(value);
82 }

◆ getStoreCGEdges()

ConstraintEdge::ConstraintEdgeSetTy & SVF::ConstraintGraph::getStoreCGEdges ( )
inline

Get Store edges.

Definition at line 206 of file ConsG.h.

207 {
208 return StoreCGEdgeSet;
209 }

◆ getSubs()

NodeBS & SVF::ConstraintGraph::getSubs ( NodeID node)
inline

Definition at line 255 of file ConsG.h.

256 {
257 return nodeToSubsMap[node];
258 }
NodeToSubsMap nodeToSubsMap
Definition ConsG.h:57

◆ getSVFStmtSet()

SVFStmt::SVFStmtSetTy & SVF::ConstraintGraph::getSVFStmtSet ( SVFStmt::PEDGEK kind)
inlineprotected

Definition at line 72 of file ConsG.h.

73 {
74 return pag->getPTASVFStmtSet(kind);
75 }

◆ getVarargNode()

NodeID SVF::ConstraintGraph::getVarargNode ( const FunObjVar * value) const
inlineprotected

Definition at line 84 of file ConsG.h.

85 {
86 return pag->getVarargNode(value);
87 }

◆ hasConstraintNode()

bool SVF::ConstraintGraph::hasConstraintNode ( NodeID id) const
inline

Definition at line 113 of file ConsG.h.

114 {
115 id = sccRepNode(id);
116 return hasGNode(id);
117 }

◆ hasEdge()

bool SVF::ConstraintGraph::hasEdge ( ConstraintNode * src,
ConstraintNode * dst,
ConstraintEdge::ConstraintEdgeK kind )
inline

Definition at line 125 of file ConsG.h.

126 {
127 ConstraintEdge edge(src,dst,kind);
128 if(kind == ConstraintEdge::Copy ||
130 return directEdgeSet.find(&edge) != directEdgeSet.end();
131 else if(kind == ConstraintEdge::Addr)
132 return AddrCGEdgeSet.find(&edge) != AddrCGEdgeSet.end();
133 else if(kind == ConstraintEdge::Store)
134 return StoreCGEdgeSet.find(&edge) != StoreCGEdgeSet.end();
135 else if(kind == ConstraintEdge::Load)
136 return LoadCGEdgeSet.find(&edge) != LoadCGEdgeSet.end();
137 else
138 assert(false && "no other kind!");
139 return false;
140 }

◆ hasNodesToBeCollapsed()

bool SVF::ConstraintGraph::hasNodesToBeCollapsed ( ) const
inline

Add/get nodes to be collapsed.

Definition at line 357 of file ConsG.h.

358 {
359 return (!nodesToBeCollapsed.empty());
360 }

◆ isBlkObjOrConstantObj()

bool SVF::ConstraintGraph::isBlkObjOrConstantObj ( NodeID id)
inline

Definition at line 307 of file ConsG.h.

308 {
309 return pag->isBlkObjOrConstantObj(id);
310 }

◆ isPWCNode()

bool SVF::ConstraintGraph::isPWCNode ( NodeID nodeId)
inline

Check/Set PWC (positive weight cycle) flag.

Definition at line 345 of file ConsG.h.

346 {
347 return getConstraintNode(nodeId)->isPWCNode();
348 }
bool isPWCNode() const
Whether a node involves in PWC, if so, all its points-to elements should become field-insensitive.
Definition ConsGNode.h:81

◆ isSingleFieldObj()

bool SVF::ConstraintGraph::isSingleFieldObj ( NodeID id) const
inline

Definition at line 319 of file ConsG.h.

320 {
321 const BaseObjVar* baseObj = pag->getBaseObject(id);
322 return (baseObj->getMaxFieldOffsetLimit() == 1);
323 }

◆ isZeroOffsettedGepCGEdge()

bool SVF::ConstraintGraph::isZeroOffsettedGepCGEdge ( ConstraintEdge * edge) const
inline

Check if a given edge is a NormalGepCGEdge with 0 offset.

Definition at line 289 of file ConsG.h.

290 {
291 if (NormalGepCGEdge *normalGepCGEdge = SVFUtil::dyn_cast<NormalGepCGEdge>(edge))
292 if (0 == normalGepCGEdge->getConstantFieldIdx())
293 return true;
294 return false;
295 }
LLVM_NODISCARD std::enable_if_t<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type > dyn_cast(const Y &Val)
Definition Casting.h:405

◆ moveEdgesToRepNode()

bool SVF::ConstraintGraph::moveEdgesToRepNode ( ConstraintNode * node,
ConstraintNode * rep )
inline

Move incoming/outgoing direct edges of a sub node to its rep node Return TRUE if there's a gep edge inside this SCC (PWC).

Definition at line 281 of file ConsG.h.

282 {
283 bool gepIn = moveInEdgesToRepNode(node, rep);
284 bool gepOut = moveOutEdgesToRepNode(node, rep);
285 return (gepIn || gepOut);
286 }
bool moveInEdgesToRepNode(ConstraintNode *node, ConstraintNode *rep)
Definition ConsG.cpp:478
bool moveOutEdgesToRepNode(ConstraintNode *node, ConstraintNode *rep)
Definition ConsG.cpp:536

◆ moveInEdgesToRepNode()

bool ConstraintGraph::moveInEdgesToRepNode ( ConstraintNode * node,
ConstraintNode * rep )

Move incoming direct edges of a sub node which is outside the SCC to its rep node Remove incoming direct edges of a sub node which is inside the SCC from its rep node Return TRUE if there's a gep edge inside this SCC (PWC).

Move incoming direct edges of a sub node which is outside SCC to its rep node Remove incoming direct edges of a sub node which is inside SCC from its rep node

only copy and gep edge can be removed

Definition at line 478 of file ConsG.cpp.

479{
480 std::vector<ConstraintEdge*> sccEdges;
481 std::vector<ConstraintEdge*> nonSccEdges;
482 for (ConstraintNode::const_iterator it = node->InEdgeBegin(), eit = node->InEdgeEnd(); it != eit;
483 ++it)
484 {
485 ConstraintEdge* subInEdge = *it;
486 if(sccRepNode(subInEdge->getSrcID()) != rep->getId())
487 nonSccEdges.push_back(subInEdge);
488 else
489 {
490 sccEdges.push_back(subInEdge);
491 }
492 }
493 // if this edge is outside scc, then re-target edge dst to rep
494 while(!nonSccEdges.empty())
495 {
496 ConstraintEdge* edge = nonSccEdges.back();
497 nonSccEdges.pop_back();
498 reTargetDstOfEdge(edge,rep);
499 }
500
501 bool criticalGepInsideSCC = false;
502 // if this edge is inside scc, then remove this edge and two end nodes
503 while(!sccEdges.empty())
504 {
505 ConstraintEdge* edge = sccEdges.back();
506 sccEdges.pop_back();
509 removeDirectEdge(edge);
510 else if (SVFUtil::isa<GepCGEdge>(edge))
511 {
512 // If the GEP is critical (i.e. may have a non-zero offset),
513 // then it brings impact on field-sensitivity.
514 if (!isZeroOffsettedGepCGEdge(edge))
515 {
516 criticalGepInsideSCC = true;
517 }
518 removeDirectEdge(edge);
519 }
521 reTargetDstOfEdge(edge,rep);
522 else if(AddrCGEdge* addr = SVFUtil::dyn_cast<AddrCGEdge>(edge))
523 {
524 removeAddrEdge(addr);
525 }
526 else
527 assert(false && "no such edge");
528 }
529 return criticalGepInsideSCC;
530}
void reTargetDstOfEdge(ConstraintEdge *edge, ConstraintNode *newDstNode)
Used for cycle elimination.
Definition ConsG.cpp:339
void removeDirectEdge(ConstraintEdge *edge)
Remove direct edge from their src and dst edge sets.
Definition ConsG.cpp:463
void removeAddrEdge(AddrCGEdge *edge)
Remove addr edge from their src and dst edge sets.
Definition ConsG.cpp:424
bool isZeroOffsettedGepCGEdge(ConstraintEdge *edge) const
Check if a given edge is a NormalGepCGEdge with 0 offset.
Definition ConsG.h:289
ConstraintEdge::ConstraintEdgeSetTy::const_iterator const_iterator
Definition ConsGNode.h:45
NodeID getSrcID() const
get methods of the components
iterator InEdgeBegin()
iterator InEdgeEnd()
NodeID getId() const
Get ID.
Definition SVFValue.h:158
LLVM_NODISCARD bool isa(const Y &Val)
Definition Casting.h:241

◆ moveOutEdgesToRepNode()

bool ConstraintGraph::moveOutEdgesToRepNode ( ConstraintNode * node,
ConstraintNode * rep )

Move outgoing direct edges of a sub node which is outside the SCC to its rep node Remove outgoing direct edges of sub node which is inside the SCC from its rep node Return TRUE if there's a gep edge inside this SCC (PWC).

Move outgoing direct edges of a sub node which is outside SCC to its rep node Remove outgoing direct edges of a sub node which is inside SCC from its rep node

only copy and gep edge can be removed

Definition at line 536 of file ConsG.cpp.

537{
538
539 std::vector<ConstraintEdge*> sccEdges;
540 std::vector<ConstraintEdge*> nonSccEdges;
541
542 for (ConstraintNode::const_iterator it = node->OutEdgeBegin(), eit = node->OutEdgeEnd(); it != eit;
543 ++it)
544 {
545 ConstraintEdge* subOutEdge = *it;
546 if(sccRepNode(subOutEdge->getDstID()) != rep->getId())
547 nonSccEdges.push_back(subOutEdge);
548 else
549 {
550 sccEdges.push_back(subOutEdge);
551 }
552 }
553 // if this edge is outside scc, then re-target edge src to rep
554 while(!nonSccEdges.empty())
555 {
556 ConstraintEdge* edge = nonSccEdges.back();
557 nonSccEdges.pop_back();
558 reTargetSrcOfEdge(edge,rep);
559 }
560 bool criticalGepInsideSCC = false;
561 // if this edge is inside scc, then remove this edge and two end nodes
562 while(!sccEdges.empty())
563 {
564 ConstraintEdge* edge = sccEdges.back();
565 sccEdges.pop_back();
568 removeDirectEdge(edge);
569 else if (SVFUtil::isa<GepCGEdge>(edge))
570 {
571 // If the GEP is critical (i.e. may have a non-zero offset),
572 // then it brings impact on field-sensitivity.
573 if (!isZeroOffsettedGepCGEdge(edge))
574 {
575 criticalGepInsideSCC = true;
576 }
577 removeDirectEdge(edge);
578 }
580 reTargetSrcOfEdge(edge,rep);
581 else if(AddrCGEdge* addr = SVFUtil::dyn_cast<AddrCGEdge>(edge))
582 {
583 removeAddrEdge(addr);
584 }
585 else
586 assert(false && "no such edge");
587 }
588 return criticalGepInsideSCC;
589}
void reTargetSrcOfEdge(ConstraintEdge *edge, ConstraintNode *newSrcNode)
Remove edge from old src target, change edge dst id and add modified edge into new src.
Definition ConsG.cpp:383
NodeID getDstID() const
iterator OutEdgeEnd()
iterator OutEdgeBegin()
iterators

◆ print()

void ConstraintGraph::print ( )

Print CG into terminal.

Print this constraint graph including its nodes and edges

Definition at line 603 of file ConsG.cpp.

604{
605
606 outs() << "-----------------ConstraintGraph--------------------------------------\n";
607
609 for (ConstraintEdge::ConstraintEdgeSetTy::iterator iter = addrs.begin(),
610 eiter = addrs.end(); iter != eiter; ++iter)
611 {
612 outs() << (*iter)->getSrcID() << " -- Addr --> " << (*iter)->getDstID()
613 << "\n";
614 }
615
617 for (ConstraintEdge::ConstraintEdgeSetTy::iterator iter = directs.begin(),
618 eiter = directs.end(); iter != eiter; ++iter)
619 {
620 if (CopyCGEdge* copy = SVFUtil::dyn_cast<CopyCGEdge>(*iter))
621 {
622 outs() << copy->getSrcID() << " -- Copy --> " << copy->getDstID()
623 << "\n";
624 }
625 else if (NormalGepCGEdge* ngep = SVFUtil::dyn_cast<NormalGepCGEdge>(*iter))
626 {
627 outs() << ngep->getSrcID() << " -- NormalGep (" << ngep->getConstantFieldIdx()
628 << ") --> " << ngep->getDstID() << "\n";
629 }
630 else if (VariantGepCGEdge* vgep = SVFUtil::dyn_cast<VariantGepCGEdge>(*iter))
631 {
632 outs() << vgep->getSrcID() << " -- VarintGep --> "
633 << vgep->getDstID() << "\n";
634 }
635 else
636 assert(false && "wrong constraint edge kind!");
637 }
638
640 for (ConstraintEdge::ConstraintEdgeSetTy::iterator iter = loads.begin(),
641 eiter = loads.end(); iter != eiter; ++iter)
642 {
643 outs() << (*iter)->getSrcID() << " -- Load --> " << (*iter)->getDstID()
644 << "\n";
645 }
646
648 for (ConstraintEdge::ConstraintEdgeSetTy::iterator iter = stores.begin(),
649 eiter = stores.end(); iter != eiter; ++iter)
650 {
651 outs() << (*iter)->getSrcID() << " -- Store --> " << (*iter)->getDstID()
652 << "\n";
653 }
654
655 outs()
656 << "--------------------------------------------------------------\n";
657
658}
copy vgep
Definition PAGGrammar.txt:9
copy
Definition cJSON.cpp:414
GenericNode< ConstraintNode, ConstraintEdge >::GEdgeSetTy ConstraintEdgeSetTy
Constraint edge type.
Definition ConsGEdge.h:85
ConstraintEdge::ConstraintEdgeSetTy & getStoreCGEdges()
Get Store edges.
Definition ConsG.h:206
ConstraintEdge::ConstraintEdgeSetTy & getDirectCGEdges()
Get Copy/call/ret/gep edges.
Definition ConsG.h:196
ConstraintEdge::ConstraintEdgeSetTy & getLoadCGEdges()
Get Load edges.
Definition ConsG.h:201
ConstraintEdge::ConstraintEdgeSetTy & getAddrCGEdges()
Get SVFIR edge.
Definition ConsG.h:191

◆ removeAddrEdge()

void ConstraintGraph::removeAddrEdge ( AddrCGEdge * edge)

Remove addr edge from their src and dst edge sets.

Remove addr edge from their src and dst edge sets

Definition at line 424 of file ConsG.cpp.

425{
428 u32_t num = AddrCGEdgeSet.erase(edge);
429 (void)num; // Suppress warning of unused variable under release build
430 assert(num && "edge not in the set, can not remove!!!");
431 delete edge;
432}
bool removeIncomingAddrEdge(AddrCGEdge *inEdge)
Definition ConsGNode.h:314
bool removeOutgoingAddrEdge(AddrCGEdge *outEdge)
Remove constraint graph edges.
Definition ConsGNode.h:305

◆ removeConstraintNode()

void SVF::ConstraintGraph::removeConstraintNode ( ConstraintNode * node)
inline

Definition at line 118 of file ConsG.h.

119 {
120 removeGNode(node);
121 }

◆ removeDirectEdge()

void ConstraintGraph::removeDirectEdge ( ConstraintEdge * edge)

Remove direct edge from their src and dst edge sets.

Remove edges from their src and dst edge sets

Definition at line 463 of file ConsG.cpp.

464{
465
468 u32_t num = directEdgeSet.erase(edge);
469 (void)num; // Suppress warning of unused variable under release build
470 assert(num && "edge not in the set, can not remove!!!");
471 delete edge;
472}
bool removeOutgoingDirectEdge(ConstraintEdge *outEdge)
Definition ConsGNode.h:323
bool removeIncomingDirectEdge(ConstraintEdge *inEdge)
Definition ConsGNode.h:336

◆ removeLoadEdge()

void ConstraintGraph::removeLoadEdge ( LoadCGEdge * edge)

Remove load edge from their src and dst edge sets.

Remove load edge from their src and dst edge sets

Definition at line 437 of file ConsG.cpp.

438{
441 u32_t num = LoadCGEdgeSet.erase(edge);
442 (void)num; // Suppress warning of unused variable under release build
443 assert(num && "edge not in the set, can not remove!!!");
444 delete edge;
445}
bool removeOutgoingLoadEdge(LoadCGEdge *outEdge)
Definition ConsGNode.h:349
bool removeIncomingLoadEdge(LoadCGEdge *inEdge)
Definition ConsGNode.h:358

◆ removeStoreEdge()

void ConstraintGraph::removeStoreEdge ( StoreCGEdge * edge)

Remove store edge from their src and dst edge sets.

Remove store edge from their src and dst edge sets

Definition at line 450 of file ConsG.cpp.

451{
454 u32_t num = StoreCGEdgeSet.erase(edge);
455 (void)num; // Suppress warning of unused variable under release build
456 assert(num && "edge not in the set, can not remove!!!");
457 delete edge;
458}
bool removeOutgoingStoreEdge(StoreCGEdge *outEdge)
Definition ConsGNode.h:367
bool removeIncomingStoreEdge(StoreCGEdge *inEdge)
Definition ConsGNode.h:376

◆ resetRep()

void SVF::ConstraintGraph::resetRep ( NodeID node)
inline

Definition at line 263 of file ConsG.h.

264 {
265 nodeToRepMap.erase(node);
266 }

◆ resetSubs()

void SVF::ConstraintGraph::resetSubs ( NodeID node)
inline

Definition at line 251 of file ConsG.h.

252 {
253 nodeToSubsMap.erase(node);
254 }

◆ reTargetDstOfEdge()

void ConstraintGraph::reTargetDstOfEdge ( ConstraintEdge * edge,
ConstraintNode * newDstNode )

Used for cycle elimination.

Remove edge from old dst target, change edge dst id and add modified edge into new dst

Re-target dst node of an edge

(1) Remove edge from old dst target, (2) Change edge dst id and (3) Add modified edge into new dst

Definition at line 339 of file ConsG.cpp.

340{
341 NodeID newDstNodeID = newDstNode->getId();
342 NodeID srcId = edge->getSrcID();
343 if(LoadCGEdge* load = SVFUtil::dyn_cast<LoadCGEdge>(edge))
344 {
345 removeLoadEdge(load);
346 addLoadCGEdge(srcId,newDstNodeID);
347 }
348 else if(StoreCGEdge* store = SVFUtil::dyn_cast<StoreCGEdge>(edge))
349 {
350 removeStoreEdge(store);
351 addStoreCGEdge(srcId,newDstNodeID);
352 }
353 else if(CopyCGEdge* copy = SVFUtil::dyn_cast<CopyCGEdge>(edge))
354 {
356 addCopyCGEdge(srcId,newDstNodeID);
357 }
358 else if(NormalGepCGEdge* gep = SVFUtil::dyn_cast<NormalGepCGEdge>(edge))
359 {
360 const AccessPath ap = gep->getAccessPath();
361 removeDirectEdge(gep);
362 addNormalGepCGEdge(srcId,newDstNodeID, ap);
363 }
364 else if(VariantGepCGEdge* gep = SVFUtil::dyn_cast<VariantGepCGEdge>(edge))
365 {
366 removeDirectEdge(gep);
367 addVariantGepCGEdge(srcId,newDstNodeID);
368 }
369 else if(AddrCGEdge* addr = SVFUtil::dyn_cast<AddrCGEdge>(edge))
370 {
371 removeAddrEdge(addr);
372 }
373 else
374 assert(false && "no other edge type!!");
375}
void removeLoadEdge(LoadCGEdge *edge)
Remove load edge from their src and dst edge sets.
Definition ConsG.cpp:437
void removeStoreEdge(StoreCGEdge *edge)
Remove store edge from their src and dst edge sets.
Definition ConsG.cpp:450

◆ reTargetSrcOfEdge()

void ConstraintGraph::reTargetSrcOfEdge ( ConstraintEdge * edge,
ConstraintNode * newSrcNode )

Remove edge from old src target, change edge dst id and add modified edge into new src.

Re-target src node of an edge (1) Remove edge from old src target, (2) Change edge src id and (3) Add modified edge into new src

Definition at line 383 of file ConsG.cpp.

384{
385 NodeID newSrcNodeID = newSrcNode->getId();
386 NodeID dstId = edge->getDstID();
387 if(LoadCGEdge* load = SVFUtil::dyn_cast<LoadCGEdge>(edge))
388 {
389 removeLoadEdge(load);
390 addLoadCGEdge(newSrcNodeID,dstId);
391 }
392 else if(StoreCGEdge* store = SVFUtil::dyn_cast<StoreCGEdge>(edge))
393 {
394 removeStoreEdge(store);
395 addStoreCGEdge(newSrcNodeID,dstId);
396 }
397 else if(CopyCGEdge* copy = SVFUtil::dyn_cast<CopyCGEdge>(edge))
398 {
400 addCopyCGEdge(newSrcNodeID,dstId);
401 }
402 else if(NormalGepCGEdge* gep = SVFUtil::dyn_cast<NormalGepCGEdge>(edge))
403 {
404 const AccessPath ap = gep->getAccessPath();
405 removeDirectEdge(gep);
406 addNormalGepCGEdge(newSrcNodeID, dstId, ap);
407 }
408 else if(VariantGepCGEdge* gep = SVFUtil::dyn_cast<VariantGepCGEdge>(edge))
409 {
410 removeDirectEdge(gep);
411 addVariantGepCGEdge(newSrcNodeID,dstId);
412 }
413 else if(AddrCGEdge* addr = SVFUtil::dyn_cast<AddrCGEdge>(edge))
414 {
415 removeAddrEdge(addr);
416 }
417 else
418 assert(false && "no other edge type!!");
419}

◆ sccRepNode()

NodeID SVF::ConstraintGraph::sccRepNode ( NodeID id) const
inline

SCC rep/sub nodes methods.

Definition at line 230 of file ConsG.h.

231 {
232 NodeToRepMap::const_iterator it = nodeToRepMap.find(id);
233 if(it==nodeToRepMap.end())
234 return id;
235 else
236 return it->second;
237 }

◆ sccSubNodes()

NodeBS & SVF::ConstraintGraph::sccSubNodes ( NodeID id)
inline

Definition at line 238 of file ConsG.h.

239 {
240 nodeToSubsMap[id].set(id);
241 return nodeToSubsMap[id];
242 }

◆ setPWCNode()

void SVF::ConstraintGraph::setPWCNode ( NodeID nodeId)
inline

Definition at line 349 of file ConsG.h.

350 {
351 getConstraintNode(nodeId)->setPWCNode();
352 }

◆ setRep()

void SVF::ConstraintGraph::setRep ( NodeID node,
NodeID rep )
inline

Definition at line 243 of file ConsG.h.

244 {
245 nodeToRepMap[node] = rep;
246 }

◆ setSubs()

void SVF::ConstraintGraph::setSubs ( NodeID node,
NodeBS & subs )
inline

Definition at line 247 of file ConsG.h.

248 {
249 nodeToSubsMap[node] |= subs;
250 }

◆ view()

void ConstraintGraph::view ( )

View graph from the debugger.

View dot graph of Constraint graph from debugger.

Definition at line 663 of file ConsG.cpp.

664{
665 SVF::ViewGraph(this, "Constraint Graph");
666}
void ViewGraph(const GraphType &G, const std::string &name, bool ShortNames=false, GraphProgram::Name Program=GraphProgram::DOT)

Member Data Documentation

◆ AddrCGEdgeSet

ConstraintEdge::ConstraintEdgeSetTy SVF::ConstraintGraph::AddrCGEdgeSet
protected

Definition at line 61 of file ConsG.h.

◆ directEdgeSet

ConstraintEdge::ConstraintEdgeSetTy SVF::ConstraintGraph::directEdgeSet
protected

Definition at line 62 of file ConsG.h.

◆ edgeIndex

EdgeID SVF::ConstraintGraph::edgeIndex
protected

Definition at line 59 of file ConsG.h.

◆ LoadCGEdgeSet

ConstraintEdge::ConstraintEdgeSetTy SVF::ConstraintGraph::LoadCGEdgeSet
protected

Definition at line 63 of file ConsG.h.

◆ nodesToBeCollapsed

WorkList SVF::ConstraintGraph::nodesToBeCollapsed
protected

Definition at line 58 of file ConsG.h.

◆ nodeToRepMap

NodeToRepMap SVF::ConstraintGraph::nodeToRepMap
protected

Definition at line 56 of file ConsG.h.

◆ nodeToSubsMap

NodeToSubsMap SVF::ConstraintGraph::nodeToSubsMap
protected

Definition at line 57 of file ConsG.h.

◆ pag

SVFIR* SVF::ConstraintGraph::pag
protected

Definition at line 55 of file ConsG.h.

◆ StoreCGEdgeSet

ConstraintEdge::ConstraintEdgeSetTy SVF::ConstraintGraph::StoreCGEdgeSet
protected

Definition at line 64 of file ConsG.h.


The documentation for this class was generated from the following files: