Another example: constant prop Set D = 2 { x ! N | x ∊ Vars Æ N ∊ Z } x := N in out F x := N (in) = in – { x ! * } [ { x ! N } x := y op z in out F x :=

Slides:



Advertisements
Similar presentations
Average Value and the 2 nd Fundamental Theorem. What is the area under the curve between 0 and 2? f(x)
Advertisements

Continuing Abstract Interpretation We have seen: 1.How to compile abstract syntax trees into control-flow graphs 2.Lattices, as structures that describe.
Static Single Assignment CS 540. Spring Efficient Representations for Reachability Efficiency is measured in terms of the size of the representation.
Variables Vocabulary.
Lesson 8-4: Direct, Joint, and Inverse Variation.
CSE 231 : Advanced Compilers Building Program Analyzers.
Common Sub-expression Elim Want to compute when an expression is available in a var Domain:
Worklist algorithm Initialize all d i to the empty set Store all nodes onto a worklist while worklist is not empty: –remove node n from worklist –apply.
From last time: live variables Set D = 2 Vars Lattice: (D, v, ?, >, t, u ) = (2 Vars, µ, ;,Vars, [, Å ) x := y op z in out F x := y op z (out) = out –
Today Today: Chapter 5 Reading: –Chapter 5 (not 5.12) –Suggested problems: 5.1, 5.2, 5.3, 5.15, 5.25, 5.33, 5.38, 5.47, 5.53, 5.62.
Administrative info Subscribe to the class mailing list –instructions are on the class web page, which is accessible from my home page, which is accessible.
Another example: constant prop Set D = 2 { x ! N | x 2 Vars Æ N 2 Z } x := N in out F x := N (in) = in – { x ! * } [ { x ! N } x := y op z in out F x :=
From last time: Lattices A lattice is a tuple (S, v, ?, >, t, u ) such that: –(S, v ) is a poset – 8 a 2 S. ? v a – 8 a 2 S. a v > –Every two elements.
From last time: reaching definitions For each use of a variable, determine what assignments could have set the value being read from the variable Information.
Static Program Analysis Xiangyu Zhang The slides are compiled from Alex Aiken’s Michael D. Ernst’s Sorin Lerner’s.
Another example p := &x; *p := 5 y := x + 1;. Another example p := &x; *p := 5 y := x + 1; x := 5; *p := 3 y := x + 1; ???
Back to lattice (D, v, ?, >, t, u ) = (2 A, ¶, A, ;, Å, [ ) where A = { x ! N | x 2 Vars Æ N 2 Z } What’s the problem with this lattice? Lattice is infinitely.
Recap Let’s do a recap of what we’ve seen so far Started with worklist algorithm for reaching definitions.
Constraints for reaching definitions Using may-point-to information: out = in [ { x ! s | x 2 may-point-to(p) } Using must-point-to aswell: out = in –
1 CS 201 Compiler Construction Lecture 6 Code Optimizations: Constant Propagation & Folding.
Project Project proposal due today (lots of projects have already sent theirs in!) I want some concrete results in 3 weeks! –for implementation projects,
From last lecture x := y op z in out F x := y op z (in) = in [ x ! in(y) op in(z) ] where a op b =
Direction of analysis Although constraints are not directional, flow functions are All flow functions we have seen so far are in the forward direction.
Projects. Dataflow analysis Dataflow analysis: what is it? A common framework for expressing algorithms that compute information about a program Why.
Project web page
From last time: reaching definitions For each use of a variable, determine what assignments could have set the value being read from the variable Information.
From last lecture We want to find a fixed point of F, that is to say a map m such that m = F(m) Define ?, which is ? lifted to be a map: ? = e. ? Compute.
Direction of analysis Although constraints are not directional, flow functions are All flow functions we have seen so far are in the forward direction.
Even more formal To reason more formally about termination and precision, we re-express our worklist algorithm mathematically We will use fixed points.
Termination Still, it’s annoying to have to perform a join in the worklist algorithm It would be nice to get rid of it, if there is a property of the flow.
Precision Going back to constant prop, in what cases would we lose precision?
Example x := read() v := a + b x := x + 1 w := x + 1 a := w v := a + b z := x + 1 t := a + b.
Compiler Construction Lecture 16 Data-Flow Analysis.
4.5 Solving Systems using Matrix Equations and Inverses.
11.1 – The Greatest Common Factor (GCF)
Section 12.5 Functions of Three Variables. Consider temperature at a point in space –It takes 3 coordinates to determine a point in space, (x, y, z),
Indeterminate Forms and L’Hopital’s Rule Chapter 4.4 April 12, 2007.
11-3: Direct and Inverse Variation
GUIDED PRACTICE for Example – – 2 12 – 4 – 6 A = Use a graphing calculator to find the inverse of the matrix A. Check the result by showing.
Slide Copyright © 2009 Pearson Education, Inc. 6.5 Variation.
4.2 Area Definition of Sigma Notation = 14.
Solving Systems by Elimination 5.4 NOTES, DATE ____________.
1 Numeric Abstract Domains Mooly Sagiv Tel Aviv University Adapted from Antoine Mine.
Solving multi step equations. 12X + 3 = 4X X 12X + 3 = 3X X 9X + 3 = X = X =
So You Want To Learn Lattice Multiplication?. 43 x 92.
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2011 Yet More Data flow analysis John Cavazos.
Exponents For all real numbers x and all positive integers m, xm = x x x … x, m factors Evaluate: Answers:
Derivative Examples Example 1 Suppose the Ball Rolling Down an Incline Lab resulted in a position vs. time function of. What is the velocity as a function.
DFA foundations Simone Campanoni
MD5 A Hash Algorithm….
Dataflow analysis.
Movable lines class activity.
Direct Variation.
The Ideal Op Amp Inverting and non-Inverting configurations
Pointer Basics Psst… over there.
MD5 A Hash Algorithm….
Polynomials Real world connections Business/Financial planning
Another example: constant prop
Solving Systems Equations in Three Variables
The Ideal Op Amp Inverting and non-Inverting configurations
Dataflow analysis.
CS 201 Compiler Construction
Variables.
Riemann Sums and Integrals
Sequences F.LE.1, 2, 5 F.BF.1, 2 A.SSE.1.a F.IF.1, 2, 3, 4
Finding the Area of Triangles
If x is a variable, then an infinite series of the form
7.1 – Functions of Several Variables
Pointer Basics Psst… over there.
LAPLACE TRANSFORMATION
Presentation transcript:

Another example: constant prop Set D = 2 { x ! N | x ∊ Vars Æ N ∊ Z } x := N in out F x := N (in) = in – { x ! * } [ { x ! N } x := y op z in out F x := y op z (in) = in – { x ! * } [ { x ! N | ( y ! N 1 ) ∊ in Æ ( z ! N 2 ) ∊ in Æ N = N 1 op N 2 }

Another example: constant prop *x := y in out F *x := y (in) = x := *y in out F x := *y (in) =

Another example: constant prop *x := y in out F *x := y (in) = in – { z ! * | z ∊ may-point(x) } [ { z ! N | z ∊ must-point-to(x) Æ y ! N ∊ in } [ { z ! N | (y ! N) ∊ in Æ (z ! N) ∊ in } x := *y in out F x := *y (in) = in – { x ! * } [ { x ! N | 8 z ∊ may-point-to(x). (z ! N) ∊ in }

Another example: constant prop x := f(...) in out F x := f(...) (in) = *x := *y + *z in out F *x := *y + *z (in) =

Another example: constant prop x := f(...) in out F x := f(...) (in) = ; *x := *y + *z in out F *x := *y + *z (in) = F a := *y;b := *z;c := a + b; *x := c (in)

Another example: constant prop s: if (...) in out[0]out[1] merge out in[0]in[1]

Lattice (D, ⊑, ⊥, ⊤, ⊔, ⊓ ) =

Lattice (D, ⊑, ⊥, ⊤, ⊔, ⊓ ) = (2 A, ¶, A, ;, Å, [ ) where A = { x ! N | x ∊ Vars Æ N ∊ Z }

Example x := 5 v := 2 x := x + 1 w := v + 1 w := 3 y := x * 2 z := y + 5 w := w * v

Back to lattice (D, ⊑, ⊥, ⊤, ⊔, ⊓ ) = (2 A, ¶, A, ;, Å, [ ) where A = { x ! N | x ∊ Vars Æ N ∊ Z } What’s the problem with this lattice?

Back to lattice (D, ⊑, ⊥, ⊤, ⊔, ⊓ ) = (2 A, ¶, A, ;, Å, [ ) where A = { x ! N | x ∊ Vars Æ N ∊ Z } What’s the problem with this lattice? Lattice is infinitely high, which means we can’t guarantee termination

Better lattice Suppose we only had one variable

Better lattice Suppose we only had one variable D = { ⊥, ⊤ } [ Z 8 i ∊ Z. ⊥ ⊑ i Æ i ⊑ ⊤ height = 3