Compiler Design Spring 2017
|
|
- Solomon Bernard Woods
- 5 years ago
- Views:
Transcription
1 Compiler Design Spring Data-Flow Analysis Dr. Zoltán Majó Compiler Group Java HotSpot Virtual Machine Oracle Corporation
2 Admin issues There will be a code review session next week On 15:15 (same time as the recitation session) Details: See description of HWC (out today) Some details (e.g., rooms) will follow by There is no recitation session today 2
3 Last lecture: Introduction to program analysis Why is program analysis needed? Foundation to reason about the correctness of programs Incl. understand language specification (e.g., Java language spec) May be essential for tools E.g., find statements that modify an array A Foundation for optimization E.g., remove unused (dead) code 3
4 Properties of program analysis Analysis must be correct Depends on use Do not mislead the compiler Analysis should be accurate As accurate as possible (given the information in the program) As accurate as feasible (may not be able to keep all details) 4
5 Outline Introduction Why do we need data-flow analysis Examples Program representation Points Paths Transfer functions 5
6 8.1 Program representation Current IR: forest of trees Edges between root nodes indicate sequencing Structure of program not directly visible in IR Sequencing of statements is enough but blurs big picture Must deal with control-flow ( big picture ) before we can consider data-flow 6
7 7
8 8
9 int foo(int max, int [] A) { int k = 1; int minval = A[0]; while (k < max) { if (A[k] < minval) { minval = A[k]; } k = k + 1; } return minval; } 9
10 int foo(int max, int [] A) { k = 1 minval = A[0] L: TCond1 = k < max if (TCond1) TCond2 = A[k] < minval if (TCond2) minval = A[k] k = k + 1 Goto L return minval } 10
11 int foo(int max, int [] A) { k = 1 minval = A[0] L: TCond1 = k < max if (TCond1) TCond2 = A[k] < minval if (TCond2) minval = A[k] k = k + 1 Goto L return minval } 11
12 int foo(int max, int [] A) { k = 1 minval = A[0] L: TCond1 = k < max if (TCond1) TCond2 = A[k] < minval if (TCond2) minval = A[k] k = k + 1 Goto L return minval } 12
13 All instructions in a box are executed together We ignore for now that there could be exceptions if (ConditionVariable) Test ConditionVariable and proceed accordingly TRUE path FALSE path Only one path is taken Goto Label has the obvious meaning 13
14 Basic block The maximal sequence of instructions that is executed together is known as a basic block Together means: w/o control flow change You can form basic blocks directly from the JavaLi IR May be harder in other languages or IRs Observations An if-statement ends a basic block We do not know which statement will be executed next A goto-statement ends a basic block A return statement ends a basic block A label starts a basic block (and ends the previous block) Method call does not end a basic block For some compilers a method call ends a basic block 14
15 Control-flow graph We can build a graph that captures the control flow CFG: control-flow graph Nodes: basic blocks Edges: There is an edge between block B 1 and block B 2 if B 2 may be executed immediately after B 1. Two special nodes: ENTRY and EXIT ENTRY has no in-edges EXIT has no out-edges All other nodes have at least one in-edge and one out-edge 15
16 k = 1 minval = A[0] L: TCond1 = k < max B0 B1 if (TCond1) TCond2 = A[k] < minval if (TCond2) B2 minval = A[k] B3 k = k + 1 Goto L B4 return minval B5 16
17 k = 1 minval = A[0] L: TCond1 = k < max if (TCond1) B0 B1 ENTRY TCond2 = A[k] < minval if (TCond2) B2 minval = A[k] B3 k = k + 1 Goto L B4 return minval B5 EXIT 17
18 x = 2; if (x > 0) { y = 0; while (x < Nmax) { } y = y + 1; x = 2 * x; if (x == Nspecial) { } } else { } y = 1; x = x * x; Construct the CFG for this program (5 min) 18
19 How many nodes (basic blocks) are in the CFG? Did you include ENTRY and EXIT? 19
20 x = 2 Cond = x > 0 if (Cond) y = 0; L: TCond = x < Nmax if (Tcond) y = y + 1 x = 2 * x Cond = x == Nspecial if (Cond) x = x * x Goto M Goto L ENTRY M: y = 1; EXIT 20
21 Control-flow graph Edge defines successor/predecessor relationship A block can be its own predecessor Edges capture possible successor (predecessor) relationships Upon further inspection may want to remove edges and/or blocks Always built for one method/function May want to include header block to deal with parameters Some compilers may include in header code to free registers, stack banging, etc., and may have an exit block for restore operations Exceptional control flow discussion postponed try-throw-catch Exception triggered by hardware 21
22 CFG construction Basic blocks are a convenient abstraction Not necessary for compiler Some algorithms easier to describe when using basic blocks, with control flow edges between blocks But many algorithms easy to explain in flat IR (sequences of statements) If you must/want to construct a CFG (and identify blocks): Single pass over current IR Form basic blocks (CFG nodes) on the fly 22
23 Comments on intermediate representations Previous example close to JavaLi source For illustration Statements: JavaLi statements (almost) Basic block concept applies also to low-level (assembler) languages Statement: asm instruction Or to other kinds of internal representations 23
24 Comments (cont d) Many algorithms easier to explain/discuss for simple statements destination = source 1 op source 2 Instead of destination = source 1 op source 2 op source 3 op source 4 We assume that our programs have this form (2 operands) Three-address code It s easy to transform a program a = b + c + d turns into temp1 = c + d a = b + temp1 24
25 Why bother? Now it s easy (e.g.) to see that there is a common subexpression a = b + c + d; x = a + 1; y = c + d; turns into temp1 = c + d; a = b + temp1; x = a + 1; y = c + d; temp1 = c + d; a = b + temp1; x = a + 1; y = temp1; 25
26 Once we identify c+d as a common sub-expression (i.e., an expression that s evaluated more than once) it s easy to change the program We could also work on large trees but it s painful Of course, it s not clear if the compiler should replace the second occurrence of c+d by temp1. 26
27 Analysis inside a basic block Local program analysis As the compiler knows that all instructions are executed together, it s easy to analyze a basic block It s still far from trivial to consider transformations or to identify operands 27
28 Example a = b + c + d ; x = b + d; There is a common sub-expression but the compiler (most likely) won t find it Even if we deal with integer operands 28
29 Another example a[k] = 1; a[m] = 2; b = a[k] + 1; Can the compiler assume a[k]= 1? k, m method parameters (int) a some (large) array (int) no multi-threading, no hidden changes to k, m 29
30 Another example a[k] = 1; a[m] = 2; b = a[k] + 1; Can the compiler assume a[k]= 1? k, m method parameters (int) a some (large) array (int) no multi-threading, no hidden changes to k, m No, as k == m is possible. 30
31 Analysis inside a basic block Analysis (and optimization) of basic blocks postponed Not difficult Chapter 8 of Aho et al. contains a discussion of the topic 31
32 Terminology Local {analysis transformation}: inside a basic block Global {analysis transformation}: inside a method/function Intra-procedural Inter-procedural {analysis transformation}: across methods/functions 32
33 Outline Introduction Why do we need data-flow analysis Examples Program representation Points Paths Transfer functions 33
34 8.2 Points Want to talk about flow of data in program Point: a place in the program Given a statement S P before_s : point before statement S is executed P after_s : point after statement S is executed Drop S if no risk of confusion Example a = b + c; // S1 x = a + 2; // S2 34
35 35
36 8.2 Points (cont d) Points can be extended to basic blocks as well Point (as before): a place in a program Given a basic block B P before_b : point before basic block B is executed P after_b : point after basic block B is executed Drop B if no risk of confusion 36
37 k = 1 minval = A[0] L: TCond1 = k < max B0 B1 if (TCond1) TCond2 = A[k] < minval if (TCond2) B2 minval = A[k] B3 k = k + 1 Goto L B4 return minval B5 37
38 38
39 8.3 Paths A path is a sequence of points (x 0, x 1, x 2,, x n ) such that for any pair (x j, x j+1 ) with 0 j<n one of these conditions holds 1. x j is the point before basic block B and x j+1 is the point after basic block B 2. x j is the point after basic block B k and x j+1 is the point before basic block B m and there is an edge from B k to B m in the CFG Definition can be extended to deal with points before/after statements. 39
40 Comments Points may have multiple predecessors Join points Join nodes (in the CFG) Points may have multiple successors Split points Split nodes When summarizing paths we may just list the basic blocks 40
41 Paths B0 B1 B2 B3 41
42 42
43 Paths i = 0 if (i>0) B0 B1 B2 B3 43
44 Paths if (i>0) B0 B1 if (i<0) B2 B3 B4 B5 B6 44
45 45
46 Paths We are interested in all paths in a CFG Even if they can never be taken in an execution Need summary information There can be arbitrarily many paths 46
47 Loops B0 if (COND) B1 B2 B3 B0 B1 B3 B0 B1 B2 B1 B3 B0 B1 B2 B1 B2 B1 B3 B0 B1 B2 B1 B2 B1 B2 B1 B2 B1 B2 B1 B2 B1 B2 B1 B2 B1 B2 47
48 48
49 Paths We deal only with finite paths Practical view: What has happened when program execution reaches B3 P before_b3 Execution (for some input) may never reach B3 Summary information is needed 49
50 Outline Introduction Why do we need data-flow analysis Examples Program representation Points Paths Transfer functions Use constant propagation as an example 50
: Compiler Design
252-210: Compiler Design 9.0 Data- Flow Analysis Thomas R. Gross Computer Science Department ETH Zurich, Switzerland Global program analysis is a crucial part of all real compilers. Global : beyond a statement
More informationCompiler Design Spring 2017
Compiler Design Spring 2017 8.6 Live variables Dr. Zoltán Majó Compiler Group Java HotSpot Virtual Machine Oracle Corporation Live variables Foundations for several optimizations If a variable is not live,
More informationCompiler Design Spring 2017
Compiler Design Spring 2017 7.5 Method invocation Dr. Zoltán Majó Compiler Group Java HotSpot Virtual Machine Oracle Corporation 1 Admin issues There will be a recitation session today In CAB G 11 @ 15:15
More informationData Structures and Algorithms in Compiler Optimization. Comp314 Lecture Dave Peixotto
Data Structures and Algorithms in Compiler Optimization Comp314 Lecture Dave Peixotto 1 What is a compiler Compilers translate between program representations Interpreters evaluate their input to produce
More informationCompiler Design Spring 2017
Compiler Design Spring 2017 Patterns (again) Dr. Zoltán Majó Compiler Group Java HotSpot Virtual Machine Oracle Corporation Why? Remember questionnaire (from the beginning of the semester)? Question 7:
More informationIntermediate Code & Local Optimizations. Lecture 20
Intermediate Code & Local Optimizations Lecture 20 Lecture Outline Intermediate code Local optimizations Next time: global optimizations 2 Code Generation Summary We have discussed Runtime organization
More informationData Flow Analysis. Program Analysis
Program Analysis https://www.cse.iitb.ac.in/~karkare/cs618/ Data Flow Analysis Amey Karkare Dept of Computer Science and Engg IIT Kanpur Visiting IIT Bombay karkare@cse.iitk.ac.in karkare@cse.iitb.ac.in
More informationIntermediate representation
Intermediate representation Goals: encode knowledge about the program facilitate analysis facilitate retargeting facilitate optimization scanning parsing HIR semantic analysis HIR intermediate code gen.
More informationIntermediate Code & Local Optimizations
Lecture Outline Intermediate Code & Local Optimizations Intermediate code Local optimizations Compiler Design I (2011) 2 Code Generation Summary We have so far discussed Runtime organization Simple stack
More informationData Flow Analysis. Agenda CS738: Advanced Compiler Optimizations. 3-address Code Format. Assumptions
Agenda CS738: Advanced Compiler Optimizations Data Flow Analysis Amey Karkare karkare@cse.iitk.ac.in http://www.cse.iitk.ac.in/~karkare/cs738 Department of CSE, IIT Kanpur Static analysis and compile-time
More informationLecture Outline. Intermediate code Intermediate Code & Local Optimizations. Local optimizations. Lecture 14. Next time: global optimizations
Lecture Outline Intermediate code Intermediate Code & Local Optimizations Lecture 14 Local optimizations Next time: global optimizations Prof. Aiken CS 143 Lecture 14 1 Prof. Aiken CS 143 Lecture 14 2
More informationLecture 3 Local Optimizations, Intro to SSA
Lecture 3 Local Optimizations, Intro to SSA I. Basic blocks & Flow graphs II. Abstraction 1: DAG III. Abstraction 2: Value numbering IV. Intro to SSA ALSU 8.4-8.5, 6.2.4 Phillip B. Gibbons 15-745: Local
More informationGlobal Optimization. Lecture Outline. Global flow analysis. Global constant propagation. Liveness analysis. Local Optimization. Global Optimization
Lecture Outline Global Optimization Global flow analysis Global constant propagation Liveness analysis Compiler Design I (2011) 2 Local Optimization Recall the simple basic-block optimizations Constant
More informationSardar Vallabhbhai Patel Institute of Technology (SVIT), Vasad M.C.A. Department COSMOS LECTURE SERIES ( ) (ODD) Code Optimization
Sardar Vallabhbhai Patel Institute of Technology (SVIT), Vasad M.C.A. Department COSMOS LECTURE SERIES (2018-19) (ODD) Code Optimization Prof. Jonita Roman Date: 30/06/2018 Time: 9:45 to 10:45 Venue: MCA
More informationAdministration CS 412/413. Why build a compiler? Compilers. Architectural independence. Source-to-source translator
CS 412/413 Introduction to Compilers and Translators Andrew Myers Cornell University Administration Design reports due Friday Current demo schedule on web page send mail with preferred times if you haven
More informationCompiler Construction 2016/2017 Loop Optimizations
Compiler Construction 2016/2017 Loop Optimizations Peter Thiemann January 16, 2017 Outline 1 Loops 2 Dominators 3 Loop-Invariant Computations 4 Induction Variables 5 Array-Bounds Checks 6 Loop Unrolling
More informationCompiler Design Spring 2017
Compiler Design Spring 2017 6.0 Runtime system and object layout Dr. Zoltán Majó Compiler Group Java HotSpot Virtual Machine Oracle Corporation 1 Runtime system Some open issues from last time Handling
More informationCFG (Control flow graph)
CFG (Control flow graph) Class B T12 오지은 200814189 신승우 201011340 이종선 200811448 Introduction to CFG Algorithm to construct Control Flow Graph Statement of Purpose Q & A Introduction to CFG Algorithm to
More informationCompiler Design Spring 2018
Compiler Design Spring 2018 2.3 Templates (for code generation) 2.4 Template-based code generator Thomas R. Gross Computer Science Department ETH Zurich, Switzerland 26 2.3 Templates Templates decide how
More informationGoals of Program Optimization (1 of 2)
Goals of Program Optimization (1 of 2) Goal: Improve program performance within some constraints Ask Three Key Questions for Every Optimization 1. Is it legal? 2. Is it profitable? 3. Is it compile-time
More informationCS153: Compilers Lecture 17: Control Flow Graph and Data Flow Analysis
CS153: Compilers Lecture 17: Control Flow Graph and Data Flow Analysis Stephen Chong https://www.seas.harvard.edu/courses/cs153 Announcements Project 5 out Due Tuesday Nov 13 (14 days) Project 6 out Due
More informationCS 406/534 Compiler Construction Putting It All Together
CS 406/534 Compiler Construction Putting It All Together Prof. Li Xu Dept. of Computer Science UMass Lowell Fall 2004 Part of the course lecture notes are based on Prof. Keith Cooper, Prof. Ken Kennedy
More informationOperational Semantics of Cool
Operational Semantics of Cool Lecture 23 Dr. Sean Peisert ECS 142 Spring 2009 1 Status Project 3 due on Friday Project 4 assigned on Friday. Due June 5, 11:55pm Office Hours this week Fri at 11am No Class
More informationLanguages and Compiler Design II IR Code Optimization
Languages and Compiler Design II IR Code Optimization Material provided by Prof. Jingke Li Stolen with pride and modified by Herb Mayer PSU Spring 2010 rev.: 4/16/2010 PSU CS322 HM 1 Agenda IR Optimization
More informationCompiler Construction 2010/2011 Loop Optimizations
Compiler Construction 2010/2011 Loop Optimizations Peter Thiemann January 25, 2011 Outline 1 Loop Optimizations 2 Dominators 3 Loop-Invariant Computations 4 Induction Variables 5 Array-Bounds Checks 6
More informationIntermediate representations IR #1: CPS/L 3. Code example. Advanced Compiler Construction Michel Schinz
Intermediate representations Intermediate representations Advanced Compiler Construction Michel Schinz 2016 03 03 The term intermediate representation (IR) or intermediate language designates the data-structure(s)
More informationIntroduction to Code Optimization. Lecture 36: Local Optimization. Basic Blocks. Basic-Block Example
Lecture 36: Local Optimization [Adapted from notes by R. Bodik and G. Necula] Introduction to Code Optimization Code optimization is the usual term, but is grossly misnamed, since code produced by optimizers
More informationComputer Organization MIPS Architecture. Department of Computer Science Missouri University of Science & Technology
Computer Organization MIPS Architecture Department of Computer Science Missouri University of Science & Technology hurson@mst.edu Computer Organization Note, this unit will be covered in three lectures.
More informationProgramming Language Processor Theory
Programming Language Processor Theory Munehiro Takimoto Course Descriptions Method of Evaluation: made through your technical reports Purposes: understanding various theories and implementations of modern
More informationRegister Allocation. CS 502 Lecture 14 11/25/08
Register Allocation CS 502 Lecture 14 11/25/08 Where we are... Reasonably low-level intermediate representation: sequence of simple instructions followed by a transfer of control. a representation of static
More informationTopic 9: Control Flow
Topic 9: Control Flow COS 320 Compiling Techniques Princeton University Spring 2016 Lennart Beringer 1 The Front End The Back End (Intel-HP codename for Itanium ; uses compiler to identify parallelism)
More informationECE 5775 (Fall 17) High-Level Digital Design Automation. Static Single Assignment
ECE 5775 (Fall 17) High-Level Digital Design Automation Static Single Assignment Announcements HW 1 released (due Friday) Student-led discussions on Tuesday 9/26 Sign up on Piazza: 3 students / group Meet
More informationLecture 5: Procedure Calls
Lecture 5: Procedure Calls Today s topics: Memory layout, numbers, control instructions Procedure calls 1 Memory Organization The space allocated on stack by a procedure is termed the activation record
More informationAdministration. Exceptions. Leftovers. Agenda. When Things Go Wrong. Handling Errors. CS 99 Summer 2000 Michael Clarkson Lecture 11
Administration Exceptions CS 99 Summer 2000 Michael Clarkson Lecture 11 Lab 10 due tomorrow No lab tomorrow Work on final projects Remaining office hours Rick: today 2-3 Michael: Thursday 10-noon, Monday
More informationRun-time Environments. Lecture 13. Prof. Alex Aiken Original Slides (Modified by Prof. Vijay Ganesh) Lecture 13
Run-time Environments Lecture 13 by Prof. Vijay Ganesh) Lecture 13 1 What have we covered so far? We have covered the front-end phases Lexical analysis (Lexer, regular expressions,...) Parsing (CFG, Top-down,
More informationPlan for Today. Concepts. Next Time. Some slides are from Calvin Lin s grad compiler slides. CS553 Lecture 2 Optimizations and LLVM 1
Plan for Today Quiz 2 How to automate the process of performance optimization LLVM: Intro to Intermediate Representation Loops as iteration spaces Data-flow Analysis Intro Control-flow graph terminology
More informationOptimizations. Optimization Safety. Optimization Safety CS412/CS413. Introduction to Compilers Tim Teitelbaum
Optimizations CS412/CS413 Introduction to Compilers im eitelbaum Lecture 24: s 24 Mar 08 Code transformations to improve program Mainly: improve execution time Also: reduce program size Can be done at
More informationMulti-dimensional Arrays
Multi-dimensional Arrays IL for Arrays & Local Optimizations Lecture 26 (Adapted from notes by R. Bodik and G. Necula) A 2D array is a 1D array of 1D arrays Java uses arrays of pointers to arrays for >1D
More informationAn Overview of GCC Architecture (source: wikipedia) Control-Flow Analysis and Loop Detection
An Overview of GCC Architecture (source: wikipedia) CS553 Lecture Control-Flow, Dominators, Loop Detection, and SSA Control-Flow Analysis and Loop Detection Last time Lattice-theoretic framework for data-flow
More informationCompiler Structure. Data Flow Analysis. Control-Flow Graph. Available Expressions. Data Flow Facts
Compiler Structure Source Code Abstract Syntax Tree Control Flow Graph Object Code CMSC 631 Program Analysis and Understanding Fall 2003 Data Flow Analysis Source code parsed to produce AST AST transformed
More informationOutline. Lecture 17: Putting it all together. Example (input program) How to make the computer understand? Example (Output assembly code) Fall 2002
Outline 5 Fall 2002 Lecture 17: Putting it all together From parsing to code generation Saman Amarasinghe 2 6.035 MIT Fall 1998 How to make the computer understand? Write a program using a programming
More informationLecture 9: Loop Invariant Computation and Code Motion
Lecture 9: Loop Invariant Computation and Code Motion I. Loop-invariant computation II. III. Algorithm for code motion Partial redundancy elimination ALSU 9.5-9.5.2 Phillip B. Gibbons 15-745: Loop Invariance
More informationCS293S Redundancy Removal. Yufei Ding
CS293S Redundancy Removal Yufei Ding Review of Last Class Consideration of optimization Sources of inefficiency Components of optimization Paradigms of optimization Redundancy Elimination Types of intermediate
More informationCONTROL FLOW ANALYSIS. The slides adapted from Vikram Adve
CONTROL FLOW ANALYSIS The slides adapted from Vikram Adve Flow Graphs Flow Graph: A triple G=(N,A,s), where (N,A) is a (finite) directed graph, s N is a designated initial node, and there is a path from
More informationEECS 583 Class 8 Classic Optimization
EECS 583 Class 8 Classic Optimization University of Michigan October 3, 2011 Announcements & Reading Material Homework 2» Extend LLVM LICM optimization to perform speculative LICM» Due Friday, Nov 21,
More informationECE 5775 High-Level Digital Design Automation Fall More CFG Static Single Assignment
ECE 5775 High-Level Digital Design Automation Fall 2018 More CFG Static Single Assignment Announcements HW 1 due next Monday (9/17) Lab 2 will be released tonight (due 9/24) Instructor OH cancelled this
More informationG Compiler Construction Lecture 12: Code Generation I. Mohamed Zahran (aka Z)
G22.2130-001 Compiler Construction Lecture 12: Code Generation I Mohamed Zahran (aka Z) mzahran@cs.nyu.edu semantically equivalent + symbol table Requirements Preserve semantic meaning of source program
More informationLecture 6: Assembly Programs
Lecture 6: Assembly Programs Today s topics: Procedures Examples Large constants The compilation process A full example 1 Procedures Local variables, AR, $fp, $sp Scratchpad and saves/restores, $fp Arguments
More informationIntermediate Representations Part II
Intermediate Representations Part II Types of Intermediate Representations Three major categories Structural Linear Hybrid Directed Acyclic Graph A directed acyclic graph (DAG) is an AST with a unique
More informationBuilding a Compiler with. JoeQ. Outline of this lecture. Building a compiler: what pieces we need? AKA, how to solve Homework 2
Building a Compiler with JoeQ AKA, how to solve Homework 2 Outline of this lecture Building a compiler: what pieces we need? An effective IR for Java joeq Homework hints How to Build a Compiler 1. Choose
More informationEECS 583 Class 3 More on loops, Region Formation
EECS 583 Class 3 More on loops, Region Formation University of Michigan September 19, 2016 Announcements & Reading Material HW1 is out Get busy on it!» Course servers are ready to go Today s class» Trace
More informationMIT Introduction to Program Analysis and Optimization. Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology
MIT 6.035 Introduction to Program Analysis and Optimization Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology Program Analysis Compile-time reasoning about run-time behavior
More informationUsing Static Single Assignment Form
Using Static Single Assignment Form Announcements Project 2 schedule due today HW1 due Friday Last Time SSA Technicalities Today Constant propagation Loop invariant code motion Induction variables CS553
More informationCS4215 Programming Language Implementation
CS4215 Programming Language Implementation You have 45 minutes to complete the exam. Use a B2 pencil to fill up the provided MCQ form. Leave Section A blank. Fill up Sections B and C. After finishing,
More informationOther Forms of Intermediate Code. Local Optimizations. Lecture 34
Other Forms of Intermediate Code. Local Optimizations Lecture 34 (Adapted from notes by R. Bodik and G. Necula) 4/18/08 Prof. Hilfinger CS 164 Lecture 34 1 Administrative HW #5 is now on-line. Due next
More informationAdministrative. Other Forms of Intermediate Code. Local Optimizations. Lecture 34. Code Generation Summary. Why Intermediate Languages?
Administrative Other Forms of Intermediate Code. Local Optimizations HW #5 is now on-line. Due next Friday. If your test grade is not glookupable, please tell us. Please submit test regrading pleas to
More informationCOMS W4115 Programming Languages and Translators Lecture 21: Code Optimization April 15, 2013
1 COMS W4115 Programming Languages and Translators Lecture 21: Code Optimization April 15, 2013 Lecture Outline 1. Code optimization strategies 2. Peephole optimization 3. Common subexpression elimination
More informationIntermediate Representations
Intermediate Representations Intermediate Representations (EaC Chaper 5) Source Code Front End IR Middle End IR Back End Target Code Front end - produces an intermediate representation (IR) Middle end
More informationCompiler Design. Fall Control-Flow Analysis. Prof. Pedro C. Diniz
Compiler Design Fall 2015 Control-Flow Analysis Sample Exercises and Solutions Prof. Pedro C. Diniz USC / Information Sciences Institute 4676 Admiralty Way, Suite 1001 Marina del Rey, California 90292
More informationIR Lowering. Notation. Lowering Methodology. Nested Expressions. Nested Statements CS412/CS413. Introduction to Compilers Tim Teitelbaum
IR Lowering CS412/CS413 Introduction to Compilers Tim Teitelbaum Lecture 19: Efficient IL Lowering 7 March 07 Use temporary variables for the translation Temporary variables in the Low IR store intermediate
More informationInstruction Selection and Scheduling
Instruction Selection and Scheduling The Problem Writing a compiler is a lot of work Would like to reuse components whenever possible Would like to automate construction of components Front End Middle
More informationIntroduction to Machine-Independent Optimizations - 6
Introduction to Machine-Independent Optimizations - 6 Machine-Independent Optimization Algorithms Department of Computer Science and Automation Indian Institute of Science Bangalore 560 012 NPTEL Course
More informationCSE P 501 Compilers. Intermediate Representations Hal Perkins Spring UW CSE P 501 Spring 2018 G-1
CSE P 501 Compilers Intermediate Representations Hal Perkins Spring 2018 UW CSE P 501 Spring 2018 G-1 Administrivia Semantics/types/symbol table project due ~2 weeks how goes it? Should be caught up on
More informationSoftware Engineering
Software Engineering Lecture 16: Testing and Debugging Debugging Peter Thiemann University of Freiburg, Germany SS 2014 Today s Topic This Lecture Execution observation Tracking causes and effects Central
More informationRegister Allocation. Global Register Allocation Webs and Graph Coloring Node Splitting and Other Transformations
Register Allocation Global Register Allocation Webs and Graph Coloring Node Splitting and Other Transformations Copyright 2015, Pedro C. Diniz, all rights reserved. Students enrolled in the Compilers class
More informationLecture Compiler Middle-End
Lecture 16-18 18 Compiler Middle-End Jianwen Zhu Electrical and Computer Engineering University of Toronto Jianwen Zhu 2009 - P. 1 What We Have Done A lot! Compiler Frontend Defining language Generating
More informationCode Generation. Frédéric Haziza Spring Department of Computer Systems Uppsala University
Code Generation Frédéric Haziza Department of Computer Systems Uppsala University Spring 2008 Operating Systems Process Management Memory Management Storage Management Compilers Compiling
More informationApproximation of the Worst-Case Execution Time Using Structural Analysis. Matteo Corti and Thomas Gross Zürich
Approximation of the Worst-Case Execution Time Using Structural Analysis Matteo Corti and Thomas Gross Zürich Goal Worst-case execution time estimation of softreal time Java applications. We focus on semantic
More informationG Programming Languages - Fall 2012
G22.2110-003 Programming Languages - Fall 2012 Lecture 2 Thomas Wies New York University Review Last week Programming Languages Overview Syntax and Semantics Grammars and Regular Expressions High-level
More informationCS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 19: Efficient IL Lowering 5 March 08
CS412/CS413 Introduction to Compilers Tim Teitelbaum Lecture 19: Efficient IL Lowering 5 March 08 CS 412/413 Spring 2008 Introduction to Compilers 1 IR Lowering Use temporary variables for the translation
More information378: Machine Organization and Assembly Language
378: Machine Organization and Assembly Language Spring 2010 Luis Ceze Slides adapted from: UIUC, Luis Ceze, Larry Snyder, Hal Perkins 1 What is computer architecture about? Computer architecture is the
More informationCS 351 Final Exam Solutions
CS 351 Final Exam Solutions Notes: You must explain your answers to receive partial credit. You will lose points for incorrect extraneous information, even if the answer is otherwise correct. Question
More informationConflicts in LR Parsing and More LR Parsing Types
Conflicts in LR Parsing and More LR Parsing Types Lecture 10 Dr. Sean Peisert ECS 142 Spring 2009 1 Status Project 2 Due Friday, Apr. 24, 11:55pm The usual lecture time is being replaced by a discussion
More informationECE 486/586. Computer Architecture. Lecture # 7
ECE 486/586 Computer Architecture Lecture # 7 Spring 2015 Portland State University Lecture Topics Instruction Set Principles Instruction Encoding Role of Compilers The MIPS Architecture Reference: Appendix
More information: Compiler Design. 9.6 Available expressions 9.7 Busy expressions. Thomas R. Gross. Computer Science Department ETH Zurich, Switzerland
252-210: Compiler Design 9.6 Available expressions 9.7 Busy expressions Thomas R. Gross Computer Science Department ETH Zurich, Switzerland Available expressions An expression a+b is available at a point
More informationControl Flow Analysis
Control Flow Analysis Last time Undergraduate compilers in a day Today Assignment 0 due Control-flow analysis Building basic blocks Building control-flow graphs Loops January 28, 2015 Control Flow Analysis
More informationControl Flow Analysis
COMP 6 Program Analysis and Transformations These slides have been adapted from http://cs.gmu.edu/~white/cs60/slides/cs60--0.ppt by Professor Liz White. How to represent the structure of the program? Based
More informationCode Generation. The Main Idea of Today s Lecture. We can emit stack-machine-style code for expressions via recursion. Lecture Outline.
The Main Idea of Today s Lecture Code Generation We can emit stack-machine-style code for expressions via recursion (We will use MIPS assembly as our target language) 2 Lecture Outline What are stack machines?
More informationWe can emit stack-machine-style code for expressions via recursion
Code Generation The Main Idea of Today s Lecture We can emit stack-machine-style code for expressions via recursion (We will use MIPS assembly as our target language) 2 Lecture Outline What are stack machines?
More informationSSA Construction. Daniel Grund & Sebastian Hack. CC Winter Term 09/10. Saarland University
SSA Construction Daniel Grund & Sebastian Hack Saarland University CC Winter Term 09/10 Outline Overview Intermediate Representations Why? How? IR Concepts Static Single Assignment Form Introduction Theory
More informationAP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS
AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this
More information4.1 Review - the DPLL procedure
Applied Logic Lecture 4: Efficient SAT solving CS 4860 Spring 2009 Thursday, January 29, 2009 The main purpose of these notes is to help me organize the material that I used to teach today s lecture. They
More informationCopyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit
Intermediate Representations Copyright 2003, Keith D. Cooper, Ken Kennedy & Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit permission to make copies
More informationCS415 Compilers. Intermediate Represeation & Code Generation
CS415 Compilers Intermediate Represeation & Code Generation These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University Review - Types of Intermediate Representations
More informationLecture 5: Procedure Calls
Lecture 5: Procedure Calls Today s topics: Procedure calls and register saving conventions 1 Example Convert to assembly: while (save[i] == k) i += 1; i and k are in $s3 and $s5 and base of array save[]
More informationCS143 Final Spring 2016
CS143 Final Spring 2016 Please read all instructions (including these) carefully. There are 5 questions on the exam, all with multiple parts. This exam is designed to take 2 hours, but you have the full
More informationsyntax tree - * * * * * *
Announcements Today: The last day to request prelim regrades Assignment A4 due next Thursday night. Please work on it early and steadily. Watch the two videos on recursion on trees before working on A4!
More informationASTS, GRAMMARS, PARSING, TREE TRAVERSALS. Lecture 14 CS2110 Fall 2018
1 ASTS, GRAMMARS, PARSING, TREE TRAVERSALS Lecture 14 CS2110 Fall 2018 Announcements 2 Today: The last day to request prelim regrades Assignment A4 due next Thursday night. Please work on it early and
More informationComputer Science 1000: Part #1. Introduction WHAT IS COMPUTER SCIENCE? WHAT IS AN ALGORITHM? THE STRUCTURE OF THIS COURSE
Computer Science 1000: Part #1 Introduction WHAT IS COMPUTER SCIENCE? WHAT IS AN ALGORITHM? THE STRUCTURE OF THIS COURSE What is Computer Science? Is Computer Science...... the study of computers?... the
More informationCSCI-1200 Data Structures Spring 2018 Lecture 7 Order Notation & Basic Recursion
CSCI-1200 Data Structures Spring 2018 Lecture 7 Order Notation & Basic Recursion Review from Lectures 5 & 6 Arrays and pointers, Pointer arithmetic and dereferencing, Types of memory ( automatic, static,
More informationChallenges in the back end. CS Compiler Design. Basic blocks. Compiler analysis
Challenges in the back end CS3300 - Compiler Design Basic Blocks and CFG V. Krishna Nandivada IIT Madras The input to the backend (What?). The target program instruction set, constraints, relocatable or
More informationLanguages and Compiler Design II IR Code Generation I
Languages and Compiler Design II IR Code Generation I Material provided by Prof. Jingke Li Stolen with pride and modified by Herb Mayer PSU Spring 2010 rev.: 4/16/2010 PSU CS322 HM 1 Agenda Grammar G1
More informationLecture 23 CIS 341: COMPILERS
Lecture 23 CIS 341: COMPILERS Announcements HW6: Analysis & Optimizations Alias analysis, constant propagation, dead code elimination, register allocation Due: Wednesday, April 25 th Zdancewic CIS 341:
More informationBackground: Pipelining Basics. Instruction Scheduling. Pipelining Details. Idealized Instruction Data-Path. Last week Register allocation
Instruction Scheduling Last week Register allocation Background: Pipelining Basics Idea Begin executing an instruction before completing the previous one Today Instruction scheduling The problem: Pipelined
More informationPrinciples of Compiler Design
Principles of Compiler Design Code Generation Compiler Lexical Analysis Syntax Analysis Semantic Analysis Source Program Token stream Abstract Syntax tree Intermediate Code Code Generation Target Program
More informationCompiler Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore
Compiler Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore Module No. # 10 Lecture No. # 16 Machine-Independent Optimizations Welcome to the
More informationDynamic Memory Allocation
Dynamic Memory Allocation CS61, Lecture 10 Prof. Stephen Chong October 4, 2011 Announcements 1/2 Assignment 4: Malloc Will be released today May work in groups of one or two Please go to website and enter
More informationCombining Analyses, Combining Optimizations - Summary
Combining Analyses, Combining Optimizations - Summary 1. INTRODUCTION Cliff Click s thesis Combining Analysis, Combining Optimizations [Click and Cooper 1995] uses a structurally different intermediate
More informationA Usability Evaluation of Google Calendar
A Usability Evaluation of Google Calendar Executive summary Purpose This study is to conduct a usability evaluation of web-based Google Calendar. Four highlevel questions about the usability of this product
More information7. Optimization! Prof. O. Nierstrasz! Lecture notes by Marcus Denker!
7. Optimization! Prof. O. Nierstrasz! Lecture notes by Marcus Denker! Roadmap > Introduction! > Optimizations in the Back-end! > The Optimizer! > SSA Optimizations! > Advanced Optimizations! 2 Literature!
More information