Practical differences between control flow graph and call (flow?) graph?
Asked Answered
P

2

12

Wikipedia has a definition for a control flow graph. I've also heard terminology thrown around referring to 'call (flow?) graph', but can't find any relevant resources. What is the relationship between the two?

Perspiratory answered 27/3, 2012 at 11:58 Comment(2)
I don't think that "call flow graph" is a standard term. Where'd you stumble upon it?Scenic
I think OP meant "call graph".Danitadaniyal
T
33

Wikipedia defines a call graph as a representation of the calling relationships between subroutines in a program. In a call graph, an edge between two nodes f and g:

      f --> g

represents the fact that subroutine f calls subroutine g. A call graph gives an inter-procedural view of a program.

A control flow graph (CFG) provides finer "details" into the structure of the program as a whole, and of the subroutines in particular. For instance, the CFG of a subroutine f will make explicit all of the paths that are induced by a conditional branch:

                             / branch1 \
    begin --> condition -->             --> codeblock --> g --> end
                             \ branch2 /

This kind of CFG is used to build an intra-procedural view of a subroutine.

Trichloromethane answered 27/3, 2012 at 12:56 Comment(1)
+1 from me.. BTW I would not use the definition on Wikipedia as authoritative.Danitadaniyal
R
9

Call graphs (CG) and control flow graphs (CFG) consist of nodes and edges. CG is interprocedural, nodes represent subroutines (methods, functions, ...), while edges represent the relationship caller-called between two subroutines (e.g., A->B, "A" is the caller subroutine, while "B" is the called subroutine). CFG is intraprocedural, nodes represent program statements, including called subroutines but also conditionals, while edges represent the flow of the program. When CG and CFG are combined, it is called interprocedural control flow graph (ICFG). CFG generation is more resource-intensive than CG but more detailed.

Regardant answered 14/1, 2020 at 18:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.