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

Info icon This 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 Definitions 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 Flow Analysis Live Variable Analysis Can a variable v at a point p be used before it is redefined along some path starting at p ? USE( p ) - the set of variables that may be used before they are defined by this statement or basic block . DEF( p ) - the set of variables that may be defined 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 Flow Analysis
Image of page 1

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

View Full Document Right Arrow Icon
Live Variable Analysis A backward data flow problem: For each point p in the program and each variable x , determine whether x can be used before being redefined along some path starting at p . For a basic block, x is live if it is used before being redefined 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 ff x may be used before it is defined in v DEF(v): x DEF(v) i ff x must be defined 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 flow 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 ff ected nodes to worklist Initialization: OUT( v ) IN( v ) Data flow equations: OUT( v ) IN( v ) CS 380C Lecture 5 4 Data Flow Analysis
Image of page 2
Live Variable Algorithm Algorithm: for all v OUT( v ) = /0 IN(
Image of page 3

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern