Data-flow analysis derives information about the dynamic behavior of a program by only examining the static code
Examples:-
➤ Definition:- A variable is live at a particular point in the program if its value at that point will be used in the future (dead, otherwise).
∴ To compute liveness at a given point, we need to look into the future
➤ Motivation: Register Allocation
➤ What is the live range of b?
Variables a and b are never simultaneously live, so they can share a register
➤ Definition:- A CFG is a graph whose nodes represent program statements and whose directed edges represent control flow
Examples
1 a := 0
2 L1: b := a + 1
3 c := c + b
4 a := b * 2
5 if a < 9 goto L1
6 return c
➤ Flow Graph Terms
Examples
➤ Def (or definition)
➤ Use
➤ More precise definition of liveness
➤ Data-flow
Liveness of variables is a property that flows through the edges of the CFG
➤ Direction of Flow
➤ We have liveness on edges- How do we talk about liveness at nodes?
➤ Two More Definitions- A variable is live-out at a node if it is live on any of that node’s outedges
A variable is live-in at a node if it is live on any
➤ Rules for computing liveness
(1) Generate liveness: If a variable is in use[n], it is live-in at node n
(2) Push liveness across edges: If a variable is live-in at a node n then it is live-out at all nodes in pred[n]
(3) Push liveness across nodes: If a variable is live-out at node n and not in def[n] then the variable is also live-in at n
➤ Data-flow equations
➤ Algorithm
This is iterative data-flow analysis (for liveness analysis)
➤ Example
➤ Example (cont)
Data-flow Equations for Liveness
➤ Improving Performance
➤ Algorithm
➤ Consider a program of size N
➤ Worst case: O(N4)
Typical case: 2 to 3 iterations with good ordering & sparse sets ⇒ O(N) to O(N2)
➤ Basic blocks
Decrease the size of the CFG by merging nodes that have a single predecessor and a single successor into basic blocks
➤ One variable at a time
Instead of computing data-flow information for all variables at once using sets, compute a (simplified) analysis for each variable separately
➤ Representation of sets
➤ Solution X
Our solution as computed on previous slides
➤ Solution Y
Imprecise conservative solutions ⇒ sub-optimal but correct programs
➤ Solution Z
Non-conservative solutions ⇒ incorrect programs
➤ Static vs. Dynamic Liveness
➤ Rule (2) for computing liveness
No compiler can statically know all a program’s dynamic properties!
➤ Liveness
➤ Control flow graphs
➤ Defs and uses
➤ Conservative approximation
➤ Reading
➤ Think about. . .
➤ Lecture
26 videos|66 docs|30 tests
|
1. What is liveliness analysis in computer science engineering? |
2. Why is liveliness analysis important in computer science engineering? |
3. What are the common challenges in liveliness analysis? |
4. How does liveliness analysis impact the performance of computer systems? |
5. What are some techniques used in liveliness analysis? |
|
Explore Courses for Computer Science Engineering (CSE) exam
|