CStar Optimizing a C Compiler

Slides:



Advertisements
Similar presentations
CSC 4181 Compiler Construction Code Generation & Optimization.
Advertisements

Synopsys University Courseware Copyright © 2012 Synopsys, Inc. All rights reserved. Compiler Optimization and Code Generation Lecture - 3 Developed By:
7. Optimization Prof. O. Nierstrasz Lecture notes by Marcus Denker.
Course Outline Traditional Static Program Analysis Software Testing
Chapter 9 Code optimization Section 0 overview 1.Position of code optimizer 2.Purpose of code optimizer to get better efficiency –Run faster –Take less.
CMPUT Compiler Design and Optimization1 CMPUT680 - Winter 2006 Topic 5: Peep Hole Optimization José Nelson Amaral
19 Classic Examples of Local and Global Code Optimizations Local Constant folding Constant combining Strength reduction.
ECE 454 Computer Systems Programming Compiler and Optimization (I) Ding Yuan ECE Dept., University of Toronto
1 Chapter 8: Code Generation. 2 Generating Instructions from Three-address Code Example: D = (A*B)+C =* A B T1 =+ T1 C T2 = T2 D.
Code optimization: –A transformation to a program to make it run faster and/or take up less space –Optimization should be safe, preserve the meaning of.
8. Code Generation. Generate executable code for a target machine that is a faithful representation of the semantics of the source code Depends not only.
Course Outline Traditional Static Program Analysis –Theory Compiler Optimizations; Control Flow Graphs Data-flow Analysis – today’s class –Classic analyses.
Chapter 10 Code Optimization. A main goal is to achieve a better performance Front End Code Gen Intermediate Code source Code target Code user Machine-
C Chuen-Liang Chen, NTUCS&IE / 321 OPTIMIZATION Chuen-Liang Chen Department of Computer Science and Information Engineering National Taiwan University.
1 Code Optimization Code produced by compilation algorithms can often be improved (ideally optimized) in terms of run-time speed and the amount of memory.
The Last Lecture Copyright 2011, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 512 at Rice University have explicit permission.
Optimization Compiler Baojian Hua
1 CS 201 Compiler Construction Lecture 5 Code Optimizations: Copy Propagation & Elimination.
Recap from last time Saw several examples of optimizations –Constant folding –Constant Prop –Copy Prop –Common Sub-expression Elim –Partial Redundancy.
CS 536 Spring Intermediate Code. Local Optimizations. Lecture 22.
9. Optimization Marcus Denker. 2 © Marcus Denker Optimization Roadmap  Introduction  Optimizations in the Back-end  The Optimizer  SSA Optimizations.
X := 11; if (x == 11) { DoSomething(); } else { DoSomethingElse(); x := x + 1; } y := x; // value of y? Phase ordering problem Optimizations can interact.
Introduction to Program Optimizations Chapter 11 Mooly Sagiv.
Validating High-Level Synthesis Sudipta Kundu, Sorin Lerner, Rajesh Gupta Department of Computer Science and Engineering, University of California, San.
Data-Flow Analysis (Chapter 11-12) Mooly Sagiv Make-up class 18/ :00 Kaplun 324.
Intermediate Code. Local Optimizations
Generative Programming. Generic vs Generative Generic Programming focuses on representing families of domain concepts Generic Programming focuses on representing.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Optimizing Compilers Nai-Wei Lin Department of Computer Science and Information Engineering National Chung Cheng University.
Topic #10: Optimization EE 456 – Compiling Techniques Prof. Carl Sable Fall 2003.
Introduction For some compiler, the intermediate code is a pseudo code of a virtual machine. Interpreter of the virtual machine is invoked to execute the.
What’s in an optimizing compiler?
ICD-C Compiler Framework Dr. Heiko Falk  H. Falk, ICD/ES, 2008 ICD-C Compiler Framework 1.Highlights and Features 2.Basic Concepts 3.Extensions.
Compiler course 1. Introduction. Outline Scope of the course Disciplines involved in it Abstract view for a compiler Front-end and back-end tasks Modules.
Generative Programming. Automated Assembly Lines.
Replay Compilation: Improving Debuggability of a Just-in Time Complier Presenter: Jun Tao.
1 Code optimization “Code optimization refers to the techniques used by the compiler to improve the execution efficiency of the generated object code”
Compiler Principles Fall Compiler Principles Lecture 0: Local Optimizations Roman Manevich Ben-Gurion University.
Lexical analyzer Parser Semantic analyzer Intermediate-code generator Optimizer Code Generator Postpass optimizer String of characters String of tokens.
Compiler Construction Dr. Naveed Ejaz Lecture 4. 2 The Back End Register Allocation:  Have each value in a register when it is used. Instruction selection.
CS412/413 Introduction to Compilers Radu Rugina Lecture 18: Control Flow Graphs 29 Feb 02.
PLC '06 Experience in Testing Compiler Optimizers Using Comparison Checking Masataka Sassa and Daijiro Sudo Dept. of Mathematical and Computing Sciences.
Assembler Design Options One-Pass and Multi-Pass Assemblers.
Chapter – 8 Software Tools.
3/2/2016© Hal Perkins & UW CSES-1 CSE P 501 – Compilers Optimizing Transformations Hal Perkins Autumn 2009.
Optimization Simone Campanoni
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Dr. Hussien Sharaf Dr Emad Nabil. Dr. Hussien M. Sharaf 2 position := initial + rate * Lexical analyzer 2. Syntax analyzer id 1 := id 2 + id 3 *
Phoenix Based Dynamic Slicing Debugging Tool Eric Cheng Lin Xu Matt Gruskin Ravi Ramaseshan Microsoft Phoenix Intern Team (Summer '06)
More Code Generation and Optimization Pat Morin COMP 3002.
CHAPTER 1 INTRODUCTION TO COMPILER SUNG-DONG KIM, DEPT. OF COMPUTER ENGINEERING, HANSUNG UNIVERSITY.
Code Optimization Code produced by compilation algorithms can often be improved (ideally optimized) in terms of run-time speed and the amount of memory.
Code Optimization Overview and Examples
Introduction to Optimization
High-level optimization Jakub Yaghob
Code Optimization.
Introduction to Advanced Topics Chapter 1 Text Book: Advanced compiler Design implementation By Steven S Muchnick (Elsevier)
Basic Block Optimizations
Introduction to Optimization
Optimizing Transformations Hal Perkins Autumn 2011
Unit IV Code Generation
Optimizing Transformations Hal Perkins Winter 2008
Code Optimization Overview and Examples Control Flow Graph
Fall Compiler Principles Lecture 10: Loop Optimizations
Introduction to Optimization
Optimization 薛智文 (textbook ch# 9) 薛智文 96 Spring.
Compiler Construction
Live Variables – Basic Block
Basic Block Optimizations
Code Optimization.
Presentation transcript:

CStar Optimizing a C Compiler Group Hellim

GROUP MEMBERS - Halit Emre Sayılır - Anıl Koyuncu - Kutay Yıldırıcı - Tayfun Çakıcıer

OUTLINE Problem Definition Framework Information Modules 1 Optimizations 2 Optimization Manager 3 Test Case Generator Screenshots

PROBLEM DEFINITION Why Performance and Efficiency - Reduce Execution Time - Decrease Space of Code - Reduce Memory Space Must be Reliable

FRAMEWORK INFO Object Oriented Software Library Own intermediate representation Design by Contract Modular

OPTIMIZATIONS Dead Code Elemination if(0) a=1; else will be replaced by a=2; a=2; Evaluation of if statement in run time avoided Space of code reduced

OPTIMIZATIONS(cont.) Constant Folding return 100*40 return 4000

OPTIMIZATIONS(cont.) Local Copy Propagation a=b; c=a+d; c = b + d ; also after dead code elimination

OPTIMIZATIONS (%35) Constant Folding (+) Basic Block Ordering Dead Code Elimination Local/Global Forward Substitution Local/Global Copy Propagation(+) Strength Reduction (+) Local/Global Common SubExpression Elimination (+) If Simplifications Algebraic Simplifications (+)

OPTIMIZATIONS(cont.) Dead Object Elimination Jump Optimizations Tail Merging Tail Recursion Procedure Cloning and Specilization Partial Redundancy Elimination Unreachable Code Elimination (+)

OPTIMIZATION MANAGER (%40) A tool for managing the optimizations which will be used during compilation An assistant for advanced users

OPTIMIZATION MANAGER Two modes: 1- File mode: There is an external file. The optimizations which will be used ,are configured in the file When the file is read , rules will be managed and then chosen optimizations will be executed

Optimization Manager Configuration File

OPTIMIZATION MANAGER 2- Interactive mode: It is a mode which interacts with user. The user will enter input via keyboard. Optimizations will be done in an interactive manner.

TEST CASE GENERATOR (%30) Aim: Automating the process of test case generation * Reduce and prevent human errors * Flexibility for generation of different test cases

TEST CASE GENERATOR How Option File Inspection

OPTION FILE

TEST CASE GENERATOR How Parse Option File Generate Options Option File Inspection IR Dump IR Code Generation Generated Test File

Screenshots Some result screenshots of the optimizations

Constant Folding

Algebraic Simplifications

Local Common Subexpression Elimination

QUESTIONS ? ? ?