two wo approa proach ches s to to in inte terproc
play

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


  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 Part one: The Functional Approach 12.06.2010 Klaas Boesche

  2. Int ntra raproc proced edura ural l an anal alysis ysis procedure main procedure p if a=0 T read a, b F t := a * b a := a - 1 call p call p a*b available? t := a * b print t t := a * b stop return 12.06.2010 Klaas Boesche 2

  3. Int nter erproc proced edura ural cha hallenges llenges Recursion Infeasible paths Function variables & Virtual functions main p … if a=0 T x := … F p main p call p a := a - 1 call x call p … q q … t := a * b return Infinite paths Filter invalid paths No static call graph • • • Efficiency vs. Precision and Efficiency • • Precision 12.06.2010 Klaas Boesche 3

  4. Out utline line  Notatio ion n and Revie iew  Functional Approach  Interprocedural MOP  Pragmatic Considerations 12.06.2010 Klaas Boesche 4

  5. Not otatio ations ns Control Flow Graphs main p 𝑞 if a=0 𝑠 T read a, b F t := a * b 𝑠 𝑛𝑏𝑗𝑜 a := a - 1 no parameters call p call p t := a * b print t t := a * b 𝑓 𝑞 𝑓 𝑛𝑏𝑗𝑜 stop return 12.06.2010 Klaas Boesche 5

  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 ⊥ Analysis direction ≤ ⊤ 12.06.2010 Klaas Boesche 6

  7. Dat ata a Flo low w Fra ramework meworks  (𝑀, 𝐺) is a data flow framework: 𝐺 is a monotone space of transfer functions Closed under composition and meet 𝑔 ∧ 𝑕 𝑦 = 𝑔 𝑦 ∧ 𝑕(𝑦) 1. ⊥ 𝑦 = ⊥ Contains 𝑗𝑒 𝑀 𝑦 = 𝑦 and 𝑔 2. 𝐺 is 𝑒𝑗𝑡𝑢𝑠𝑗𝑐𝑣𝑢𝑗𝑤𝑓 iff ∀𝑔, 𝑦, 𝑧: 𝑔 𝑦 ∧ 𝑔(𝑧) = 𝑔(𝑦 ∧ 𝑧)  Restrict 𝐺 to graph 𝐻 = (𝑂, 𝐹) : Smallest 𝑇 ⊆ 𝐺 such that 𝑔 𝑛,𝑜 𝑛, 𝑜 ∈ 𝐹 ⊆ 𝑇 and 1. and 2. hold 12.06.2010 Klaas Boesche 7

  8. Int ntra raproc proced edura ural exam ampl ple  Available expression framework for the single expression a * b : 𝑀 = ⊤, 1, ⊥ 𝐺 = 𝑔 ⊤ , 𝑔 1 , 𝑗𝑒 𝑀 , 𝑔 ⊥ ⊤ : a * b not available 1 : a * b available 𝑔 ⊤ 𝑦 = ⊤, 𝑔 1 𝑦 = 1 12.06.2010 Klaas Boesche 8

  9. Int ntra raproc proced edura ural exam ampl ple main p ⊤ 𝑞 if a=0 𝑠 T read a, b ⊤ 𝑗𝑒 𝑀 F t := a * b 𝑠 𝑛𝑏𝑗𝑜 1 ⊤ 𝑜 𝑞 𝑔 a := a - 1 1 ⊤ 𝑑 𝑛𝑏𝑗𝑜 𝑔 call p ⊤ ⊤ 𝑑 𝑞 𝑔 call p ⊤ 𝑔 t := a * b ⊤ ⊤ print t 𝑛 𝑞 𝑜 𝑛𝑏𝑗𝑜 t := a * b 1 1 𝑗𝑒 𝑀 𝑔 𝑔 1 ⊤ 𝑓 𝑞 𝑓 𝑛𝑏𝑗𝑜 stop return 12.06.2010 Klaas Boesche 9

  10. Int ntra raproc proced edura ural equations uations The data flow equations 𝑦 𝑠 = ⊤ 𝑜 ∈ 𝑂 − *𝑠+ 𝑦 𝑜 = 𝑔 𝑛,𝑜 𝑦 𝑛 𝑛,𝑜 ∈𝐹 approximate the meet-over-all paths (MOP) solution 𝑞 ( ⊤)|𝑞 ∈ 𝑞𝑏𝑢𝑖 𝐻 𝑠, 𝑜 + 𝑜 ∈ 𝑂 𝑧 𝑜 = *𝑔 (𝑜 1 ,𝑜 2 ) where 𝑔 𝑞=(𝑜 1 ,…,𝑜 𝑙 ) = 𝑔 (𝑜 𝑙−1 ,𝑜 𝑙 ) ∘ ⋯ ∘ 𝑔 12.06.2010 Klaas Boesche 10

  11. Int ntra raproc proced edura ural sol olutions utions 𝐺 is 𝑒𝑗𝑡𝑢𝑠𝑗𝑐𝑣𝑢𝑗𝑤𝑓 ⟹ ∗ = 𝑧 𝑜 The maximum fixed point solution 𝑦 𝑜 ∗ ≤ 𝑧 𝑜 𝐺 is 𝑛𝑝𝑜𝑝𝑢𝑝𝑜𝑓 ⟹ 𝑦 𝑜 12.06.2010 Klaas Boesche 11

  12. Out utline line  Notation and Review  Functi ctional onal Approac ach  Interprocedural MOP  Pragmatic Considerations 12.06.2010 Klaas Boesche 12

  13. Int nter erproc proced edura ural Gra raphs phs Two representations: 0 ∪ 𝐹 𝑞 𝐹 0 = 𝐹 𝑞 1 0 𝐹 𝑞 = 𝐹 𝑞 𝐻 = 𝑂 𝑞 , 𝐹 𝑞 1. 𝑞 𝑞 𝐹 ∗ = 𝐹 0 ∪ 𝐹 1 𝐻 ∗ = 𝑂 𝑞 , 𝐹 ∗ 𝑞 2. 𝑞 s p 𝑞 0 … 𝑠 𝐹 𝑞 Intraprocedural edges 0 0 𝐹 𝑡 𝐹 𝑞 𝐹 1 1 𝐹 𝑞 call p … Intraprocedural edges with interprocedural control flow 1 0 𝐹 𝑡 𝐹 𝑞 𝑓 𝑞 return 𝐹 1 𝐹 1 0 𝐹 𝑡 Interprocedural edges … 12.06.2010 Klaas Boesche 13

  14. Ex Exam ample ple 𝐻 main p 𝑞 if a=0 𝑠 T read a, b F t := a * b 𝑠 𝑛𝑏𝑗𝑜 a := a - 1 call p 1 𝐹 𝑛𝑏𝑗𝑜 call p 1 𝐹 𝑞 t := a * b print t t := a * b 𝑓 𝑞 𝑓 𝑛𝑏𝑗𝑜 stop return 12.06.2010 Klaas Boesche 14

  15. Exam Ex ample ple 𝐻 ∗ main p 𝑞 if a=0 𝑠 T read a, b F t := a * b 𝑠 𝑛𝑏𝑗𝑜 a := a - 1 call p call p t := a * b print t t := a * b 𝑓 𝑞 𝑓 𝑛𝑏𝑗𝑜 stop return 12.06.2010 Klaas Boesche 15

  16. Int nter erproc proced edura urally lly Val alid id pat aths hs 𝑞 , 𝑜) 𝐽𝑊𝑄 0 (𝑠 p 𝑞 𝑠 q 𝑟 𝑠 call q 𝑛 𝑓 𝑟 return 𝑛′ 𝑜 12.06.2010 Klaas Boesche 16

  17. Int nter erproc proced edura urally lly Val alid id pat aths hs 𝑛𝑏𝑗𝑜 , 𝑜) 𝐽𝑊𝑄(𝑠 main 𝑠 𝑛𝑏𝑗𝑜 𝑟 1 ∈ 𝐽𝑊𝑄 0 (𝑠 𝑛𝑏𝑗𝑜 , 𝑜) 𝑞 2 𝑞 2 call 𝑞 2 𝑠 𝑑 1 𝑞 2 , 𝑜) 𝑟 2 ∈ 𝐽𝑊𝑄 0 (𝑠 𝑞 𝑘 𝑑 2 … 𝑞 𝑘 𝑠 call 𝑞 3 𝑞 𝑘 , 𝑜) 𝑟 𝑘 ∈ 𝐽𝑊𝑄 0 (𝑠 𝑜 12.06.2010 Klaas Boesche 17

  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

  19. Int nter erproc proced edura urally lly Val alid id pat aths hs  𝑞 ∈ 𝑞𝑏𝑢𝑖 𝐻 ∗ 𝑠 𝑟 , 𝑜 𝑗𝑡 𝑗𝑜 𝐽𝑊𝑄 0 𝑠 𝑟 , 𝑜 ⟺ q' 𝑞| 𝐹 1 𝑗𝑡 𝑑𝑝𝑛𝑞𝑚𝑓𝑢𝑓 𝑟′ 𝑠 call q ' 𝑛 defined as: 𝑞 1 𝑓 𝑟′ return 𝑛′ 1. 𝑞| 𝐹 1 = 𝜁 2. 𝑞| 𝐹 1 = 𝑞 1 ∥ 𝑞 2 and 𝑞 1 , 𝑞 2 𝑏𝑠𝑓 𝑑𝑝𝑛𝑞𝑚𝑓𝑢𝑓 𝑟′ ∥ 𝑞 1 ∥ 𝑓 𝑟′ , 𝑛 ′ and 𝑞 1 𝑗𝑡 𝑑𝑝𝑛𝑞𝑚𝑓𝑢𝑓 3. 𝑞| 𝐹 1 = 𝑛, 𝑠 12.06.2010 Klaas Boesche 19

  20. Int nter erproc proced edura urally lly Val alid id pat aths hs  𝑟 ∈ 𝐽𝑊𝑄 𝑠 𝑛𝑏𝑗𝑜 , 𝑜 ∶⟺ ∥ 𝑟 𝑘 𝑟 = 𝑟 1 ∥ 𝑑 1 , 𝑠 ∥ 𝑟 2 ∥ ⋯ ∥ 𝑑 𝑘−1 , 𝑠 𝑞 2 𝑞 𝑘 𝑞 𝑘 , 𝑜 ∀𝑗 < 𝑘: 𝑟 𝑗 ∈ 𝐽𝑊𝑄 0 𝑠 𝑞 𝑗 , 𝑑 𝑗 and 𝑟 𝑘 ∈ 𝐽𝑊𝑄 0 𝑠  Also called Path Decomposition 12.06.2010 Klaas Boesche 20

  21. Ex Exam amples ples 𝑞 , 𝑓 𝑞 , 𝑜 𝑑 𝑛𝑏𝑗𝑜 , 𝑠 𝑞 , 𝑑 𝑞 , 𝑠 𝐻 ∗ 𝑞 if a=0 𝑠 T read a, b F t := a * b 𝑠 𝑛𝑏𝑗𝑜 a := a - 1 𝑑 𝑛𝑏𝑗𝑜 call p 𝑑 𝑞 call p t := a * b print t 𝑜 t := a * b 𝑓 𝑞 𝑓 𝑛𝑏𝑗𝑜 stop return 12.06.2010 Klaas Boesche 21

  22. Ex Exam amples ples 𝑞 , 𝑓 𝑞 , 𝑜 , 𝑓 𝑞 , 𝑜 𝑑 𝑛𝑏𝑗𝑜 , 𝑠 𝑞 , 𝑑 𝑞 , 𝑠 𝑞 , 𝑑 𝑞 , 𝑠 𝐻 ∗ 𝑞 if a=0 𝑠 T read a, b F t := a * b 𝑠 𝑛𝑏𝑗𝑜 a := a - 1 𝑑 𝑛𝑏𝑗𝑜 call p 𝑑 𝑞 call p t := a * b print t 𝑜 t := a * b 𝑓 𝑞 𝑓 𝑛𝑏𝑗𝑜 stop return 12.06.2010 Klaas Boesche 22

  23. Fun unctional ctional ap approach roach p 𝑞 𝑠 𝜚 𝑠 𝑞 ,𝑛 𝜚 𝑠 𝑞 ,𝑚 𝑟 𝑠 call q 𝑛 𝜚 𝑠 𝑞 ,𝑜 𝜚 𝑠 𝑟 ,𝑓 𝑟 𝑓 𝑟 𝑚 return 𝑔 𝑚,𝑜 𝑜 Information 𝑦 at 𝑠 𝑞 is transformed to 𝜚 𝑠 𝑞 ,𝑜 𝑦 at 𝑜 12.06.2010 Klaas Boesche 23

  24. Fun unctional ctional Ap Appr proac oach h equ quations ations 𝜚 𝑠 𝑞 ,𝑠 𝑞 = 𝑗𝑒 𝑀 𝜚 𝑠 𝑞 ,𝑜 = 𝑖 𝑛,𝑜 ∘ 𝜚 𝑠 𝑞 ,𝑛 𝑞 + 𝑜 ∈ 𝑂 𝑞 − *𝑠 𝑛,𝑜 ∈ 𝐹 𝑞 0 𝑛, 𝑜 ∈ 𝐹 𝑞 𝑔 𝑛,𝑜 𝑖 𝑛,𝑜 = 1 , 𝑛 𝑑𝑏𝑚𝑚𝑡 𝑟 𝜚 𝑠 𝑟 ,𝑓 𝑟 𝑛, 𝑜 ∈ 𝐹 𝑞 Recursion implicitly encoded  Initialize the equations with in equations 𝜚 𝑠 𝑞 ,𝑠 𝑞 = 𝑗𝑒 𝑀 𝑞 + 𝜚 𝑠 𝑞 ,𝑜 = 𝑔 ⊥ 𝑜 ∈ 𝑂 𝑞 − *𝑠  Compute the maximal fixed point 12.06.2010 Klaas Boesche 24

  25. Exam Ex ample ple main p 𝑞 if a=0 𝑠 T read a, b 𝑗𝑒 𝑀 𝑗𝑒 𝑀 F t := a * b 𝑛 𝑠 1 𝑜 𝑞 𝑔 a := a - 1 1 ∘ 𝜚 𝑠 𝑛 ,𝑠 𝑛 ⊤ 𝑑 𝑛 𝑔 𝑔 call p 𝑑 𝑞 call p t := a * b 𝜚 𝑠 𝑞 ,𝑓 𝑞 ∘ 𝜚 𝑠 𝑛 ,𝑑 𝑛 print t 𝑛 𝑞 𝑜 𝑛 t := a * b 1 1 𝑗𝑒 𝑀 𝑔 𝑔 1 ∘ 𝜚 𝑠 𝑛 ,𝑜 𝑛 𝑓 𝑞 𝑓 𝑛 𝑔 stop return 12.06.2010 Klaas Boesche 25

Recommend


More recommend