Chapter_10_Liveness_Analysis

# Chapter_10_Liveness_Analysis - Chapter 10 Chapter 10...

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

Chapter 10 Liveness Analysis Chapter 10

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

View Full Document
the compiler needs to analyze the intermediate-representation program to determine ： which temporaries are in use at the same time. a variable is live ： if it holds a value that may be needed in the future. this analysis is called liveness analysis. Chapter 10
a control-flow graph: Each statement in the program is a node in the flow graph. if statement x can be followed by statement y , there is an edge from x to y. Chapter 10

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

View Full Document
The variable a is live from 1 → 2, and again from 4 → 5 → 2, but not from 2 → 3 → 4. Chapter 10
Variable b is used in statement 4, so b is live on the 3 → 4 edge. Statement 3 does not assign into b , then b is also live on the 2 → 3 edge. Statement 2 assigns into b . The contents of b on the 1 → 2 edge are not needed by anyone; b is dead on this edge. So the live range of b is {2 → 3, 3 → 4}. Chapter 10

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

View Full Document
The variable c is live on entry to this program. Perhaps it is a formal parameter. If it is a local variable, then liveness analysis has detected an uninitialized variable. Chapter 10
10.1 SOLUTION OF DATAFLOW EQUATIONS Flow-graph terminology :(1) A flow-graph node has out-edges that lead to successor nodes, and in-edges that come from predecessor nodes. The set pred [ n ] is all the predecessors of node n , and succ [ n ] is the set of successors. the out-edges of node 5 are 5 → 6 and 5 → 2, succ [5] = {2, 6}. The in-edges of 2 are 5 → 2 and 1 → 2, pred [2] = {1, 5}.

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

View Full Document
10.1 Flow-graph terminology :(2) An occurrence of a variable on the right-hand side of an assignment (or in other expressions) uses the variable. the def of a variable as the set of graph nodes that define it; or the def of a graph node as the set of variables that it defines; An assignment to a variable or temporary defines that variable.
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 10/20/2011 for the course COMPUTER S 10586 taught by Professor Jilinwang during the Spring '09 term at Zhejiang University.

### Page1 / 26

Chapter_10_Liveness_Analysis - Chapter 10 Chapter 10...

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

View Full Document
Ask a homework question - tutors are online