lecture-11 - More Dataow Analysis Friday Recall steps to...

Info icon This preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
More Dataflow Analysis Friday, November 19, 2010
Image of page 1

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

View Full Document Right Arrow Icon
Recall steps to building analysis Step 1: Choose lattice Step 2: Choose direction of dataflow (forward or backward) Step 3: Create monotonic transfer function Step 4: Choose confluence operator ( i.e. , what to do at merges) Either join or meet in the lattice Let’s walk through these steps for a new analysis Friday, November 19, 2010
Image of page 2
Liveness analysis Which variables are live at a particular program point? Used all over the place in compilers Register allocation Loop optimizations Friday, November 19, 2010
Image of page 3

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

View Full Document Right Arrow Icon
Choose lattice What do we want to know? At each program point, want to maintain the set of variables that are live Lattice elements: sets of variables Natural choice for lattice: powerset of variables! { } {a} {b} {c} {a,b} {a,c} {b,c} {a,b,c} Friday, November 19, 2010
Image of page 4
Choose dataflow direction A variable is live if it is used later in the program without being redefined At a given program point, we want to know information about what happens later in the program This means that liveness is a backwards analysis Recall that we did liveness backwards when we looked at single basic blocks Friday, November 19, 2010
Image of page 5

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

View Full Document Right Arrow Icon
Create x-fer functions What do we do for a statement like: x = y + z If x was live “before” (i.e., live after the statement), it isn’t now (i.e., is not live before the statement) If y and z were not live “before,” they are now What about: x = x Friday, November 19, 2010
Image of page 6
Create x-fer functions Let’s generalize For any statement s , we can look at which live variables are killed , and which new variables are made live ( generated ) Which variables are killed in s ? The variables that are defined in s : DEF( s ) Which variables are made live in s ? The variables that are used in s : USE( s ) If the set of variables that are live after s is X, what is the set of variables live before s ? Is this monotonic? T s ( X ) = use ( s ) ( X - def ( s )) Friday, November 19, 2010
Image of page 7

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

View Full Document Right Arrow Icon
Dealing with aliases Aliases, as usual, cause problems Consider What should USE(*z = *w) and DEF(*z = *w) be? Keep in mind: the goal is to get a list of variables that may be live at a program point For now, assume there is no aliasing int x, y int *z, *w; if (...) z = &y else z = &x if (...) w = &y else w = &x *z = *w; //which variable is defined? which is used? Friday, November 19, 2010
Image of page 8
Dealing with function calls Similar problem as aliases: Simple solution: functions can do anything – redefine variables, use variables So DEF(foo()) is { } and USE(foo()) is V Real solution: interprocedural analysis, which determines what
Image of page 9

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

View Full Document Right Arrow Icon
Image of page 10
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