Simplified Gated Assignment Surinder Jain Supervisor : Bernhard Scholz Assignment 3 – INFO5993.

Slides:



Advertisements
Similar presentations
Algorithm Analysis Input size Time I1 T1 I2 T2 …
Advertisements

1 CIS 461 Compiler Design and Construction Fall 2014 Instructor: Hugh McGuire slides derived from Tevfik Bultan, Keith Cooper, and Linda Torczon Lecture-Module.
Static Single-Assignment ? ? Introduction: Over last few years [1991] SSA has been Stablished as… Intermediate program representation.
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.
Semantics Static semantics Dynamic semantics attribute grammars
8. Static Single Assignment Form Marcus Denker. © Marcus Denker SSA Roadmap  Static Single Assignment Form (SSA)  Converting to SSA Form  Examples.
School of EECS, Peking University “Advanced Compiler Techniques” (Fall 2011) SSA Guo, Yao.
Intermediate Code Generation
ICE1341 Programming Languages Spring 2005 Lecture #6 Lecture #6 In-Young Ko iko.AT. icu.ac.kr iko.AT. icu.ac.kr Information and Communications University.
1 CS 201 Compiler Construction Lecture 3 Data Flow Analysis.
Compilation 2011 Static Analysis Johnni Winther Michael I. Schwartzbach Aarhus University.
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
Static Single Assignment CS 540. Spring Efficient Representations for Reachability Efficiency is measured in terms of the size of the representation.
CS 31003: Compilers Introduction to Phases of Compiler.
1 Translation Validation: From Simulink to C Michael RyabtsevOfer Strichman Technion, Haifa, Israel Acknowledgement: sponsored by a grant from General.
The Assembly Language Level
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
ISBN Chapter 3 Describing Syntax and Semantics.
CS 355 – Programming Languages
1 Pass Compiler 1. 1.Introduction 1.1 Types of compilers 2.Stages of 1 Pass Compiler 2.1 Lexical analysis 2.2. syntactical analyzer 2.3. Code generation.
CIS 101: Computer Programming and Problem Solving Lecture 8 Usman Roshan Department of Computer Science NJIT.
1 Intermediate representation Goals: –encode knowledge about the program –facilitate analysis –facilitate retargeting –facilitate optimization scanning.
Lecture #17, June 5, 2007 Static Single Assignment phi nodes Dominators Dominance Frontiers Dominance Frontiers when inserting phi nodes.
Computer Science 1620 Programming & Problem Solving.
ISBN Lecture 01 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Lecture 01 Topics Motivation Programming.
Describing Syntax and Semantics
Program Analysis Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Introduction & Overview CS4533 from Cooper & Torczon.
Chapter 12: Simulation and Modeling Invitation to Computer Science, Java Version, Third Edition.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
5.3 Machine-Independent Compiler Features
METHODS Introduction to Systems Programming - COMP 1005, 1405 Instructor : Behnam Hajian
JIT in webkit. What’s JIT See time_compilation for more info. time_compilation.
Gary MarsdenSlide 1University of Cape Town Principles of programming language design Gary Marsden Semester 2 – 2001.
Invariant Based Programming in Education Tutorial, FM’08 Linda Mannila
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
Vladimir Misic: Design111:43:34 AM Software design.
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
Software Life Cycle Requirements and problem analysis. –What exactly is this system supposed to do? Design –How will the system solve the problem? Coding.
SWE 619 © Paul Ammann Procedural Abstraction and Design by Contract Paul Ammann Information & Software Engineering SWE 619 Software Construction cs.gmu.edu/~pammann/
Chapter Twenty-ThreeModern Programming Languages1 Formal Semantics.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Formal Semantics Chapter Twenty-ThreeModern Programming Languages, 2nd ed.1.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
Algorithm Analysis Data Structures and Algorithms (60-254)
© Paul Ammann, 2008 Design by Contract Paul Ammann CS/SWE 332.
Detecting Equality of Variables in Programs Bowen Alpern, Mark N. Wegman, F. Kenneth Zadeck Presented by: Abdulrahman Mahmoud.
Semantics In Text: Chapter 3.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Chapter – 8 Software Tools.
Recap Introduction to Inheritance Inheritance in C++ IS-A Relationship Polymorphism in Inheritance Classes in Inheritance Visibility Rules Constructor.
Testing Programs with Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
11 Making Decisions in a Program Session 2.3. Session Overview  Introduce the idea of an algorithm  Show how a program can make logical decisions based.
Functional Programming
Code Optimization.
Programming Languages
Weakest Precondition of Unstructured Programs
Introduction to programming
Debugging and Random Numbers
Compiler Lecture 1 CS510.
Graph Paper Programming
Chapter 6 Intermediate-Code Generation
The Metacircular Evaluator
Lecture 23 Pages : Separating Syntactic Analysis from Execution. We omit many details so you have to read the section in the book. The halting.
CSE401 Introduction to Compiler Construction
The Metacircular Evaluator
Copyright 2003, Keith D. Cooper & Linda Torczon, all rights reserved.
Basic Concepts of Algorithm
Rehearsal: Lazy Evaluation Infinite Streams in our lazy evaluator
Presentation transcript:

Simplified Gated Assignment Surinder Jain Supervisor : Bernhard Scholz Assignment 3 – INFO5993

 Programs have bugs  Fully testing of a program is not feasible  Bugs get through and cause havoc  Ariane rocket blows up after take-off (zero underflow error)  Spacecraft goes to safe mode – successive commands at a multiple of 1000 seconds  Cancer treatment machine gives overdose of radiation and kills a patient

 Static compile time techniques  Predicts safe and computable approximations to program behaviour arising dynamically at run- time, without ever running the program Static Program Analysis

 SSA, a technique of Static Program Analysis  Simplifies variable definition and use analysis  Is used as an Intermediate Representation by many compilers including LLVM Static Single Assignment

 A variable should be assigned only once in a program  Change the variable name on second assignment  Use the second variable name in rest of the program  Since each variable is defined only once, it has only one static value.  It is easy to search for that definition during program analysis Static Single Assignment

 X=1; Y=X+2; X=2; Z=X+3  X is being assigned twice, once as 1 and then as 2.  To change the program to SSA form  X=1;Y=X+2; X2=2 ;Z= X2 +3 Static Single Assignment - Example

 X=1 ;If Y>0 then X=2 ;Z=Z+X;  Second assignment of X is conditional  SSA form converts the program as  X=1;If Y>0 then X2=2 ; X3=gamma(Y>0,X,X2); Z=Z+ X3 Gamma is iif function, if first parameter is true, return second otherwise return third parameter as result. Static Single Assignment – Conditionals

 W=0;While Z>0;W=W+X;Z=Z-1;EndWhile;Print (W);  Gated SA form converts it as  W=0;L :W1= Beta (W,W2);If Z>0 then W2=W1+X;Z=Z-1;Goto L; W3= EtaFalse (W,W2);Print(W3); Beta returns first parameter when called first time, subsequent calls, it returns second parameter. EtaFalse returns W2 if loop was entered otherwise it returns W. Static Single Assignment – Loops

Beta returns first parameter when called first time, subsequent calls, it returns second parameter  Beta is a contextual function  Its result does not depend on its parameters alone  Its result depends on the context in which it has been called  It can, however, be programmed separately for each location it is used in What is wrong with gated beta function

EtaFalse returns W2 if loop was entered otherwise it returns W  EtaFalse is a contextual function  Its result does not depend on its parameters alone  Its result depends on the context in which it has been called  It can, however, be programmed separately for each location it is used in What is wrong with gated Eta function

Gamma is iif function, if first parameter is true, return second otherwise returns third parameter as its result.  Gamma is a non-contextual function  Its result depends on its parameters alone and on nothing else  It can be programmed once and use everywhere else What is wrong with Gamma function

 But for Gamma, other two functions behave differently in different contexts and in different calls in the same context  They are not static defined functions  They can not be used in formulating static program analysis equations  They hinder symbolic analysis of the program once it has been converted into Gated SSA form Problem Description

 Can we combine the benefits of SSA form with Symbolic Analysis techniques  Can we define an SSA form that does not use Beta and EtaFalse  Can we define an SSA form using non- contextual pure functions only

1. Static Single Assignment – Cytron shows how to compute it efficiently with a contextual phi function 2. Various (too many) papers showing its use in compiler construction, code translation and in compiler optimizations 3. Ferriere et al improved phi function to psi function for predication based compilers 4. Balance et all separated phi function into three separate gating functions called gamma, mu and eta functions. 5. Campbell el al found problems and inaccuracies with gamma, mu and eta functions. They made a fix and renamed mu as beta. SSA and gating functions are contextual but are being used widely by compilers and optimizers

 Definition of gating functions by Balance et al and their improvements by Campbell have been studied.  Mechanism of their implementation by compilers and code generated for these functions has been studied  It was seen that some of this code can be moved out of gating functions into program source code  This resulted in elimination of contextual beta and eta functions by non-contextual gamma function

 A new form called Simplified Gated Assignment (SGA) form is being proposed  An explanation of how to deduce them from existing work has been given  An example has been worked out step by step  No formal proof or algorithms to compute it have been provided as it is derived by simply moving out some code of mu and eta function to program

 Programs can be converted into SGA form  The SGA form is very close to existing SSA form  SSA form requires that each variable is assigned only once  SGA form enforces it for all programmer defined variables  It permits exception for one specific type of control variable which can be defined using a specific protocol

 Duplicate assignment of control variable can be removed for languages that permit dynamic allocation of variables  For other languages, it does not increase the complexity as the duplicate definition is defined only twice and used only once  All existing methods of compiler construction and optimization that use SSA as an intermediate representation can also use GSA

 Have simplified SSA with non-contextual functions permitting more opportunities for optimization  Changes to SSA form are transparent to compilers  Symbolic Analysis and abstract interpretation techniques can use GSA function and compute equations for exact results rather than inequalities that compute approximate results

 SGA preserves all benefits of SSA and GSA forms without having to use any non- contextual function  It can be used by compilers with equal ease  Another step to remove reasons for approximate results from Symbolic Analysis

Algorithm to convert from SSA to SGA and a formal proof of its correctness can be constructed and shown to be O(n logn) Symbolic Analysis can simplify its inequations and convert them into equations by using GSA form of the program