Two wo Approa proach ches s to to In Inte terproc procedura - - PowerPoint PPT Presentation

two wo approa proach ches s to to in inte terproc
SMART_READER_LITE
LIVE PREVIEW

Two wo Approa proach ches s to to In Inte terproc procedura - - PowerPoint PPT Presentation

Two wo Approa proach ches s to to In Inte terproc procedura dural l Data ta Flow w Analysi lysis Micha a Sharir ir Amir Pnuel ueli Part one: The Functional Approach 12.06.2010 Klaas Boesche Int ntra raproc proced edura


slide-1
SLIDE 1

Two wo Approa proach ches s to to In Inte terproc procedura dural l Data ta Flow w Analysi lysis

Micha a Sharir ir Amir Pnuel ueli

12.06.2010 Klaas Boesche

Part one: The Functional Approach

slide-2
SLIDE 2

Int ntra raproc proced edura ural l an anal alysis ysis

12.06.2010 Klaas Boesche 2

if a=0 call p t := a * b return

procedure p

a := a - 1

T F

read a, b t := a * b call p t := a * b print t stop

procedure main

a*b available?

slide-3
SLIDE 3

Int nter erproc proced edura ural cha hallenges llenges

12.06.2010 Klaas Boesche 3

Recursion p

main

q

  • Infinite paths
  • Efficiency vs.

Precision

Infeasible paths

  • Filter invalid paths
  • Precision and Efficiency

call p … if a=0 call p t := a * b return

p

a := a - 1 T F …

main

Function variables & Virtual functions p q

call x x := … …

  • No static call graph
slide-4
SLIDE 4

Out utline line

 Notatio

ion n and Revie iew

 Functional Approach  Interprocedural MOP  Pragmatic Considerations

12.06.2010 Klaas Boesche 4

slide-5
SLIDE 5

𝑓𝑞 𝑠

𝑞

Not

  • tatio

ations ns

12.06.2010 Klaas Boesche 5

if a=0 call p t := a * b return

p

a := a - 1

T F

read a, b t := a * b call p t := a * b print t stop

main

𝑠𝑛𝑏𝑗𝑜 𝑓𝑛𝑏𝑗𝑜 no parameters

Control Flow Graphs

slide-6
SLIDE 6

Dat ata a Flo low w Fra ramework meworks

 (𝑀, 𝐺) is a data flow framework:

𝑀 is a meet-semilattice

  • ∧ = greatest lower bound
  • ⊤ = smallest element (no information)
  • ⊥ = largest element ("undefined")
  • bounded - No infinite descending chain

12.06.2010 Klaas Boesche 6

⊤ ⊥ ≤ Analysis direction

slide-7
SLIDE 7

Dat ata a Flo low w Fra ramework meworks

 (𝑀, 𝐺) is a data flow framework:

𝐺 is a monotone space of transfer functions

1.

Closed under composition and meet 𝑔 ∧ 𝑕 𝑦 = 𝑔 𝑦 ∧ 𝑕(𝑦)

2.

Contains 𝑗𝑒𝑀 𝑦 = 𝑦 and 𝑔

⊥ 𝑦 = ⊥

𝐺 is 𝑒𝑗𝑡𝑢𝑠𝑗𝑐𝑣𝑢𝑗𝑤𝑓 iff ∀𝑔, 𝑦, 𝑧: 𝑔 𝑦 ∧ 𝑔(𝑧) = 𝑔(𝑦 ∧ 𝑧)

 Restrict 𝐺 to graph 𝐻 = (𝑂, 𝐹):

Smallest 𝑇 ⊆ 𝐺 such that 𝑔 𝑛,𝑜 𝑛, 𝑜 ∈ 𝐹 ⊆ 𝑇 and 1. and

  • 2. hold

12.06.2010 Klaas Boesche 7

slide-8
SLIDE 8

Int ntra raproc proced edura ural exam ampl ple

12.06.2010 Klaas Boesche 8

 Available expression framework for the

single expression a * b:

𝑀 = ⊤, 1, ⊥ 𝐺 = 𝑔

⊤, 𝑔 1, 𝑗𝑒𝑀, 𝑔 ⊥

⊤: a * b not available 1: a * b available 𝑔

⊤ 𝑦 = ⊤, 𝑔 1 𝑦 = 1

slide-9
SLIDE 9

Int ntra raproc proced edura ural exam ampl ple

12.06.2010 Klaas Boesche 9

if a=0 call p t := a * b return

p

a := a - 1

T F

read a, b t := a * b call p t := a * b print t stop

main

𝑠𝑛𝑏𝑗𝑜 𝑓𝑛𝑏𝑗𝑜 𝑑𝑛𝑏𝑗𝑜 𝑜𝑛𝑏𝑗𝑜 𝑠

𝑞

𝑓𝑞 𝑑𝑞 𝑜𝑞 𝑛𝑞 𝑔

1

𝑔

1

𝑗𝑒𝑀 𝑗𝑒𝑀 𝑔

𝑔

𝑔

𝑔

1

⊤ ⊤ ⊤ ⊤ ⊤ ⊤ 1 1 ⊤

slide-10
SLIDE 10

Int ntra raproc proced edura ural equations uations

The data flow equations

12.06.2010 Klaas Boesche 10

𝑦𝑠 = ⊤ 𝑦𝑜 = 𝑔 𝑛,𝑜 𝑦𝑛

𝑛,𝑜 ∈𝐹

𝑜 ∈ 𝑂 − *𝑠+

approximate the meet-over-all paths (MOP) solution

𝑧𝑜 = *𝑔

𝑞( ⊤)|𝑞 ∈ 𝑞𝑏𝑢𝑖𝐻 𝑠, 𝑜 + 𝑜 ∈ 𝑂

where 𝑔

𝑞=(𝑜1,…,𝑜𝑙) = 𝑔 (𝑜𝑙−1,𝑜𝑙) ∘ ⋯ ∘ 𝑔 (𝑜1,𝑜2)

slide-11
SLIDE 11

Int ntra raproc proced edura ural sol

  • lutions

utions

𝐺 is 𝑒𝑗𝑡𝑢𝑠𝑗𝑐𝑣𝑢𝑗𝑤𝑓 ⟹ The maximum fixed point solution 𝑦𝑜

∗ = 𝑧𝑜

𝐺 is 𝑛𝑝𝑜𝑝𝑢𝑝𝑜𝑓 ⟹ 𝑦𝑜

∗ ≤ 𝑧𝑜

12.06.2010 Klaas Boesche 11

slide-12
SLIDE 12

Out utline line

 Notation and Review  Functi

ctional

  • nal Approac

ach

 Interprocedural MOP  Pragmatic Considerations

12.06.2010 Klaas Boesche 12

slide-13
SLIDE 13

Int nter erproc proced edura ural Gra raphs phs

Two representations:

1.

𝐻 = 𝑂𝑞

𝑞

, 𝐹𝑞

𝑞

2.

𝐻∗ = 𝑂𝑞

𝑞

, 𝐹∗

12.06.2010 Klaas Boesche 13

p

… … call p

s

𝐹𝑡 𝐹𝑡 𝐹𝑡

1

return …

𝑠

𝑞

𝑓𝑞 𝐹1 𝐹1 𝐹𝑞 𝐹𝑞

𝐹𝑞 = 𝐹𝑞

0 ∪ 𝐹𝑞 1

𝐹∗ = 𝐹0 ∪ 𝐹1 𝐹0 = 𝐹𝑞

𝑞 𝐹𝑞 Intraprocedural edges 𝐹𝑞

1

Intraprocedural edges with interprocedural control flow 𝐹1 Interprocedural edges

slide-14
SLIDE 14

Ex Exam ample ple

12.06.2010 Klaas Boesche 14

if a=0 call p t := a * b return

p

a := a - 1

T F

read a, b t := a * b call p t := a * b print t stop

main

𝑠𝑛𝑏𝑗𝑜 𝑓𝑛𝑏𝑗𝑜

𝐻

𝑠

𝑞

𝑓𝑞 𝐹𝑞

1

𝐹𝑛𝑏𝑗𝑜

1

slide-15
SLIDE 15

Ex Exam ample ple

12.06.2010 Klaas Boesche 15

if a=0 call p t := a * b return

p

a := a - 1

T F

read a, b t := a * b call p t := a * b print t stop

main

𝑠𝑛𝑏𝑗𝑜 𝑓𝑛𝑏𝑗𝑜

𝐻∗

𝑠

𝑞

𝑓𝑞

slide-16
SLIDE 16

Int nter erproc proced edura urally lly Val alid id pat aths hs

12.06.2010 Klaas Boesche 16

𝐽𝑊𝑄0(𝑠

𝑞, 𝑜)

𝑠

𝑟

𝑓𝑟

p

𝑠

𝑞

𝑜

call q return 𝑛 𝑛′

q

slide-17
SLIDE 17

Int nter erproc proced edura urally lly Val alid id pat aths hs

12.06.2010 Klaas Boesche 17

𝐽𝑊𝑄(𝑠

𝑛𝑏𝑗𝑜, 𝑜)

main

𝑠𝑛𝑏𝑗𝑜 𝑜 𝑠

𝑞𝑘

call 𝑞2 call 𝑞3

𝑠

𝑞2

𝑞2

𝑑1 𝑑2 …

𝑞𝑘

𝑟1 ∈ 𝐽𝑊𝑄0(𝑠𝑛𝑏𝑗𝑜, 𝑜) 𝑟2 ∈ 𝐽𝑊𝑄0(𝑠

𝑞2, 𝑜)

𝑟𝑘 ∈ 𝐽𝑊𝑄0(𝑠

𝑞𝑘, 𝑜)

slide-18
SLIDE 18

Pa Path th no nota tations tions

 𝑞1, 𝑞2 ∈ 𝑞𝑏𝑢𝑖𝐻∗ 𝑠

𝑟, 𝑜

 𝑞1|𝐹1 ≔ Sequence of call & return edges in 𝑞1  𝑞 = 𝑞1 ∥ 𝑞2 ≔ Concatenation of 𝑞1, 𝑞2

12.06.2010 Klaas Boesche 18

slide-19
SLIDE 19

Int nter erproc proced edura urally lly Val alid id pat aths hs

 𝑞 ∈ 𝑞𝑏𝑢𝑖𝐻∗ 𝑠

𝑟, 𝑜 𝑗𝑡 𝑗𝑜 𝐽𝑊𝑄0 𝑠 𝑟, 𝑜 ⟺

𝑞|𝐹1 𝑗𝑡 𝑑𝑝𝑛𝑞𝑚𝑓𝑢𝑓 defined as:

  • 1. 𝑞|𝐹1 = 𝜁
  • 2. 𝑞|𝐹1 = 𝑞1 ∥ 𝑞2 and 𝑞1, 𝑞2 𝑏𝑠𝑓 𝑑𝑝𝑛𝑞𝑚𝑓𝑢𝑓
  • 3. 𝑞|𝐹1 = 𝑛, 𝑠

𝑟′ ∥ 𝑞1 ∥ 𝑓𝑟′, 𝑛′ and 𝑞1 𝑗𝑡 𝑑𝑝𝑛𝑞𝑚𝑓𝑢𝑓

12.06.2010 Klaas Boesche 19 𝑠

𝑟′

𝑓𝑟′

q'

call q ' return 𝑛 𝑛′

𝑞1

slide-20
SLIDE 20

Int nter erproc proced edura urally lly Val alid id pat aths hs

 𝑟 ∈ 𝐽𝑊𝑄 𝑠

𝑛𝑏𝑗𝑜, 𝑜 ∶⟺

𝑟 = 𝑟1 ∥ 𝑑1, 𝑠

𝑞2

∥ 𝑟2 ∥ ⋯ ∥ 𝑑

𝑘−1, 𝑠 𝑞𝑘

∥ 𝑟𝑘 ∀𝑗 < 𝑘: 𝑟𝑗 ∈ 𝐽𝑊𝑄0 𝑠

𝑞𝑗, 𝑑𝑗 and 𝑟𝑘 ∈ 𝐽𝑊𝑄0 𝑠 𝑞𝑘, 𝑜

 Also called Path Decomposition

12.06.2010 Klaas Boesche 20

slide-21
SLIDE 21

Ex Exam amples ples

12.06.2010 Klaas Boesche 21

if a=0 call p t := a * b return a := a - 1

T F

read a, b t := a * b call p t := a * b print t stop

𝑠𝑛𝑏𝑗𝑜 𝑓𝑛𝑏𝑗𝑜

𝐻∗ 𝑑𝑛𝑏𝑗𝑜, 𝑠

𝑞 , 𝑑𝑞, 𝑠 𝑞 , 𝑓𝑞, 𝑜

𝑜 𝑑𝑛𝑏𝑗𝑜 𝑑𝑞 𝑠

𝑞

𝑓𝑞

slide-22
SLIDE 22

𝑑𝑛𝑏𝑗𝑜, 𝑠

𝑞 , 𝑑𝑞, 𝑠 𝑞 , 𝑑𝑞, 𝑠 𝑞 , 𝑓𝑞, 𝑜 , 𝑓𝑞, 𝑜

Ex Exam amples ples

12.06.2010 Klaas Boesche 22

if a=0 call p t := a * b return a := a - 1

T F

read a, b t := a * b call p t := a * b print t stop

𝑠𝑛𝑏𝑗𝑜 𝑓𝑛𝑏𝑗𝑜

𝐻∗

𝑑𝑛𝑏𝑗𝑜 𝑑𝑞 𝑠

𝑞

𝑓𝑞 𝑜

slide-23
SLIDE 23

Fun unctional ctional ap approach roach

12.06.2010 Klaas Boesche 23 𝑠

𝑟

𝑓𝑟

p

𝑠

𝑞

𝑜

call q return 𝑛

𝜚𝑠𝑞,𝑜 𝜚𝑠𝑟,𝑓𝑟 𝜚𝑠𝑞,𝑛

𝑚

𝜚𝑠𝑞,𝑚 𝑔 𝑚,𝑜

Information 𝑦 at 𝑠

𝑞

is transformed to 𝜚𝑠𝑞,𝑜 𝑦 at 𝑜

slide-24
SLIDE 24

Fun unctional ctional Ap Appr proac

  • ach

h equ quations ations

12.06.2010 Klaas Boesche 24

𝜚𝑠𝑞,𝑠𝑞 = 𝑗𝑒𝑀 𝜚𝑠𝑞,𝑜 = 𝑖 𝑛,𝑜 ∘ 𝜚𝑠𝑞,𝑛

𝑛,𝑜 ∈ 𝐹𝑞

𝑖 𝑛,𝑜 = 𝑔 𝑛,𝑜 𝜚𝑠𝑟,𝑓𝑟 𝑛, 𝑜 ∈ 𝐹𝑞

1, 𝑛 𝑑𝑏𝑚𝑚𝑡 𝑟

𝑛, 𝑜 ∈ 𝐹𝑞

 Initialize the equations with

𝜚𝑠𝑞,𝑠𝑞 = 𝑗𝑒𝑀 𝜚𝑠𝑞,𝑜 = 𝑔

⊥ 𝑜 ∈ 𝑂𝑞 − *𝑠 𝑞+

 Compute the maximal fixed point

𝑜 ∈ 𝑂𝑞 − *𝑠

𝑞+

Recursion implicitly encoded in equations

slide-25
SLIDE 25

Ex Exam ample ple

12.06.2010 Klaas Boesche 25

𝑗𝑒𝑀 𝑔

1 ∘ 𝜚𝑠𝑛,𝑠𝑛

𝜚𝑠𝑞,𝑓𝑞 ∘ 𝜚𝑠𝑛,𝑑𝑛 𝑔

1 ∘ 𝜚𝑠𝑛,𝑜𝑛

if a=0 call p t := a * b return

p

a := a - 1

T F

read a, b t := a * b call p t := a * b print t stop

main

𝑠

𝑛

𝑓𝑛 𝑑𝑛 𝑜𝑛 𝑠

𝑞

𝑓𝑞 𝑔

1

𝑔

1

𝑗𝑒𝑀 𝑗𝑒𝑀 𝑔

𝑔

1

𝑑𝑞 𝑜𝑞 𝑛𝑞

slide-26
SLIDE 26

Ex Exam ample ple

12.06.2010 Klaas Boesche 26

𝑗𝑒𝑀 𝑗𝑒𝑀 ∘ 𝜚𝑠𝑞,𝑠𝑞 𝑔

⊤ ∘ 𝜚𝑠𝑞,𝑜𝑞

if a=0 call p t := a * b return

p

a := a - 1

T F

read a, b t := a * b call p t := a * b print t stop

main

𝑠

𝑛

𝑓𝑛 𝑑𝑛 𝑜𝑛 𝑠

𝑞

𝑓𝑞 𝑔

1

𝑔

1

𝑗𝑒𝑀 𝑗𝑒𝑀 𝑔

𝑔

1

𝑑𝑞 𝑜𝑞 𝑛𝑞 𝜚𝑠𝑞,𝑓𝑞 ∘ 𝜚𝑠𝑞,𝑑𝑞 𝑗𝑒𝑀 ∘ 𝜚𝑠𝑞,𝑠𝑞 ∧ 𝑔

1 ∘ 𝜚𝑠𝑞,𝑛𝑞

slide-27
SLIDE 27

Ex Exam ample ple

12.06.2010 Klaas Boesche 27

Functi ction

  • n

Initial l value ue Iterati ation n 1 2 3

𝜚𝑠𝑛,𝑠𝑛

𝑗𝑒𝑀 𝑗𝑒𝑀 𝑗𝑒𝑀 𝑗𝑒𝑀

𝜚𝑠𝑛,𝑑𝑛

𝑔

𝑔

1

𝑔

1

𝑔

1

𝜚𝑠𝑛,𝑜𝑛

𝑔

𝑔

𝑔

1

𝑔

1

𝜚𝑠𝑛,𝑓𝑛

𝑔

𝑔

1

𝑔

1

𝑔

1

𝜚𝑠𝑞,𝑠𝑞

𝑗𝑒𝑀 𝑗𝑒𝑀 𝑗𝑒𝑀 𝑗𝑒𝑀

𝜚𝑠𝑞,𝑜𝑞

𝑔

𝑗𝑒𝑀 𝑗𝑒𝑀 𝑗𝑒𝑀

𝜚𝑠𝑞,𝑑𝑞

𝑔

𝑔

𝑔

𝑔

𝜚𝑠𝑞,𝑛𝑞

𝑔

𝑔

𝑔

𝑔

𝜚𝑠𝑞,𝑓𝑞

𝑔

𝑗𝑒𝑀 𝑗𝑒𝑀 𝑗𝑒𝑀 𝜚𝑠𝑞,𝑠𝑞 = 𝑗𝑒𝑀 𝜚𝑠𝑞,𝑛𝑞 = 𝜚𝑠𝑞,𝑓𝑞 ∘ 𝜚𝑠𝑞,𝑑𝑞 𝜚𝑠𝑛,𝑑𝑛 = 𝑔

1 ∘ 𝜚𝑠𝑛,𝑠𝑛

𝜚𝑠𝑞,𝑜𝑞 = 𝑗𝑒𝑀 ∘ 𝜚𝑠𝑞,𝑠𝑞 𝜚𝑠𝑛,𝑜𝑛 = 𝜚𝑠𝑞,𝑓𝑞 ∘ 𝜚𝑠𝑛,𝑑𝑛 𝜚𝑠𝑞,𝑓𝑞 = 𝑗𝑒𝑀 ∘ 𝜚𝑠𝑞,𝑠𝑞 ∧ 𝑔

1 ∘ 𝜚𝑠𝑞,𝑛𝑞

𝜚𝑠𝑞,𝑑𝑞 = 𝑔

⊤ ∘ 𝜚𝑠𝑞,𝑜𝑞

𝜚𝑠𝑛,𝑠𝑛 = 𝑗𝑒𝑀 𝜚𝑠𝑛,𝑓𝑛 = 𝑔

1 ∘ 𝜚𝑠𝑛,𝑜𝑛

slide-28
SLIDE 28

𝑦𝑠𝑛𝑏𝑗𝑜 = ⊤

𝑦𝑠𝑞 = 𝜚𝑠𝑟,𝑑 𝑦𝑠𝑟 | 𝑑 𝑑𝑏𝑚𝑚𝑡 𝑞 𝑗𝑜 𝑟

 Compute the maximal fixed point iteratively

𝑦𝑜 = 𝜚𝑠𝑞,𝑜 𝑦𝑠𝑞

 Computes the solution for all other nodes

So Solu lution tion

12.06.2010 Klaas Boesche 28

slide-29
SLIDE 29

Ex Exam ample ple (continued)

  • ntinued)

12.06.2010 Klaas Boesche 29

read a, b t := a * b call p t := a * b print t stop

main

𝑠

𝑛

𝑓𝑛 𝑑𝑛 𝑜𝑛 ⊤ 1 1 1

if a=0 call p t := a * b return

p

a := a - 1

T F

𝑠

𝑞

𝑓𝑞 𝑑𝑞 𝑜𝑞 𝑛𝑞 ⊤ ⊤ ⊤ ⊤ ⊤ Functi ctions

  • ns

𝜚𝑠𝑛,𝑠𝑛 = 𝑗𝑒𝑀 𝜚𝑠𝑛,𝑑𝑛 = 𝑔

1

𝜚𝑠𝑛,𝑜𝑛 = 𝑔

1

𝜚𝑠𝑛,𝑓𝑛 = 𝑔

1

𝜚𝑠𝑞,𝑠𝑞 = 𝑗𝑒𝑀 𝜚𝑠𝑞,𝑜𝑞 = 𝑗𝑒𝑀 𝜚𝑠𝑞,𝑑𝑞 = 𝑔

𝜚𝑠𝑞,𝑛𝑞 = 𝑔

𝜚𝑠𝑞,𝑓𝑞 = 𝑗𝑒𝑀

𝑦𝑠𝑞 = 𝜚𝑠𝑛,𝑑𝑛 𝑦𝑠𝑛 ∧ 𝜚𝑠𝑞,𝑑𝑞 𝑦𝑠𝑞 = 𝑔

1 𝑦𝑠𝑛 ∧ 𝑔 ⊤(𝑦𝑠𝑞)

slide-30
SLIDE 30

Out utline line

 Notation and Review  Functional Approach  Interpr

proce

  • cedu

dural al MOP

 Pragmatic Considerations

12.06.2010 Klaas Boesche 30

slide-31
SLIDE 31

Int nter erproc proced edura ural MOP P sol

  • luti

ution

  • n

𝜔𝑜 = 𝑔

𝑟| 𝑟 ∈ 𝐽𝑊𝑄 𝑠𝑛𝑏𝑗𝑜, 𝑜

𝑧𝑜 = 𝜔𝑜 ⊤

12.06.2010 Klaas Boesche 31

main

𝑠𝑛𝑏𝑗𝑜 𝑜 𝑔

𝑟1

𝑔

𝑟2 …

𝜔𝑜

slide-32
SLIDE 32

𝐽𝑊𝑄0 Lemm emma

 𝜚𝑠𝑞,𝑜 = 𝑔

𝑟| 𝑟 ∈ 𝐽𝑊𝑄0 𝑠 𝑞, 𝑜

12.06.2010 Klaas Boesche 32

p

𝑠

𝑞

𝑜

call q return

𝜚𝑠𝑞,𝑜 𝑔

𝑟| 𝑟 ∈ 𝐽𝑊𝑄0 𝑠 𝑞, 𝑜

slide-33
SLIDE 33

𝐽𝑊𝑄0 Lemm emma: a: Pr Proo

  • of

 𝜚𝑠𝑞,𝑜 ≥ 𝑔

𝑟| 𝑟 ∈ 𝐽𝑊𝑄0 𝑠 𝑞, 𝑜

 By induction on 𝜚𝑠𝑞,𝑜

𝑗

, the i-th approximation For i = 0:

  • If 𝑜 = 𝑠

𝑞 then 𝜚𝑠𝑞,𝑜

= 𝑗𝑒𝑀 = 𝑔

𝜁 ≥ 𝑔 𝑟| 𝑟 ∈ 𝐽𝑊𝑄 0 𝑠 𝑞, 𝑠 𝑞

  • If 𝑜 ≠ 𝑠

𝑞 then 𝜚𝑠𝑞,𝑜

= 𝑔

⊥ ≥ 𝑔 ∈ 𝐺

IH: 𝜚𝑠𝑞,𝑜

𝑗

≥ 𝑔

𝑟| 𝑟 ∈ 𝐽𝑊𝑄0 𝑠 𝑞, 𝑜

For i + 1: see blackboard

12.06.2010 Klaas Boesche 33

slide-34
SLIDE 34

𝐽𝑊𝑄0 Lemm emma: a: Pr Proo

  • of

 𝑔

𝑟| 𝑟 ∈ 𝐽𝑊𝑄0 𝑠 𝑞, 𝑜

≥ 𝜚𝑠𝑞,𝑜

 Show: ∀𝑟 ∈ 𝐽𝑊𝑄

0 𝑠 𝑞, 𝑜 : 𝑔 𝑟 ≥ 𝜚𝑠𝑞,𝑜 by induction

  • ver the length 𝑙 of 𝑟

For k = 0:

  • Then 𝑔

𝑟 = 𝜚𝑠𝑞,𝑠𝑞 = 𝑗𝑒𝑀

IH: ∀𝑟 ∈ 𝐽𝑊𝑄0 𝑠

𝑞, 𝑜 , 𝑟 ≤ 𝑙: 𝑔 𝑟 ≥ 𝜚𝑠𝑞,𝑜

For k + 1: see blackboard

12.06.2010 Klaas Boesche 34

slide-35
SLIDE 35

MOP P Rewritte written n

 𝜔𝑜 = 𝑔

𝑟| 𝑟 ∈ 𝐽𝑊𝑄 𝑠 𝑛𝑏𝑗𝑜, 𝑜

 𝜓𝑜 =

𝜚𝑠𝑞𝑘,𝑜 ∘ 𝜚𝑠𝑞𝑘−1,𝑑𝑘−1 ∘ ⋯ ∘ 𝜚𝑠𝑛𝑏𝑗𝑜,𝑑1| 𝑑𝑗 𝑑𝑏𝑚𝑚𝑡 𝑞𝑗+1

 Then 𝜔𝑜 = 𝜓𝑜 with 𝐽𝑊𝑄

0 Lemma and Path

decomposition

 Thus 𝑧𝑜 = 𝜔𝑜 ⊤ = 𝜓𝑜 ⊤

12.06.2010 Klaas Boesche 35

slide-36
SLIDE 36

Eq Equivalenc uivalence e to to MOP

 𝐺 𝑒𝑗𝑡𝑢𝑠𝑗𝑐𝑣𝑢𝑗𝑤𝑓 ⟹ 𝑧𝑜 = 𝑦𝑜  Proof: Show that 𝑦𝑠𝑞 = 𝑧𝑠𝑞 then with

𝑦𝑜 = 𝜚𝑠𝑞,𝑜 𝑦𝑠𝑞 = 𝜚𝑠𝑞,𝑜 𝑧𝑠𝑞 , 𝑧𝑜 = 𝜓𝑜 ⊤ = 𝜚𝑠𝑞𝑘,𝑜 ∘ 𝜚𝑠𝑞𝑘−1,𝑑𝑘−1 ∘ ⋯ ∘ 𝜚𝑠𝑛𝑏𝑗𝑜,𝑑1| 𝑑𝑗 𝑑𝑏𝑚𝑚𝑡 𝑞𝑗+1 ⊤ = 𝜚𝑠𝑞,𝑜 ∘ 𝜓𝑠𝑞 ⊤ = 𝜚𝑠𝑞,𝑜 𝑧𝑠𝑞 it follows that 𝑦𝑜 = 𝑧𝑜 ∀𝑜 ∈ 𝑂∗

12.06.2010 Klaas Boesche 36

slide-37
SLIDE 37

Eq Equivalenc uivalence e to to MOP

 New "Intraprocedural" Data Flow Problem:

  • 𝐻𝑑 = 𝑂𝑑, 𝐹𝑑 𝐹𝑑 = 𝐹𝑑

0 ∪ 𝐹𝑑 1

  • 𝑕 𝑛,𝑜 = 𝜚𝑛,𝑜, 𝑛, 𝑜 ∈ 𝐹𝑑

𝑗𝑒𝑀, 𝑛, 𝑜 ∈ 𝐹𝑑

1

12.06.2010 Klaas Boesche 37

p

call p

s

𝐹𝑑 𝐹𝑑

1

𝑠

𝑞

𝑠

𝑡

call p

𝐹𝑑 𝐹𝑑

1

slide-38
SLIDE 38

Eq Equivalenc uivalence e to to MOP

  • 𝑕 𝑛,𝑜 = 𝜚𝑛,𝑜, 𝑛, 𝑜 ∈ 𝐹𝑑

𝑗𝑒𝑀, 𝑛, 𝑜 ∈ 𝐹𝑑

1

12.06.2010 Klaas Boesche 38

p

call p

s

𝐹𝑑 𝐹𝑑

1

𝑠

𝑞

𝑠

𝑡

call p

𝐹𝑑 𝐹𝑑

1

𝑦𝑠𝑛𝑏𝑗𝑜 = ⊤ 𝑦𝑠𝑞 = 𝜚𝑠𝑟,𝑑 𝑦𝑠𝑟 | 𝑑 𝑑𝑏𝑚𝑚𝑡 𝑞 𝑗𝑜 𝑟 𝑦𝑜 = 𝜚𝑠𝑞,𝑜 𝑦𝑠𝑞 𝑦𝑠 = ⊤ 𝑦𝑜 = 𝑕 𝑛,𝑜 𝑦𝑛

𝑛,𝑜 ∈𝐹

interprocedural intraprocedural

slide-39
SLIDE 39

Eq Equivalenc uivalence e to to MOP

12.06.2010 Klaas Boesche 39

𝑦𝑠𝑛𝑏𝑗𝑜 = ⊤ 𝑦𝑠𝑞 = 𝜚𝑠𝑟,𝑑 𝑦𝑠𝑟 | 𝑑 𝑑𝑏𝑚𝑚𝑡 𝑞 𝑗𝑜 𝑟 𝑦𝑜 = 𝜚𝑠𝑞,𝑜 𝑦𝑠𝑞 interprocedural intraprocedural 𝑦𝑠𝑛𝑏𝑗𝑜 = ⊤ 𝑦𝑠𝑞 = 𝑗𝑒𝑀 𝑦𝑛

𝑛,𝑠𝑞 ∈𝐹𝑑

1

= 𝑦𝑛

𝑛,𝑠𝑞 ∈𝐹𝑑

1

= 𝜚𝑠𝑟,𝑑 𝑦𝑠𝑟 | 𝑑 𝑑𝑏𝑚𝑚𝑡 𝑞 𝑗𝑜 𝑟 𝑦𝑑 = 𝜚𝑛,𝑑 𝑦𝑛

𝑛,𝑑 ∈𝐹𝑑

= 𝜚𝑠𝑞,𝑑 𝑦𝑠𝑞

slide-40
SLIDE 40

Eq Equivalenc uivalence e to to MOP

  • 𝑕 𝑛,𝑜 = 𝜚𝑛,𝑜, 𝑛, 𝑜 ∈ 𝐹𝑑

𝑗𝑒𝑀, 𝑛, 𝑜 ∈ 𝐹𝑑

1

  • Follows from 𝑧𝑜 = 𝜚𝑠𝑞𝑘,𝑜 ∘ ⋯ ∘ 𝜚𝑠𝑛𝑏𝑗𝑜,𝑑1| 𝑑𝑗 𝑑𝑏𝑚𝑚𝑡 𝑞𝑗+1

⊤ and by construction of 𝐻𝑑

12.06.2010 Klaas Boesche 40

p

call p

s

𝐹𝑑 𝐹𝑑

1

𝑠

𝑞

𝑠

𝑡

call p

𝐹𝑑 𝐹𝑑

1

𝑧𝑜 = 𝑔

𝑟| 𝑟 ∈ 𝐽𝑊𝑄 𝑠𝑛𝑏𝑗𝑜, 𝑜

⊤ interprocedural intraprocedural 𝑧𝑜 = *𝑔

𝑞( ⊤)|𝑞 ∈ 𝑞𝑏𝑢𝑖𝐻 𝑠, 𝑜 +

slide-41
SLIDE 41

Eq Equivalenc uivalence e to to MOP

12.06.2010 Klaas Boesche 41

𝐺 is 𝑒𝑗𝑡𝑢𝑠𝑗𝑐𝑣𝑢𝑗𝑤𝑓 ⟹ The maximum fixed point solution 𝑦𝑜

∗ of the

functional approach = the interprocedural MOP solution 𝑧𝑜 𝐺 is 𝑛𝑝𝑜𝑝𝑢𝑝𝑜𝑓 ⟹ 𝑦𝑜

∗ ≤ 𝑧𝑜

slide-42
SLIDE 42

Out utline line

 Notation and Review  Functional Approach  Interprocedural MOP  Pragm

gmati atic Consider iderat ation ions

12.06.2010 Klaas Boesche 42

slide-43
SLIDE 43

Pr Prag agmatic atic problems roblems

 Representation of 𝜚:

  • Symbolic not always possible
  • Explicit representation maybe not finite if 𝑀 𝑗𝑜𝑔𝑗𝑜𝑗𝑢𝑓:

12.06.2010 Klaas Boesche 43

main: A := 0 call P print A p: if cond then A := A + 1 call P A := A – 1 endif return 𝜚𝑠𝑞,𝑓𝑞 𝐵, 0 𝜚𝑠𝑞,𝑓𝑞 𝐵, 1 𝜚𝑠𝑞,𝑓𝑞 𝐵, 2 …

slide-44
SLIDE 44

Pr Prag agmatic atic problems roblems

  • Approach with symbolic representation may not

converge when 𝑀 𝑗𝑜𝑔𝑗𝑜𝑗𝑢𝑓 𝑏𝑜𝑒 𝐺 𝑣𝑜𝑐𝑝𝑣𝑜𝑒𝑓𝑒: ∀𝑙 ≥ 0: Need 𝑙 iterations to show 𝜚𝑠𝑞,𝑓𝑞 𝐵, −𝑙 = ∅

12.06.2010 Klaas Boesche 44

main: A := 0 call P print A p: if cond then A := A + 2 + (A<0)?-1:1 call P A := A – 1 endif return

slide-45
SLIDE 45

Pr Prac actic tical al re result ult

 If 𝑀, 𝐺 𝑒𝑗𝑡𝑢𝑠𝑗𝑐𝑣𝑢𝑗𝑤𝑓 and 𝑀 𝑔𝑗𝑜𝑗𝑢𝑓 then the

iterative solution of converges and results in the interprocedural MOP solution

12.06.2010 Klaas Boesche 45

𝜚𝑠𝑞,𝑠𝑞 = 𝑗𝑒𝑀 𝜚𝑠𝑞,𝑜 = 𝑖 𝑛,𝑜 ∘ 𝜚𝑠𝑞,𝑛

𝑛,𝑜 ∈ 𝐹𝑞

𝑦𝑠𝑛𝑏𝑗𝑜 = ⊤ 𝑦𝑠𝑞 = 𝜚𝑠𝑟,𝑑 𝑦𝑠𝑟 | 𝑑 𝑑𝑏𝑚𝑚𝑡 𝑞 𝑗𝑜 𝑟 𝑦𝑜 = 𝜚𝑠𝑞,𝑜 𝑦𝑠𝑞

slide-46
SLIDE 46

Al Algo gorithm rithm

 Assume 𝑀 𝑔𝑗𝑜𝑗𝑢𝑓 and no symbolic

representation available

 Compute 𝜚𝑠𝑞,𝑜 only for necessary values

12.06.2010 Klaas Boesche 46

𝑋 ≔ 𝑠

𝑛𝑏𝑗𝑜, ⊤

; 𝑄𝐼𝐽 𝑠

𝑛𝑏𝑗𝑜, ⊤ = ⊤

𝑥𝑖𝑗𝑚𝑓 𝑋 ≠ ∅ 𝑠𝑓𝑛𝑝𝑤𝑓 𝑡𝑝𝑛𝑓 𝑜, 𝑦 𝑔𝑠𝑝𝑛 𝑋 𝑣𝑞𝑒𝑏𝑢𝑓 𝑄𝐼𝐽𝑡 𝑏𝑜𝑒 𝑋 𝑦𝑜 = ∧𝑏∈𝑀 𝑄𝐼𝐽 𝑜, 𝑏

slide-47
SLIDE 47

Al Algo gorithm rithm: : up updat dating ing 𝑄𝐼𝐽𝑡 an and 𝑋

𝑞𝑠𝑝𝑞𝑏𝑕𝑏𝑢𝑓 𝑦, 𝑨, 𝑛 : 𝑄𝐼𝐽 𝑛, 𝑦 ≔ 𝑄𝐼𝐽 𝑛, 𝑦 ∧ 𝑨; 𝑗𝑔 𝑄𝐼𝐽 𝑑𝑖𝑏𝑜𝑕𝑓𝑒: 𝑋 ≔ 𝑋 ∪ 𝑛, 𝑦

12.06.2010 Klaas Boesche 47

slide-48
SLIDE 48

Al Algo gorithm rithm: : up updat dating ing 𝑄𝐼𝐽𝑡 an and 𝑋

12.06.2010 Klaas Boesche 48 𝑠

𝑞

𝑓𝑞

q

𝑠

𝑟

𝑜

call p return

𝑦 𝑧 ≔ 𝑄𝐼𝐽(𝑜, 𝑦) 𝑛 p 𝑨 ≔ 𝑄𝐼𝐽(𝑓𝑞, 𝑧)

𝑗𝑔 𝑨 𝑣𝑜𝑒𝑓𝑔𝑗𝑜𝑓𝑒: 𝑞𝑠𝑝𝑞𝑏𝑕𝑏𝑢𝑓 𝑧, 𝑧, 𝑠

𝑞

𝑓𝑚𝑡𝑓: 𝑞𝑠𝑝𝑞𝑏𝑕𝑏𝑢𝑓 𝑦, 𝑨, 𝑛

Case 1

slide-49
SLIDE 49

Al Algo gorithm rithm: : up updat dating ing 𝑄𝐼𝐽𝑡 an and 𝑋

12.06.2010 Klaas Boesche 49

Case 2

𝑔𝑝𝑠 𝑓𝑏𝑑𝑖 𝑑𝑏𝑚𝑚 𝑑𝑞 𝑢𝑝 𝑟 𝑏𝑜𝑒 𝑣 ∈ 𝑀 𝑥𝑗𝑢𝑖 𝑦 = 𝑄𝐼𝐽 𝑑𝑞, 𝑣 ∶ 𝑞𝑠𝑝𝑞𝑏𝑕𝑏𝑢𝑓 𝑣, 𝑧, 𝑛𝑞

𝑠

𝑟

q

𝑜

return 𝑠

𝑞

p

𝑑𝑞 𝑛𝑞

𝑦 𝑣 𝑦 = 𝑄𝐼𝐽(𝑑𝑞, 𝑣) 𝑧 ≔ 𝑄𝐼𝐽(𝑜, 𝑦)

slide-50
SLIDE 50

Al Algo gorithm rithm: : up updat dating ing 𝑄𝐼𝐽𝑡 an and 𝑋

12.06.2010 Klaas Boesche 50

Case 3

𝑔𝑝𝑠 𝑓𝑏𝑑𝑖 𝑜, 𝑛 ∈ 𝐹𝑟

0:

𝑞𝑠𝑝𝑞𝑏𝑕𝑏𝑢𝑓 𝑦, 𝑔 𝑜,𝑛 𝑧 , 𝑛

𝑠

𝑟

q

𝑜

𝑛1

𝑦

𝑛𝑙 …

𝑧 ≔ 𝑄𝐼𝐽(𝑜, 𝑦)

slide-51
SLIDE 51

Ex Exam ample ple

12.06.2010 Klaas Boesche 51

𝑋 ≔ *

𝑄𝐼𝐽 𝑠

𝑛, ⊤ = ⊤

read a, b t := a * b call p t := a * b print t stop

main

𝑠

𝑛

𝑓𝑛 𝑑𝑛 𝑜𝑛 𝑔

1

𝑔

1

if a=0 call p t := a * b return

p

a := a - 1

T F

𝑠

𝑞

𝑓𝑞 𝑔

1

𝑗𝑒𝑀 𝑗𝑒𝑀 𝑔

𝑑𝑞 𝑜𝑞 𝑛𝑞 𝑞𝑠𝑝𝑞𝑏𝑕𝑏𝑢𝑓 ⊤, 𝑔

1 ⊤ , 𝑑𝑛

𝑄𝐼𝐽 𝑑𝑛, ⊤ = 1

+ 𝑠

𝑛, ⊤

𝑑𝑛, ⊤

𝑞𝑠𝑝𝑞𝑏𝑕𝑏𝑢𝑓 1,1, 𝑠

𝑞

𝑠

𝑞, 1 𝑄𝐼𝐽 𝑠

𝑞, 1 = 1

𝑞𝑠𝑝𝑞𝑏𝑕𝑏𝑢𝑓 1, 𝑗𝑒𝑀(1), 𝑜𝑞 𝑞𝑠𝑝𝑞𝑏𝑕𝑏𝑢𝑓 1, 𝑗𝑒𝑀(1), 𝑓𝑞 𝑄𝐼𝐽 𝑜𝑞, 1 = 1 𝑄𝐼𝐽 𝑓𝑞, 1 = 1

… 𝑓𝑞, 1

𝑞𝑠𝑝𝑞𝑏𝑕𝑏𝑢𝑓 ⊤, 1, 𝑜𝑛 𝑄𝐼𝐽 𝑜𝑛, ⊤ = 1

… … …

slide-52
SLIDE 52

Su Summa mary: ry: Define fine va valid lid pat aths hs

12.06.2010 Klaas Boesche 52

𝐽𝑊𝑄0(𝑠

𝑞, 𝑜)

𝑠

𝑟

𝑓𝑟

p

𝑠

𝑞

𝑜

call q return 𝑛 𝑛′

𝐽𝑊𝑄(𝑠

𝑛𝑏𝑗𝑜, 𝑜) q

main

𝑠𝑛𝑏𝑗𝑜 𝑜 𝑠

𝑞𝑘

call𝑞2

𝑑1

𝑞𝑘

𝑟1 ∈ 𝐽𝑊𝑄0(𝑠𝑛𝑏𝑗𝑜, 𝑜) 𝑟𝑘 ∈ 𝐽𝑊𝑄0(𝑠

𝑞𝑘, 𝑜)

slide-53
SLIDE 53

Su Summa mary: ry: Fun uncti ctional

  • nal App

Approa roach ch

12.06.2010 Klaas Boesche 53 𝑠

𝑟

𝑓𝑟

p

𝑠

𝑞

𝑜

call q return 𝑛

𝜚𝑠𝑞,𝑜 𝜚𝑠𝑟,𝑓𝑟 𝜚𝑠𝑞,𝑛

𝑚

𝜚𝑠𝑞,𝑚 𝑔 𝑚,𝑜

Information 𝑦 at 𝑠

𝑞

is transformed to 𝜚𝑠𝑞,𝑜 𝑦 at 𝑜

slide-54
SLIDE 54

Su Summa mary: ry: Fun uncti ctional

  • nal Resu

esult lt

12.06.2010 Klaas Boesche 54

𝐺 is 𝑒𝑗𝑡𝑢𝑠𝑗𝑐𝑣𝑢𝑗𝑤𝑓 ⟹ The maximum fixed point solution 𝑦𝑜

∗ of the

functional approach = the interprocedural MOP solution 𝑧𝑜

slide-55
SLIDE 55

Su Summa mary: ry: Pr Prac acti tical cal As Aspec pects ts

 Represent 𝜚𝑠𝑞,𝑜 symbolically or by explicit

relation

 Explicit approach may require much space  𝑀 𝑗𝑜𝑔𝑗𝑜𝑗𝑢𝑓 ⟹ Explicit approach may diverge  𝑀 𝑗𝑜𝑔𝑗𝑜𝑗𝑢𝑓, 𝐺 𝑣𝑜𝑐𝑝𝑣𝑜𝑒𝑓𝑒 ⟹ Symbolic

approach may diverge

12.06.2010 Klaas Boesche 55