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

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

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

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

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

CSE506: Operating Systems CSE 506: Operating Systems

CSE506: Operating Systems CSE 506: Operating Systems

ECE573 Introduction to Compilers & Translators

Program Analysis And Its Support in Software Development

15-411/ Compiler Design

Programming Languages

CS 241 Data Organization using C

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

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

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

Advanced Compiler Construction

Introduction to Computer Systems

Introduction to Computer Systems

CS 241 Data Organization. August 21, 2018

CS240: Programming in C

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

CSE 544 Principles of Database Management Systems

ECE Introduction to Compilers and Translation Engineering

CS503 Advanced Programming I CS305 Computer Algorithms I

Principles of Program Analysis. Lecture 1 Harry Xu Spring 2013

Introduction to Computer Systems

Introduction to Computer Systems

378: Machine Organization and Assembly Language

CS 406/534 Compiler Construction Putting It All Together

Chris Riesbeck, Fall Introduction to Computer Systems

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

CSE 544 Advanced Systems Security

COMP 401 COURSE OVERVIEW

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

Programming Languages

KOMAR UNIVERSITY OF SCIENCE AND TECHNOLOGY (KUST)

COURSE OUTLINE. School of Engineering Technology and Applied Science

CS/SE 153 Concepts of Compiler Design

Undergraduate Compilers in a Day

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

CS153: Compilers Lecture 1: Introduction

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

COMP 117: Internet-scale Distributed Systems Lessons from the World Wide Web

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

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

Advanced Compiler Construction

Welcome to CS 241 Systems Programming at Illinois

General Course Information. Catalogue Description. Objectives

COS 333: Advanced Programming Techniques. Copyright 2017 by Robert M. Dondero, Ph.D. Princeton University

CSCI 4250/6250 Fall 2013 Computer and Network Security. Instructor: Prof. Roberto Perdisci

In this course, you need to use Pearson etext. Go to "Pearson etext and Video Notes".

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

WELCOME TO CS 16! Enrollment status: 117/ Problem Solving with Computers-I

CS 240 Fall 2015 Section 004. Alvin Chao, Professor

EDIT571-5T1 Fireworks CRN Credits 2 Online August 30 November 6

CS/SE 153 Concepts of Compiler Design

CMPE012 Computer Engineering 12 (and Lab) Computing Systems and Assembly Language Programming. Summer 2009

CMPE 152 Compiler Design

Introduction. CS 2210 Compiler Design Wonsun Ahn

Overview of the Class

Introduction to Computer Systems

CSCI 565 Compiler Design and Implementation Spring 2014

ECONOMICS 5317: CONTEMPORARY GOVERNMENT AND BUSINESS RELATIONS

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

Syllabus: Capstone Web

Languages and Compilers

Introduction to Prof. Clarkson Fall Today s music: Prelude from Final Fantasy VII by Nobuo Uematsu (remastered by Sean Schafianski)

CS 6371: Advanced Programming Languages

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

COS 333: Advanced Programming Techniques

Introduction to Computer Systems

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

Spring 2017 :: CSE 506. Introduction. Nima Honarmand

EECE.2160: ECE Application Programming Spring 2017

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

CS 150 Introduction to Computer Science 1

Welcome! COMS 4118 Opera3ng Systems I Spring 2018

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

CIS192: Python Programming

Course Administration

CMPE 150/L : Introduction to Computer Networks

61A LECTURE 1 FUNCTIONS, VALUES. Steven Tang and Eric Tzeng June 24, 2013

Computer Science Technology Houston Community College

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

CIS 3308 Web Application Programming Syllabus

Computer Science Technology Department

In this course, you need to use Pearson etext. Go to "Pearson etext and Video Notes".

Welcome to CS 241 Systems Programming at Illinois

CS313T ADVANCED PROGRAMMING LANGUAGE

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

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

[301] Introduction. Tyler Caraza-Harter

CIS 101 Orientation Document Fall 2017

ITNW 1425 Fundamentals of Networking Technologies Course Syllabus fall 2012

CSCE 5013: Cloud Computing Spring 2017

CSC116: Introduction to Computing - Java

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

Syllabus of ENPM 691: Secure Programming in C

CPSC 213 Labs Cheat-Manual

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 for research-oriented students useful for implementation-oriented students

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 Familiarity with C/C++ Project will be in C++ Standard ugrad cs curriculum likely enough Talk to me if you re concerned

Course work In-class midterm (30%) Date posted on web site In-class final (30%) Date published by official calendar Course project (35%) Class participation (5%)

Course project Goal of the project Get some hands on experience with compilers Two options, most will do option 1 Option 1: LLVM project Implement some analyses in LLVM, three milestones Hand in your code and it s auto-graded Option 2: Research (by instructor approval) Pick some interesting idea, and try it out Proposals due at the beginning of the second week Can leverage your existing research

LLVM Project M1: Simple instrumentation M2: Analysis framework M3: Implement Analyses in framework You will extend LLVM. This will require C++ If you don t know C++, you will learn If you don t think you can learn C++, think about dropping this class? To be done alone

Research Project Requires instructor approval You need to come up with your own idea by the end of week 1 Most students doing this will be PhD students It s ok to leverage or overlap with existing research I envision at most 10 people doing this

Readings Paper readings throughout the quarter Seminal papers and state of the art Gives you historical perspective Shows you lineage from idea to practice

Administrative info Class web page is up https://ucsd-pl.github.io/cse231/ (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?