dataflow analysis
reasoning about flow of data in program
different kinds of dataflow analysis
constants, variables, expressions
what do dataflow analysis used in
bug-finding tools and compilers
what is a control-flow graph?
a graph that summarizes the flow of control in all possible runs of the program
what does each node represent?
a unique primitive statement
what does each edge represent?
denotes immediate possible successor
can we achieve soundness, completeness, and termination?
no
what does dataflow analysis sacrifice?
completeness
How does dataflow analysis sacrifice completeness?
abstract away control-flow condition with non-deterministic choice
what non-deterministic choice does dataflow analysis use?
assume a condition can be evaluated to true or false. It considers path that is not possible in the actual run, thus incomplete
applications of dataflow analysis
reaching definition analysis, very busy expression analysis, available expression analysis, and live variable analysis.
reaching definition analysis
find usages of uninitialized variables
very busy expression analysis
reduce code size (use in pacemakers)
available expression analysis
use by the compiler to avoid recomputing expressions. Start with all available expression, and cross each out whenever it changes.
live variable analysis
use by the compiler to efficiently allocate registers to program variables
reaching definition analysis’ goal
result of dataflow analysis (informally)
result of dataflow analysis (formally)
(reaching definition analysis operation 1) how to compute IN[n]
IN[n] = U(OUT[predecessors(n)])
(reaching definition analysis operation 2) how to compute OUT[n]
OUT(n) = (IN[n] - KILL[n]) U GEN[n]
(reaching definition analysis) KILL[n]) & GEN[n] of a condtion
empty sets
(reaching definition analysis) KILL[n] & GEN[n] of an assignment
GEN[n] = {}; KILL[n]={: m!=n}
(reaching definition analysis) Chaotic Iteration
for (each node n):
IN[n] = OUT[n] = null
OUT[entry] = {: v is a program variable}
Repeat:
for each node n: operation1; operation2; until IN[n] & OUT[n] stop changingwhy does it always terminate