![](/rp/kFAqShRrnkQMbH6NYLBYoJ3lq9s.png)
Control Flow Graph (CFG) – Software Engineering
2024年11月22日 · A Control Flow Graph (CFG) is the graphical representation of control flow or computation during the execution of programs or applications. Control flow graphs are mostly used in static analysis as well as compiler applications, as they can accurately represent the flow inside a program unit.
17.8 Application: Control Flow Graphs - Department of Computer …
A control-flow graph (CFG) of a program is a graph \(G = (V, E)\) where: \(V\) is the set of all (maximal) basic blocks in the program code, plus one special elements representing the end of a program.
Control-Flow Graphs •Graphical representation of a program •Edges in graph represent control flow: how execution traverses a program •Nodes represent statements 6 x := 0; y := 0; while (n > 0) {if (n % 2 = 0) {x := x + n; y := y + 1;} else {y := y + n; x := x + 1;} n := n - 1;} print(x); x:=x+n y:=y+1 y := 0 n > 0 n%2=0 y:=y+n print(x) n ...
Control Flow Graph (CFG) A control flow graph(CFG), or simply a flow graph, is a directed graph in which: –(i) the nodes are basic blocks; and –(ii) the edges are induced from the possible flow of the program The basic block whose leader is the first intermediate language statement is …
Control Flow Graph (CFG) - GitHub Pages
A Control Flow Graph (CFG) is a compact and intuitive representation of all control flow paths in a program. Nodes in the CFG are called basic blocks, which contains statement numbers that are known to be executed one by one in sequence.
Control Flow Graph (CFG) A control flow graph (CFG), or simply a flow graph, is a directed graph in which: –(i) the nodes are basic blocks; and –(ii) the edges are induced from the possible flow of the program The basic block whose leader is the first intermediate language statement is …
Control Flow Graphs • Control Flow Graph (CFG) = graph representation of computation and control flow in the program – framework to statically analyze program control-flow •In a CFG: – Nodes are basic blocks; they represent computation – Edges characterize control flow between basic blocks • Can build the CFG representation either ...
Flowing through the Graph: • Given the available expressions Din[L] that flow into a block labeled L, we can compute the definitions Dout[L] that flow out by just using the gen & kill's for each statement in L's block. • For each block L, we can define: – succ[L] = the blocks L might jump to.
2 Control Flow Analysis 7 Identify Basic Blocks Input: A sequence of intermediate code statements 1. Determine the leaders, the first statements of basic blocks • The first statement in the sequence (entry point) is a leader • Any statement that is the target of a branch (conditional or unconditional) is a leader
CONTROL FLOW GRAPHS • Motivation: language-independent and machine-independent representation of control flow in programs used in high-level and low-level code optimizers . The flow graph data structure lends itself to use of several important algorithms from graph theory.