

























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, focusing on dataflow analysis. The notes cover the concepts of liveness analysis and reaching definitions analysis. Students are encouraged to work on project 3 and prepare for exam 2. Examples and calculations for both liveness and reaching definitions analysis.
Typology: Study Guides, Projects, Research
1 / 33
This page cannot be seen from the preview
Don't miss anything!


























Project 3 – should have started work on this
Schedule for the rest of the semester
» Today – Dataflow analysis » Wednes 11/29 – Finish dataflow, optimizations » Mon 12/4 – Optimizations, start on register allocation » Wednes 12/6 – Register allocation, Exam 2 review » Mon 12/11 – Exam 2 in class » Wednes 12/13 – No class (Project 3 due)
Reading for today’s class
» 10.5, 10.6. 10.10, 10.
Pick an arbitrary point in the program Which VRs contain useful data values?(liveness or upward exposed uses)Which definitions may reachthis point? (reaching defns)Which definitions are guaranteedto reach this point? (available defns)Which uses below are exposed?(downward exposed uses)
r1 = r2 + r3r6 = r4 – r
r4 = 4r6 = 8
r6 = r2 + r3r7 = r4 – r
Dataflow analysis
that summarizes the creation/destruction of values in a program. Used to identify legal optimization opportunities.
Defn: For each point p in a program and each variabley, determine whether y can be used before beingredefined starting at p
Algorithm sketch
» For each BB, y is live if it is used before defined in the BB or
it is live leaving the block
» Backward dataflow analysis as propagation occurs from uses
upwards to defs
4 sets
» USE = set of external variables consumed in the BB » DEF = set of variables defined in the BB » IN = set of variables that are live at the entry point of a BB » OUT = set of variables that are live at the exit point of a BB
for
each basic block in the procedure, X, do
DEF(X) = 0 USE(X) = 0 for
each operation in sequential order in X, op, do
for
each source operand of op, src, do if
(src not in DEF(X)) then
USE(X) += src
endif
endfor for
each destination operand of op, dest, do DEF(X) += dest
endfor
endfor
endfor
def is the union of all the LHS’s use is all the VRs that are used before defined
r1 = MEM[r2+0]
r2 = r2 + 1 r3 = r1 * r
r1 = r1 + 5 r3 = r5 – r
r7 = r3 * 2
r2 = 0
r7 = 23
r1 = 4
r8 = r7 + 5 r1 = r3 – r
r3 = r1 * 2
USE = r2,r4 DEF = r1,r2,r
USE =
∅
DEF = r1,r2,r
USE = r1,r5 DEF = r1,r3,r
USE = r3,r7 DEF = r1,r3,r
r1 = 3 r2 = r3r3 = r
r1 = r1 + 1 r7 = r1 * r
r2 = 0
r2 = r2 + 1
r4 = r2 + r1 r9 = r4 + r
Compute liveness, ie calculate USE/DEF calculate IN/OUT
1: r1 = r2 + r32: r6 = r4 – r
3: r4 = 44: r6 = 8
5: r6 = r2 + r36: r7 = r4 – r
defs 1 and 2 reach this point
defs 1, 3, 4 reach this point def 2 is killed by 4
defs 1, 3, 5, 6 reach this point defs 2, 4 are killed by 5
Algorithm sketch
» Forward dataflow analysis as propagation
occurs from defs downwards
4 sets
» GEN = set of definitions generated in the BB
(operations not registers like liveness !!)
» KILL = set of definitions killed in the BB » IN = set of definitions reaching the BB entry » OUT = set of definitions reaching the BB exit
1: r1 = MEM[r2+0]2: r2 = r2 + 13: r3 = r1 * r
4: r1 = r1 + 55: r3 = r5 – r16: r7 = r3 * 2
7: r2 = 08: r7 = 239: r1 = 4
10: r8 = r7 + 511: r1 = r3 – r812: r3 = r1 * 2
initialize IN(X) = 0 for all basic blocks X initialize OUT(X) = GEN(X) for all basic blocks X change = 1 while
(change) do
change = 0 for
each basic block in procedure, X, do
old_OUT = OUT(X) IN(X) = Union(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
IN = set of definitions reaching the entry of BB OUT = set of definitions leaving BB
1: r1 = 32: r2 = r33: r3 = r4 4: r1 = r1 + 15: r7 = r1 * r
6: r2 = 0
7: r2 = r2 + 1
8: r4 = r2 + r1 9: r9 = r4 + r
Reaching definitions
Calculate GEN/KILL Calculate IN/OUT
Convenient way to access/use reaching defsinfo
Def-Use chains
» Given a def, what are all the possible
consumers of the operand produced
» Maybe consumer
Use-Def chains
» Given a use, what are all the possible
producers of the operand consumed
» Maybe producer