Intra-procedural Data Flow Analysis Backwards analyses

Size: px
Start display at page:

Download "Intra-procedural Data Flow Analysis Backwards analyses"

Transcription

1 Live variables Dead code elimination Very Busy Expressions Code hoisting Bitvector frameworks Monotone frameworks Intra-procedural Data Flow Analysis Backwards analyses Hanne Riis Nielson and Flemming Nielson Informatics and Mathematical Modelling Technical University of Denmark c Hanne Riis Nielson & Flemming Nielson c HRN&FN (cf. slide 2) October 28,

2 Copyright This set of transparencies is mainly based on Flemming Nielson, Hanne Riis Nielson, Chris Hankin: Principles of Program Analysis. Springer, 1999; ISBN They may be used by instructors for presentations based on the book but may not be copied and distributed electronically or by other means. A handout version with four slides per page may be used for producing paper copies of the slides for students; the students may be charged no fee beyond reasonable production cost. The handout version of the transparancies is available from the webpage riis/ppa.htm. c HRN&FN (cf. slide 2) October 28,

3 Summary: Forward analyses Summary: Forward analyses [x := a] l A (l) A (l) [...] l 1 [...] l k [...] l A (l 1 ) A (l k ) A (l) A (l) = (A (l)\kill A (B l )) gen A (B l ) where B l blocks(s ) ι A if l = init(s ) A (l) = A {A (l ) (l, l) flow(s )} otherwise where A RD AE ι A {(x,?) x FV(S )} A c HRN&FN (cf. slide 2) October 28,

4 Live variables Live Variables Analysis A variable is live at the exit from a label if there is a path from the label to a use of the variable that does not re-define the variable. The aim of the Live Variables Analysis is to determine For each program point, which variables may be live at the exit from the point. Example point of interest [ x :=2] 1 ; [y:=4] 2 ; [x:=1] 3 ; (if [y>x] 4 then [z:=y] 5 else [z:=y*y] 6 ); [x:=z] 7 c HRN&FN (cf. slide 2) October 28,

5 Live variables The basic idea LV (l) [x := a] l LV (l) Analysis information: [...] l LV (l) [...] l 1 [...] l 2 LV (l 1 ) LV (l 2 ) LV (l): the variables that are live at the entry of block l LV (l): the variables that are live at at the exit of block l kill LV (l): the variables that are killed by an elementary block gen LV (l): the variables that are generated by an elementary block c HRN&FN (cf. slide 2) October 28,

6 Live variables Analysis of elementary blocks Definition of the set of variables that are killed by an elementary block (i.e. they are no longer used in the future) and the set of variables that are generated by the block (they may be used in the future): kill LV ([x := a] l ) = {x} kill LV ([skip] l ) = kill LV ([b] l ) = gen LV ([x := a] l ) = FV(a) gen LV ([skip] l ) = gen LV ([b] l ) = FV(b) c HRN&FN (cf. slide 2) October 28,

7 Live variables Analysis of programs LV (l) [x := a] l LV (l) = LV (l) [...] l LV (l) [...] l 1 [...] l 2 LV (l 1 ) LV (l 2 ) Var if l final(s ) {LV (l ) (l, l) flow R (S )} otherwise LV (l) = (LV (l)\kill LV (B l )) gen LV (B l ) where B l blocks(s ) c HRN&FN (cf. slide 2) October 28,

8 Live variables Example [x:=2] 1 ; [y:=4] 2 ; [x:=1] 3 ; (if [y>x] 4 then [z:=y] 5 else [z:=y*y] 6 ); [x:=z] 7 Equations: LV (1) = LV (1)\{x} LV (2) = LV (2)\{y} LV (3) = LV (3)\{x} LV (4) = LV (4) {x, y} LV (5) = (LV (5)\{z}) {y} LV (6) = (LV (6)\{z}) {y} LV (7) = {z} LV (1) = LV (2) LV (2) = LV (3) LV (3) = LV (4) LV (4) = LV (5) LV (6) LV (5) = LV (7) LV (6) = LV (7) LV (7) = Analysis of elementary blocks: l kill LV (l) gen LV (l) 1 {x} 2 {y} 3 {x} 4 {x, y} 5 {z} {y} 6 {z} {y} 7 {x} {z} Smallest solution: l LV (l) LV (l) 1 2 {y} 3 {y} {x, y} 4 {x, y} {y} 5 {y} {z} 6 {y} {z} 7 {z} c HRN&FN (cf. slide 2) October 28,

9 Live variables Why smallest solution? while [x>1] l do [skip] l od; [x:=x+1] l Equations: LV (l) = LV (l) {x} LV (l ) = LV (l ) LV (l ) = {x} LV (l) = LV (l ) LV (l ) LV (l ) = LV (l) [x>1] l yes [skip] l no [x:=x+1] l LV (l ) = {x} After some calculations: LV (l) = LV (l) {x} Many solutions to this equation: any superset of {x} c HRN&FN (cf. slide 2) October 28,

10 Live variables Dead code elimination Dead Code Elimination An assignment [x := a] l is dead if the value of x is not used before it is redefined. Dead assignments can be eliminated from the program. Example: [x:=2] 1 ; [y:=4] 2 ; [x:=1] 3 ; (if [y>x] 4 then [z:=y] 5 else [z:=y*y] 6 ); [x:=z] 7 Live variables analysis enables a transformation into [y:=4] 2 ; [x:=1] 3 ; (if [y>x] 4 then [z:=y] 5 else [z:=y*y] 6 ); [x:=z] 7 c HRN&FN (cf. slide 2) October 28,

11 Live variables Faint variables Faint variables Consider the following program: [x:=1] 1 ; [x:=x-1] 2 ; [x:=2] 3 Clearly x is dead at the exits from 2 and 3. But x is live at the exit of 1 even though its only use is to calculate a new value for a variable that turns out to be dead. We shall say that a variable is a faint variable if it is dead or if it is only used to calculate new values for faint variables; otherwise it is strongly live. In the example x is faint at the exits from 1 and 2. Exercise: Define a data flow analysis that detects strongly live variables. c HRN&FN (cf. slide 2) October 28,

12 Very busy expressions Very Busy Expressions Analysis An expression is very busy at the exit from a label if, no matter what path is taken from the label, the expression is always used before any of the variables occurring in it are redefined. The aim of the Very Busy Expressions Analysis is to determine For each program point, which expressions must be very busy at the exit from the point. Example point of interest if [a>b] 1 then ([x:= b-a ] 2 ; [y:= a-b ] 3 ) else ([y:= b-a ] 4 ; [x:= a-b ] 5 ) c HRN&FN (cf. slide 2) October 28,

13 Very busy expressions The basic idea VB (l) [x := a] l VB (l) Analysis information: [...] l VB (l) [...] l 1 [...] l 2 VB (l 1 ) VB (l 2 ) VB (l): the expressions that are very busy at at the exit of block l VB (l): the expressions that are very busy at the entry of block l kill VB (l): the expressions that are killed by an elementary block gen VB (l): the expressions that are generated by an elementary block c HRN&FN (cf. slide 2) October 28,

14 Very busy expressions Analysis of elementary blocks Definition of the expressions that are killed by an elementary block (i.e. they values are no longer guaranteed to be needed in the future) and the assignments that are generated by the block (their values are now guaranteed to be needed in the future): kill VB ([x := a] l ) = {a AExp x FV(a )} kill VB ([skip] l ) = kill VB ([b] l ) = gen VB ([x := a] l ) = AExp(a) gen VB ([skip] l ) = gen VB ([b] l ) = AExp(b) c HRN&FN (cf. slide 2) October 28,

15 Very busy expressions Analysis of programs VB (l) [x := a] l VB (l) [...] l VB (l) [...] l 1 [...] l 2 VB (l 1 ) VB (l 2 ) VB (l) = if l final(s ) {VB (l ) (l, l) flow R (S )} otherwise VB (l) = (VB (l)\kill VB (B l )) gen VB (B l ) where B l blocks(s ) c HRN&FN (cf. slide 2) October 28,

16 Very busy expressions Example if [a>b] 1 then ([x:=b-a] 2 ; [y:=a-b] 3 ) else ([y:=b-a] 4 ; [x:=a-b] 5 ) Equations: VB (1) = VB (1) VB (2) = VB (2) {b-a} VB (3) = {a-b} VB (4) = VB (4) {b-a} VB (5) = {a-b} VB (1) = VB (2) VB (4) VB (2) = VB (3) VB (3) = VB (4) = VB (5) VB (5) = Analysis of elementary blocks: l kill VB (l) gen VB (l) 1 2 {b-a} 3 {a-b} 4 {b-a} 5 {a-b} Largest solution: l VB (l) VB (l) 1 {a-b, b-a} {a-b, b-a} 2 {a-b, b-a} {a-b} 3 {a-b} 4 {a-b, b-a} {a-b} 5 {a-b} c HRN&FN (cf. slide 2) October 28,

17 Very busy expressions Why largest solution? while [x>1] l do [skip] l od; [x:=x+1] l Equations: VB (l) = VB (l) VB (l ) = VB (l ) VB (l ) = {x+1} VB (l) = VB (l ) VB (l ) VB (l ) = VB (l) [x>1] l yes [skip] l no [x:=x+1] l VB (l ) = After some simplifications: VB (l) = VB (l) {x+1} Two solutions to this equation: {x+1} and c HRN&FN (cf. slide 2) October 28,

18 Very busy expressions Code hoisting Code Hoisting Code hoisting finds expressions that are always evaluated following some point in the program regardless of the execution path and moves them to the latest point beyond which they would always be executed. Example: if [a>b] 1 then ([x:= b-a ] 2 ; [y:= a-b ] 3 ) else ([y:= b-a ] 4 ; [x:= a-b ] 5 ) The Very Busy Expressions analysis enables a transformation into [t1:= b-a ] 6 ; [t2:= b-a ] 7 ; if [a>b] 1 then ([x:=t1] 2 ; [y:=t2] 3 ) else ([y:=t1] 4 ; [x:=t2] 5 ) c HRN&FN (cf. slide 2) October 28,

19 Bit vector frameworks The classical analyses revisited The classical analyses compute information in a set of the form P(D) for some finite set D and the equations have the general form: ι if l E A (l) = {A (l ) (l, l) F } otherwise A (l) = (A (l) \ kill l ) gen l where A, A : Lab P(D) and F is flow(s ) or flow R (S ) and E is {init(s )} or final(s ), is or on P(D) and ι D specifies the initial/final information, kill l D and gen l D specify the information invalidated by/generated by B l blocks(s ). c HRN&FN (cf. slide 2) October 28,

20 Bit vector frameworks Examples Available Reaching Very Busy Live Expressions Definitions Expressions Variables P(D) P(AExp ) P(Var Lab ) P(AExp ) P(Var ) ι {(x,?) x FV(S )} Var E {init(s )} {init(s )} final(s ) final(s ) F flow(s ) flow(s ) flow R (S ) flow R (S ) f l f l (X) = (X \ kill l ) gen l where B l blocks(s ) (and X D) c HRN&FN (cf. slide 2) October 28,

21 Bit vector frameworks Forward versus backwards analyses The forward analyses have F to be flow(s ) and then A concerns entry conditions and A concerns exit conditions. Reaching definitions analysis Available expressions analysis The backward analyses have F to be flow R (S ) and then A concerns exit conditions and A concerns entry conditions. Very busy expressions analysis Live variables analysis c HRN&FN (cf. slide 2) October 28,

22 Bit vector frameworks May versus must analyses When is we require the smallest sets that solve the equations and we are able to detect properties satisfied by at least one execution path to (or from) the entry (or exit) of a label; the analysis is a may-analysis. Reaching definitions analysis Live variables analysis When is we require the greatest sets that solve the equations and we are able to detect properties satisfied by all execution paths reaching (or leaving) the entry (or exit) of a label; the analysis is a must-analysis. Available expressions analysis Very busy expressions analysis c HRN&FN (cf. slide 2) October 28,

23 Bit vector frameworks Bit vectors The classical analyses operate operates over elements of P(D) where D is a finite set. The elements can be represented as bit vectors: Each element of D can be assigned a unique bit position i (1 i n). A subset S of D is then represented by a vector of n bits: if the i th element of D is in S then the i th bit is 1 if the i th element of D is not in S then the i th bit is 0 Then we have efficient implementations of set union as logical or set intersection as logical and c HRN&FN (cf. slide 2) October 28,

24 Bit vector frameworks More bit vector frameworks Upwards exposed uses determines for a program point, what uses of a variable are reached by a particular definition (assignment) a backwards may analysis Copy analysis determines whether there on every execution path from a copy statement x := y to a use of x there are no assignments to y a forward must analysis Dominators determines for each program point which program points are guaranteed to have been executed before the current one is reached a forward must analysis Dual available expressions determines for each program point which expressions may not be available when execution reaches that point a forward may analysis c HRN&FN (cf. slide 2) October 28,

25 Bit vector frameworks Non-bit vector frameworks Constant propagation determines for each program point whether or not a variable has a constant value whenever execution reaches that point Detection of signs analysis determines for each program point the possible signs of that the values of the variables may have whenever execution reaches that point Faint variables determines for each program point which variables are faint: a variable is faint if it is dead or it it is only used to compute new values of faint variables May be unitialised determines for each program point which variables have dubious values: a variable has a dubious value if either it is not initialised or its value depend on variables with dubious values c HRN&FN (cf. slide 2) October 28,

Iterative Dataflow Analysis

Iterative Dataflow Analysis Iterative Dataflow Analysis CS 352 9/24/07 Slides adapted from Nielson, Nielson, Hankin Principles of Program Analysis Key Ideas Need a mechanism to evaluate (statically) statements in a program Problem:

More information

Principles of Program Analysis: Data Flow Analysis

Principles of Program Analysis: Data Flow Analysis Principles of Program Analysis: Data Flow Analysis Transparencies based on Chapter 2 of the book: Flemming Nielson, Hanne Riis Nielson and Chris Hankin: Principles of Program Analysis. Springer Verlag

More information

Probabilistic Model Checking and [Program] Analysis (CO469)

Probabilistic Model Checking and [Program] Analysis (CO469) Probabilistic Model Checking and [Program] Analysis (CO469) Program Analysis Herbert Wiklicky herbert@doc.ic.ac.uk Spring 208 / 64 Overview Topics we will cover in this part will include:. Language WHILE

More information

Inter-procedural Data Flow Analysis

Inter-procedural Data Flow Analysis Flow insensitive analysis Context insensitive analysis Context sensitive analysis Inter-procedural Data Flow Analysis Hanne Riis Nielson and Flemming Nielson email: {riis,nielson}@imm.dtu.dk Informatics

More information

Principles of Program Analysis: A Sampler of Approaches

Principles of Program Analysis: A Sampler of Approaches Principles of Program Analysis: A Sampler of Approaches Transparencies based on Chapter 1 of the book: Flemming Nielson, Hanne Riis Nielson and Chris Hankin: Principles of Program Analysis Springer Verlag

More information

Probabilistic Program Analysis

Probabilistic Program Analysis Probabilistic Program Analysis Data Flow Analysis and Regression Alessandra Di Pierro University of Verona, Italy alessandra.dipierro@univr.it Herbert Wiklicky Imperial College London, UK herbert@doc.ic.ac.uk

More information

Introduction to data-flow analysis. Data-flow analysis. Control-flow graphs. Data-flow analysis. Example: liveness. Requirements

Introduction to data-flow analysis. Data-flow analysis. Control-flow graphs. Data-flow analysis. Example: liveness. Requirements Data-flow analysis Michel Schinz based on material by Erik Stenman and Michael Schwartzbach Introduction to data-flow analysis Data-flow analysis Example: liveness Data-flow analysis is a global analysis

More information

Dataflow Analysis. Chapter 9, Section 9.2, 9.3, 9.4

Dataflow Analysis. Chapter 9, Section 9.2, 9.3, 9.4 Dataflow Analysis Chapter 9, Section 9.2, 9.3, 9.4 2 Dataflow Analysis Dataflow analysis is a sub area of static program analysis Used in the compiler back end for optimizations of three address code and

More information

Dataflow Analysis. Dragon book, Chapter 9, Section 9.2, 9.3, 9.4

Dataflow Analysis. Dragon book, Chapter 9, Section 9.2, 9.3, 9.4 Dataflow Analysis Dragon book, Chapter 9, Section 9.2, 9.3, 9.4 2 Dataflow Analysis Dataflow analysis is a sub-area of static program analysis Used in the compiler back end for optimizations of three-address

More information

Principles of Program Analysis: Abstract Interpretation

Principles of Program Analysis: Abstract Interpretation Principles of Program Analysis: Abstract Interpretation Transparencies based on Chapter 4 of the book: Flemming Nielson, Hanne Riis Nielson and Chris Hankin: Principles of Program Analysis. Springer Verlag

More information

Principles of Program Analysis: Data Flow Analysis

Principles of Program Analysis: Data Flow Analysis Principles of Program Analysis: Data Flow Analysis Transparencies based on Chapter 2 of the book: Flemming Nielson, Hanne Riis Nielson and Chris Hankin: Principles of Program Analysis. Springer Verlag

More information

We define a dataflow framework. A dataflow framework consists of:

We define a dataflow framework. A dataflow framework consists of: So far been talking about various dataflow problems (e.g. reaching definitions, live variable analysis) in very informal terms. Now we will discuss a more fundamental approach to handle many of the dataflow

More information

Static Program Analysis

Static Program Analysis Static Program Analysis Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ss-18/spa/ Recap: Interprocedural Dataflow Analysis Outline of

More information

Program verification

Program verification Program verification Data-flow analyses, numerical domains Laure Gonnord and David Monniaux University of Lyon / LIP September 29, 2015 1 / 75 Context Program Verification / Code generation: Variables

More information

Compiler Design. Data Flow Analysis. Hwansoo Han

Compiler Design. Data Flow Analysis. Hwansoo Han Compiler Design Data Flow Analysis Hwansoo Han Control Flow Graph What is CFG? Represents program structure for internal use of compilers Used in various program analyses Generated from AST or a sequential

More information

Static Analysis of Programs: A Heap-Centric View

Static Analysis of Programs: A Heap-Centric View Static Analysis of Programs: A Heap-Centric View (www.cse.iitb.ac.in/ uday) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay 5 April 2008 Part 1 Introduction ETAPS

More information

Data Flow Analysis. Lecture 6 ECS 240. ECS 240 Data Flow Analysis 1

Data Flow Analysis. Lecture 6 ECS 240. ECS 240 Data Flow Analysis 1 Data Flow Analysis Lecture 6 ECS 240 ECS 240 Data Flow Analysis 1 The Plan Introduce a few example analyses Generalize to see the underlying theory Discuss some more advanced issues ECS 240 Data Flow Analysis

More information

Data flow analysis. DataFlow analysis

Data flow analysis. DataFlow analysis Data flow analysis DataFlow analysis compile time reasoning about the runtime flow of values in the program represent facts about runtime behavior represent effect of executing each basic block propagate

More information

Mechanics of Static Analysis

Mechanics of Static Analysis Escuela 03 III / 1 Mechanics of Static Analysis David Schmidt Kansas State University www.cis.ksu.edu/~schmidt Escuela 03 III / 2 Outline 1. Small-step semantics: trace generation 2. State generation and

More information

DFA of non-distributive properties

DFA of non-distributive properties DFA of non-distributive properties The general pattern of Dataflow Analysis GA (p)= i if p E { GA (q) q F } otherwise GA (p)= f p ( GA (p) ) where : E is the set of initial/final points of the control-flow

More information

Probabilistic data flow analysis: a linear equational approach

Probabilistic data flow analysis: a linear equational approach Probabilistic data flow analysis: a linear equational approach Alessandra Di Pierro University of Verona Verona, Italy alessandra.dipierro@univr.it Herbert Wiklicky Imperial College London London, UK herbert@doc.ic.ac.uk

More information

Principles of Program Analysis: Control Flow Analysis

Principles of Program Analysis: Control Flow Analysis Principles of Program Analysis: Control Flow Analysis Transparencies based on Chapter 3 of the book: Flemming Nielson, Hanne Riis Nielson and Chris Hankin: Principles of Program Analysis. Springer Verlag

More information

Semantics with Applications: Model-Based Program Analysis

Semantics with Applications: Model-Based Program Analysis Semantics with Applications: Model-Based Program Analysis c Hanne Riis Nielson c Flemming Nielson Computer Science Department, Aarhus University, Denmark (October 1996) Contents 1 Introduction 1 1.1 Side-stepping

More information

Dataflow Analysis - 2. Monotone Dataflow Frameworks

Dataflow Analysis - 2. Monotone Dataflow Frameworks Dataflow Analysis - 2 Monotone dataflow frameworks Definition Convergence Safety Relation of MOP to MFP Constant propagation Categorization of dataflow problems DataflowAnalysis 2, Sp06 BGRyder 1 Monotone

More information

Static Program Analysis

Static Program Analysis Static Program Analysis Lecture 16: Abstract Interpretation VI (Counterexample-Guided Abstraction Refinement) Thomas Noll Lehrstuhl für Informatik 2 (Software Modeling and Verification) noll@cs.rwth-aachen.de

More information

Data Flow Analysis (I)

Data Flow Analysis (I) Compiler Design Data Flow Analysis (I) Hwansoo Han Control Flow Graph What is CFG? Represents program structure for internal use of compilers Used in various program analyses Generated from AST or a sequential

More information

we first add 7 and then either divide by x - 7 = 1 Adding 7 to both sides 3 x = x = x = 3 # 8 1 # x = 3 # 4 # 2 x = 6 1 =?

we first add 7 and then either divide by x - 7 = 1 Adding 7 to both sides 3 x = x = x = 3 # 8 1 # x = 3 # 4 # 2 x = 6 1 =? . Using the Principles Together Applying Both Principles a Combining Like Terms a Clearing Fractions and Decimals a Contradictions and Identities EXAMPLE Solve: An important strategy for solving new problems

More information

Groups. 3.1 Definition of a Group. Introduction. Definition 3.1 Group

Groups. 3.1 Definition of a Group. Introduction. Definition 3.1 Group C H A P T E R t h r e E Groups Introduction Some of the standard topics in elementary group theory are treated in this chapter: subgroups, cyclic groups, isomorphisms, and homomorphisms. In the development

More information

Lecture 5 Introduction to Data Flow Analysis

Lecture 5 Introduction to Data Flow Analysis Lecture 5 Introduction to Data Flow Analysis I. Structure of data flow analysis II. III. IV. Example 1: Reaching definition analysis Example 2: Liveness analysis Framework Phillip B. Gibbons 15-745: Intro

More information

Topic-I-C Dataflow Analysis

Topic-I-C Dataflow Analysis Topic-I-C Dataflow Analysis 2012/3/2 \course\cpeg421-08s\topic4-a.ppt 1 Global Dataflow Analysis Motivation We need to know variable def and use information between basic blocks for: constant folding dead-code

More information

(b). Identify all basic blocks in your three address code. B1: 1; B2: 2; B3: 3,4,5,6; B4: 7,8,9; B5: 10; B6: 11; B7: 12,13,14; B8: 15;

(b). Identify all basic blocks in your three address code. B1: 1; B2: 2; B3: 3,4,5,6; B4: 7,8,9; B5: 10; B6: 11; B7: 12,13,14; B8: 15; (a). Translate the program into three address code as defined in Section 6.2, dragon book. (1) i := 2 (2) if i > n goto (7) (3) a[i] := TRUE (4) t2 := i+1 (5) i := t2 (6) goto (2) (7) count := 0 (8) s

More information

Axiomatic Semantics: Verification Conditions. Review of Soundness and Completeness of Axiomatic Semantics. Announcements

Axiomatic Semantics: Verification Conditions. Review of Soundness and Completeness of Axiomatic Semantics. Announcements Axiomatic Semantics: Verification Conditions Meeting 12, CSCI 5535, Spring 2009 Announcements Homework 4 is due tonight Wed forum: papers on automated testing using symbolic execution 2 Questions? Review

More information

CHAPTER 3 BOOLEAN ALGEBRA

CHAPTER 3 BOOLEAN ALGEBRA CHAPTER 3 BOOLEAN ALGEBRA (continued) This chapter in the book includes: Objectives Study Guide 3.1 Multiplying Out and Factoring Expressions 3.2 Exclusive-OR and Equivalence Operations 3.3 The Consensus

More information

Dataflow Analysis. A sample program int fib10(void) { int n = 10; int older = 0; int old = 1; Simple Constant Propagation

Dataflow Analysis. A sample program int fib10(void) { int n = 10; int older = 0; int old = 1; Simple Constant Propagation -74 Lecture 2 Dataflow Analysis Basic Blocks Related Optimizations SSA Copyright Seth Copen Goldstein 200-8 Dataflow Analysis Last time we looked at code transformations Constant propagation Copy propagation

More information

SAMPLE ANSWERS MARKER COPY

SAMPLE ANSWERS MARKER COPY Page 1 of 12 School of Computer Science 60-265-01 Computer Architecture and Digital Design Fall 2012 Midterm Examination # 1 Tuesday, October 23, 2012 SAMPLE ANSWERS MARKER COPY Duration of examination:

More information

SOLUTIONS TO EXERCISES FOR. MATHEMATICS 133 Part 2. I. Topics from linear algebra

SOLUTIONS TO EXERCISES FOR. MATHEMATICS 133 Part 2. I. Topics from linear algebra SOLUTIONS TO EXERCISES FOR MATHEMATICS 133 Part Fall 013 NOTE ON ILLUSTRATIONS. Drawings for several of the solutions in this file are available in the following document: http://math.ucr.edu/ res/math133/math133solutionsa.figures.f13.pdf

More information

Chapter 3 Combinational Logic Design

Chapter 3 Combinational Logic Design Logic and Computer Design Fundamentals Chapter 3 Combinational Logic Design Part 2 Combinational Logic Charles Kime & Thomas Kaminski 28 Pearson Education, Inc. (Hyperlinks are active in View Show mode)

More information

A DARK GREY P O N T, with a Switch Tail, and a small Star on the Forehead. Any

A DARK GREY P O N T, with a Switch Tail, and a small Star on the Forehead. Any Y Y Y X X «/ YY Y Y ««Y x ) & \ & & } # Y \#$& / Y Y X» \\ / X X X x & Y Y X «q «z \x» = q Y # % \ & [ & Z \ & { + % ) / / «q zy» / & / / / & x x X / % % ) Y x X Y $ Z % Y Y x x } / % «] «] # z» & Y X»

More information

Data-Flow Analysis. Compiler Design CSE 504. Preliminaries

Data-Flow Analysis. Compiler Design CSE 504. Preliminaries Data-Flow Analysis Compiler Design CSE 504 1 Preliminaries 2 Live Variables 3 Data Flow Equations 4 Other Analyses Last modifled: Thu May 02 2013 at 09:01:11 EDT Version: 1.3 15:28:44 2015/01/25 Compiled

More information

CMSC 631 Program Analysis and Understanding. Spring Data Flow Analysis

CMSC 631 Program Analysis and Understanding. Spring Data Flow Analysis CMSC 631 Program Analysis and Understanding Spring 2013 Data Flow Analysis Data Flow Analysis A framework for proving facts about programs Reasons about lots of little facts Little or no interaction between

More information

Dataflow analysis. Theory and Applications. cs6463 1

Dataflow analysis. Theory and Applications. cs6463 1 Dataflow analysis Theory and Applications cs6463 1 Control-flow graph Graphical representation of runtime control-flow paths Nodes of graph: basic blocks (straight-line computations) Edges of graph: flows

More information

Scalar Optimisation Part 2

Scalar Optimisation Part 2 Scalar Optimisation Part 2 Michael O Boyle January 2014 1 Course Structure L1 Introduction and Recap 4-5 lectures on classical optimisation 2 lectures on scalar optimisation Last lecture on redundant expressions

More information

Lecture 2: Axiomatic semantics

Lecture 2: Axiomatic semantics Chair of Software Engineering Trusted Components Prof. Dr. Bertrand Meyer Lecture 2: Axiomatic semantics Reading assignment for next week Ariane paper and response (see course page) Axiomatic semantics

More information

Math 115 Practice for Exam 2

Math 115 Practice for Exam 2 Math 115 Practice for Exam Generated October 30, 017 Name: SOLUTIONS Instructor: Section Number: 1. This exam has 5 questions. Note that the problems are not of equal difficulty, so you may want to skip

More information

Abstract Interpretation and Static Analysis

Abstract Interpretation and Static Analysis / 1 Abstract Interpretation and Static Analysis David Schmidt Kansas State University www.cis.ksu.edu/~schmidt Welcome! / 2 / 3 Four parts 1. Introduction to static analysis what it is and how to apply

More information

Section 2: Classes of Sets

Section 2: Classes of Sets Section 2: Classes of Sets Notation: If A, B are subsets of X, then A \ B denotes the set difference, A \ B = {x A : x B}. A B denotes the symmetric difference. A B = (A \ B) (B \ A) = (A B) \ (A B). Remarks

More information

Static Analysis: Applications and Logics

Static Analysis: Applications and Logics Escuela 03 IV / 1 Static Analysis: Applications and Logics David Schmidt Kansas State University www.cis.ksu.edu/~schmidt Escuela 03 IV / 2 Outline 1. Applications: abstract testing and safety checking

More information

Axiomatic Semantics. Lecture 9 CS 565 2/12/08

Axiomatic Semantics. Lecture 9 CS 565 2/12/08 Axiomatic Semantics Lecture 9 CS 565 2/12/08 Axiomatic Semantics Operational semantics describes the meaning of programs in terms of the execution steps taken by an abstract machine Denotational semantics

More information

Multiplication of Polynomials

Multiplication of Polynomials Summary 391 Chapter 5 SUMMARY Section 5.1 A polynomial in x is defined by a finite sum of terms of the form ax n, where a is a real number and n is a whole number. a is the coefficient of the term. n is

More information

Discrete Mathematics. (c) Marcin Sydow. Sets. Set operations. Sets. Set identities Number sets. Pair. Power Set. Venn diagrams

Discrete Mathematics. (c) Marcin Sydow. Sets. Set operations. Sets. Set identities Number sets. Pair. Power Set. Venn diagrams Contents : basic definitions and notation A set is an unordered collection of its elements (or members). The set is fully specified by its elements. Usually capital letters are used to name sets and lowercase

More information

Software Verification

Software Verification Software Verification Grégoire Sutre LaBRI, University of Bordeaux, CNRS, France Summer School on Verification Technology, Systems & Applications September 2008 Grégoire Sutre Software Verification VTSA

More information

Generalizing Data-flow Analysis

Generalizing Data-flow Analysis Generalizing Data-flow Analysis Announcements PA1 grades have been posted Today Other types of data-flow analysis Reaching definitions, available expressions, reaching constants Abstracting data-flow analysis

More information

AST rewriting. Part I: Specifying Transformations. Imperative object programs. The need for path queries. fromentry, paths, toexit.

AST rewriting. Part I: Specifying Transformations. Imperative object programs. The need for path queries. fromentry, paths, toexit. Part I: Specifying Transformations Oege de Moor Ganesh Sittampalam Programming Tools Group, Oxford focus AST rewriting To apply rule: rewrite(pat 0, pat 1 ) Match: focus = φ(pat 0 ) Replace: focus := φ(pat

More information

MIDTERM: CS 6375 INSTRUCTOR: VIBHAV GOGATE October,

MIDTERM: CS 6375 INSTRUCTOR: VIBHAV GOGATE October, MIDTERM: CS 6375 INSTRUCTOR: VIBHAV GOGATE October, 23 2013 The exam is closed book. You are allowed a one-page cheat sheet. Answer the questions in the spaces provided on the question sheets. If you run

More information

Linear Equations in Linear Algebra

Linear Equations in Linear Algebra 1 Linear Equations in Linear Algebra 1.1 SYSTEMS OF LINEAR EQUATIONS LINEAR EQUATION x 1,, x n A linear equation in the variables equation that can be written in the form a 1 x 1 + a 2 x 2 + + a n x n

More information

To hand in: (a) Prove that a group G is abelian (= commutative) if and only if (xy) 2 = x 2 y 2 for all x, y G.

To hand in: (a) Prove that a group G is abelian (= commutative) if and only if (xy) 2 = x 2 y 2 for all x, y G. Homework #6. Due Thursday, October 14th Reading: For this homework assignment: Sections 3.3 and 3.4 (up to page 167) Before the class next Thursday: Sections 3.5 and 3.4 (pp. 168-171). Also review the

More information

Causal Dataflow Analysis for Concurrent Programs

Causal Dataflow Analysis for Concurrent Programs Causal Dataflow Analysis for Concurrent Programs Azadeh Farzan P. Madhusudan Department of Computer Science, University of Illinois at Urbana-Champaign. {afarzan,madhu}@cs.uiuc.edu Abstract. We define

More information

Spring 2015 Program Analysis and Verification. Lecture 6: Axiomatic Semantics III. Roman Manevich Ben-Gurion University

Spring 2015 Program Analysis and Verification. Lecture 6: Axiomatic Semantics III. Roman Manevich Ben-Gurion University Spring 2015 Program Analysis and Verification Lecture 6: Axiomatic Semantics III Roman Manevich Ben-Gurion University Tentative syllabus Semantics Static Analysis Abstract Interpretation fundamentals Analysis

More information

WUCT121. Discrete Mathematics. Numbers

WUCT121. Discrete Mathematics. Numbers WUCT121 Discrete Mathematics Numbers 1. Natural Numbers 2. Integers and Real Numbers 3. The Principle of Mathematical Induction 4. Elementary Number Theory 5. Congruence Arithmetic WUCT121 Numbers 1 Section

More information

Dataflow Analysis Lecture 2. Simple Constant Propagation. A sample program int fib10(void) {

Dataflow Analysis Lecture 2. Simple Constant Propagation. A sample program int fib10(void) { -4 Lecture Dataflow Analysis Basic Blocks Related Optimizations Copyright Seth Copen Goldstein 00 Dataflow Analysis Last time we looked at code transformations Constant propagation Copy propagation Common

More information

Axioms of Kleene Algebra

Axioms of Kleene Algebra Introduction to Kleene Algebra Lecture 2 CS786 Spring 2004 January 28, 2004 Axioms of Kleene Algebra In this lecture we give the formal definition of a Kleene algebra and derive some basic consequences.

More information

Worksheet on Relations

Worksheet on Relations Worksheet on Relations Recall the properties that relations can have: Definition. Let R be a relation on the set A. R is reflexive if for all a A we have ara. R is irreflexive or antireflexive if for all

More information

Notes for Math 601, Fall based on Introduction to Mathematical Logic by Elliott Mendelson Fifth edition, 2010, Chapman & Hall

Notes for Math 601, Fall based on Introduction to Mathematical Logic by Elliott Mendelson Fifth edition, 2010, Chapman & Hall Notes for Math 601, Fall 2010 based on Introduction to Mathematical Logic by Elliott Mendelson Fifth edition, 2010, Chapman & Hall All first-order languages contain the variables: v 0, v 1, v 2,... the

More information

Topics in Logic, Set Theory and Computability

Topics in Logic, Set Theory and Computability Topics in Logic, Set Theory and Computability Homework Set #3 Due Friday 4/6 at 3pm (by email or in person at 08-3234) Exercises from Handouts 7-C-2 7-E-6 7-E-7(a) 8-A-4 8-A-9(a) 8-B-2 8-C-2(a,b,c) 8-D-4(a)

More information

Lecture 2: A crash course in Real Analysis

Lecture 2: A crash course in Real Analysis EE5110: Probability Foundations for Electrical Engineers July-November 2015 Lecture 2: A crash course in Real Analysis Lecturer: Dr. Krishna Jagannathan Scribe: Sudharsan Parthasarathy This lecture is

More information

Secure Information Flow Based on Data Flow Analysis

Secure Information Flow Based on Data Flow Analysis SSN 746-7659, Engand, UK Journa of nformation and Computing Science Vo., No. 4, 007, pp. 5-60 Secure nformation Fow Based on Data Fow Anaysis Jianbo Yao Center of nformation and computer, Zunyi Norma Coege,

More information

Logic in Automatic Verification

Logic in Automatic Verification Logic in Automatic Verification Javier Esparza Sofware Reliability and Security Group Institute for Formal Methods in Computer Science University of Stuttgart Many thanks to Abdelwaheb Ayari, David Basin,

More information

Introduction to Set Operations

Introduction to Set Operations Introduction to Set Operations CIS008-2 Logic and Foundations of Mathematics David Goodwin david.goodwin@perisic.com 12:00, Friday 21 st October 2011 Outline 1 Recap 2 Introduction to sets 3 Class Exercises

More information

Foundations of Computation

Foundations of Computation The Australian National University Semester 2, 2018 Research School of Computer Science Tutorial 6 Dirk Pattinson Foundations of Computation The tutorial contains a number of exercises designed for the

More information

Fall Math 140 Week-in-Review #5 courtesy: Kendra Kilmer (covering Sections 3.4 and 4.1) Section 3.4

Fall Math 140 Week-in-Review #5 courtesy: Kendra Kilmer (covering Sections 3.4 and 4.1) Section 3.4 Section 3.4 A Standard Maximization Problem has the following properties: The objective function is to be maximized. All variables are non-negative. Fall 2017 Math 140 Week-in-Review #5 courtesy: Kendra

More information

Linear Algebra Lecture Notes-I

Linear Algebra Lecture Notes-I Linear Algebra Lecture Notes-I Vikas Bist Department of Mathematics Panjab University, Chandigarh-6004 email: bistvikas@gmail.com Last revised on February 9, 208 This text is based on the lectures delivered

More information

Introduction to Vectors

Introduction to Vectors Introduction to Vectors K. Behrend January 31, 008 Abstract An introduction to vectors in R and R 3. Lines and planes in R 3. Linear dependence. 1 Contents Introduction 3 1 Vectors 4 1.1 Plane vectors...............................

More information

Spring 2014 Program Analysis and Verification. Lecture 6: Axiomatic Semantics III. Roman Manevich Ben-Gurion University

Spring 2014 Program Analysis and Verification. Lecture 6: Axiomatic Semantics III. Roman Manevich Ben-Gurion University Spring 2014 Program Analysis and Verification Lecture 6: Axiomatic Semantics III Roman Manevich Ben-Gurion University Syllabus Semantics Static Analysis Abstract Interpretation fundamentals Analysis Techniques

More information

Hoare Examples & Proof Theory. COS 441 Slides 11

Hoare Examples & Proof Theory. COS 441 Slides 11 Hoare Examples & Proof Theory COS 441 Slides 11 The last several lectures: Agenda Denotational semantics of formulae in Haskell Reasoning using Hoare Logic This lecture: Exercises A further introduction

More information

Compilation and Program Analysis (#8) : Abstract Interpretation

Compilation and Program Analysis (#8) : Abstract Interpretation Compilation and Program Analysis (#8) : Abstract Interpretation Laure Gonnord http://laure.gonnord.org/pro/teaching/capm.html Laure.Gonnord@ens-lyon.fr Master, ENS de Lyon Nov 7 Objective Compilation vs

More information

Sets. Alice E. Fischer. CSCI 1166 Discrete Mathematics for Computing Spring, Outline Sets An Algebra on Sets Summary

Sets. Alice E. Fischer. CSCI 1166 Discrete Mathematics for Computing Spring, Outline Sets An Algebra on Sets Summary An Algebra on Alice E. Fischer CSCI 1166 Discrete Mathematics for Computing Spring, 2018 Alice E. Fischer... 1/37 An Algebra on 1 Definitions and Notation Venn Diagrams 2 An Algebra on 3 Alice E. Fischer...

More information

Handout 5. α a1 a n. }, where. xi if a i = 1 1 if a i = 0.

Handout 5. α a1 a n. }, where. xi if a i = 1 1 if a i = 0. Notes on Complexity Theory Last updated: October, 2005 Jonathan Katz Handout 5 1 An Improved Upper-Bound on Circuit Size Here we show the result promised in the previous lecture regarding an upper-bound

More information

Undergraduate Notes in Mathematics. Arkansas Tech University Department of Mathematics. College Algebra for STEM

Undergraduate Notes in Mathematics. Arkansas Tech University Department of Mathematics. College Algebra for STEM Undergraduate Notes in Mathematics Arkansas Tech University Department of Mathematics College Algebra for STEM Marcel B. Finan c All Rights Reserved 2015 Edition To my children Amin & Nadia Preface From

More information

Model Checking & Program Analysis

Model Checking & Program Analysis Model Checking & Program Analysis Markus Müller-Olm Dortmund University Overview Introduction Model Checking Flow Analysis Some Links between MC and FA Conclusion Apology for not giving proper credit to

More information

Before we show how languages can be proven not regular, first, how would we show a language is regular?

Before we show how languages can be proven not regular, first, how would we show a language is regular? CS35 Proving Languages not to be Regular Before we show how languages can be proven not regular, first, how would we show a language is regular? Although regular languages and automata are quite powerful

More information

Review. Example 1. Elementary matrices in action: (a) a b c. d e f = g h i. d e f = a b c. a b c. (b) d e f. d e f.

Review. Example 1. Elementary matrices in action: (a) a b c. d e f = g h i. d e f = a b c. a b c. (b) d e f. d e f. Review Example. Elementary matrices in action: (a) 0 0 0 0 a b c d e f = g h i d e f 0 0 g h i a b c (b) 0 0 0 0 a b c d e f = a b c d e f 0 0 7 g h i 7g 7h 7i (c) 0 0 0 0 a b c a b c d e f = d e f 0 g

More information

Reading: Chapter 9.3. Carnegie Mellon

Reading: Chapter 9.3. Carnegie Mellon I II Lecture 3 Foundation of Data Flow Analysis Semi-lattice (set of values, meet operator) Transfer functions III Correctness, precision and convergence IV Meaning of Data Flow Solution Reading: Chapter

More information

CSC D70: Compiler Optimization Dataflow-2 and Loops

CSC D70: Compiler Optimization Dataflow-2 and Loops CSC D70: Compiler Optimization Dataflow-2 and Loops Prof. Gennady Pekhimenko University of Toronto Winter 2018 The content of this lecture is adapted from the lectures of Todd Mowry and Phillip Gibbons

More information

What happens to the value of the expression x + y every time we execute this loop? while x>0 do ( y := y+z ; x := x:= x z )

What happens to the value of the expression x + y every time we execute this loop? while x>0 do ( y := y+z ; x := x:= x z ) Starter Questions Feel free to discuss these with your neighbour: Consider two states s 1 and s 2 such that s 1, x := x + 1 s 2 If predicate P (x = y + 1) is true for s 2 then what does that tell us about

More information

Notes on Abstract Interpretation

Notes on Abstract Interpretation Notes on Abstract Interpretation Alexandru Sălcianu salcianu@mit.edu November 2001 1 Introduction This paper summarizes our view of the abstract interpretation field. It is based on the original abstract

More information

Solving Systems of Linear Equations Using Matrices

Solving Systems of Linear Equations Using Matrices Solving Systems of Linear Equations Using Matrices What is a Matrix? A matrix is a compact grid or array of numbers. It can be created from a system of equations and used to solve the system of equations.

More information

CHAPTER 6. Copyright Cengage Learning. All rights reserved.

CHAPTER 6. Copyright Cengage Learning. All rights reserved. CHAPTER 6 SET THEORY Copyright Cengage Learning. All rights reserved. SECTION 6.4 Boolean Algebras, Russell s Paradox, and the Halting Problem Copyright Cengage Learning. All rights reserved. Boolean Algebras,

More information

Unifying Theories of Programming

Unifying Theories of Programming 1&2 Unifying Theories of Programming Unifying Theories of Programming 3&4 Theories Unifying Theories of Programming designs predicates relations reactive CSP processes Jim Woodcock University of York May

More information

Notes on generating functions in automata theory

Notes on generating functions in automata theory Notes on generating functions in automata theory Benjamin Steinberg December 5, 2009 Contents Introduction: Calculus can count 2 Formal power series 5 3 Rational power series 9 3. Rational power series

More information

Notes. Relations. Introduction. Notes. Relations. Notes. Definition. Example. Slides by Christopher M. Bourke Instructor: Berthe Y.

Notes. Relations. Introduction. Notes. Relations. Notes. Definition. Example. Slides by Christopher M. Bourke Instructor: Berthe Y. Relations Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry Spring 2006 Computer Science & Engineering 235 Introduction to Discrete Mathematics Sections 7.1, 7.3 7.5 of Rosen cse235@cse.unl.edu

More information

Boolean Algebras. Chapter 2

Boolean Algebras. Chapter 2 Chapter 2 Boolean Algebras Let X be an arbitrary set and let P(X) be the class of all subsets of X (the power set of X). Three natural set-theoretic operations on P(X) are the binary operations of union

More information

Material Covered on the Final

Material Covered on the Final Material Covered on the Final On the final exam, you are responsible for: Anything covered in class, except for stories about my good friend Ken Kennedy All lecture material after the midterm ( below the

More information

Lecture 17: Floyd-Hoare Logic for Partial Correctness

Lecture 17: Floyd-Hoare Logic for Partial Correctness Lecture 17: Floyd-Hoare Logic for Partial Correctness Aims: To look at the following inference rules Page 1 of 9 sequence; assignment and consequence. 17.1. The Deduction System for Partial Correctness

More information

The Assignment Axiom (Hoare)

The Assignment Axiom (Hoare) The Assignment Axiom (Hoare) Syntax: V := E Semantics: value of V in final state is value of E in initial state Example: X:=X+ (adds one to the value of the variable X) The Assignment Axiom {Q[E/V ]} V

More information

Adequate set of connectives, logic gates and circuits

Adequate set of connectives, logic gates and circuits Adequate set of connectives, logic gates and circuits Lila Kari University of Waterloo Adequate set of connectives, logic gates and circuits CS245, Logic and Computation 1 / 59 Connectives We have mentioned

More information

REMARKS 1.4: (a) In general discussion the operation in a group G is usually written as multiplication and a b is written as ab. (b) If the operation

REMARKS 1.4: (a) In general discussion the operation in a group G is usually written as multiplication and a b is written as ab. (b) If the operation FIRST-YEAR GROUP THEORY 1 DEFINITIONS AND EXAMPLES It is highly desirable that you buy, or in some other way have access to a copy of, the following book which will be referred to in these notes as Jordan

More information

Theory of Stochastic Processes 3. Generating functions and their applications

Theory of Stochastic Processes 3. Generating functions and their applications Theory of Stochastic Processes 3. Generating functions and their applications Tomonari Sei sei@mist.i.u-tokyo.ac.jp Department of Mathematical Informatics, University of Tokyo April 20, 2017 http://www.stat.t.u-tokyo.ac.jp/~sei/lec.html

More information

Combinational Digital Design. Laboratory Manual. Experiment #6. Simplification using Karnaugh Map

Combinational Digital Design. Laboratory Manual. Experiment #6. Simplification using Karnaugh Map The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2013 Khaleel I. Shaheen Combinational Digital Design Laboratory Manual Experiment #6 Simplification

More information

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska LECTURE 1 Course Web Page www3.cs.stonybrook.edu/ cse303 The webpage contains: lectures notes slides; very detailed solutions to

More information

CHAPTER - 6 DISTRIBUTIVE CONVEX SUBLATTICE

CHAPTER - 6 DISTRIBUTIVE CONVEX SUBLATTICE CHAPTER - 6 DISTRIBUTIVE CONVEX SUBLATTICE 0 Introduction: The concept of standard convex sublattice or standard sublattice (i.e., generalization of standard ideals for convex sublattice) has been introduced

More information