CS 614: Theory and Construction of Compilers Lecture 17 Fall 2003 Department of Computer Science University of Alabama Joel Jones.

Slides:



Advertisements
Similar presentations
Continuing Abstract Interpretation We have seen: 1.How to compile abstract syntax trees into control-flow graphs 2.Lattices, as structures that describe.
Advertisements

Lecture 11: Code Optimization CS 540 George Mason University.
Data Flow Analysis. Goal: make assertions about the data usage in a program Use these assertions to determine if and when optimizations are legal Local:
1 CS 201 Compiler Construction Lecture 3 Data Flow Analysis.
Data-Flow Analysis Framework Domain – What kind of solution is the analysis looking for? Ex. Variables have not yet been defined – Algorithm assigns a.
CS412/413 Introduction to Compilers Radu Rugina Lecture 37: DU Chains and SSA Form 29 Apr 02.
Some Properties of SSA Mooly Sagiv. Outline Why is it called Static Single Assignment form What does it buy us? How much does it cost us? Open questions.
School of EECS, Peking University “Advanced Compiler Techniques” (Fall 2011) Dataflow Analysis Introduction Guo, Yao Part of the slides are adapted from.
Foundations of Data-Flow Analysis. Basic Questions Under what circumstances is the iterative algorithm used in the data-flow analysis correct? How precise.
Early Global Program Optimizations Chapter Mooly Sagiv.
CSE 231 : Advanced Compilers Building Program Analyzers.
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.
1 CS 201 Compiler Construction Lecture 10 SSA-Based Sparse Conditional Constant Propagation.
CS 536 Spring Global Optimizations Lecture 23.
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.
Data Flow Analysis Compiler Design Nov. 3, 2005.
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.
1 CS 201 Compiler Construction Lecture 3 Data Flow Analysis.
Data Flow Analysis Compiler Design October 5, 2004 These slides live on the Web. I obtained them from Jeff Foster and he said that he obtained.
CS 412/413 Spring 2007Introduction to Compilers1 Lecture 29: Control Flow Analysis 9 Apr 07 CS412/413 Introduction to Compilers Tim Teitelbaum.
Administrative stuff Office hours: After class on Tuesday.
1 CS 201 Compiler Construction Lecture 6 Code Optimizations: Constant Propagation & Folding.
Data Flow Analysis Compiler Design Nov. 8, 2005.
Course Outline Traditional Static Program Analysis –Theory Compiler Optimizations; Control Flow Graphs, Data-flow Analysis Data-flow Frameworks --- today’s.
San Diego October 4-7, 2006 Over 1,000 women in computing Events for undergraduates considering careers and graduate school Events for graduate students.
Recap: Reaching defns algorithm From last time: reaching defns worklist algo We want to avoid using structure of the domain outside of the flow functions.
Prof. Fateman CS 164 Lecture 221 Global Optimization Lecture 22.
Orderings and Bounds Parallel FSM Decomposition Prof. K. J. Hintz Department of Electrical and Computer Engineering Lecture 10 Update and modified by Marek.
U NIVERSITY OF M ASSACHUSETTS, A MHERST D EPARTMENT OF C OMPUTER S CIENCE Advanced Compilers CMPSCI 710 Spring 2003 Data flow analysis Emery Berger University.
1 CS 201 Compiler Construction Lecture 4 Data Flow Framework.
Machine-Independent Optimizations Ⅰ CS308 Compiler Theory1.
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.
1 CS 201 Compiler Construction Lecture 10 SSA-Based Sparse Conditional Constant Propagation.
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.
Prof. Bodik CS 164 Lecture 16, Fall Global Optimization Lecture 16.
Constant Propagation. The constant propagation framework is different from all the data-flow problems discussed so far, in that It has an unbounded set.
1 CS 201 Compiler Construction Data Flow Analysis.
Data Flow Analysis. 2 Source code parsed to produce AST AST transformed to CFG Data flow analysis operates on control flow graph (and other intermediate.
Solving fixpoint equations
Machine-Independent Optimizations Ⅱ CS308 Compiler Theory1.
Dataflow Analysis Topic today Data flow analysis: Section 3 of Representation and Analysis Paper (Section 3) NOTE we finished through slide 30 on Friday.
CS 614: Theory and Construction of Compilers Lecture 7 Fall 2002 Department of Computer Science University of Alabama Joel Jones.
Data-Flow Analysis (Chapter 8). Outline What is Data-Flow Analysis? Structure of an optimizing compiler An example: Reaching Definitions Basic Concepts:
CS 614: Theory and Construction of Compilers Lecture 15 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
CS 614: Theory and Construction of Compilers Lecture 5 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
Data Flow Analysis II AModel Checking and Abstract Interpretation Feb. 2, 2011.
CS 614: Theory and Construction of Compilers Lecture 8 Fall 2002 Department of Computer Science University of Alabama Joel Jones.
Iterative Dataflow Problems Taken largely from notes of Alex Aiken (UC Berkeley) and Martin Rinard (MIT) Dataflow information used in optimization Several.
Optimization Simone Campanoni
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.
CS 614: Theory and Construction of Compilers Lecture 4 Fall 2002 Department of Computer Science University of Alabama Joel Jones.
Lub and glb Given a poset (S, · ), and two elements a 2 S and b 2 S, then the: –least upper bound (lub) is an element c such that a · c, b · c, and 8 d.
DFA foundations Simone Campanoni
CS 614: Theory and Construction of Compilers
Solve Linear Systems by Graphing
Simone Campanoni DFA foundations Simone Campanoni
Global optimizations.
Discrete Math (2) Haiming Chen Associate Professor, PhD
Fall Compiler Principles Lecture 10: Loop Optimizations
Data Flow Analysis Compiler Design
Lecture 20: Dataflow Analysis Frameworks 11 Mar 02
Background material.
Formalization of DFA using lattices
Background material.
Formalization of DFA using lattices
Live variables and copy propagation
Formalization of DFA using lattices
Formalization of DFA using lattices
Presentation transcript:

CS 614: Theory and Construction of Compilers Lecture 17 Fall 2003 Department of Computer Science University of Alabama Joel Jones

Lecture 17©2003 Joel Jones2 Overview Lattices and Flow Functions Taxonomy of DataFlow Problems and Solution Methods Iterative Data-Flow Analysis Reading for Next Time

Lecture 17©2003 Joel Jones3 Lattices and Flow Functions Lattice – an algebraic structure that has associated with it elements and functions that map from one element of the lattice to the other. (these are necessary but not sufficient conditions).

Lecture 17©2003 Joel Jones4 Lattice Preliminaries See handout

Lecture 17©2003 Joel Jones5 Lattice properties A lattice consists of a set of values and two operations called meet and join Meet – forms greatest lower bound Join - forms least upper bound Properties of meet and join See handout

Lecture 17©2003 Joel Jones6 Properties of Common Lattices in Compilers Elements are bit vectors Meet and Join are bit-wise and and or, respectively Bottom element is all zeros and Top element is all ones Pair Up: What would the lattice for booleans look like?, factors of 12 ordered by divisibility?

Lecture 17©2003 Joel Jones7 Taxonomy of Data-Flow Problems and Solution Methods How characterize? Information provided Relational or independent Types of lattices, meanings, and functions Direction: forward, backward, both

Lecture 17©2003 Joel Jones8 Data-flow Problems Reaching DefinitionsIbit-vectorFWhich definitions reach which program points Available ExpressionsIbit-vectorFWhich expressions reach which program points Live VariablesIbit-vectorBWhich variables have a use between program point and exit Upwards Exposed Uses Ibit-vectorBWhat use of variables at program point are reached by which definitions Copy-propagationIbit-vectorFWhich program points a copy expression reaches (x  y) Constant-propagationIICP n F Which constant assignments (x  const) reach which points with same constant value Partial-redundancyIbit-vectorBiWhich computations are performed >1 times without modification

Lecture 17©2003 Joel Jones9 Iterative Data-Flow Analysis See handout Worklist_Iterate(N:set of Node; entry:Node, F: Node x L  L, dfin: Node  L, init: L) dfin(entry) := init; Worklist: set of Node := N - {entry} for each B: Node  N do dfin(B) := top od repeat B :=   ; Worklist -= {B}; totaleffect := top for each P  Pred(B) do effect := F(P, dfin(P)) totaleffect meetAssign effect od if dfin(B) ≠ totaleffect then dfin(B) := totaleffect; Worklist  Succ(B) fi Until Worklist = ø end

Lecture 17©2003 Joel Jones10 Readings for Next Time Sections 8.2–8.4 of the textbook