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

Slides:



Advertisements
Similar presentations
SSA and CPS CS153: Compilers Greg Morrisett. Monadic Form vs CFGs Consider CFG available exp. analysis: statement gen's kill's x:=v 1 p v 2 x:=v 1 p v.
Advertisements

1 SSA review Each definition has a unique name Each use refers to a single definition The compiler inserts  -functions at points where different control.
Data-Flow Analysis II CS 671 March 13, CS 671 – Spring Data-Flow Analysis Gather conservative, approximate information about what a program.
Chapter 9 Code optimization Section 0 overview 1.Position of code optimizer 2.Purpose of code optimizer to get better efficiency –Run faster –Take less.
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:
SSA.
Control Flow Analysis. Construct representations for the structure of flow-of-control of programs Control flow graphs represent the structure of flow-of-control.
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2011 More Control Flow John Cavazos University.
1 Code Optimization. 2 The Code Optimizer Control flow analysis: control flow graph Data-flow analysis Transformations Front end Code generator Code optimizer.
Control Flow Analysis (Chapter 7) Mooly Sagiv (with Contributions by Hanne Riis Nielson)
1 Constant Propagation for Loops with Factored Use-Def Chains Reporter : Lai, Yen-Chang.
1 CS 201 Compiler Construction Lecture 2 Control Flow Analysis.
Trace-Based Automatic Parallelization in the Jikes RVM Borys Bradel University of Toronto.
Program Representations Xiangyu Zhang. CS590F Software Reliability Why Program Representations  Initial representations Source code (across languages).
1 CS 201 Compiler Construction Lecture 2 Control Flow Analysis.
U NIVERSITY OF M ASSACHUSETTS, A MHERST D EPARTMENT OF C OMPUTER S CIENCE Advanced Compilers CMPSCI 710 Spring 2003 Lecture 2 Emery Berger University of.
CMPUT Compiler Design and Optimization
1 Intermediate representation Goals: –encode knowledge about the program –facilitate analysis –facilitate retargeting –facilitate optimization scanning.
PSUCS322 HM 1 Languages and Compiler Design II Basic Blocks Material provided by Prof. Jingke Li Stolen with pride and modified by Herb Mayer PSU Spring.
ECE1724F Compiler Primer Sept. 18, 2002.
1 Intermediate representation Goals: encode knowledge about the program facilitate analysis facilitate retargeting facilitate optimization scanning parsing.
1 CS 201 Compiler Construction Lecture 1 Introduction.
Lecture 6 Program Flow Analysis Forrest Brewer Ryan Kastner Jose Amaral.
1 CS 201 Compiler Construction Lecture 3 Data Flow Analysis.
2015/6/24\course\cpeg421-10F\Topic1-b.ppt1 Topic 1b: Flow Analysis Some slides come from Prof. J. N. Amaral
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.
Program Representations Xiangyu Zhang. CS590Z Software Defect Analysis Program Representations  Static program representations Abstract syntax tree;
CS 412/413 Spring 2007Introduction to Compilers1 Lecture 29: Control Flow Analysis 9 Apr 07 CS412/413 Introduction to Compilers Tim Teitelbaum.
1 CS 201 Compiler Construction Lecture 6 Code Optimizations: Constant Propagation & Folding.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 10 Instructor: Paul Beame.
School of EECS, Peking University “Advanced Compiler Techniques” (Fall 2011) Loops Guo, Yao.
Data Flow Analysis Compiler Design Nov. 8, 2005.
1 Region-Based Data Flow Analysis. 2 Loops Loops in programs deserve special treatment Because programs spend most of their time executing loops, improving.
1 Code Optimization Chapter 9 (1 st ed. Ch.10) COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University,
Software (Program) Analysis. Automated Static Analysis Static analyzers are software tools for source text processing They parse the program text and.
Dataflow Analysis Topic today Data flow analysis: Section 3 of Representation and Analysis Paper (Section 3) NOTE we finished through slide 30 on Friday.
1 CS 201 Compiler Construction Introduction. 2 Instructor Information Rajiv Gupta Office: WCH Room Tel: (951) Office.
CS 614: Theory and Construction of Compilers Lecture 7 Fall 2002 Department of Computer Science University of Alabama Joel Jones.
CS 614: Theory and Construction of Compilers Lecture 17 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
1 Control Flow Analysis Topic today Representation and Analysis Paper (Sections 1, 2) For next class: Read Representation and Analysis Paper (Section 3)
Announcements & Reading Material
CS412/413 Introduction to Compilers Radu Rugina Lecture 18: Control Flow Graphs 29 Feb 02.
1 Control Flow Graphs. 2 Optimizations Code transformations to improve program –Mainly: improve execution time –Also: reduce program size Can be done.
Control Flow Analysis Compiler Baojian Hua
1 CS 201 Compiler Construction Lecture 2 Control Flow Analysis.
Machine-Independent Optimizations Ⅳ CS308 Compiler Theory1.
Dominators and CFGs Taken largely from University of Delaware Compiler Notes.
CS 614: Theory and Construction of Compilers Lecture 10 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
CS 614: Theory and Construction of Compilers Lecture 8 Fall 2002 Department of Computer Science University of Alabama Joel Jones.
1 Code Optimization Chapter 9 (1 st ed. Ch.10) COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University,
Loops Simone Campanoni
Simone Campanoni CFA Simone Campanoni
Basic Program Analysis
CS 201 Compiler Construction
EECS 583 – Class 2 Control Flow Analysis
Constructing and Using
CS 201 Compiler Construction
Taken largely from University of Delaware Compiler Notes
Control Flow Analysis CS 4501 Baishakhi Ray.
Code Optimization Chapter 10
Optimizing Compilers CISC 673 Spring 2009 More Control Flow
CS 201 Compiler Construction
Topic 4: Flow Analysis Some slides come from Prof. J. N. Amaral
Code Optimization Overview and Examples Control Flow Graph
Control Flow Analysis (Chapter 7)
Interval Partitioning of a Flow Graph
EECS 583 – Class 2 Control Flow Analysis
Taken largely from University of Delaware Compiler Notes
Lecture 17: Register Allocation via Graph Colouring
CS 201 Compiler Construction
Presentation transcript:

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

Lecture 15©2003 Joel Jones2 Overview Control Flow Analysis Basic Blocks Types of Analyses Control Flow Graphs Interval Analysis Control Flow Graphs Representation and Formation Traversals and Edges Finding Loops Reading for Next Time

Lecture 15©2003 Joel Jones3 Control Flow Analysis Control flow analysis is the discovery of the hierarchical flow of control within a procedure Used in concert with data flow analysis in performing optimizations

Lecture 15©2003 Joel Jones4 Basic Blocks All forms of control flow analysis begin with basic blocks Basic blocks are formed from a linear form of IR, such as MIR A basic block consists of a sequence of instructions that can be entered only at the beginning and exited only at the end

Lecture 15©2003 Joel Jones5 Example of Basic Block Formation Pair Up: Find the Basic Blocks receive m (val) f0 <- 0 f1 <- 1 if m <= 1 goto L3 i <- 2 L1: if i <= m goto L2 return f2 L2: f2 <- f0 + f1 f1 <- f2 i <- i + 1 goto L1 L3: return m

Lecture 15©2003 Joel Jones6 Control Flow Graphs A control flow graph (CFG) is a rooted, directed graph The nodes of a CFG are basic blocks plus two distinguished nodes, the entry and exit nodes The edges of a CFG correspond to the flow of control from one basic block (BB) the the next Additionally, an edge is placed between the entry node and the first node of the procedure Also, edges are placed from each final BB (BBs with no successors) to the exit

Lecture 15©2003 Joel Jones7 Control Flow Graphs (cont.) Pair Up: Draw the Control Flow Graph receive m (val) f0 <- 0 f1 <- 1 if m <= 1 goto L3 i <- 2 L1: if i <= m goto L2 return f2 L2: f2 <- f0 + f1 f1 <- f2 i <- i + 1 goto L1 L3: return m

Lecture 15©2003 Joel Jones8 Code for Graphs, CFGs, and Graph Traversals See handouts

Lecture 15©2003 Joel Jones9 Definitions Dominance – a relation between nodes m dom n iff every path from the start node to n must include m Natural loop – a strongly connected component where there is an edge m  n where n dominates m

Lecture 15©2003 Joel Jones10 Definitions (cont.) Immediate Dominance – for a ≠ b, a idom b iff a dom b and there does not exist a node c such that c ≠ a and c ≠ b for which a dom c and c dom b Post domiance, p postdominates i, p pdom i if every possible path from i to exit includes p, i.e. i dom p in the flowgraph with edges reversed and exit and entry interchanged Strongly connected component (SCC) – a subgraph where every node is reachable from every other node

Lecture 15©2003 Joel Jones11 Examples of SCCs, Dominance Figure 7.27a, 7.28

Lecture 15©2003 Joel Jones12 Readings for Next Time Section 7.7 of Muchnick Sections 8–8.1 of the textbook