Live Variables Analysis Uday Khedker (www.cse.iitb.ac.in/uday) - - PowerPoint PPT Presentation

live variables analysis
SMART_READER_LITE
LIVE PREVIEW

Live Variables Analysis Uday Khedker (www.cse.iitb.ac.in/uday) - - PowerPoint PPT Presentation

Live Variables Analysis Uday Khedker (www.cse.iitb.ac.in/uday) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay Dec 2017 WSSE Pune Liveness Analysis: Outline 1/25 Outline Live Variables Analysis


slide-1
SLIDE 1

Live Variables Analysis

Uday Khedker

(www.cse.iitb.ac.in/˜uday) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay

Dec 2017

slide-2
SLIDE 2

WSSE Pune Liveness Analysis: Outline 1/25

Outline

  • Live Variables Analysis
  • Strongly Live Variables Analysis
  • Some Observations

Dec 2017 IIT Bombay

slide-3
SLIDE 3

Part 1

Live Variables Analysis

slide-4
SLIDE 4

WSSE Pune Liveness Analysis: Live Variables Analysis 2/25

Defining Live Variables Analysis

A variable v is live at a program point p, if some path from p to program exit contains an r-value oc- currence of v which is not preceded by an l-value

  • ccurrence of v.

v =a∗b a=v +2 End

p

Start v =a∗b v =a+2 End

p

Start

v = v + 2

v =v +2 End

p

Start

Dec 2017 IIT Bombay

slide-5
SLIDE 5

WSSE Pune Liveness Analysis: Live Variables Analysis 2/25

Defining Live Variables Analysis

A variable v is live at a program point p, if some path from p to program exit contains an r-value oc- currence of v which is not preceded by an l-value

  • ccurrence of v.

v is live at p v =a∗b a=v +2 End

p

Start v =a∗b v =a+2 End

p

Start

v = v + 2

v =v +2 End

p

Start

Dec 2017 IIT Bombay

slide-6
SLIDE 6

WSSE Pune Liveness Analysis: Live Variables Analysis 2/25

Defining Live Variables Analysis

A variable v is live at a program point p, if some path from p to program exit contains an r-value oc- currence of v which is not preceded by an l-value

  • ccurrence of v.

v is live at p v is not live at p v =a∗b a=v +2 End

p

Start v =a∗b v =a+2 End

p

Start

v = v + 2

v =v +2 End

p

Start

Dec 2017 IIT Bombay

slide-7
SLIDE 7

WSSE Pune Liveness Analysis: Live Variables Analysis 2/25

Defining Live Variables Analysis

A variable v is live at a program point p, if some path from p to program exit contains an r-value oc- currence of v which is not preceded by an l-value

  • ccurrence of v.

v is live at p v is not live at p v is live at p v =a∗b a=v +2 End

p

Start v =a∗b v =a+2 End

p

Start

v = v + 2

v =v +2 End

p

Start

Dec 2017 IIT Bombay

slide-8
SLIDE 8

WSSE Pune Liveness Analysis: Live Variables Analysis 2/25

Defining Live Variables Analysis

A variable v is live at a program point p, if some path from p to program exit contains an r-value oc- currence of v which is not preceded by an l-value

  • ccurrence of v.

Path based specification v is live at p v is not live at p v is live at p v =a∗b a=v +2 End

p

Start v =a∗b v =a+2 End

p

Start

v = v + 2

v =v +2 End

p

Start

Dec 2017 IIT Bombay

slide-9
SLIDE 9

WSSE Pune Liveness Analysis: Live Variables Analysis 3/25

Defining Data Flow Analysis for Live Variables Analysis

INi Geni, Killi OUT

i

INj Genj, Killj OUT

j

INk = Genk ∪ (OUT

k − Killk)

Genk, Killk OUT

k = INi ∪ INj Dec 2017 IIT Bombay

slide-10
SLIDE 10

WSSE Pune Liveness Analysis: Live Variables Analysis 3/25

Defining Data Flow Analysis for Live Variables Analysis

INi Geni, Killi OUT

i

INj Genj, Killj OUT

j

INk = Genk ∪ (OUT

k − Killk)

Genk, Killk OUT

k = INi ∪ INj

Basic Blocks ≡ Single statements or Maximal groups

  • f sequentially executed statements

Dec 2017 IIT Bombay

slide-11
SLIDE 11

WSSE Pune Liveness Analysis: Live Variables Analysis 3/25

Defining Data Flow Analysis for Live Variables Analysis

INi Geni, Killi OUT

i

INj Genj, Killj OUT

j

INk = Genk ∪ (OUT

k − Killk)

Genk, Killk OUT

k = INi ∪ INj

Basic Blocks ≡ Single statements or Maximal groups

  • f sequentially executed statements

Control Transfer

Dec 2017 IIT Bombay

slide-12
SLIDE 12

WSSE Pune Liveness Analysis: Live Variables Analysis 3/25

Defining Data Flow Analysis for Live Variables Analysis

INi Geni, Killi OUT

i

INj Genj, Killj OUT

j

INk = Genk ∪ (OUT

k − Killk)

Genk, Killk OUT

k = INi ∪ INj

INi Geni, Killi OUT

i

INj Genj, Killj OUT

j

INk = Genk ∪ (OUT

k − Killk)

Genk, Killk OUT

k = INi ∪ INj Dec 2017 IIT Bombay

slide-13
SLIDE 13

WSSE Pune Liveness Analysis: Live Variables Analysis 3/25

Defining Data Flow Analysis for Live Variables Analysis

INi Geni, Killi OUT

i

INj Genj, Killj OUT

j

INk = Genk ∪ (OUT

k − Killk)

Genk, Killk OUT

k = INi ∪ INj

INi Geni, Killi OUT

i

INj Genj, Killj OUT

j

INk = Genk ∪ (OUT

k − Killk)

Genk, Killk OUT

k = INi ∪ INj

Local Data Flow Properties

Dec 2017 IIT Bombay

slide-14
SLIDE 14

WSSE Pune Liveness Analysis: Live Variables Analysis 4/25

Local Data Flow Properties for Live Variables Analysis

Genn = { v | variable v is used in basic block n and is not preceded by a definition of v } Killn = { v | basic block n contains a definition of v }

Dec 2017 IIT Bombay

slide-15
SLIDE 15

WSSE Pune Liveness Analysis: Live Variables Analysis 4/25

Local Data Flow Properties for Live Variables Analysis

Genn = { v | variable v is used in basic block n and is not preceded by a definition of v } Killn = { v | basic block n contains a definition of v } r-value occurrence

Value is only read, e.g. x,y,z in x.sum = y.data + z.data

Dec 2017 IIT Bombay

slide-16
SLIDE 16

WSSE Pune Liveness Analysis: Live Variables Analysis 4/25

Local Data Flow Properties for Live Variables Analysis

Genn = { v | variable v is used in basic block n and is not preceded by a definition of v } Killn = { v | basic block n contains a definition of v } r-value occurrence

Value is only read, e.g. x,y,z in x.sum = y.data + z.data

l-value occurrence

Value is modified e.g. y in y = x.lptr

Dec 2017 IIT Bombay

slide-17
SLIDE 17

WSSE Pune Liveness Analysis: Live Variables Analysis 4/25

Local Data Flow Properties for Live Variables Analysis

Genn = { v | variable v is used in basic block n and is not preceded by a definition of v } Killn = { v | basic block n contains a definition of v } r-value occurrence

Value is only read, e.g. x,y,z in x.sum = y.data + z.data

l-value occurrence

Value is modified e.g. y in y = x.lptr

within n

Dec 2017 IIT Bombay

slide-18
SLIDE 18

WSSE Pune Liveness Analysis: Live Variables Analysis 4/25

Local Data Flow Properties for Live Variables Analysis

Genn = { v | variable v is used in basic block n and is not preceded by a definition of v } Killn = { v | basic block n contains a definition of v } r-value occurrence

Value is only read, e.g. x,y,z in x.sum = y.data + z.data

l-value occurrence

Value is modified e.g. y in y = x.lptr

within n anywhere in n

Dec 2017 IIT Bombay

slide-19
SLIDE 19

WSSE Pune Liveness Analysis: Live Variables Analysis 5/25

Defining Data Flow Analysis for Live Variables Analysis

INi Geni, Killi OUT

i

INj Genj, Killj OUT

j

INk = Genk ∪ (OUT

k − Killk)

Genk, Killk OUT

k = INi ∪ INj Dec 2017 IIT Bombay

slide-20
SLIDE 20

WSSE Pune Liveness Analysis: Live Variables Analysis 5/25

Defining Data Flow Analysis for Live Variables Analysis

INi Geni, Killi OUT

i

INj Genj, Killj OUT

j

INk = Genk ∪ (OUT

k − Killk)

Genk, Killk OUT

k = INi ∪ INj

Global Data Flow Properties

Dec 2017 IIT Bombay

slide-21
SLIDE 21

WSSE Pune Liveness Analysis: Live Variables Analysis 5/25

Defining Data Flow Analysis for Live Variables Analysis

INi Geni, Killi OUT

i

INj Genj, Killj OUT

j

INk = Genk ∪ (OUT

k − Killk)

Genk, Killk OUT

k = INi ∪ INj

Global Data Flow Properties Edge based specifications

Dec 2017 IIT Bombay

slide-22
SLIDE 22

WSSE Pune Liveness Analysis: Live Variables Analysis 6/25

Data Flow Equations For Live Variables Analysis

INn = (OUT

n − Killn) ∪ Genn

OUT

n

=    BI n is End block

  • s∈succ(n)

INs

  • therwise

Dec 2017 IIT Bombay

slide-23
SLIDE 23

WSSE Pune Liveness Analysis: Live Variables Analysis 6/25

Data Flow Equations For Live Variables Analysis

INn = (OUT

n − Killn) ∪ Genn

OUT

n

=    BI n is End block

  • s∈succ(n)

INs

  • therwise
  • INn and OUT

n are sets of variables Dec 2017 IIT Bombay

slide-24
SLIDE 24

WSSE Pune Liveness Analysis: Live Variables Analysis 6/25

Data Flow Equations For Live Variables Analysis

INn = (OUT

n − Killn) ∪ Genn

OUT

n

=    BI n is End block

  • s∈succ(n)

INs

  • therwise
  • INn and OUT

n are sets of variables

  • BI is boundary information representing the effect of calling contexts

◮ ∅ for local variables except for the values being returned ◮ set of global variables used further in any calling context

(can be safely approximated by the set of all global variables)

Dec 2017 IIT Bombay

slide-25
SLIDE 25

WSSE Pune Liveness Analysis: Live Variables Analysis 7/25

Data Flow Equations for Our Example

w = x 1 while (x.data < max) 2 x = x.rptr 3 y = x.lptr 4 z = New class of z 5 y = y.lptr 6 z.sum = x.data + y.data 7 IN1 = (OUT

1 − Kill1) ∪ Gen1

OUT

1 = IN2

IN2 = (OUT

2 − Kill2) ∪ Gen2

OUT

2 = IN3 ∪ IN4

IN3 = (OUT

3 − Kill3) ∪ Gen3

OUT

3 = IN2

IN4 = (OUT

4 − Kill4) ∪ Gen4

OUT

4 = IN5

IN5 = (OUT

5 − Kill5) ∪ Gen5

OUT

5 = IN6

IN6 = (OUT

6 − Kill6) ∪ Gen6

OUT

6 = IN7

IN7 = (OUT

7 − Kill7) ∪ Gen7

OUT

7 = ∅ Dec 2017 IIT Bombay

slide-26
SLIDE 26

WSSE Pune Liveness Analysis: Live Variables Analysis 7/25

Data Flow Equations for Our Example

w = x 1 while (x.data < max) 2 x = x.rptr 3 y = x.lptr 4 z = New class of z 5 y = y.lptr 6 z.sum = x.data + y.data 7 IN1 = (OUT

1 − Kill1) ∪ Gen1

OUT

1 = IN2

IN2 = (OUT

2 − Kill2) ∪ Gen2

OUT

2 = IN3 ∪ IN4

IN3 = (OUT

3 − Kill3) ∪ Gen3

OUT

3 = IN2

IN4 = (OUT

4 − Kill4) ∪ Gen4

OUT

4 = IN5

IN5 = (OUT

5 − Kill5) ∪ Gen5

OUT

5 = IN6

IN6 = (OUT

6 − Kill6) ∪ Gen6

OUT

6 = IN7

IN7 = (OUT

7 − Kill7) ∪ Gen7

OUT

7 = ∅ Dec 2017 IIT Bombay

slide-27
SLIDE 27

WSSE Pune Liveness Analysis: Live Variables Analysis 7/25

Data Flow Equations for Our Example

w = x 1 while (x.data < max) 2 x = x.rptr 3 y = x.lptr 4 z = New class of z 5 y = y.lptr 6 z.sum = x.data + y.data 7 IN1 = (OUT

1 − Kill1) ∪ Gen1

OUT

1 = IN2

IN2 = (OUT

2 − Kill2) ∪ Gen2

OUT

2 = IN3 ∪ IN4

IN3 = (OUT

3 − Kill3) ∪ Gen3

OUT

3 = IN2

IN4 = (OUT

4 − Kill4) ∪ Gen4

OUT

4 = IN5

IN5 = (OUT

5 − Kill5) ∪ Gen5

OUT

5 = IN6

IN6 = (OUT

6 − Kill6) ∪ Gen6

OUT

6 = IN7

IN7 = (OUT

7 − Kill7) ∪ Gen7

OUT

7 = ∅ Dec 2017 IIT Bombay

slide-28
SLIDE 28

WSSE Pune Liveness Analysis: Live Variables Analysis 7/25

Data Flow Equations for Our Example

w = x 1 while (x.data < max) 2 x = x.rptr 3 y = x.lptr 4 z = New class of z 5 y = y.lptr 6 z.sum = x.data + y.data 7 IN1 = (OUT

1 − Kill1) ∪ Gen1

OUT

1 = IN2

IN2 = (OUT

2 − Kill2) ∪ Gen2

OUT

2 = IN3 ∪ IN4

IN3 = (OUT

3 − Kill3) ∪ Gen3

OUT

3 = IN2

IN4 = (OUT

4 − Kill4) ∪ Gen4

OUT

4 = IN5

IN5 = (OUT

5 − Kill5) ∪ Gen5

OUT

5 = IN6

IN6 = (OUT

6 − Kill6) ∪ Gen6

OUT

6 = IN7

IN7 = (OUT

7 − Kill7) ∪ Gen7

OUT

7 = ∅ Dec 2017 IIT Bombay

slide-29
SLIDE 29

WSSE Pune Liveness Analysis: Live Variables Analysis 7/25

Data Flow Equations for Our Example

w = x 1 while (x.data < max) 2 x = x.rptr 3 y = x.lptr 4 z = New class of z 5 y = y.lptr 6 z.sum = x.data + y.data 7 IN1 = (OUT

1 − Kill1) ∪ Gen1

OUT

1 = IN2

IN2 = (OUT

2 − Kill2) ∪ Gen2

OUT

2 = IN3 ∪ IN4

IN3 = (OUT

3 − Kill3) ∪ Gen3

OUT

3 = IN2

IN4 = (OUT

4 − Kill4) ∪ Gen4

OUT

4 = IN5

IN5 = (OUT

5 − Kill5) ∪ Gen5

OUT

5 = IN6

IN6 = (OUT

6 − Kill6) ∪ Gen6

OUT

6 = IN7

IN7 = (OUT

7 − Kill7) ∪ Gen7

OUT

7 = ∅ Dec 2017 IIT Bombay

slide-30
SLIDE 30

WSSE Pune Liveness Analysis: Live Variables Analysis 7/25

Data Flow Equations for Our Example

w = x 1 while (x.data < max) 2 x = x.rptr 3 y = x.lptr 4 z = New class of z 5 y = y.lptr 6 z.sum = x.data + y.data 7 IN1 = (OUT

1 − Kill1) ∪ Gen1

OUT

1 = IN2

IN2 = (OUT

2 − Kill2) ∪ Gen2

OUT

2 = IN3 ∪ IN4

IN3 = (OUT

3 − Kill3) ∪ Gen3

OUT

3 = IN2

IN4 = (OUT

4 − Kill4) ∪ Gen4

OUT

4 = IN5

IN5 = (OUT

5 − Kill5) ∪ Gen5

OUT

5 = IN6

IN6 = (OUT

6 − Kill6) ∪ Gen6

OUT

6 = IN7

IN7 = (OUT

7 − Kill7) ∪ Gen7

OUT

7 = ∅ Dec 2017 IIT Bombay

slide-31
SLIDE 31

WSSE Pune Liveness Analysis: Live Variables Analysis 7/25

Data Flow Equations for Our Example

w = x 1 while (x.data < max) 2 x = x.rptr 3 y = x.lptr 4 z = New class of z 5 y = y.lptr 6 z.sum = x.data + y.data 7 Cyclic Dependence IN1 = (OUT

1 − Kill1) ∪ Gen1

OUT

1 = IN2

IN2 = (OUT

2 − Kill2) ∪ Gen2

OUT

2 = IN3 ∪ IN4

IN3 = (OUT

3 − Kill3) ∪ Gen3

OUT

3 = IN2

IN4 = (OUT

4 − Kill4) ∪ Gen4

OUT

4 = IN5

IN5 = (OUT

5 − Kill5) ∪ Gen5

OUT

5 = IN6

IN6 = (OUT

6 − Kill6) ∪ Gen6

OUT

6 = IN7

IN7 = (OUT

7 − Kill7) ∪ Gen7

OUT

7 = ∅ Dec 2017 IIT Bombay

slide-32
SLIDE 32

WSSE Pune Liveness Analysis: Live Variables Analysis 8/25

Performing Live Variables Analysis

Gen ={x}, Kill ={w} w = x Gen ={x}, Kill =∅ while (x.data < max) Gen ={x}, Kill ={x} x = x.rptr Gen ={x}, Kill ={y} y = x.lptr Gen =∅, Kill ={z} z = New class of z Gen ={y}, Kill ={y} y = y.lptr Gen ={x, y, z}, Kill =∅ z.sum = x.data + y.data

Dec 2017 IIT Bombay

slide-33
SLIDE 33

WSSE Pune Liveness Analysis: Live Variables Analysis 8/25

Performing Live Variables Analysis

Gen ={x}, Kill ={w} w = x Gen ={x}, Kill =∅ while (x.data < max) Gen ={x}, Kill ={x} x = x.rptr Gen ={x}, Kill ={y} y = x.lptr Gen =∅, Kill ={z} z = New class of z Gen ={y}, Kill ={y} y = y.lptr Gen ={x, y, z}, Kill =∅ z.sum = x.data + y.data Gen and Kill need not be mutually exclusive

Dec 2017 IIT Bombay

slide-34
SLIDE 34

WSSE Pune Liveness Analysis: Live Variables Analysis 8/25

Performing Live Variables Analysis

Gen ={x}, Kill ={w} w = x Gen ={x}, Kill =∅ while (x.data < max) Gen ={x}, Kill ={x} x = x.rptr Gen ={x}, Kill ={y} y = x.lptr Gen =∅, Kill ={z} z = New class of z Gen ={y}, Kill ={y} y = y.lptr Gen ={x, y, z}, Kill =∅ z.sum = x.data + y.data z is an r-value occurrence and not an l-value occurrence

Dec 2017 IIT Bombay

slide-35
SLIDE 35

WSSE Pune Liveness Analysis: Live Variables Analysis 8/25

Performing Live Variables Analysis

Gen ={x}, Kill ={w} w = x Gen ={x}, Kill =∅ while (x.data < max) Gen ={x}, Kill ={x} x = x.rptr Gen ={x}, Kill ={y} y = x.lptr Gen =∅, Kill ={z} z = New class of z Gen ={y}, Kill ={y} y = y.lptr Gen ={x, y, z}, Kill =∅ z.sum = x.data + y.data x, y, z are considered to be used based purely on local use even if the value of z is not used later. A different analy- sis called strongly live variables analysis improves on this.

Dec 2017 IIT Bombay

slide-36
SLIDE 36

WSSE Pune Liveness Analysis: Live Variables Analysis 8/25

Performing Live Variables Analysis

Gen ={x}, Kill ={w} w = x Gen ={x}, Kill =∅ while (x.data < max) Gen ={x}, Kill ={x} x = x.rptr Gen ={x}, Kill ={y} y = x.lptr Gen =∅, Kill ={z} z = New class of z Gen ={y}, Kill ={y} y = y.lptr Gen ={x, y, z}, Kill =∅ z.sum = x.data + y.data

Initialization ∅ ∅ ∅ ∅ ∅ ∅ ∅ ∅ ∅ ∅ ∅ ∅ ∅ ∅

Dec 2017 IIT Bombay

slide-37
SLIDE 37

WSSE Pune Liveness Analysis: Live Variables Analysis 8/25

Performing Live Variables Analysis

Gen ={x}, Kill ={w} w = x Gen ={x}, Kill =∅ while (x.data < max) Gen ={x}, Kill ={x} x = x.rptr Gen ={x}, Kill ={y} y = x.lptr Gen =∅, Kill ={z} z = New class of z Gen ={y}, Kill ={y} y = y.lptr Gen ={x, y, z}, Kill =∅ z.sum = x.data + y.data

Traversal Iteration #1 ∅ {x, y, z} {x, y, z} {x, y, z} {x, y, z} {x, y} {x, y} {x} ∅ {x} {x} {x} {x} {x}

Ignoring max be- cause we are doing analysis for pointer variables w, x, y, z

Dec 2017 IIT Bombay

slide-38
SLIDE 38

WSSE Pune Liveness Analysis: Live Variables Analysis 8/25

Performing Live Variables Analysis

Gen ={x}, Kill ={w} w = x Gen ={x}, Kill =∅ while (x.data < max) Gen ={x}, Kill ={x} x = x.rptr Gen ={x}, Kill ={y} y = x.lptr Gen =∅, Kill ={z} z = New class of z Gen ={y}, Kill ={y} y = y.lptr Gen ={x, y, z}, Kill =∅ z.sum = x.data + y.data

Traversal ∅ {x, y, z} {x, y, z} {x, y, z} {x, y, z} {x, y} {x, y} {x} ∅ {x} {x} {x} {x} {x}

Ignoring max be- cause we are doing analysis for pointer variables w, x, y, z

Iteration #2 ∅ {x, y, z} {x, y, z} {x, y, z} {x, y, z} {x, y} {x, y} {x} {x} {x} {x} {x} {x} {x}

Dec 2017 IIT Bombay

slide-39
SLIDE 39

WSSE Pune Liveness Analysis: Live Variables Analysis 9/25

Performing Live Variables Analysis

Local data flow properties when basic blocks contain multiple statements

Gen ={x}, Kill ={w} w = x Gen ={x}, Kill =∅ while (x.data < max) Gen ={x}, Kill ={x} x = x.rptr Gen ={x}, Kill ={y, z} y = x.lptr z = New class of z y = y.lptr z.sum = x.data + y.data

Dec 2017 IIT Bombay

slide-40
SLIDE 40

WSSE Pune Liveness Analysis: Live Variables Analysis 10/25

Local Data Flow Properties for Live Variables Analysis

INn = Genn ∪ (OUT

n − Killn)

  • Genn : Use not preceded by definition
  • Killn : Definition anywhere in a block

Dec 2017 IIT Bombay

slide-41
SLIDE 41

WSSE Pune Liveness Analysis: Live Variables Analysis 10/25

Local Data Flow Properties for Live Variables Analysis

INn = Genn ∪ (OUT

n − Killn)

  • Genn : Use not preceded by definition

Upwards exposed use

  • Killn : Definition anywhere in a block

Stop the effect from being propagated across a block

Dec 2017 IIT Bombay

slide-42
SLIDE 42

WSSE Pune Liveness Analysis: Live Variables Analysis 11/25

Using Data Flow Information of Live Variables Analysis

  • Used for register allocation

If variable x is live in a basic block b, it is a potential candidate for register allocation

Dec 2017 IIT Bombay

slide-43
SLIDE 43

WSSE Pune Liveness Analysis: Live Variables Analysis 11/25

Using Data Flow Information of Live Variables Analysis

  • Used for register allocation

If variable x is live in a basic block b, it is a potential candidate for register allocation

  • Used for dead code elimination

If variable x is not live after an assignment x = . . ., then the assignment is redundant and can be deleted as dead code

Dec 2017 IIT Bombay

slide-44
SLIDE 44

Part 2

Strongly Live Variables Analysis

slide-45
SLIDE 45

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 12/25

Strongly Live Variables Analysis

  • A variable is strongly live if

◮ it is used in a statement other than assignment statement, or

(same as simple liveness)

◮ it is used in an assignment statement defining a variable that is

strongly live (different from simple liveness)

  • Killing: An assignment statement, an input statement, or BI

(this is same as killing in simple liveness)

  • Generation: A direct use or a use for defining values that are strongly live

(this is different from generation in simple liveness)

Dec 2017 IIT Bombay

slide-46
SLIDE 46

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 13/25

Understanding Strong Liveness

y = x print (x) y = x print (y) y = x print (z)

Dec 2017 IIT Bombay

slide-47
SLIDE 47

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 13/25

Understanding Strong Liveness

y = x print (x) Strong Liveness y = x print (y) y = x print (z)

Dec 2017 IIT Bombay

slide-48
SLIDE 48

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 13/25

Understanding Strong Liveness

y = x print (x) Strong Liveness ∅ y = x print (y) y = x print (z)

Dec 2017 IIT Bombay

slide-49
SLIDE 49

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 13/25

Understanding Strong Liveness

y = x print (x) Strong Liveness ∅ {x} y = x print (y) y = x print (z)

Dec 2017 IIT Bombay

slide-50
SLIDE 50

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 13/25

Understanding Strong Liveness

y = x print (x) Strong Liveness ∅ {x} {x} y = x print (y) y = x print (z)

Dec 2017 IIT Bombay

slide-51
SLIDE 51

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 13/25

Understanding Strong Liveness

y = x print (x) Strong Liveness ∅ {x} {x} Simple Liveness ∅ {x} {x} y = x print (y) y = x print (z)

Dec 2017 IIT Bombay

slide-52
SLIDE 52

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 13/25

Understanding Strong Liveness

y = x print (x) Strong Liveness ∅ {x} {x} Simple Liveness ∅ {x} {x} y = x print (y) y = x print (z) Same

Dec 2017 IIT Bombay

slide-53
SLIDE 53

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 13/25

Understanding Strong Liveness

y = x print (x) Strong Liveness ∅ {x} {x} Simple Liveness ∅ {x} {x} y = x print (y) Strong Liveness y = x print (z) Same

Dec 2017 IIT Bombay

slide-54
SLIDE 54

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 13/25

Understanding Strong Liveness

y = x print (x) Strong Liveness ∅ {x} {x} Simple Liveness ∅ {x} {x} y = x print (y) Strong Liveness ∅ y = x print (z) Same

Dec 2017 IIT Bombay

slide-55
SLIDE 55

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 13/25

Understanding Strong Liveness

y = x print (x) Strong Liveness ∅ {x} {x} Simple Liveness ∅ {x} {x} y = x print (y) Strong Liveness ∅ {y} y = x print (z) Same

Dec 2017 IIT Bombay

slide-56
SLIDE 56

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 13/25

Understanding Strong Liveness

y = x print (x) Strong Liveness ∅ {x} {x} Simple Liveness ∅ {x} {x} y = x print (y) Strong Liveness ∅ {y} {x} y = x print (z) Same

Dec 2017 IIT Bombay

slide-57
SLIDE 57

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 13/25

Understanding Strong Liveness

y = x print (x) Strong Liveness ∅ {x} {x} Simple Liveness ∅ {x} {x} y = x print (y) Strong Liveness ∅ {y} {x} Simple Liveness ∅ {x} {y} y = x print (z) Same

Dec 2017 IIT Bombay

slide-58
SLIDE 58

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 13/25

Understanding Strong Liveness

y = x print (x) Strong Liveness ∅ {x} {x} Simple Liveness ∅ {x} {x} y = x print (y) Strong Liveness ∅ {y} {x} Simple Liveness ∅ {x} {y} y = x print (z) Same Same

Dec 2017 IIT Bombay

slide-59
SLIDE 59

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 13/25

Understanding Strong Liveness

y = x print (x) Strong Liveness ∅ {x} {x} Simple Liveness ∅ {x} {x} y = x print (y) Strong Liveness ∅ {y} {x} Simple Liveness ∅ {x} {y} y = x print (z) Strong Liveness Same Same

Dec 2017 IIT Bombay

slide-60
SLIDE 60

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 13/25

Understanding Strong Liveness

y = x print (x) Strong Liveness ∅ {x} {x} Simple Liveness ∅ {x} {x} y = x print (y) Strong Liveness ∅ {y} {x} Simple Liveness ∅ {x} {y} y = x print (z) Strong Liveness ∅ Same Same

Dec 2017 IIT Bombay

slide-61
SLIDE 61

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 13/25

Understanding Strong Liveness

y = x print (x) Strong Liveness ∅ {x} {x} Simple Liveness ∅ {x} {x} y = x print (y) Strong Liveness ∅ {y} {x} Simple Liveness ∅ {x} {y} y = x print (z) Strong Liveness ∅ {z} Same Same

Dec 2017 IIT Bombay

slide-62
SLIDE 62

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 13/25

Understanding Strong Liveness

y = x print (x) Strong Liveness ∅ {x} {x} Simple Liveness ∅ {x} {x} y = x print (y) Strong Liveness ∅ {y} {x} Simple Liveness ∅ {x} {y} y = x print (z) Strong Liveness ∅ {z} {z} Same Same

Dec 2017 IIT Bombay

slide-63
SLIDE 63

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 13/25

Understanding Strong Liveness

y = x print (x) Strong Liveness ∅ {x} {x} Simple Liveness ∅ {x} {x} y = x print (y) Strong Liveness ∅ {y} {x} Simple Liveness ∅ {x} {y} y = x print (z) Strong Liveness ∅ {z} {z} Simple Liveness ∅ {z} {z, x} Same Same

Dec 2017 IIT Bombay

slide-64
SLIDE 64

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 13/25

Understanding Strong Liveness

y = x print (x) Strong Liveness ∅ {x} {x} Simple Liveness ∅ {x} {x} y = x print (y) Strong Liveness ∅ {y} {x} Simple Liveness ∅ {x} {y} y = x print (z) Strong Liveness ∅ {z} {z} Simple Liveness ∅ {z} {z, x} Same Same Different

Dec 2017 IIT Bombay

slide-65
SLIDE 65

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 14/25

Live Variables Analysis: Simple and Strong Liveness

  • A variable is live at a program

point if its current value is likely to be used later

Dec 2017 IIT Bombay

slide-66
SLIDE 66

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 14/25

Live Variables Analysis: Simple and Strong Liveness

  • A variable is live at a program

point if its current value is likely to be used later

  • We want to compute the smallest

set of variables that are live

Dec 2017 IIT Bombay

slide-67
SLIDE 67

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 14/25

Live Variables Analysis: Simple and Strong Liveness

  • A variable is live at a program

point if its current value is likely to be used later

  • We want to compute the smallest

set of variables that are live a = 1; b = 2 c = 3; n = 6 B1 if a ≤ n B2 a = a + 1 B3 if a ≤ 11 B4 t1 = a + b a = t1 + c print ”Hello” B5 B6 print ”Hi” T F T F

Dec 2017 IIT Bombay

slide-68
SLIDE 68

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 14/25

Live Variables Analysis: Simple and Strong Liveness

  • A variable is live at a program

point if its current value is likely to be used later

  • We want to compute the smallest

set of variables that are live

  • Simple liveness considers every

use of a variable as useful a = 1; b = 2 c = 3; n = 6 B1 if a ≤ n B2 a = a + 1 B3 if a ≤ 11 B4 t1 = a + b a = t1 + c print ”Hello” B5 B6 print ”Hi” T F T F ∅ ∅ ∅ { } } { } {a, {a, , n} {a, , n} , n} {a, , n} {a, , n} {a, ∅ a, b, c a, b, c b, c b, c b, c b, c b, c b, c

Dec 2017 IIT Bombay

slide-69
SLIDE 69

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 14/25

Live Variables Analysis: Simple and Strong Liveness

  • A variable is live at a program

point if its current value is likely to be used later

  • We want to compute the smallest

set of variables that are live

  • Simple liveness considers every

use of a variable as useful

  • Strong liveness checks the liveness
  • f the result before declaring the
  • perands to be live

a = 1; b = 2 c = 3; n = 6 B1 if a ≤ n B2 a = a + 1 B3 if a ≤ 11 B4 t1 = a + b a = t1 + c print ”Hello” B5 B6 print ”Hi” T F T F ∅ ∅ ∅ { } } { } {a, {a, , n} {a, , n} , n} {a, , n} {a, , n} {a, ∅ / / // / / / a, b, c / / / / / / / a, b, c / / / / b, c / / / / b, c / / / / b, c / / / / b, c / / / / b, c / / / / b, c

Dec 2017 IIT Bombay

slide-70
SLIDE 70

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 14/25

Live Variables Analysis: Simple and Strong Liveness

  • A variable is live at a program

point if its current value is likely to be used later

  • We want to compute the smallest

set of variables that are live

  • Simple liveness considers every

use of a variable as useful

  • Strong liveness checks the liveness
  • f the result before declaring the
  • perands to be live
  • Strong liveness is more precise

than simple liveness a = 1; b = 2 c = 3; n = 6 B1 if a ≤ n B2 a = a + 1 B3 if a ≤ 11 B4 t1 = a + b a = t1 + c print ”Hello” B5 B6 print ”Hi” T F T F ∅ ∅ ∅ { } } { } {a, {a, , n} {a, , n} , n} {a, , n} {a, , n} {a, ∅ / / // / / / a, b, c / / / / / / / a, b, c / / / / b, c / / / / b, c / / / / b, c / / / / b, c / / / / b, c / / / / b, c

Dec 2017 IIT Bombay

slide-71
SLIDE 71

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 15/25

Data Flow Equations for Strongly Live Variables Analysis

INn = fn(OUT

n)

OUT

n

=    BI n is End

  • s∈succ(n)

INs

  • therwise

where, fn(X) =        (X − {y}) ∪ (Opd(e) ∩ Var) n is y = e, e ∈ Expr, y ∈ X X − {y} n is input(y) X ∪ {y} n is use(y) X

  • therwise

Dec 2017 IIT Bombay

slide-72
SLIDE 72

WSSE Pune Liveness Analysis: Strongly Live Variables Analysis 15/25

Data Flow Equations for Strongly Live Variables Analysis

INn = fn(OUT

n)

OUT

n

=    BI n is End

  • s∈succ(n)

INs

  • therwise

where, fn(X) =        (X − {y}) ∪ (Opd(e) ∩ Var) n is y = e, e ∈ Expr, y ∈ X X − {y} n is input(y) X ∪ {y} n is use(y) X

  • therwise

If y is not strongly live, the assignment is skipped using the “otherwise” clause

Dec 2017 IIT Bombay

slide-73
SLIDE 73

Part 3

Some Observations

slide-74
SLIDE 74

WSSE Pune Liveness Analysis: Some Observations 16/25

What Does Data Flow Analysis Involve?

  • Defining the analysis.
  • Formulating the analysis.
  • Performing the analysis.

Dec 2017 IIT Bombay

slide-75
SLIDE 75

WSSE Pune Liveness Analysis: Some Observations 16/25

What Does Data Flow Analysis Involve?

  • Defining the analysis. Define the properties of execution paths
  • Formulating the analysis.
  • Performing the analysis.

Dec 2017 IIT Bombay

slide-76
SLIDE 76

WSSE Pune Liveness Analysis: Some Observations 16/25

What Does Data Flow Analysis Involve?

  • Defining the analysis. Define the properties of execution paths
  • Formulating the analysis. Define data flow equations

◮ Linear simultaneous equations on sets rather than numbers ◮ Later we will generalize the domain of values

  • Performing the analysis.

Dec 2017 IIT Bombay

slide-77
SLIDE 77

WSSE Pune Liveness Analysis: Some Observations 16/25

What Does Data Flow Analysis Involve?

  • Defining the analysis. Define the properties of execution paths
  • Formulating the analysis. Define data flow equations

◮ Linear simultaneous equations on sets rather than numbers ◮ Later we will generalize the domain of values

  • Performing the analysis. Solve data flow equations for the given program

flow graph

Dec 2017 IIT Bombay

slide-78
SLIDE 78

WSSE Pune Liveness Analysis: Some Observations 16/25

What Does Data Flow Analysis Involve?

  • Defining the analysis. Define the properties of execution paths
  • Formulating the analysis. Define data flow equations

◮ Linear simultaneous equations on sets rather than numbers ◮ Later we will generalize the domain of values

  • Performing the analysis. Solve data flow equations for the given program

flow graph

  • Many unanswered questions

Initial value? Termination? Complexity? Properties of Solutions?

Dec 2017 IIT Bombay

slide-79
SLIDE 79

WSSE Pune Liveness Analysis: Some Observations 17/25

Iterative Solution of Linear Simultaneous Equations

  • Simultaneous equations represented in the form of the product of a matrix
  • f coefficients (A) with the vector of unknowns (x)

Ax = b

  • Start with approximate values
  • Compute new values repeatedly from old values
  • Two classical methods

◮ Gauss-Seidel Method (Gauss: 1823, 1826), (Seidel: 1874) ◮ Jacobi Method (Jacobi: 1845)

Dec 2017 IIT Bombay

slide-80
SLIDE 80

WSSE Pune Liveness Analysis: Some Observations 18/25

Our Method of Performing Data Flow Analysis

  • Round robin iteration
  • Essentially Jacobi method
  • Unknowns are the data flow variables INi and OUT

i

  • Domain of values is not numbers
  • Computation in a fixed order

◮ either forward (reverse post order) traversal, or ◮ backward (post order) traversal

  • ver the control flow graph

Dec 2017 IIT Bombay

slide-81
SLIDE 81

WSSE Pune Liveness Analysis: Some Observations 19/25

Soundness and Precision of Live Variables Analysis

Consider dead code elimination based on liveness information

Dec 2017 IIT Bombay

slide-82
SLIDE 82

WSSE Pune Liveness Analysis: Some Observations 19/25

Soundness and Precision of Live Variables Analysis

Consider dead code elimination based on liveness information

  • Spurious inclusion of a non-live variable

x = y + 10 print y print y i j End OUT

i = {x, y}

Dec 2017 IIT Bombay

slide-83
SLIDE 83

WSSE Pune Liveness Analysis: Some Observations 19/25

Soundness and Precision of Live Variables Analysis

Consider dead code elimination based on liveness information

  • Spurious inclusion of a non-live variable

◮ A dead assignment may not be eliminated ◮ Solution is sound but may be imprecise

x = y + 10 print y print y i j End OUT

i = {x, y}

Dec 2017 IIT Bombay

slide-84
SLIDE 84

WSSE Pune Liveness Analysis: Some Observations 19/25

Soundness and Precision of Live Variables Analysis

Consider dead code elimination based on liveness information

  • Spurious inclusion of a non-live variable

◮ A dead assignment may not be eliminated ◮ Solution is sound but may be imprecise

  • Spurious exclusion of a live variable

x = y + 10 print y print y i j End OUT

i = {x, y}

x = z + 10 print x, y print y i j End OUT

i = {y}

Dec 2017 IIT Bombay

slide-85
SLIDE 85

WSSE Pune Liveness Analysis: Some Observations 19/25

Soundness and Precision of Live Variables Analysis

Consider dead code elimination based on liveness information

  • Spurious inclusion of a non-live variable

◮ A dead assignment may not be eliminated ◮ Solution is sound but may be imprecise

  • Spurious exclusion of a live variable

◮ A useful assignment may be eliminated ◮ Solution is unsound

x = y + 10 print y print y i j End OUT

i = {x, y}

x = z + 10 print x, y print y i j End OUT

i = {y}

Dec 2017 IIT Bombay

slide-86
SLIDE 86

WSSE Pune Liveness Analysis: Some Observations 19/25

Soundness and Precision of Live Variables Analysis

Consider dead code elimination based on liveness information

  • Spurious inclusion of a non-live variable

◮ A dead assignment may not be eliminated ◮ Solution is sound but may be imprecise

  • Spurious exclusion of a live variable

◮ A useful assignment may be eliminated ◮ Solution is unsound

  • Given L2 ⊇ L1 representing liveness information

◮ Using L2 in place of L1 is sound ◮ Using L1 in place of L2 may not be sound

x = y + 10 print y print y i j End OUT

i = {x, y}

x = z + 10 print x, y print y i j End OUT

i = {y}

Dec 2017 IIT Bombay

slide-87
SLIDE 87

WSSE Pune Liveness Analysis: Some Observations 19/25

Soundness and Precision of Live Variables Analysis

Consider dead code elimination based on liveness information

  • Spurious inclusion of a non-live variable

◮ A dead assignment may not be eliminated ◮ Solution is sound but may be imprecise

  • Spurious exclusion of a live variable

◮ A useful assignment may be eliminated ◮ Solution is unsound

  • Given L2 ⊇ L1 representing liveness information

◮ Using L2 in place of L1 is sound ◮ Using L1 in place of L2 may not be sound

  • The smallest set of all live variables is most precise

◮ Since liveness sets grow (confluence is ∪), we

choose ∅ as the initial conservative value

x = y + 10 print y print y i j End OUT

i = {x, y}

x = z + 10 print x, y print y i j End OUT

i = {y}

Dec 2017 IIT Bombay

slide-88
SLIDE 88

WSSE Pune Liveness Analysis: Some Observations 20/25

Termination, Convergence, and Complexity

  • For live variables analysis,

◮ The set of all variables is finite, and ◮ the confluence operation (i.e. meet) is union, hence ◮ the set associated with a data flow variable can only grow

⇒ Termination is guaranteed

Dec 2017 IIT Bombay

slide-89
SLIDE 89

WSSE Pune Liveness Analysis: Some Observations 20/25

Termination, Convergence, and Complexity

  • For live variables analysis,

◮ The set of all variables is finite, and ◮ the confluence operation (i.e. meet) is union, hence ◮ the set associated with a data flow variable can only grow

⇒ Termination is guaranteed

  • Since initial value is ∅, live variables analysis converges on the smallest set

Dec 2017 IIT Bombay

slide-90
SLIDE 90

WSSE Pune Liveness Analysis: Some Observations 20/25

Termination, Convergence, and Complexity

  • For live variables analysis,

◮ The set of all variables is finite, and ◮ the confluence operation (i.e. meet) is union, hence ◮ the set associated with a data flow variable can only grow

⇒ Termination is guaranteed

  • Since initial value is ∅, live variables analysis converges on the smallest set
  • How many iterations do we need for reaching the convergence?

Dec 2017 IIT Bombay

slide-91
SLIDE 91

WSSE Pune Liveness Analysis: Some Observations 20/25

Termination, Convergence, and Complexity

  • For live variables analysis,

◮ The set of all variables is finite, and ◮ the confluence operation (i.e. meet) is union, hence ◮ the set associated with a data flow variable can only grow

⇒ Termination is guaranteed

  • Since initial value is ∅, live variables analysis converges on the smallest set
  • How many iterations do we need for reaching the convergence?
  • Going beyond live variables analysis

◮ Do the sets always grow for other data flow frameworks? ◮ What is the complexity of round robin analysis for other analyses?

Dec 2017 IIT Bombay

slide-92
SLIDE 92

WSSE Pune Liveness Analysis: Some Observations 21/25

Conservative Nature of Analysis (1)

x=abs(x) b1 if (x < 0) b2 x=a+y b3 x=a+z b4 x=a+z b5 T F

Dec 2017 IIT Bombay

slide-93
SLIDE 93

WSSE Pune Liveness Analysis: Some Observations 21/25

Conservative Nature of Analysis (1)

x=abs(x) b1 if (x < 0) b2 x=a+y b3 x=a+z b4 x=a+z b5 T F

  • abs(n) returns the absolute value of n

Dec 2017 IIT Bombay

slide-94
SLIDE 94

WSSE Pune Liveness Analysis: Some Observations 21/25

Conservative Nature of Analysis (1)

x=abs(x) b1 if (x < 0) b2 x=a+y b3 x=a+z b4 x=a+z b5 T F

  • abs(n) returns the absolute value of n
  • Is y live on entry to block b2?

Dec 2017 IIT Bombay

slide-95
SLIDE 95

WSSE Pune Liveness Analysis: Some Observations 21/25

Conservative Nature of Analysis (1)

x=abs(x) b1 if (x < 0) b2 x=a+y b3 x=a+z b4 x=a+z b5 T F

  • abs(n) returns the absolute value of n
  • Is y live on entry to block b2?
  • By execution semantics, NO

Path b1→b2→b3 is an infeasible execution path

Dec 2017 IIT Bombay

slide-96
SLIDE 96

WSSE Pune Liveness Analysis: Some Observations 21/25

Conservative Nature of Analysis (1)

x=abs(x) b1 if (x < 0) b2 x=a+y b3 x=a+z b4 x=a+z b5 T F

  • abs(n) returns the absolute value of n
  • Is y live on entry to block b2?
  • By execution semantics, NO

Path b1→b2→b3 is an infeasible execution path

  • A compiler makes conservative

assumptions: All branch outcomes are possible ⇒ Consider every path in CFG as a po- tential execution path

Dec 2017 IIT Bombay

slide-97
SLIDE 97

WSSE Pune Liveness Analysis: Some Observations 21/25

Conservative Nature of Analysis (1)

x=abs(x) b1 if (x < 0) b2 x=a+y b3 x=a+z b4 x=a+z b5 T F

  • abs(n) returns the absolute value of n
  • Is y live on entry to block b2?
  • By execution semantics, NO

Path b1→b2→b3 is an infeasible execution path

  • A compiler makes conservative

assumptions: All branch outcomes are possible ⇒ Consider every path in CFG as a po- tential execution path

  • Our analysis concludes that y is live on

entry to block b2

Dec 2017 IIT Bombay

slide-98
SLIDE 98

WSSE Pune Liveness Analysis: Some Observations 22/25

Conservative Nature of Analysis (2)

if (x < 0) b1 a=a+y b2 x=a+z b3 if (x < 0) b4 x=c+1 b5 x=b+1 b6 if (x < 0) b7 T F T F

Dec 2017 IIT Bombay

slide-99
SLIDE 99

WSSE Pune Liveness Analysis: Some Observations 22/25

Conservative Nature of Analysis (2)

if (x < 0) b1 a=a+y b2 x=a+z b3 if (x < 0) b4 x=c+1 b5 x=b+1 b6 if (x < 0) b7 T F T F

  • Is b live on entry to block b2?

Dec 2017 IIT Bombay

slide-100
SLIDE 100

WSSE Pune Liveness Analysis: Some Observations 22/25

Conservative Nature of Analysis (2)

if (x < 0) b1 a=a+y b2 x=a+z b3 if (x < 0) b4 x=c+1 b5 x=b+1 b6 if (x < 0) b7 T F T F

  • Is b live on entry to block b2?
  • By execution semantics, NO

Path b1→b2→b4→b6 is an infeasible execution path

Dec 2017 IIT Bombay

slide-101
SLIDE 101

WSSE Pune Liveness Analysis: Some Observations 22/25

Conservative Nature of Analysis (2)

if (x < 0) b1 a=a+y b2 x=a+z b3 if (x < 0) b4 x=c+1 b5 x=b+1 b6 if (x < 0) b7 T F T F

  • Is b live on entry to block b2?
  • By execution semantics, NO

Path b1→b2→b4→b6 is an infeasible execution path

  • Is c live on entry to block b3?

Path b1→b3→b4→b6 is a feasible execution path

Dec 2017 IIT Bombay

slide-102
SLIDE 102

WSSE Pune Liveness Analysis: Some Observations 22/25

Conservative Nature of Analysis (2)

if (x < 0) b1 a=a+y b2 x=a+z b3 if (x < 0) b4 x=c+1 b5 x=b+1 b6 if (x < 0) b7 T F T F

  • Is b live on entry to block b2?
  • By execution semantics, NO

Path b1→b2→b4→b6 is an infeasible execution path

  • Is c live on entry to block b3?

Path b1→b3→b4→b6 is a feasible execution path

  • A compiler make conservative assumptions

⇒ our analysis is path insensitive Note: It is flow sensitive (i.e. information is computed for every control flow points)

Dec 2017 IIT Bombay

slide-103
SLIDE 103

WSSE Pune Liveness Analysis: Some Observations 22/25

Conservative Nature of Analysis (2)

if (x < 0) b1 a=a+y b2 x=a+z b3 if (x < 0) b4 x=c+1 b5 x=b+1 b6 if (x < 0) b7 T F T F

  • Is b live on entry to block b2?
  • By execution semantics, NO

Path b1→b2→b4→b6 is an infeasible execution path

  • Is c live on entry to block b3?

Path b1→b3→b4→b6 is a feasible execution path

  • A compiler make conservative assumptions

⇒ our analysis is path insensitive Note: It is flow sensitive (i.e. information is computed for every control flow points)

  • Our analysis concludes that b is live at the

entry of b2

Dec 2017 IIT Bombay

slide-104
SLIDE 104

WSSE Pune Liveness Analysis: Some Observations 22/25

Conservative Nature of Analysis (2)

if (x < 0) b1 a=a+y b2 x=a+z b3 if (x < 0) b4 x=c+1 b5 x=b+1 b6 if (x < 0) b7 T F T F

  • Is b live on entry to block b2?
  • By execution semantics, NO

Path b1→b2→b4→b6 is an infeasible execution path

  • Is c live on entry to block b3?

Path b1→b3→b4→b6 is a feasible execution path

  • A compiler make conservative assumptions

⇒ our analysis is path insensitive Note: It is flow sensitive (i.e. information is computed for every control flow points)

  • Our analysis concludes that b is live at the

entry of b2

  • Is c live at the entry of b3?

Dec 2017 IIT Bombay

slide-105
SLIDE 105

WSSE Pune Liveness Analysis: Some Observations 23/25

Conservative Nature of Analysis at Intraprocedural Level

  • We assume that all paths are potentially executable
  • Our analysis is path insensitive

◮ The data flow information at a program point p is path insensitive

  • information at p is merged along all paths reaching p

◮ The data flow information reaching p is computed path insensitively

  • information is merged at all shared points in paths reaching p
  • may generate spurious information due to non-distributive flow

functions

Dec 2017 IIT Bombay

slide-106
SLIDE 106

WSSE Pune Liveness Analysis: Some Observations 24/25

Conservative Nature of Analysis at Interprocedural Level

  • Context insensitivity

◮ Merges of information across all calling contexts

  • Flow insensitivity

◮ Disregards the control flow

More about it later

Dec 2017 IIT Bombay

slide-107
SLIDE 107

WSSE Pune Liveness Analysis: Some Observations 25/25

Looking Ahead The exciting word of pointer analysis beckons us

Dec 2017 IIT Bombay