Advanced Compiler Design. CSE 231 Instructor: Sorin Lerner

Similar documents
Advanced Compiler Design. CSE 231 Instructor: Sorin Lerner

Advanced Compiler Design. CSE 231 Instructor: Sorin Lerner

CSE 501: Compiler Construction. Course outline. Goals for language implementation. Why study compilers? Models of compilation

Usually, target code is semantically equivalent to source code, but not always!

CS 406/534 Compiler Construction Putting It All Together

Hi! My name is Sorin. Programming Languages. Why study PL? (discussion) Why study PL? Course Goals. CSE : Fall 2017

Advanced Compiler Construction

Programming Languages

15-411/ Compiler Design

Overview of the Class

CSE 501 Midterm Exam: Sketch of Some Plausible Solutions Winter 1997

Static Program Analysis

COMP 181. Agenda. Midterm topics. Today: type checking. Purpose of types. Type errors. Type checking

Undergraduate Compilers in a Day

Recap: Pointers. int* int& *p &i &*&* ** * * * * IFMP 18, M. Schwerhoff

CS/SE 153 Concepts of Compiler Design

Program Analysis And Its Support in Software Development

Introduction to Computer Systems

Hi! My name is Sorin. Programming Languages. Why study PL? (discussion) Why study PL? Course Goals. CSE 130 : Fall 2014

Static Program Analysis

CSE443 Compilers. Dr. Carl Alphonce 343 Davis Hall

ECE573 Introduction to Compilers & Translators

Principles of Program Analysis. Lecture 1 Harry Xu Spring 2013

Introduction. CS 2210 Compiler Design Wonsun Ahn

ECE Introduction to Compilers and Translation Engineering

Programming Languages

Tonight s Agenda. CSC340: Requirements Engineering. Course Objectives. Requirements Engineering. Software Engineering. What is Software Engineering?

Hi! My name is Sorin. Programming Languages. Why study PL? (discussion) Why study PL? Course Goals. CSE 130 : Fall 2013

Compilers. Lecture 2 Overview. (original slides by Sam

CMPE 152 Compiler Design

Shared Variables and Interference

CS 553: Algorithmic Language Compilers (PLDI) Graduate Students and Super Undergraduates... Logistics. Plan for Today

Intro to C: Pointers and Arrays

Introduction to Computer Systems

CS 241 Data Organization. August 21, 2018

Physics 2660: Fundamentals of Scientific Computing. Lecture 3 Instructor: Prof. Chris Neu

A Gentle Introduction to Program Analysis

CSE4305: Compilers for Algorithmic Languages CSE5317: Design and Construction of Compilers

CSE 307: Principles of Programming Languages

Programming Project 4: COOL Code Generation

Shared Variables and Interference

CSCI 565 Compiler Design and Implementation Spring 2014

CSE 501! Principles and Applications! of Program Analysis! " Alvin Cheung" Spring 15"

CSE 417 Practical Algorithms. (a.k.a. Algorithms & Computational Complexity)

We made it! Java: Assembly language: OS: Machine code: Computer system:

Lecture 1: Overview

Structure of Programming Languages Lecture 10

Compilers. Computer Science 431

CS240: Programming in C

Resource-aware Computing Lecture 1- Grading, Rules and Introduction

CS/SE 153 Concepts of Compiler Design

CS354 gdb Tutorial Written by Chris Feilbach

USC 227 Office hours: 3-4 Monday and Wednesday CS553 Lecture 1 Introduction 4

CS558 Programming Languages

Optimizing for Bugs Fixed

Lecture Compiler Middle-End

COMP 321: Introduction to Computer Systems

Lecture 14. No in-class files today. Homework 7 (due on Wednesday) and Project 3 (due in 10 days) posted. Questions?

CSE413: Programming Languages and Implementation Racket structs Implementing languages with interpreters Implementing closures

Announcements. Scope, Function Calls and Storage Management. Block Structured Languages. Topics. Examples. Simplified Machine Model.

CS558 Programming Languages

Advanced Compiler Construction

CSE4305: Compilers for Algorithmic Languages CSE5317: Design and Construction of Compilers

CS 553 Compiler Construction Fall 2009 Project #1 Adding doubles to MiniJava Due September 8, 2009

ECE 5775 (Fall 17) High-Level Digital Design Automation. Static Single Assignment

CS61C Machine Structures. Lecture 3 Introduction to the C Programming Language. 1/23/2006 John Wawrzynek. www-inst.eecs.berkeley.

CSE4305: Compilers for Algorithmic Languages CSE5317: Design and Construction of Compilers

Compiler Design Spring 2018

Welcome to CSE131b: Compiler Construction

An Overview to Compiler Design. 2008/2/14 \course\cpeg421-08s\topic-1a.ppt 1

CS 240 Fall 2015 Section 004. Alvin Chao, Professor

Grade Weights. Language Design and Overview of COOL. CS143 Lecture 2. Programming Language Economics 101. Lecture Outline

CS 241 Data Organization using C

General Course Information. Catalogue Description. Objectives

Overview of the ECE Computer Software Curriculum. David O Hallaron Associate Professor of ECE and CS Carnegie Mellon University

CS558 Programming Languages

Compiler Construction

CMPE 152 Compiler Design

Topic 7: Intermediate Representations

CS11 Advanced C++ Spring 2018 Lecture 1

CS 701. Class Meets. Instructor. Teaching Assistant. Key Dates. Charles N. Fischer. Fall Tuesdays & Thursdays, 11:00 12: Engineering Hall

CSE 332: Data Abstractions. Ruth Anderson Spring 2014 Lecture 1

BLM2031 Structured Programming. Zeyneb KURT

CS415 Compilers Overview of the Course. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

CS153: Compilers Lecture 15: Local Optimization

Intermediate Representation (IR)

Alias Analysis. Last time Interprocedural analysis. Today Intro to alias analysis (pointer analysis) CS553 Lecture Alias Analysis I 1

CS503 Advanced Programming I CS305 Computer Algorithms I

CMPE 152 Compiler Design

CSE450. Translation of Programming Languages. Lecture 11: Semantic Analysis: Types & Type Checking

CMPSC 497: Static Analysis

Loop-Oriented Array- and Field-Sensitive Pointer Analysis for Automatic SIMD Vectorization

About this exam review

CSE 113 A. Announcements - Lab

Incremental Evaluation of OCL invariants in the Essential MOF object model

Advanced Programming Methods. Introduction in program analysis

Advanced C Programming

Data Abstraction. An Abstraction for Inductive Data Types. Philip W. L. Fong.

CS313T ADVANCED PROGRAMMING LANGUAGE

CSE373: Data Structures & Algorithms Lecture 23: Course Victory Lap. Kevin Quinn Fall 2015

Transcription:

Advanced Compiler Design CSE 231 Instructor: Sorin Lerner

Let s look at a compiler if ( ) { x := ; } else { y := ; } ; Parser Compiler Compiler Optimizer Code Gen Exec

Let s look at a compiler Compiler Parser Optimizer Code Gen

Advanced Optimizer Design CSE 231 Instructor: Sorin Lerner

What does an optimizer do? Compiler Parser Optimizer Code Gen 1. Compute information about a program 2. Use that information to perform program transformations (with the goal of improving some metric, e.g. performance)

What do these tools have in common? Bug finders Program verifiers Code refactoring tools Garbage collectors Runtime monitoring system And optimizers

What do these tools have in common? Bug finders Program verifiers Code refactoring tools Garbage collectors Runtime monitoring system And optimizers They all analyze and transform programs We will learn about the techniques underlying all these tools

Program Analyses, Transformations, and Applications CSE 231 Instructor: Sorin Lerner

Course goals Understand basic techniques cornerstone of a variety of program analysis tools useful no matter what your future path Get a feel for compiler research/implementation useful if you don t have a research area picked also useful if you have a research area picked

Course topics Representing programs Analyzing and transforming programs Applications of these techniques

Course topics (more details) Representations Abstract Syntax Tree Control Flow Graph Dataflow Graph Static Single Assignment Control Dependence Graph Program Dependence Graph Call Graph

Course topics (more details) Analysis/Transformation Algorithms Dataflow Analysis Interprocedural analysis Pointer analysis Rule-based analyses and transformations Constraint-based analysis

Course topics (more details) Applications Scalar optimizations Loop optimizations Object oriented optimizations Program verification Bug finding

Course pre-requisites No compilers background necessary No familiarity with lattices I will review what is necessary in class Familiarity with functional/oo programming Optimization techniques for these kinds of languages Standard ugrad cs curriculum likely enough Talk to me if you re concerned

Course work In-class midterm (30%) Take-home final (30%) Course project (35%) Class readings (5%)

Course project Get some hands on experience with compilers Use LLVM infrastructure to implement Dynamic instrumentation DFA engine Groups of 3 Make groups by next Tuesday

Course project Week 1: Make groups Weeks 2-4: Part 1 Implement dynamic instrumentation Write a one page report Weeks 5-10: Part 2 Design and Implement DFA engine Visualize DFA results Implement Const Prop, CSE, Ptr Analysis, Live Vars Write a 10 page report

Readings Paper readings throughout the quarter One or two papers per week Seminal papers and state of the art Will give you a feel for what research looks like

Administrative info Class web page is up http://cseweb.ucsd.edu/classes/sp14/cse231-a/ (or Google Sorin Lerner, follow Teaching Now ) Will post lectures, readings, project info, etc. Piazza link on web page Use for questions, answers Especially LLVM/project Q&A

Questions?

Program Analyzer Issues (discuss) Input Program Analyzer Output

Program Analyzer Issues (discuss) Input Program Analyzer Output

Program Analyzer Issues (discuss) Input Program Analyzer Output

Instructor s discussion notes Input issues Input Program Analyzer Output Input is a program, but What language is the program written in? imperative vs. functional vs. object-oriented? maybe even declarative? what pointer model does the language use? reflection, exceptions, continuations? type system trusted or not? one often analyzes an intermediate language... how does one design such a language?

Instructor s discussion notes Input issues Input Program Analyzer Output How much of the program do we see? all? one file at a time? one library at a time? reflection Any additional inputs? any human help? profile info?

Instructor s discussion notes Analysis issues Input Program Analyzer Output Analysis/compilation model Separate compilation/analysis quick, but no opportunities for interprocedural analysis Link-time allows interprocedural and whole program analysis but what about shared precompiled libraries? and what about compile-time? Run-time best optimization/analysis potential (can even use run-time state as additional information) can handle run-time extensions to the program but severe pressure to limit compilation time Selective run-time compilation choose what part of compilation to delay until run-time can balance compile-time/benefit tradeoffs

Instructor s discussion notes Analysis issues Input Program Analyzer Output Does running-time matter? for use in IDE? or in overnight compile?

Instructor s discussion notes Output issues Input Program Analyzer Output Form of output varies widely, depending on analysis alias information constantness information loop terminates/does not terminate Correctness of analysis results depends on what the results are used for are we attempting to design algorithms for solving undecidable problems? notion of approximation statistical output

Program Transformation Issues (discuss) Input Program Transformer Output

Instructor s discussion notes Input issues Input Program Transformer Output A program, and Program analysis results Profile info? Environment: # of CPUs, # of cores/cpu, cache size, etc. Anything else?

Instructor s discussion notes Transformation issues Input Program Transformer Output What is profitable? What order to perform transformations? What happens to the program representation? What happens to the computed information? For example alias information? Need to recompute?

Instructor s discussion notes Output issues Input Program Transformer Output Output in same IL as input? Should the output program behave the same way as the input program?