Taken largely from University of Delaware Compiler Notes

Slides:



Advertisements
Similar presentations
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.
Advertisements

Course Outline Traditional Static Program Analysis –Theory Compiler Optimizations; Control Flow Graphs Data-flow Analysis – today’s class –Classic analyses.
- 1 - Dominator Tree BB0 BB1 BB2BB3 BB4 BB6 BB7 BB5 BB0 BB1 BB2BB3 BB4 BB6 BB5 BB7 BBDOM0 10,1 20,1,2 30,1,3 BBDOM 40,1,3,4 50,1,3,5 60,1,3,6 70,1,7 Dom.
Course Outline Traditional Static Program Analysis –Theory Compiler Optimizations; Control Flow Graphs Data-flow Analysis – today’s class –Classic analyses.
CS Fall 2012, Lab 08 Haohan Zhu. Boston University Slideshow Title Goes Here CS Fall 2012, Lab /17/2015 Tree - Data Structure  Basic.
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.
SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Binary Search Tree A running demonstration of binary search.
A Deeper Look at Data-flow Analysis Copyright 2011, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 512 at Rice University.
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2009 Static Single Assignment John Cavazos.
1 CS 201 Compiler Construction Lecture 2 Control Flow Analysis.
Jeffrey D. Ullman Stanford University Flow Graph Theory.
1 CS 201 Compiler Construction Lecture 2 Control Flow Analysis.
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.
2015/6/24\course\cpeg421-10F\Topic1-b.ppt1 Topic 1b: Flow Analysis Some slides come from Prof. J. N. Amaral
CS 412/413 Spring 2007Introduction to Compilers1 Lecture 29: Control Flow Analysis 9 Apr 07 CS412/413 Introduction to Compilers Tim Teitelbaum.
Lecture 21 Trees. “ A useful data structure for many applications”
School of EECS, Peking University “Advanced Compiler Techniques” (Fall 2011) Loops Guo, Yao.
Efficiency of Iterative Algorithms
CSC 2300 Data Structures & Algorithms February 6, 2007 Chapter 4. Trees.
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,
Trees CSC 172 SPRING 2002 LECTURE 14. Lists We have seen lists: public class Node { Object data; Node next; } 
Binary Trees 2 Overview Trees. Terminology. Traversal of Binary Trees. Expression Trees. Binary Search Trees.
Compiled by: Dr. Mohammad Omar Alhawarat
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2009 Static Single Assignment John Cavazos.
Trees : Part 1 Section 4.1 (1) Theory and Terminology (2) Preorder, Postorder and Levelorder Traversals.
Computer Science 112 Fundamentals of Programming II Introduction to Trees.
Advanced Compiler Techniques LIU Xianhua School of EECS, Peking University Loops.
Binary Trees In computer science, a binary tree is a tree data structure in which each node has at most two children, which are referred to as the left.
Trees By P.Naga Srinivasu M.tech,(MBA). Basic Tree Concepts A tree consists of finite set of elements, called nodes, and a finite set of directed lines.
Dead Code Elimination This lecture presents the algorithm Dead from EaC2e, Chapter 10. That algorithm derives, in turn, from Rob Shillner’s unpublished.
Announcements & Reading Material
CS 614: Theory and Construction of Compilers Lecture 15 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
Control Flow Analysis Compiler Baojian Hua
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2011 Static Single Assignment John Cavazos.
CMSC 202, Version 5/02 1 Trees. CMSC 202, Version 5/02 2 Tree Basics 1.A tree is a set of nodes. 2.A tree may be empty (i.e., contain no nodes). 3.If.
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.
1 Trees : Part 1 Reading: Section 4.1 Theory and Terminology Preorder, Postorder and Levelorder Traversals.
1 Code Optimization Chapter 9 (1 st ed. Ch.10) COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University,
CSC317 1 Binary Search Trees (binary because branches either to left or to right) Operations: search min max predecessor successor. Costs? Time O(h) with.
Fundamentals of Algorithms MCS - 2 Lecture # 17. Binary Search Trees.
Loops Simone Campanoni
Breadth-First Search (BFS)
Simone Campanoni CFA Simone Campanoni
Fundamentals of Programming II Introduction to Trees
Tracing An Algorithm for Strongly Connected Components that uses Depth First Search Graph obtained from Text, page a-al: Geetika Tewari.
CS 201 Compiler Construction
EECS 583 – Class 2 Control Flow Analysis
Section 8.1 Trees.
Princeton University Spring 2016
Alyce Brady CS 470: Data Structures CS 510: Computer Algorithms
CS 201 Compiler Construction
Factored Use-Def Chains and Static Single Assignment Forms
Code Optimization Chapter 10
Code Optimization Chapter 9 (1st ed. Ch.10)
Optimizing Compilers CISC 673 Spring 2009 More Control Flow
Building SSA Form COMP 512 Rice University Houston, Texas Fall 2003
Topic 4: Flow Analysis Some slides come from Prof. J. N. Amaral
Chapter 9 Binary Trees.
Control Flow Analysis (Chapter 7)
Dominator Tree First BB is the root node, each node
EECS 583 – Class 7 Static Single Assignment Form
Optimizing Compilers CISC 673 Spring 2011 Static Single Assignment II
EECS 583 – Class 2 Control Flow Analysis
EECS 583 – Class 7 Static Single Assignment Form
Taken largely from University of Delaware Compiler Notes
Chapter 20: Binary Trees.
Presentation transcript:

Taken largely from University of Delaware Compiler Notes Dominators and CFGs Taken largely from University of Delaware Compiler Notes

Dominators Node (basic block) D in a CFG dominates node N if every path from the start node to N goes through D. We say that node D is a dominator of node N. Define dom(N) = set of node N’s dominators, or the dominator set for node N. Note: by definition, each node dominates itself i.e., N  dom(N).

An Example Domination relation: { (1, 1), (1, 2), (1, 3), (1, 4) … (2, 3), (2, 4), … (2, 10) } 1 S 2 3 Direct domination: 4 1 <d 2, 2 <d 3, … 5 6 7 DOM: 8 DOM(1) = {1} DOM(2) = {1, 2} DOM(3) = {1, 2, 3} DOM(10) = {1, 2, 10) 9 10

Immediate Dominators and Dominator Tree Node M is the immediate dominator of node N ==> Node M must be the last dominator of N on any path from the start node to N. Therefore, every node other than the start node must have a unique immediate dominator (the start node has no immediate dominator.) What does this mean ?

Dominator Tree A flowgraph (left) and its dominator tree (right) S 1 2 3 4 5 6 7 8 9 10 S 1 2 3 4 5 7 8 6 9 10 A flowgraph (left) and its dominator tree (right)

Question Answer: NO! Example: consider nodes 5 and 8. Assume an immediate dominator n’ of a node n, is n’ necessarily an immediate predecessor in the flow graph? Answer: NO! Example: consider nodes 5 and 8.

An Example (Dominators) 1 2 3 4 5 6 7 8 9 10

Depth-First Search (DFS) An “ordering” of nodes of CFG BBs dfs_nums 1..N Each BB dfs_num represents when that BB first encountered in DFS Write dfs(BB root);

DFS and Depth-First Order CONFUSING: They are NOT the same DFS as defined: order of first visitation during depth-first search Depth-First Order “The depth-first ordering of the nodes is the reverse of a postorder traversal” (Aho-Sethi-Ullman) Used (sometimes) to identify loops Later …

An Example DFS 1 2 3 4 5 6 7 8 9 10