Dominators and CFGs 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

- 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.
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.
Analysis of Algorithms Depth First Search. Graph A representation of set of objects Pairs of objects are connected Interconnected objects are called “vertices.
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 Depth First Search dfs(0, 0) open site blocked site reachable from top via open sites.
Discrete Structures Lecture 13: Trees Ji Yanyan United International College Thanks to Professor Michael Hvidsten.
1 CS 201 Compiler Construction Lecture 2 Control Flow Analysis.
Jeffrey D. Ullman Stanford University Flow Graph Theory.
Implementation of Graph Decomposition and Recursive Closures Graph Decomposition and Recursive Closures was published in 2003 by Professor Chen. The project.
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.
Data Flow Analysis Compiler Design Nov. 3, 2005.
Lecture 6 Program Flow Analysis Forrest Brewer Ryan Kastner Jose Amaral.
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.
Graphs & Graph Algorithms Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
School of EECS, Peking University “Advanced Compiler Techniques” (Fall 2011) Loops Guo, Yao.
2/10/03Tucker, Sec Tucker, Applied Combinatorics, Sec. 3.2, Important Definitions Enumeration: Finding all of the possible paths in a rooted tree.
Efficiency of Iterative Algorithms
Depth-First Search Lecture 24 COMP171 Fall Graph / Slide 2 Depth-First Search (DFS) * DFS is another popular graph search strategy n Idea is similar.
Three Types of Depth-First Search Alyce Brady CS 470: Data Structures CS 510: Computer Algorithms.
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,
Binary Trees 2 Overview Trees. Terminology. Traversal of Binary Trees. Expression Trees. Binary Search Trees.
Dominators, control-dependence and SSA form. Organization Dominator relation of CFGs –postdominator relation Dominator tree Computing dominator relation.
Discussion #32 1/13 Discussion #32 Properties and Applications of Depth-First 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.
Dead Code Elimination This lecture presents the algorithm Dead from EaC2e, Chapter 10. That algorithm derives, in turn, from Rob Shillner’s unpublished.
CS 614: Theory and Construction of Compilers Lecture 15 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
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
Binary Tree Implementation. Binary Search Trees (BST) Nodes in Left subtree has smaller values Nodes in right subtree has bigger values.
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2011 Static Single Assignment John Cavazos.
Hello Everyone!!! 1. Tree And Graphs 2 Features of Trees  Tree Nodes Each node have 0 or more children A node have must one parent  Binary tree Tree.
1 CS 201 Compiler Construction Lecture 2 Control Flow Analysis.
Machine-Independent Optimizations Ⅳ CS308 Compiler Theory1.
1 Trees : Part 1 Reading: Section 4.1 Theory and Terminology Preorder, Postorder and Levelorder Traversals.
Best-first search is a search algorithm which explores a graph by expanding the most promising node chosen according to a specified rule.
1 Code Optimization Chapter 9 (1 st ed. Ch.10) COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University,
Fundamentals of Algorithms MCS - 2 Lecture # 17. Binary Search Trees.
Loops Simone Campanoni
Simone Campanoni CFA Simone Campanoni
Fundamentals of Programming II Introduction to Trees
CS 201 Compiler Construction
Section 8.1 Trees.
Princeton University Spring 2016
CS 201 Compiler Construction
Factored Use-Def Chains and Static Single Assignment Forms
Taken largely from University of Delaware Compiler Notes
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
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
Taken largely from University of Delaware Compiler Notes
Chapter 20: Binary Trees.
Presentation transcript:

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).

Domination relation: An Example S { (1, 1), (1, 2), (1, 3), (1, 4) … (2, 3), (2, 4), … (2, 10) } Direct domination: DOM : 1 < d 2, 2 < d 3, … DOM(1) = {1} DOM(2) = {1, 2} DOM(3) = {1, 2, 3} DOM(10) = {1, 2, 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 S A flowgraph (left) and its dominator tree (right)

Question 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)

Depth-First Search (DFS) zAn “ordering” of nodes of CFG zBBs dfs_nums 1..N zEach BB dfs_num represents when that BB first encountered in DFS zWrite dfs(BB root);

DFS and Depth-First Order zCONFUSING: They are NOT the same zDFS as defined: order of first visitation during depth-first search zDepth-First Order y“The depth-first ordering of the nodes is the reverse of the order in which we last visit the nodes in a preorder traversal” (Aho-Sethi-Ullman) yUsed (sometimes) to identify loops yLater …

An Example DFS