lecture-11

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

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

More Dataflow Analysis Friday, November 19, 2010

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

View Full Document
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
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

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

View Full Document
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
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

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

View Full Document
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
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

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

View Full Document
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
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

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

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

{[ snackBarMessage ]}

### What students are saying

• 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.

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

• 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.

Dana University of Pennsylvania ‘17, Course Hero Intern

• 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.

Jill Tulane University ‘16, Course Hero Intern