lecture-11-6up

lecture-11-6up - Recall steps to building analysis More...

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

View Full Document Right Arrow Icon
More Datafow Analysis Friday, November 19, 2010 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 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 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 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 Friday, November 19, 2010 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
Background image of page 1

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

View Full Document Right Arrow Icon
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 )) Friday, November 19, 2010 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 – rede±ne variables, use variables So DEF(foo()) is { } and USE(foo()) is V Real solution: interprocedural analysis, which determines what
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 5

lecture-11-6up - Recall steps to building analysis More...

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

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