Static Value-Flow Analysis
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
SVF::ICFG Class Reference

#include <ICFG.h>

Inheritance diagram for SVF::ICFG:
SVF::GenericGraph< NodeTy, EdgeTy >

Public Types

typedef OrderedMap< NodeID, ICFGNode * > ICFGNodeIDToNodeMapTy
 
typedef ICFGEdge::ICFGEdgeSetTy ICFGEdgeSetTy
 
typedef ICFGNodeIDToNodeMapTy::iterator iterator
 
typedef ICFGNodeIDToNodeMapTy::const_iterator const_iterator
 
typedef Map< const SVFFunction *, FunEntryICFGNode * > FunToFunEntryNodeMapTy
 
typedef Map< const SVFFunction *, FunExitICFGNode * > FunToFunExitNodeMapTy
 
typedef std::vector< const SVFLoop * > SVFLoopVec
 
typedef Map< const ICFGNode *, SVFLoopVecICFGNodeToSVFLoopVec
 
- Public Types inherited from SVF::GenericGraph< NodeTy, EdgeTy >
typedef NodeTy NodeType
 
typedef EdgeTy 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

 ICFG ()
 Constructor.
 
 ~ICFG () override
 Destructor.
 
ICFGNodegetICFGNode (NodeID id) const
 Get a ICFG node.
 
bool hasICFGNode (NodeID id) const
 Whether has the ICFGNode.
 
ICFGEdgehasIntraICFGEdge (ICFGNode *src, ICFGNode *dst, ICFGEdge::ICFGEdgeK kind)
 Whether we has a SVFG edge.
 
ICFGEdgehasInterICFGEdge (ICFGNode *src, ICFGNode *dst, ICFGEdge::ICFGEdgeK kind)
 
ICFGEdgehasThreadICFGEdge (ICFGNode *src, ICFGNode *dst, ICFGEdge::ICFGEdgeK kind)
 
ICFGEdgegetICFGEdge (const ICFGNode *src, const ICFGNode *dst, ICFGEdge::ICFGEdgeK kind)
 Get a SVFG edge according to src and dst.
 
void dump (const std::string &file, bool simple=false)
 Dump graph into dot file.
 
void view ()
 View graph from the debugger.
 
void updateCallGraph (PTACallGraph *callgraph)
 update ICFG for indirect calls
 
bool isInLoop (const ICFGNode *node)
 Whether node is in a loop.
 
void addNodeToSVFLoop (const ICFGNode *node, const SVFLoop *loop)
 Insert (node, loop) to icfgNodeToSVFLoopVec.
 
SVFLoopVecgetSVFLoops (const ICFGNode *node)
 Get loops where a node resides.
 
const ICFGNodeToSVFLoopVecgetIcfgNodeToSVFLoopVec () const
 
FunEntryICFGNodegetFunEntryICFGNode (const SVFFunction *fun)
 Add a function entry node.
 
FunExitICFGNodegetFunExitICFGNode (const SVFFunction *fun)
 Add a function exit node.
 
GlobalICFGNodegetGlobalICFGNode () const
 
const std::vector< const ICFGNode * > & getSubNodes (const ICFGNode *node) const
 
const ICFGNodegetRepNode (const ICFGNode *node) const
 
void updateSubAndRep (const ICFGNode *rep, const ICFGNode *sub)
 
- Public Member Functions inherited from SVF::GenericGraph< NodeTy, EdgeTy >
 GenericGraph ()
 Constructor.
 
virtual ~GenericGraph ()
 Destructor.
 
void destroy ()
 Release memory.
 
iterator begin ()
 Iterators.
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
void addGNode (NodeID id, NodeType *node)
 Add a Node.
 
NodeTypegetGNode (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 ()
 

Public Attributes

NodeID totalICFGNode
 
- Public Attributes inherited from SVF::GenericGraph< NodeTy, EdgeTy >
u32_t edgeNum
 total num of node
 
u32_t nodeNum
 total num of edge
 

Protected Member Functions

ICFGEdgeaddIntraEdge (ICFGNode *srcNode, ICFGNode *dstNode)
 Add intraprocedural and interprocedural control-flow edges.
 
ICFGEdgeaddConditionalIntraEdge (ICFGNode *srcNode, ICFGNode *dstNode, s64_t branchCondVal)
 
ICFGEdgeaddCallEdge (ICFGNode *srcNode, ICFGNode *dstNode)
 
ICFGEdgeaddRetEdge (ICFGNode *srcNode, ICFGNode *dstNode)
 
void removeICFGEdge (ICFGEdge *edge)
 Remove a ICFG edge.
 
void removeICFGNode (ICFGNode *node)
 Remove a ICFGNode.
 
void checkIntraEdgeParents (const ICFGNode *srcNode, const ICFGNode *dstNode)
 sanitize Intra edges, verify that both nodes belong to the same function.
 
virtual IntraICFGNodeaddIntraICFGNode (const SVFBasicBlock *bb, bool isRet)
 
virtual CallICFGNodeaddCallICFGNode (const SVFBasicBlock *bb, const SVFType *ty, const SVFFunction *calledFunc, bool isVararg, bool isvcall, s32_t vcallIdx, const std::string &funNameOfVcall)
 
virtual RetICFGNodeaddRetICFGNode (CallICFGNode *call)
 
virtual FunEntryICFGNodeaddFunEntryICFGNode (const SVFFunction *svfFunc)
 
virtual FunExitICFGNodeaddFunExitICFGNode (const SVFFunction *svfFunc)
 
virtual void addICFGNode (ICFGNode *node)
 Add a ICFG node.
 

Private Member Functions

void addSubNode (const ICFGNode *rep, const ICFGNode *sub)
 when ICFG is simplified, SubNode would merge repNode, then update the map
 
void updateRepNode (const ICFGNode *rep, const ICFGNode *sub)
 when ICFG is simplified, some node would be removed, this map records the removed node to its rep node
 
bool addICFGEdge (ICFGEdge *edge)
 Add ICFG edge, only used by addIntraEdge, addCallEdge, addRetEdge etc.
 
FunEntryICFGNodegetFunEntryBlock (const SVFFunction *fun)
 Get/Add a function entry node.
 
FunExitICFGNodegetFunExitBlock (const SVFFunction *fun)
 Get/Add a function exit node.
 

Private Attributes

FunToFunEntryNodeMapTy FunToFunEntryNodeMap
 map a function to its FunExitICFGNode
 
FunToFunExitNodeMapTy FunToFunExitNodeMap
 map a function to its FunEntryICFGNode
 
GlobalICFGNodeglobalBlockNode
 unique basic block for all globals
 
ICFGNodeToSVFLoopVec icfgNodeToSVFLoopVec
 map ICFG node to the SVF loops where it resides
 
Map< const ICFGNode *, std::vector< const ICFGNode * > > _subNodes
 map a node(1st node of basicblock) to its subnodes
 
Map< const ICFGNode *, const ICFGNode * > _repNode
 map a subnode to its representative node(1st node of basicblock)
 

Friends

class ICFGBuilder
 
class SVFIRWriter
 
class SVFIRReader
 
class ICFGSimplification
 

Additional Inherited Members

- Protected Attributes inherited from SVF::GenericGraph< NodeTy, EdgeTy >
IDToNodeMapTy IDToNodeMap
 node map
 

Detailed Description

Definition at line 47 of file ICFG.h.

Member Typedef Documentation

◆ const_iterator

typedef ICFGNodeIDToNodeMapTy::const_iterator SVF::ICFG::const_iterator

Definition at line 59 of file ICFG.h.

◆ FunToFunEntryNodeMapTy

Definition at line 61 of file ICFG.h.

◆ FunToFunExitNodeMapTy

Definition at line 62 of file ICFG.h.

◆ ICFGEdgeSetTy

Definition at line 57 of file ICFG.h.

◆ ICFGNodeIDToNodeMapTy

Definition at line 56 of file ICFG.h.

◆ ICFGNodeToSVFLoopVec

Definition at line 64 of file ICFG.h.

◆ iterator

typedef ICFGNodeIDToNodeMapTy::iterator SVF::ICFG::iterator

Definition at line 58 of file ICFG.h.

◆ SVFLoopVec

Definition at line 63 of file ICFG.h.

Constructor & Destructor Documentation

◆ ICFG()

ICFG::ICFG ( )

Constructor.

Constructor

  • Build ICFG 1) build ICFG nodes statements for top level pointers (PAGEdges) 2) connect ICFG edges between two statements (PAGEdges)

Definition at line 210 of file ICFG.cpp.

210 : totalICFGNode(0), globalBlockNode(nullptr)
211{
212}
NodeID totalICFGNode
Definition ICFG.h:66
GlobalICFGNode * globalBlockNode
unique basic block for all globals
Definition ICFG.h:71

◆ ~ICFG()

ICFG::~ICFG ( )
override

Destructor.

Definition at line 214 of file ICFG.cpp.

215{
217 for (const auto &it: icfgNodeToSVFLoopVec)
218 {
219 for (const auto &loop: it.second)
220 {
221 loops.insert(loop);
222 }
223 }
224
225 for (const auto &it: loops)
226 {
227 delete it;
228 }
229 icfgNodeToSVFLoopVec.clear();
230}
ICFGNodeToSVFLoopVec icfgNodeToSVFLoopVec
map ICFG node to the SVF loops where it resides
Definition ICFG.h:72
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

Member Function Documentation

◆ addCallEdge()

ICFGEdge * ICFG::addCallEdge ( ICFGNode srcNode,
ICFGNode dstNode 
)
protected

Add interprocedural call edges between two nodes

Definition at line 366 of file ICFG.cpp.

367{
369 if (edge != nullptr)
370 {
371 assert(edge->isCallCFGEdge() && "this should be a call CFG edge!");
372 return nullptr;
373 }
374 else
375 {
377 return (addICFGEdge(callEdge) ? callEdge : nullptr);
378 }
379}
bool addICFGEdge(ICFGEdge *edge)
Add ICFG edge, only used by addIntraEdge, addCallEdge, addRetEdge etc.
Definition ICFG.h:277
ICFGEdge * hasInterICFGEdge(ICFGNode *src, ICFGNode *dst, ICFGEdge::ICFGEdgeK kind)
Definition ICFG.cpp:268

◆ addCallICFGNode()

virtual CallICFGNode * SVF::ICFG::addCallICFGNode ( const SVFBasicBlock bb,
const SVFType ty,
const SVFFunction calledFunc,
bool  isVararg,
bool  isvcall,
s32_t  vcallIdx,
const std::string &  funNameOfVcall 
)
inlineprotectedvirtual

Definition at line 183 of file ICFG.h.

187 {
188
189 CallICFGNode* callICFGNode =
190 new CallICFGNode(totalICFGNode++, bb, ty, calledFunc, isVararg,
191 isvcall, vcallIdx, funNameOfVcall);
193 return callICFGNode;
194 }
virtual void addICFGNode(ICFGNode *node)
Add a ICFG node.
Definition ICFG.h:219

◆ addConditionalIntraEdge()

ICFGEdge * ICFG::addConditionalIntraEdge ( ICFGNode srcNode,
ICFGNode dstNode,
s64_t  branchCondVal 
)
protected

Add conditional intraprocedural edges between two nodes

Definition at line 344 of file ICFG.cpp.

345{
346
349 if (edge != nullptr)
350 {
351 assert(edge->isIntraCFGEdge() && "this should be an intra CFG edge!");
352 return nullptr;
353 }
354 else
355 {
357 intraEdge->setBranchCondVal(branchCondVal);
359 }
360}
void checkIntraEdgeParents(const ICFGNode *srcNode, const ICFGNode *dstNode)
sanitize Intra edges, verify that both nodes belong to the same function.
Definition ICFG.h:165
ICFGEdge * hasIntraICFGEdge(ICFGNode *src, ICFGNode *dst, ICFGEdge::ICFGEdgeK kind)
Whether we has a SVFG edge.
Definition ICFG.cpp:251

◆ addFunEntryICFGNode()

virtual FunEntryICFGNode * SVF::ICFG::addFunEntryICFGNode ( const SVFFunction svfFunc)
inlineprotectedvirtual

Definition at line 204 of file ICFG.h.

205 {
206 FunEntryICFGNode* sNode = new FunEntryICFGNode(totalICFGNode++,svfFunc);
209 }
FunToFunEntryNodeMapTy FunToFunEntryNodeMap
map a function to its FunExitICFGNode
Definition ICFG.h:69

◆ addFunExitICFGNode()

virtual FunExitICFGNode * SVF::ICFG::addFunExitICFGNode ( const SVFFunction svfFunc)
inlineprotectedvirtual

Definition at line 211 of file ICFG.h.

212 {
213 FunExitICFGNode* sNode = new FunExitICFGNode(totalICFGNode++, svfFunc);
216 }
FunToFunExitNodeMapTy FunToFunExitNodeMap
map a function to its FunEntryICFGNode
Definition ICFG.h:70

◆ addICFGEdge()

bool SVF::ICFG::addICFGEdge ( ICFGEdge edge)
inlineprivate

Add ICFG edge, only used by addIntraEdge, addCallEdge, addRetEdge etc.

Definition at line 277 of file ICFG.h.

278 {
279 bool added1 = edge->getDstNode()->addIncomingEdge(edge);
280 bool added2 = edge->getSrcNode()->addOutgoingEdge(edge);
281 bool all_added = added1 && added2;
282 assert(all_added && "ICFGEdge not added?");
283 return all_added;
284 }

◆ addICFGNode()

virtual void SVF::ICFG::addICFGNode ( ICFGNode node)
inlineprotectedvirtual

Add a ICFG node.

Definition at line 219 of file ICFG.h.

220 {
221 addGNode(node->getId(),node);
222 _repNode[node] = node;
223 _subNodes[node].push_back(node);
224 }
void addGNode(NodeID id, NodeType *node)
Add a Node.
Map< const ICFGNode *, const ICFGNode * > _repNode
map a subnode to its representative node(1st node of basicblock)
Definition ICFG.h:75
Map< const ICFGNode *, std::vector< const ICFGNode * > > _subNodes
map a node(1st node of basicblock) to its subnodes
Definition ICFG.h:74

◆ addIntraEdge()

ICFGEdge * ICFG::addIntraEdge ( ICFGNode srcNode,
ICFGNode dstNode 
)
protected

Add intraprocedural and interprocedural control-flow edges.

Add intraprocedural edges between two nodes

Definition at line 325 of file ICFG.cpp.

326{
329 if (edge != nullptr)
330 {
331 assert(edge->isIntraCFGEdge() && "this should be an intra CFG edge!");
332 return nullptr;
333 }
334 else
335 {
338 }
339}

◆ addIntraICFGNode()

virtual IntraICFGNode * SVF::ICFG::addIntraICFGNode ( const SVFBasicBlock bb,
bool  isRet 
)
inlineprotectedvirtual

Definition at line 175 of file ICFG.h.

176 {
177 IntraICFGNode* intraIcfgNode =
178 new IntraICFGNode(totalICFGNode++, bb, isRet);
180 return intraIcfgNode;
181 }

◆ addNodeToSVFLoop()

void SVF::ICFG::addNodeToSVFLoop ( const ICFGNode node,
const SVFLoop loop 
)
inline

Insert (node, loop) to icfgNodeToSVFLoopVec.

Definition at line 124 of file ICFG.h.

125 {
126 icfgNodeToSVFLoopVec[node].push_back(loop);
127 }

◆ addRetEdge()

ICFGEdge * ICFG::addRetEdge ( ICFGNode srcNode,
ICFGNode dstNode 
)
protected

Add interprocedural return edges between two nodes

Definition at line 384 of file ICFG.cpp.

385{
387 if (edge != nullptr)
388 {
389 assert(edge->isRetCFGEdge() && "this should be a return CFG edge!");
390 return nullptr;
391 }
392 else
393 {
395 return (addICFGEdge(retEdge) ? retEdge : nullptr);
396 }
397}

◆ addRetICFGNode()

virtual RetICFGNode * SVF::ICFG::addRetICFGNode ( CallICFGNode call)
inlineprotectedvirtual

Definition at line 196 of file ICFG.h.

197 {
198 RetICFGNode* retICFGNode = new RetICFGNode(totalICFGNode++, call);
199 call->setRetICFGNode(retICFGNode);
201 return retICFGNode;
202 }

◆ addSubNode()

void SVF::ICFG::addSubNode ( const ICFGNode rep,
const ICFGNode sub 
)
inlineprivate

when ICFG is simplified, SubNode would merge repNode, then update the map

Definition at line 261 of file ICFG.h.

262 {
263 std::vector<const ICFGNode*>& subNodes = _subNodes[sub];
264 if(std::find(subNodes.begin(), subNodes.end(), rep) == subNodes.end())
265 {
266 subNodes.push_back(rep);
267 }
268 }

◆ checkIntraEdgeParents()

void SVF::ICFG::checkIntraEdgeParents ( const ICFGNode srcNode,
const ICFGNode dstNode 
)
inlineprotected

sanitize Intra edges, verify that both nodes belong to the same function.

Definition at line 165 of file ICFG.h.

166 {
167 const SVFFunction* srcfun = srcNode->getFun();
168 const SVFFunction* dstfun = dstNode->getFun();
169 if(srcfun != nullptr && dstfun != nullptr)
170 {
171 assert((srcfun == dstfun) && "src and dst nodes of an intra edge should in the same function!" );
172 }
173 }

◆ dump()

void ICFG::dump ( const std::string &  file,
bool  simple = false 
)

Dump graph into dot file.

Dump ICFG

Definition at line 403 of file ICFG.cpp.

404{
406}
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:50

◆ getFunEntryBlock()

FunEntryICFGNode * SVF::ICFG::getFunEntryBlock ( const SVFFunction fun)
inlineprivate

Get/Add a function entry node.

Definition at line 287 of file ICFG.h.

288 {
289 FunToFunEntryNodeMapTy::const_iterator it = FunToFunEntryNodeMap.find(fun);
290 if (it == FunToFunEntryNodeMap.end())
291 return nullptr;
292 return it->second;
293 }

◆ getFunEntryICFGNode()

FunEntryICFGNode * ICFG::getFunEntryICFGNode ( const SVFFunction fun)

Add a function entry node.

Get a basic block ICFGNode TODO:: need to fix the assertions

Definition at line 234 of file ICFG.cpp.

235{
237 assert (entry && "fun entry not created in ICFGBuilder?");
238 return entry;
239}
FunEntryICFGNode * getFunEntryBlock(const SVFFunction *fun)
Get/Add a function entry node.
Definition ICFG.h:287

◆ getFunExitBlock()

FunExitICFGNode * SVF::ICFG::getFunExitBlock ( const SVFFunction fun)
inlineprivate

Get/Add a function exit node.

Definition at line 296 of file ICFG.h.

297 {
298 FunToFunExitNodeMapTy::const_iterator it = FunToFunExitNodeMap.find(fun);
299 if (it == FunToFunExitNodeMap.end())
300 return nullptr;
301 return it->second;
302 }

◆ getFunExitICFGNode()

FunExitICFGNode * ICFG::getFunExitICFGNode ( const SVFFunction fun)

Add a function exit node.

Definition at line 241 of file ICFG.cpp.

242{
243 FunExitICFGNode* exit = getFunExitBlock(fun);
244 assert (exit && "fun exit not created in ICFGBuilder?");
245 return exit;
246}
FunExitICFGNode * getFunExitBlock(const SVFFunction *fun)
Get/Add a function exit node.
Definition ICFG.h:296

◆ getGlobalICFGNode()

GlobalICFGNode * SVF::ICFG::getGlobalICFGNode ( ) const
inline

Definition at line 236 of file ICFG.h.

237 {
238 return globalBlockNode;
239 }

◆ getICFGEdge()

ICFGEdge * ICFG::getICFGEdge ( const ICFGNode src,
const ICFGNode dst,
ICFGEdge::ICFGEdgeK  kind 
)

Get a SVFG edge according to src and dst.

Return the corresponding ICFGEdge

Definition at line 303 of file ICFG.cpp.

304{
305
306 ICFGEdge * edge = nullptr;
307 u32_t counter = 0;
308 for (ICFGEdge::ICFGEdgeSetTy::iterator iter = src->OutEdgeBegin();
309 iter != src->OutEdgeEnd(); ++iter)
310 {
311 if ((*iter)->getDstID() == dst->getId() && (*iter)->getEdgeKind() == kind)
312 {
313 counter++;
314 edge = (*iter);
315 }
316 }
317 assert(counter <= 1 && "there's more than one edge between two ICFG nodes");
318 return edge;
319
320}
unsigned u32_t
Definition CommandLine.h:18
iterator OutEdgeEnd()
iterator OutEdgeBegin()
iterators
NodeID getId() const
Get ID.

◆ getICFGNode()

ICFGNode * SVF::ICFG::getICFGNode ( NodeID  id) const
inline

Get a ICFG node.

Definition at line 86 of file ICFG.h.

87 {
88 return getGNode(id);
89 }
NodeType * getGNode(NodeID id) const
Get a node.

◆ getIcfgNodeToSVFLoopVec()

const ICFGNodeToSVFLoopVec & SVF::ICFG::getIcfgNodeToSVFLoopVec ( ) const
inline

Definition at line 137 of file ICFG.h.

138 {
140 }

◆ getRepNode()

const ICFGNode * SVF::ICFG::getRepNode ( const ICFGNode node) const
inline

Definition at line 246 of file ICFG.h.

247 {
248 return _repNode.at(node);
249 }

◆ getSubNodes()

const std::vector< const ICFGNode * > & SVF::ICFG::getSubNodes ( const ICFGNode node) const
inline

Definition at line 241 of file ICFG.h.

242 {
243 return _subNodes.at(node);
244 }

◆ getSVFLoops()

SVFLoopVec & SVF::ICFG::getSVFLoops ( const ICFGNode node)
inline

Get loops where a node resides.

Definition at line 130 of file ICFG.h.

131 {
132 auto it = icfgNodeToSVFLoopVec.find(node);
133 assert(it != icfgNodeToSVFLoopVec.end() && "node not in loop");
134 return it->second;
135 }

◆ hasICFGNode()

bool SVF::ICFG::hasICFGNode ( NodeID  id) const
inline

Whether has the ICFGNode.

Definition at line 92 of file ICFG.h.

93 {
94 return hasGNode(id);
95 }
bool hasGNode(NodeID id) const
Has a node.

◆ hasInterICFGEdge()

ICFGEdge * ICFG::hasInterICFGEdge ( ICFGNode src,
ICFGNode dst,
ICFGEdge::ICFGEdgeK  kind 
)

Whether we has an inter ICFG edge

Definition at line 268 of file ICFG.cpp.

269{
270 ICFGEdge edge(src,dst, kind);
273 if (outEdge && inEdge)
274 {
275 assert(outEdge == inEdge && "edges not match");
276 return outEdge;
277 }
278 else
279 return nullptr;
280}
bool hasIncomingEdge() const
Has incoming/outgoing edge set.
bool hasOutgoingEdge() const

◆ hasIntraICFGEdge()

ICFGEdge * ICFG::hasIntraICFGEdge ( ICFGNode src,
ICFGNode dst,
ICFGEdge::ICFGEdgeK  kind 
)

Whether we has a SVFG edge.

Whether we has an intra ICFG edge

Definition at line 251 of file ICFG.cpp.

252{
253 ICFGEdge edge(src,dst,kind);
256 if (outEdge && inEdge)
257 {
258 assert(outEdge == inEdge && "edges not match");
259 return outEdge;
260 }
261 else
262 return nullptr;
263}

◆ hasThreadICFGEdge()

ICFGEdge * ICFG::hasThreadICFGEdge ( ICFGNode src,
ICFGNode dst,
ICFGEdge::ICFGEdgeK  kind 
)

Whether we has an thread ICFG edge

Definition at line 285 of file ICFG.cpp.

286{
287 ICFGEdge edge(src,dst,kind);
290 if (outEdge && inEdge)
291 {
292 assert(outEdge == inEdge && "edges not match");
293 return outEdge;
294 }
295 else
296 return nullptr;
297}

◆ isInLoop()

bool SVF::ICFG::isInLoop ( const ICFGNode node)
inline

Whether node is in a loop.

Definition at line 117 of file ICFG.h.

118 {
119 auto it = icfgNodeToSVFLoopVec.find(node);
120 return it != icfgNodeToSVFLoopVec.end();
121 }

◆ removeICFGEdge()

void SVF::ICFG::removeICFGEdge ( ICFGEdge edge)
inlineprotected

Remove a ICFG edge.

Definition at line 151 of file ICFG.h.

152 {
153 edge->getDstNode()->removeIncomingEdge(edge);
154 edge->getSrcNode()->removeOutgoingEdge(edge);
155 delete edge;
156 }

◆ removeICFGNode()

void SVF::ICFG::removeICFGNode ( ICFGNode node)
inlineprotected

Remove a ICFGNode.

Definition at line 159 of file ICFG.h.

160 {
161 removeGNode(node);
162 }
void removeGNode(NodeType *node)
Delete a node.

◆ updateCallGraph()

void ICFG::updateCallGraph ( PTACallGraph callgraph)

update ICFG for indirect calls

Update ICFG for indirect calls

if this is an external function (no function body), connect calleeEntryNode to calleeExitNode

Remove callBlockNode to retBlockNode intraICFGEdge since we found at least one inter procedural edge

Definition at line 419 of file ICFG.cpp.

420{
421 PTACallGraph::CallEdgeMap::const_iterator iter = callgraph->getIndCallMap().begin();
422 PTACallGraph::CallEdgeMap::const_iterator eiter = callgraph->getIndCallMap().end();
423 for (; iter != eiter; iter++)
424 {
425 CallICFGNode* callBlockNode = const_cast<CallICFGNode*>(iter->first);
426 assert(callBlockNode->isIndirectCall() && "this is not an indirect call?");
427 const PTACallGraph::FunctionSet & functions = iter->second;
428 for (PTACallGraph::FunctionSet::const_iterator func_iter = functions.begin(); func_iter != functions.end(); func_iter++)
429 {
430 const SVFFunction* callee = *func_iter;
431 RetICFGNode* retBlockNode = const_cast<RetICFGNode*>(callBlockNode->getRetICFGNode());
433 if (isExtCall(callee))
434 addIntraEdge(callBlockNode, retBlockNode);
435 else
436 {
439 if(ICFGEdge* callEdge = addCallEdge(callBlockNode, calleeEntryNode))
440 {
441 for (const SVFStmt *stmt : callBlockNode->getSVFStmts())
442 {
443 if(const CallPE *callPE = SVFUtil::dyn_cast<CallPE>(stmt))
444 {
445 if(callPE->getFunEntryICFGNode() == calleeEntryNode)
446 SVFUtil::cast<CallCFGEdge>(callEdge)->addCallPE(callPE);
447 }
448 }
449 }
451 {
452 for (const SVFStmt *stmt : retBlockNode->getSVFStmts())
453 {
454 if(const RetPE *retPE = SVFUtil::dyn_cast<RetPE>(stmt))
455 {
456 if(retPE->getFunExitICFGNode() == calleeExitNode)
457 SVFUtil::cast<RetCFGEdge>(retEdge)->addRetPE(retPE);
458 }
459 }
460 }
461
465 }
466
467 }
468 }
469 // dump ICFG
470 if (Options::DumpICFG())
471 {
472 dump("icfg_final");
473 }
474}
const RetICFGNode * getRetICFGNode() const
Return callsite.
Definition ICFGNode.h:457
bool isIndirectCall() const
Return true if this is an indirect call.
Definition ICFGNode.h:482
void removeICFGEdge(ICFGEdge *edge)
Remove a ICFG edge.
Definition ICFG.h:151
ICFGEdge * addCallEdge(ICFGNode *srcNode, ICFGNode *dstNode)
Definition ICFG.cpp:366
void dump(const std::string &file, bool simple=false)
Dump graph into dot file.
Definition ICFG.cpp:403
ICFGEdge * addRetEdge(ICFGNode *srcNode, ICFGNode *dstNode)
Definition ICFG.cpp:384
ICFGEdge * addIntraEdge(ICFGNode *srcNode, ICFGNode *dstNode)
Add intraprocedural and interprocedural control-flow edges.
Definition ICFG.cpp:325
static const Option< bool > DumpICFG
Definition Options.h:123
CallEdgeMap & getIndCallMap()
Get callees from an indirect callsite.
Set< const SVFFunction * > FunctionSet
bool isExtCall(const SVFFunction *fun)
Definition SVFUtil.h:278

◆ updateRepNode()

void SVF::ICFG::updateRepNode ( const ICFGNode rep,
const ICFGNode sub 
)
inlineprivate

when ICFG is simplified, some node would be removed, this map records the removed node to its rep node

Definition at line 271 of file ICFG.h.

272 {
273 _repNode[rep] = sub;
274 }

◆ updateSubAndRep()

void SVF::ICFG::updateSubAndRep ( const ICFGNode rep,
const ICFGNode sub 
)
inline

Definition at line 252 of file ICFG.h.

253 {
254 addSubNode(rep, sub);
255 updateRepNode(rep, sub);
256 }
void updateRepNode(const ICFGNode *rep, const ICFGNode *sub)
when ICFG is simplified, some node would be removed, this map records the removed node to its rep nod...
Definition ICFG.h:271
void addSubNode(const ICFGNode *rep, const ICFGNode *sub)
when ICFG is simplified, SubNode would merge repNode, then update the map
Definition ICFG.h:261

◆ view()

void ICFG::view ( )

View graph from the debugger.

View ICFG

Definition at line 411 of file ICFG.cpp.

412{
413 SVF::ViewGraph(this, "Interprocedural Control-Flow Graph");
414}
void ViewGraph(const GraphType &G, const std::string &name, bool ShortNames=false, GraphProgram::Name Program=GraphProgram::DOT)

Friends And Related Symbol Documentation

◆ ICFGBuilder

Definition at line 49 of file ICFG.h.

◆ ICFGSimplification

friend class ICFGSimplification
friend

Definition at line 52 of file ICFG.h.

◆ SVFIRReader

Definition at line 51 of file ICFG.h.

◆ SVFIRWriter

Definition at line 50 of file ICFG.h.

Member Data Documentation

◆ _repNode

Map<const ICFGNode*, const ICFGNode*> SVF::ICFG::_repNode
private

map a subnode to its representative node(1st node of basicblock)

Definition at line 75 of file ICFG.h.

◆ _subNodes

Map<const ICFGNode*, std::vector<const ICFGNode*> > SVF::ICFG::_subNodes
private

map a node(1st node of basicblock) to its subnodes

Definition at line 74 of file ICFG.h.

◆ FunToFunEntryNodeMap

FunToFunEntryNodeMapTy SVF::ICFG::FunToFunEntryNodeMap
private

map a function to its FunExitICFGNode

Definition at line 69 of file ICFG.h.

◆ FunToFunExitNodeMap

FunToFunExitNodeMapTy SVF::ICFG::FunToFunExitNodeMap
private

map a function to its FunEntryICFGNode

Definition at line 70 of file ICFG.h.

◆ globalBlockNode

GlobalICFGNode* SVF::ICFG::globalBlockNode
private

unique basic block for all globals

Definition at line 71 of file ICFG.h.

◆ icfgNodeToSVFLoopVec

ICFGNodeToSVFLoopVec SVF::ICFG::icfgNodeToSVFLoopVec
private

map ICFG node to the SVF loops where it resides

Definition at line 72 of file ICFG.h.

◆ totalICFGNode

NodeID SVF::ICFG::totalICFGNode

Definition at line 66 of file ICFG.h.


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