Presentation is loading. Please wait.

Presentation is loading. Please wait.

Live Variable Analysis

Similar presentations


Presentation on theme: "Live Variable Analysis"— Presentation transcript:

1 Live Variable Analysis
Determines for each “point” in a program what (variable’s) values are live at that point. Program “points” are defined before and after each statement of a basic block. A value is “live” iff It has been written (defined) It might be read (used) on some path later in the control flow graph

2 Statement Dataflow Consider a statement, S,
dest = src1 operator src2, OR dest = operator(src1, src2, … srcN) Keep two sets for each statement Written (defined) Read (used)

3 Live Variables – Basic Block
For each block, BB, compute Written, read, readB4written, for BB Initialize each BB Live-in = readB4written, Live-out = Ø Repeat until neither live-in, live-out change For each BB Live-out(BB) U= U Live-in(Successor) Live-in(BB) U= Live-out(BB) – written(BB)

4 Live Analysis – Statements

5 Whole Algorithm Traverse each statement, S, in function
Compute S->written, S->read For each basic block, BB, compute BB->live-in and BB->live-out (See Live Variables – Basic Block) For each basic block, BB Live = BB->live-out Traverse each statement, S, of BB, in reverse Live = Live – S->written S->live = Live Live = Live ∨ S->read


Download ppt "Live Variable Analysis"

Similar presentations


Ads by Google