583L6 - EECS 583 – Class 6 Dataflow Analysis University...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: EECS 583 – Class 6 Dataflow Analysis University of Michigan September 26, 2011 - 1 - Announcements & Reading Material Today’s class » Compilers: Principles, Techniques, and Tools , A. Aho, R. Sethi, and J. Ullman, Addison-Wesley, 1988. (Sections: 10.5, 10.6, 10.9, 10.10) Material for Wednesday » Compilers: Principles, Techniques, and Tools , A. Aho, R. Sethi, and J. Ullman, Addison-Wesley, 1988, 9.9, 10.2, 10.3, 10.7 - 2 - Live Variable (Liveness) Analysis Defn: For each point p in a program and each variable y, determine whether y can be used before being redefined 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 » GEN = set of external variables consumed in the BB » KILL = set of external variable uses killed by the BB equivalent to set of variables defined by 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 - 3 - Computing GEN/KILL Sets For Each BB for each basic block in the procedure, X, do GEN(X) = 0 KILL(X) = 0 for each operation in reverse sequential order in X, op, do for each destination operand of op, dest, do GEN(X) -= dest KILL(X) += dest endfor for each source operand of op, src, do GEN(X) += src KILL(X) -= src endfor endfor endfor - 4 - Compute IN/OUT Sets for all BBs initialize IN(X) to 0 for all basic blocks X change = 1 while (change) do change = 0 for each basic block in procedure, X, do old_IN = IN(X) OUT(X) = Union(IN(Y)) for all successors Y of X IN(X) = GEN(X) + (OUT(X) – KILL(X)) if (old_IN != IN(X)) then change = 1 endif endfor endfor - 5 - Example – Liveness Computation OUT = Union(IN(succs)) IN = GEN + (OUT – KILL ) r1 = MEM[r2+0] r2 = MEM[r1 + 1] r8 = r1 * r2 r1 = r1 + 5 r3 = r5 – r1 r7 = r3 * 2 r2 = 0 r7 = r1 + r2 r3 = 4 r3 = r3 + r7 r1 = r2 – r8 r3 = r1 * 2 BB1 BB2 BB3 BB4 - 6 - Class Problem r1 = 3 r2 = r3 r3 = r4 r1 = r1 + 1 r7 = r1 * r2 r4 = r4 + 1 r4 = r3 + r2 r8 = 8 r9 = r7 + r8 Compute liveness Calculate GEN/KILL for each BB Calculate IN/OUT for each BB - 7 - Reaching Definition Analysis (rdefs) A definition of a variable x is an operation that assigns, or may assign, a value to x A definition d reaches a point p if there is a path from the point immediately following d to p such that d is not “killed” along that path A definition of a variable is killed between 2 points when...
View Full Document

{[ snackBarMessage ]}

Page1 / 25

583L6 - EECS 583 – Class 6 Dataflow Analysis University...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online