
























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A lecture note from the university of michigan's eecs 483 course on dataflow analysis. It covers topics such as liveness, generalized dataflow analysis, and the transfer and meet functions. The document also includes examples and problems for students to work on.
Typology: Study notes
1 / 32
This page cannot be seen from the preview
Don't miss anything!

























Liveness
» For each point p in a program and each variable y,
determine whether y can be used before beingredefined starting at p
Reaching defs:
» A definition d reaches a point p if there is a path from
the point immediately following d to p such that d isnot “killed” along that path
» A definition is killed between 2 points when there is
another definition of the same variable along the path
» Represent with DU/UD chains
r1 = 3 r2 = r3r3 = r
r1 = r1 + 1 r7 = r1 * r
r2 = 0
r2 = r2 + 1
r4 = r2 + r1 r9 = r4 + r
Note, I’ve shown the DU chains. UD chains are the reverse
Y
Liveness and reaching defs are basicallythe same thing!!!!!!!!!!!!!!!!!!
» All dataflow is basically the same with a few
parameters
y
Meaning of gen/kill (use/def)
y
Backward / Forward
y
All paths / some paths (must/may)
X
X
Y
Dataflow can be slow
» How to implement it efficiently? » How to represent the info?
Y
while (change)
» change = false » for each BB
y
apply meet function
y
apply transfer function
y
if any changes
Æ
change = true
Y
Liveness = upward exposed uses
Upward exposed defs
y
GEN += dest; KILL += dest
Downward exposed uses
y
GEN += src; KILL -= src;
y
GEN -= dest; KILL += dest;
Downward exposed defs
y
GEN += dest; KILL += dest;
Example – Upward Exposed Defs
up_def_OUT =
A definition d is available
at a point p if along all
paths from d to p, d is not killed
Remember, a definition of a variable is killed between 2 points when there is another definitionof that variable along the path
» r1 = r2 + r3 kills previous definitions of r
Algorithm
» Forward dataflow analysis as propagation occurs from
defs downwards
» Use the Intersect function as the meet operator to
guarantee the all-path requirement
» GEN/KILL/IN/OUT similar to reaching defs
U = universal set of all operations in the Procedure IN(0) = 0 OUT(0) = GEN(0) for each basic block in procedure, W, (W != 0), do
change = 1 while
(change) do
change = 0 for
each basic block in procedure, X, do
old_OUT = OUT(X) IN(X) = Intersect(OUT(Y)) for all predecessors Y of X OUT(X) = GEN(X) + (IN(X) – KILL(X)) if
(old_OUT != OUT(X)) then
change = 1
endif
endfor
endfor
1: r1 = MEM[r2+0] 2: r2 = r2 + 1 3: r3 = r1 * r
4: r1 = r1 + 5 5: r3 = r5 – r1 6: r8 = r3 * 2
7: r7 = 0 8: r1 = r1 + 5 9: r7 = r1 - 6
10: r8 = r7 + r8 11: r1 = r3 – r8 12: r3 = r1 * 2
Compute the Aexpr IN/OUT sets for each BB
1: r1 = r6 * r9 2: r2 = r2 + 1 3: r5 = r3 * r
4: r1 = r2 + 1 5: r3 = r3 * r4 6: r8 = r3 * 2
7: r7 = r3 * r4 8: r1 = r1 + 5 9: r7 = r1 - 6
10: r8 = r2 + 1 11: r1 = r3 * r4 12: r3 = r6 * r
Y
Order basic blocks are visited is important(faster convergence)
Y
Forward analysis – DFS order
» Visit a node only when all its predecessors
have been visited
Y
Backward analysis – PostDFS order
» Visit a node only when all of its successors
have been visited