• Keine Ergebnisse gefunden

Recapitulation: Data Flow Analysis

N/A
N/A
Protected

Academic year: 2022

Aktie "Recapitulation: Data Flow Analysis"

Copied!
10
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Recapitulation: Data Flow Analysis

What are goals of data flow analysis?

statically collect information about values of variables and expressions at certain program points

statically collect information about the usage of variables at certain program points

use collected information for program optimization

(2)

A variable

v

is

live

at a program point S if there is an execution path starting in S on which an application of v preceds a definition of v.

S

x = v + y;

v live

v dead

(3)

Liveness Analysis (2)

What kind of data flow analysis is liveness analysis?

! backwardanalysis

! information on exit of basic blocks is theunion of the information at the entry of all successors

(4)

How are the data flow equations for liveness analysis defined?

! gen(B): variables applied in B without prior definition

! kill(B): variables defined in B

! in(B) =gen(B)∪(out(B)\kill(B))

! out(B) =!

s∈succ(B)in(s)

(5)

Liveness Analysis (4)

Computation of liveness information by least fixpoint iteration:

for each basic block B {

in(B) = {}; out(B) = {};

} repeat {

for each basic block B {

in’(B) = in(B); out’(B) = out(B);

in(B) = union(gen(B),setminus(out(B), kill(B));

out(B) = union(in(S)) for all successors S of B;

} }

until in’(B) = in(B) and out’(B) = out(B) for all B

(6)

Further Aspects:

Can a variable be live and contained in dead code at the same time?

yes, e.g., if live variable is contained in a branch that is never executed.

How can live variable information be efficiently represented and computed?

by bit vectors and bit vector operations

(7)

Available Expressions

An expression

x⊕y

is

available

at a program point S if

on all paths from the start to S

x⊕y

is computed at least once and there are no definition of x and y since the most recent

occurrence of

x⊕y.

Information about available expressions can be used for common

subexpression elimination.

(8)

Forward analysis

where entry information is

intersection

of exit information of predecessors:

gen(B): all expressions

x ⊕y

that are computed in B where

x

or

y

are not defined afterwards

kill(B): any definition of

x

or

y

in B kills the expressions

x⊕y

in(B) =!

s∈pred(B)out(s)

out(B) =gen(B)∪(in(B))\kill(B)

(9)

Available Expressions (3)

Computation by greatest fixpoint iteration:

for each basic block B {

in(B) = {all expressions};

out(B) = {all expressions};

}

in(start) = {};

repeat {

for each basic block B {

in’(B) = in(B); out’(B) = out(B);

in(B) = intersection(out(S)) for all predecessors S of B;

out(B) = union(gen(B),setminus(in(B), kill(B));

} }

until in’(B) = in(B) and out’(B) = out(B) for all B

(10)

Recommended Reading:

Appel: Chapter 10 and Chapter 17

Aho, Sethi, Ullmann: Compilers; Chapter 10

Referenzen

ÄHNLICHE DOKUMENTE

[r]

Her research interests include environmental ethics, economic philosophy, theories of justice, pluralism in ethics and in social sciences, and sustainability economics..

Static Program Analysis is the analysis of run-time behavior of programs without executing them (sometimes called static testing). Approximations of program behaviours by

with

with

• When , is & we require the greatest sets that solve the equations and we are able to detect properties satisfied by all execution paths reaching (or leaving) the entry (or

In order to support the primary research objective of preparing "integrative studies of both global and universal.. issues" and "analyses of alternative strategies for

u t Because the program transformation process employs first-order reasoning and partial evaluation in the symbolic execution phase, as well as using updates during program