Advanced Compiler Design

Slides:



Advertisements
Similar presentations
Control-Flow Graphs & Dataflow Analysis CS153: Compilers Greg Morrisett.
Advertisements

Advanced Compiler Design CSE 231 Instructor: Sorin Lerner.
Object Oriented Programming in Java George Mason University Fall 2011
Intro to CIT 594
Recap from last time We saw various different issues related to program analysis and program transformations You were not expected to know all of these.
Recap from last time We saw various different issues related to program analysis and program transformations You were not expected to know all of these.
Cpeg421-08S/final-review1 Course Review Tom St. John.
Administrative info Subscribe to the class mailing list –instructions are on the class web page, click on “Course Syllabus” –if you don’t subscribe by.
Advanced Compilers CSE 231 Instructor: Sorin Lerner.
Administrative info Subscribe to the class mailing list –instructions are on the class web page, which is accessible from my home page, which is accessible.
Advanced Compilers CSE 231 Instructor: Sorin Lerner.
4/25/08Prof. Hilfinger CS164 Lecture 371 Global Optimization Lecture 37 (From notes by R. Bodik & G. Necula)
UMass Lowell Computer Science Advanced Algorithms Computational Geometry Prof. Karen Daniels Spring, 2004 Project.
CS 410 Applied Algorithms Applied Algorithms Lecture #1 Introduction, class information, first problems.
Advanced Compilers CSE 231 Instructor: Sorin Lerner.
Class 0: Review and Perspective. cis 335 Fall 2001 Barry Cohen Class info n Barry Cohen n n Office hours: W 3:15-4:40.
CSC 171 – FALL 2004 COMPUTER PROGRAMMING LECTURE 0 ADMINISTRATION.
Recap from last time We saw various different issues related to program analysis and program transformations You were not expected to know all of these.
7/3/2015Data Structures and Algorithms1 Dick Steflik Fall 2012.
Recap from last time We saw various different issues related to program analysis and program transformations You were not expected to know all of these.
Prof. Bodik CS 164 Lecture 16, Fall Global Optimization Lecture 16.
COP4020/CGS5426 Programming languages Syllabus. Instructor Xin Yuan Office: 168 LOV Office hours: T, H 10:00am – 11:30am Class website:
Computer Science 102 Data Structures and Algorithms V Fall 2009 Lecture 1: administrative details Professor: Evan Korth New York University 1.
Testing. Definition From the dictionary- the means by which the presence, quality, or genuineness of anything is determined; a means of trial. For software.
COMP 111 Programming Languages 1 First Day. Course COMP111 Dr. Abdul-Hameed Assawadi Office: Room AS15 – No. 2 Tel: Ext. ??
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2011 Course Overview John Cavazos University.
1 Object Oriented Design COP 3331 Spring 2011 MWF 11:50 AM – 12:40 PM CHE 103 Instructor:Dr. Rollins Turner Dept. of Computer Science and Engineering ENB.
Welcome to CS 115! Introduction to Programming. Class URL Write this down!
Introduction to Data Structures
CMSC 671 Introduction to Artificial Intelligence Course Overview Fall 2012.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Advanced Compilers CMPSCI 710 Spring 2004 Lecture 1 Emery Berger University of Massachusetts,
Principles of Computer Science I Honors Section Note Set 1 CSE 1341 – H 1.
Course Information Andy Wang CIS 5930 Computer Systems Performance Analysis.
CS Welcome to CS 5383, Topics in Software Assurance, Toward Zero-defect Programming Spring 2007.
1 Data Structures COP 4530 Spring 2010 MW 4:35 PM – 5:50 PM CHE 101 Instructor:Dr. Rollins Turner Dept. of Computer Science and Engineering ENB
Data Structures and Algorithms in Java AlaaEddin 2012.
Principles of Imperative Computation Lecture 1 January 15 th, 2012.
Course topics Representing programs Analyzing and transforming programs Applications of these techniques.
Course Information Andy Wang CIS 5930 Computer Systems Performance Analysis.
A Single Intermediate Language That Supports Multiple Implemtntation of Exceptions Delvin Defoe Washington University in Saint Louis Department of Computer.
CSc 120 Introduction to Computer Programing II
Welcome to CSE 502 Introduction.
Course Overview - Database Systems
CS6501 Advanced Topics in Information Retrieval Course Policy
CS101 Computer Programming I
CSC207 Fall 2016.
ECE 533 Digital Image Processing
CSE 662 – Languages and Databases Class Overview
Compiler Construction (CS-636)
It’s called “wifi”! Source: Somewhere on the Internet!
Advanced Compilers CMPSCI 710 Spring 2003 Lecture 1
Computer Science 102 Data Structures CSCI-UA
September 27 – Course introductions; Adts; Stacks and Queues
Cpt S 471/571: Computational Genomics
Welcome to CS 1010! Algorithmic Problem Solving.
Course Overview - Database Systems
Welcome to CS 1340! Computing for scientists.
Welcome to CS 1010! Algorithmic Problem Solving.
EECE 310 Software Engineering
Introduction to Programming Using C++
Cpt S 471/571: Computational Genomics
Welcome to CSE 502 Introduction.
CMSC201 Computer Science I for Majors Final Exam Information
Advanced Compiler Design
Intro to CIT 594
Optimizing Compilers CISC 673 Spring 2009 Course Overview
Academic Integrity.
IS 135 Business Programming
Advanced Compiler Design
EEL4930/5934 Reconfigurable Computing
Presentation transcript:

Advanced Compiler Design CSE 231 Instructor: Sorin Lerner

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

Let’s look at a compiler Parser Code Gen Compiler Parser Code Gen Compiler Optimizer

Advanced Optimizer Design CSE 231 Instructor: Sorin Lerner

What does an optimizer do? Parser Code Gen Compiler Optimizer Compute information about a program 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%) In-class final (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 Option 1: LLVM 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 Piazza link on web page 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 Output Program Analyzer

Program Analyzer Issues (discuss) Input Output Program Analyzer

Program Analyzer Issues (discuss) Input Output Program Analyzer

Input issues Input is a program, but… Instructor’s discussion notes Input issues Program Analyzer Input 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?

Input issues How much of the program do we see? Any additional inputs? Instructor’s discussion notes Input issues Program Analyzer Input 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?

Analysis issues Analysis/compilation model Instructor’s discussion notes Analysis issues Program Analyzer Input 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

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

Output issues Form of output varies widely, depending on analysis Instructor’s discussion notes Output issues Program Analyzer Input 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 Output Program Transformer

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

Transformation issues Instructor’s discussion notes Transformation issues Program Transformer Input 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?

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