05 - Putting Data Flow Analysis to Work Last Time Iterative...

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

View Full Document Right Arrow Icon
Putting Data Flow Analysis to Work Last Time Iterative Worklist Algorithm via Reaching Defnitions Why it terminates. What it computes. Why it works. How Fast it goes. Today Live Variable Analysis (backward problem) Constant Propagation: A Progression in Analysis CS 380C Lecture 5 1 Data ±low Analysis Live Variable Analysis Can a variable v at a point p be used beFore it is redefned along some path starting at p ? USE( p ) - the set oF variables that may be used beFore they are defned by this statement or basic block . DE±( p ) - the set oF variables that may be defned by this statement or basic block. 0: read I 1: read N 2: call check (N) 3: I = 1 4: while (I < N) do 5: A(i) = A(i) + I 6: I = I + 1 7: endwhile 8: print A(N) CS 380C Lecture 5 2 Data ±low Analysis
Background image of page 1

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

View Full DocumentRight Arrow Icon
Live Variable Analysis Abackwa rddatafowp rob lem : For each point p in the program and each variable x ,dete rm inewhethe r x can be used before being rede±ned along some path starting at p . For a basic block, x is live if it is used before being rede±ned within that block, or if it is live going out of the block. IN( v ) is the set variables live coming into a block, and OUT( v ) is the set of variables live going out of a block. USE(v): x USE(v) i² x may be used before it is de±ned in v DEF(v): x DEF(v) i² x must be de±ned before it is used in v (DEF(v) == KILL(v)) OUT ( v )= S s SUCC ( v ) IN ( s ) IN ( v USE ( v ) S ( OUT ( v ) - DEF ( v )) The monotone data fow Framework uses powerset of X (all variables) lattice. The transfer function T v ( x USE ( v ) [ ( x - DEF ( v )) The meet is set union. The operation space is monotone and distributive, therefore the solution will result in the MOP solution. CS 380C Lecture 5 3 Data Flow Analysis Work List Iterative Algorithm Rehashed initialization worklist the set of all nodes while ( worklist ± = /0 ) pick and remove a node n from worklist recompute Data Flow Equations if the answer changed then add a²ected nodes to worklist Initialization: OUT( v ) IN( v ) Data ³ow equations: OUT( v ) IN( v ) CS 380C Lecture 5 4 Data Flow Analysis
Background image of page 2
Live Variable Algorithm Algorithm: for all v OUT( v )= /0 IN( v )=USE( v )
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

05 - Putting Data Flow Analysis to Work Last Time Iterative...

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

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