lecture-12

# lecture-12 - More Dataow Analysis Monday Recall steps to...

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

More Datafow Analysis Monday, November 14, 2011

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 dataFow (forward or backward) Step 3: Create monotonic transfer function Step 4: Choose confuence 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 Monday, November 14, 2011
Liveness analysis Which variables are live at a particular program point? Used all over the place in compilers Register allocation Loop optimizations Monday, November 14, 2011

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} Monday, November 14, 2011
Choose datafow direction A variable is live iF it is used later in the program without being rede±ned 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 Monday, November 14, 2011

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 Monday, November 14, 2011
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 defned 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 )) Monday, November 14, 2011

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? Monday, November 14, 2011
Dealing with function calls Similar problem as aliases: Simple solution: functions can do anything – redeFne variables, use variables So DE±(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 ]}

### Page1 / 30

lecture-12 - More Dataow Analysis Monday Recall steps to...

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

View Full Document
Ask a homework question - tutors are online