This preview shows pages 1–7. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Principles of Program Analysis: Algorithms Transparencies based on Chapter 6 of the book: Flemming Nielson, Hanne Riis Nielson and Chris Hankin: Principles of Program Analysis . Springer Verlag 2005. c Flemming Nielson & Hanne Riis Nielson & Chris Hankin. PPA Chapter 6 c F.Nielson & H.Riis Nielson & C.Hankin (Dec. 2004) 1 Worklist Algorithms We abstract away from the details of a particular analysis: We want to compute the solution to a set of equations { x 1 = t 1 , , x N = t N } or inequations { x 1 w t 1 , , x N w t N } defined in terms of a set of flow variables x 1 , ,x N ; here t 1 , ,t N are terms using the flow variables. PPA Section 6.1 c F.Nielson & H.Riis Nielson & C.Hankin (Dec. 2004) 2 Equations or inequations? It does not really matter: A solution of the equation system { x 1 = t 1 , ,x N = t N } is also a solution of the inequation system { x 1 w t 1 , ,x N w t N } The least solution to the inequation systems { x 1 w t 1 , ,x N w t N } is also a solution to the equation system { x 1 = t 1 , ,x N = t N } The inequation system { x w t 1 , ,x w t n } (same left hand sides) and the equation { x = x t t 1 t t t n } have the same solutions. The least solution to the equation { x = x t t 1 t t t n } is also the least solution of { x = t 1 t t t n } (where the x com ponent has been removed on the right hand side). PPA Section 6.1 c F.Nielson & H.Riis Nielson & C.Hankin (Dec. 2004) 3 Example While program Reaching Definitions Analysis of if [ b 1 ] 1 then (while [ b 2 ] 2 do [ x := a 1 ] 3 ) else (while [ b 3 ] 4 do [ x := a 2 ] 5 ); [ x := a 3 ] 6 gives equations of the form RD entry (1) = X ? RD exit (1) = RD entry (1) RD entry (2) = RD exit (1) RD exit (3) RD exit (2) = RD entry (2) RD entry (3) = RD exit (2) RD exit (3) = ( RD entry (3) \ X 356? ) X 3 RD entry (4) = RD exit (1) RD exit (5) RD exit (4) = RD entry (4) RD entry (5) = RD exit (4) RD exit (5) = ( RD entry (5) \ X 356? ) X 5 RD entry (6) = RD exit (2) RD exit (4) RD exit (6) = ( RD entry (6) \ X 356? ) X 6 where e.g. X 356? denotes the definitions of x at labels 3, 5, 6 and ? PPA Section 6.1 c F.Nielson & H.Riis Nielson & C.Hankin (Dec. 2004) 4 Example (cont.) Focussing on RD entry and expressed as equations using the flow variables { x 1 , , x 6 } : x 1 = X ? x 2 = x 1 ( x 3 \ X 356? ) X 3 x 3 = x 2 x 4 = x 1 ( x 5 \ X 356? ) X 5 x 5 = x 4 x 6 = x 2 x 4 Alternatively we can use inequations : x 1 X ? x 2 x 1 x 2 x 3 \ X 356? x 2 X 3 x 3 x 2 x 4 x 1 x 4 x 5 \ X 356? x 4 X 5 x 5 x 4 x 6 x 2 x 6 x 4 PPA Section 6.1 c F.Nielson & H.Riis Nielson & C.Hankin (Dec. 2004) 5 Assumptions There is a finite constraint system S of the form ( x i w t i ) N i =1 for N 1 where the left hand sides x i are not necessarily distinct; the form of the terms t i of the right hand sides is left unspecified.of the right hand sides is left unspecified....
View Full
Document
 Spring '10
 Gopalan
 Algorithms

Click to edit the document details