Control-flow graph
top: why don't we link control flow in the lead?
| ← Previous revision | Revision as of 16:58, 19 April 2026 | ||
| Line 4: | Line 4: | ||
[[File:Some types of control flow graphs.svg|thumb|Some CFG examples: (a) an [[if-then-else]] (b) a [[while loop]] (c) a natural loop with two exits, e.g. while with an if...break in the middle; non-structured but reducible (d) an irreducible CFG: a loop with two entry points, e.g. goto into a while or for loop]] |
[[File:Some types of control flow graphs.svg|thumb|Some CFG examples: (a) an [[if-then-else]] (b) a [[while loop]] (c) a natural loop with two exits, e.g. while with an if...break in the middle; non-structured but reducible (d) an irreducible CFG: a loop with two entry points, e.g. goto into a while or for loop]] |
||
[[File:Rust_MIR_CFG.svg|thumb|A control-flow graph used by the [[Rust (programming language)|Rust]] compiler to perform codegen.]] |
[[File:Rust_MIR_CFG.svg|thumb|A control-flow graph used by the [[Rust (programming language)|Rust]] compiler to perform codegen.]] |
||
In [[computer science]], a '''control-flow graph''' ('''CFG''') is a [[Depiction|representation]], using [[directed graph|graph]] notation, of all paths that might be traversed through a [[function (computer programming)|function]] during its [[execution (computing)|execution]]. The control-flow graph was conceived by [[Frances Allen|Frances E. Allen]],{{sfn|Allen|1970}}{{sfn|Allen|Cocke|1976}} who noted that [[Reese Prosser|Reese T. Prosser]] used [[Adjacency matrix|boolean connectivity matrices]] for flow analysis before.{{sfn|Prosser|1959}} |
In [[computer science]], a '''control-flow graph''' ('''CFG''') is a [[Depiction|representation]], using [[directed graph|graph]] notation, of all paths that might be traversed through a [[function (computer programming)|function]] during its [[execution (computing)|execution]], or [[control flow]]. The control-flow graph was conceived by [[Frances Allen|Frances E. Allen]],{{sfn|Allen|1970}}{{sfn|Allen|Cocke|1976}} who noted that [[Reese Prosser|Reese T. Prosser]] used [[Adjacency matrix|boolean connectivity matrices]] for flow analysis before.{{sfn|Prosser|1959}} |
||
The CFG is essential to many [[compiler optimization#Data-flow optimizations|compiler optimization]]s and [[static code analysis|static-analysis]] tools. |
The CFG is essential to many [[compiler optimization#Data-flow optimizations|compiler optimization]]s and [[static code analysis|static-analysis]] tools. |
||