































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
































Program Analysis
6 Jan 2004
290G - Lecture 1a
What is Program Analysis For?
6 Jan 2004
290G - Lecture 1a
Dataflow Analysis
Part 1
6 Jan 2004
290G - Lecture 1a
Control-Flow Graphs
6 Jan 2004
290G - Lecture 1a
x := a + b; y := a * b; while y > a + b {
a := a + 1;^ x := a + b
}
if y > a + b a := a + 1 x := a + b x := a + b y := a * b
Available Expressions
6 Jan 2004
290G - Lecture 1a
For each program pointp, which expressionsmust have already beencomputed, and not latermodified, on all paths top.
if y > a + b a := a + 1 x := a + b x := a + b y := a * b
a+b isavailablehere
Optimization: Whereavailable, expressionsneed not berecomputed.
Dataflow Equations
6 Jan 2004
290G - Lecture 1a
8 / 39
(
)
if
otherwise
|if
in
out
s
pred
s
out
in
′∈
I
Liveness Analysis
6 Jan 2004
290G - Lecture 1a
For each program pointp, which of thevariables defined atthat point are used onsome execution path?
if y > a + b a := a + 1 x := a + b x := a + b y := a * b
x is notlive here
Optimization: If avariable is not live, noneed to keep it in aregister.
Dataflow Equations
6 Jan 2004
290G - Lecture 1a
11 / 39
(
)
(
)
(
(
)
(
))
(
)
if
(
)
(
)
(
)
otherwise
out
in out
in
s
succ s
L
s
L
s
write s
read s
succ s
L
s
L
s
′∈
=
−
∪
∅
= ∅
⎧
⎫
⎪
⎪
= ⎨
⎬
′
⎪
⎪
⎩
⎭
U
Available Expressions Again
6 Jan 2004
290G - Lecture 1a
13 / 39
(
)
if
otherwise
in
out
s
pred
s
out
in
′∈
Available Expressions: Schematic
6 Jan 2004
290G - Lecture 1a
(
)
1
2
out
in
s
pred
s
out
in
′∈
Transfer function:
Must analysis: property holds on all paths Forwards analysis: from inputs to outputs
Live Variables: Schematic
6 Jan 2004
290G - Lecture 1a
1
2
(
)
(
)
(
)
(
)
(
)
out
in out
in
s
succ s
L
s
L
s
C
C
L
s
L
s
′∈
=
−
∪
′
=
U
Transfer function:
May analysis: property holds on some path Backwards analysis: from outputs to inputs
Very Busy Expressions
6 Jan 2004
290G - Lecture 1a
e is very busy at program point
p if every path from p must evaluate e beforeany variable in e is redefined
One Cut at the Dataflow Design Space
6 Jan 2004
290G - Lecture 1a
May
Must
Forwards
Reachingdefinitions
Availableexpressions
Backwards
Live variables
Very busyexpressions
The Literature
6 Jan 2004
290G - Lecture 1a