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

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

Programming Languages

ECE573 Introduction to Compilers & Translators

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

15-411/ Compiler Design

CS 241 Data Organization using C

Introduction to Programming System Design CSCI 455x (4 Units)

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

CS 241 Data Organization. August 21, 2018

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

Programming Languages

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

Introduction to Computer Systems

CSE 113 A. Announcements - Lab

ECE Introduction to Compilers and Translation Engineering

Principles of Program Analysis. Lecture 1 Harry Xu Spring 2013

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

Introduction to Computer Systems

Advanced Compiler Construction

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

COMP 401 COURSE OVERVIEW

CSCI 565 Compiler Design and Implementation Spring 2014

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

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

CS 406/534 Compiler Construction Putting It All Together

CS503 Advanced Programming I CS305 Computer Algorithms I

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

General Course Information. Catalogue Description. Objectives

CS 240 Fall 2015 Section 004. Alvin Chao, Professor

Program Analysis And Its Support in Software Development

CS313T ADVANCED PROGRAMMING LANGUAGE

Undergraduate Compilers in a Day

Introduction to Computer Systems

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

CS/SE 153 Concepts of Compiler Design

Chris Riesbeck, Fall Introduction to Computer Systems

Optimized C++ o Websites and handouts Optional: Effective C++, Scott Meyers. Fall 2013

CS354 gdb Tutorial Written by Chris Feilbach

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

EECE.2160: ECE Application Programming Spring 2017

CS 553 Compiler Construction Fall 2007 Project #1 Adding floats to MiniJava Due August 31, 2005

CS240: Programming in C

Languages and Compilers

Lecture 1: Overview

CSE 544 Principles of Database Management Systems

Overview of the Class and Introduction to DB schemas and queries. Lois Delcambre

Overview of the Class

Compilers. Lecture 2 Overview. (original slides by Sam

Levels in memory hierarchy

Overview. CSE 101: Design and Analysis of Algorithms Lecture 1

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

CS/SE 153 Concepts of Compiler Design

CMPE 152 Compiler Design

Syllabus COSC-051-x - Computer Science I Fall Office Hours: Daily hours will be entered on Course calendar (or by appointment)

CMPE 152 Compiler Design

CSE 240 Introduction to Computer Architecture

CPSC 213 Labs Cheat-Manual

Compilers. Computer Science 431

Programming Project 4: COOL Code Generation

CSE 240 Introduction to Computer Architecture

Introduction to Computer Systems

COS 333: Advanced Programming Techniques

Trina Gregory. Background. Contact

CIS192: Python Programming

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

TEACHING & ASSESSMENT (T & A) PLAN College of Economics Management and Information Systems Department of Information Systems

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

CS61BL. Lecture 1: Welcome to CS61BL! Intro to Java and OOP Testing Error-handling

San José State University Computer Science CS 122 Advanced Python Programming Spring 2018

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

Structure of Programming Languages Lecture 10

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

CMPUT 391 Database Management Systems. Fall Semester 2006, Section A1, Dr. Jörg Sander. Introduction

About this exam review

CSE 333 Lecture 1 - Systems programming

CSE 401/M501 Compilers

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

Lecture 1: CSE 373. Data Structures and Algorithms

CSCE 441 Computer Graphics Fall 2018

Welcome to CS61A! Last modified: Thu Jan 23 03:58: CS61A: Lecture #1 1

CS 106B, Lecture 1 Introduction to C++

EECS 395 Programming Languages

Web Client Side Programming

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

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

Lecture 16 Pointer Analysis

CS111: Intro to Computer Science

Shared Variables and Interference

CS 4349 Lecture August 21st, 2017

EECS 321 Programming Languages

CS510 Operating System Foundations. Jonathan Walpole

Asking for information (with three complex questions, so four main paragraphs)

ECE Object-Oriented Programming using C++ and Java

Lecture Compiler Middle-End

CSE443 Compilers. Dr. Carl Alphonce 343 Davis Hall

Introduction to Computer Systems

CS 152 Computer Architecture and Engineering Lecture 1 Single Cycle Design

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 Goal of the project Get some hands on experience with compilers and/or Get a feel for what research is like in PL Three kinds of projects: research-y: explore some interesting ideas and try them out implementation-y: pick some existing idea out there, and implement it paper-y: read 10 good papers on a topic, and write a report summarizing and integrating

Course project Groups of 3 (make groups by this Friday) Pick something to advance your personal enrichment goals Eg: Pick something related to your research, something that you want to learn about Milestones Project proposal (due end of week 2) Mid-point status report (5 weeks in) Final presentation/written report (end of quarter)

Readings Paper readings throughout the quarter 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/sp15/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

Academic Integrity Governed by Policy on Integrity of Scholarship (http://senate.ucsd.edu/operating-procedures/senate- Manual/Appendices/2) Allegations are handled by Academic Integrity Office (https://students.ucsd.edu/academics/academic-integrity) Course penalty for any cheating in 231 will be a failing grade for the entire class Cheaters may be subject to additional administrative sanctions

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?