Synthesizing Loops For Program Inversion

Size: px
Start display at page:

Download "Synthesizing Loops For Program Inversion"

Transcription

1 For RC 212 Synthesizing Loops For Program Inversion Cong Hou, Daniel Quinlan, David Jefferson, Richard Fujimoto, Richard Vuduc

2 Program Inversion Given a program P, and its inverse P -, then we have P ; P - = no-op Examples: ++a/--a, swap(a,b)/swap(a,b), compression/ decompression, encryption/decryption, etc.. Assume the input and output of P are IN and OUT: P IN P - OUT Reverse program 2

3 Program Inversion What if P is not reversible? IN: a a = ; OUT: a P 3

4 Program Inversion What if P is not reversible? IN: a a = ; OUT: a Make it reversible! P IN: a s = a; a = ; IN: a, s a = s; OUT: a, s OUT: a P + P - 3

5 Program Inversion What if P is not reversible? IN: a a = ; OUT: a Make it reversible! P State Saving IN: a s = a; a = ; IN: a, s a = s; OUT: a, s OUT: a P + P - 3

6 Program Inversion What if P is not reversible? IN: a a = ; OUT: a Make it reversible! P State Saving Forward program IN: a IN: a, s P + s = a; a = ; OUT: a, s a = s; OUT: a P + P - IN P - OUT+S Reverse program 3

7 Our Previous Work We have built a framework that can generate the forward and reverse programs for loop-free programs. We have implemented this framework into a compiler called Backstroke. For more details please refer to our CC paper: C. Hou, G. Vulov, D. Quinlan, D. Jefferson, R. Fujimoto, and R. Vuduc. A new method for program inversion. International Conference on Compiler Construction,

8 Overview Of Our Previous Work Our approach: Original Function SSA form CFG SSA Value Search Route Forward and Reverse Functions 5

9 Overview Of Our Previous Work Original Function SSA form CFG SSA Value Search Route Forward and Reverse Functions We turn the program into the SSA (Static Single Assignment) form CFG (Control Flow ), so that each variable is defined only once and can represent a distinct value. An SSA graph is then built to show the data dependencies between different values. 6

10 Overview Of Our Previous Work Original Function SSA form CFG SSA Value Search Route Forward and Reverse Functions We build a Value Search (VSG) showing all equality relations between values in the program. Finding the inverse becomes a search problem in this graph. Each equality is constrained by a condition represented by a set of CFG paths. 7

11 Overview Of Our Previous Work Original Function SSA form CFG SSA Value Search Route Forward and Reverse Functions We then search for the desired values by following the equalities until available values are reached. The search should guarantee that each value is retrieved for all CFG paths. The search result which we call a Route (RG) shows valid data dependences in reverse program. 8

12 Overview Of Our Previous Work Original Function SSA form CFG SSA Value Search Route Forward and Reverse Functions The forward and reverse programs are built based on the search result. 9

13 Example: Building SSA Form CFG Original Function SSA form CFG SSA Value Search Route Forward and Reverse Functions IN: a, b void foo() { if (a == ) a = 1; else { b = a + 1; a = ; OUT: a, b Entry if (a == ) T F b 1 = a + 1; a 1 = 1; a 2 = ; a 3 = Φ(a 1, a 2 ); b 2 = Φ(b, b 1 ); Exit SSA form CFG 1

14 Example: Building SSA Original Function SSA form CFG SSA Value Search Route Forward and Reverse Functions Entry if (a == ) Φ T a 1 = 1; F b 1 = a + 1; a 2 = ; 1 a 1 a 3 a 2 Φ b 2 a 3 = Φ(a 1, a 2 ); == + b 2 = Φ(b, b 1 ); b 1 b Exit a 1 SSA form CFG SSA 11

15 Example: Building Value Search Original Function SSA form CFG SSA Value Search Route Forward and Reverse Functions Φ a 3 {T,F b {T 1 Φ Φ SS Φ a 1 a 2 b 2 a 3 {F {F b 2 == + b 1 b 1 a 1 a 2 {T,F - b 1 {F + 1 {F a Target nodes {T a 1 SSA Available nodes Value Search 12

16 Example: Building Value Search Original Function SSA form CFG SSA Value Search Route Forward and Reverse Functions Φ a 3 State saving edges {T,F b {T 1 Φ Φ SS Φ a 1 a 2 b 2 a 3 {F {F b 2 == + b 1 b 1 a 1 a 2 {T,F - b 1 {F + 1 {F a Target nodes {T a 1 SSA Available nodes Value Search 12

17 Example: Building Value Search Original Function SSA form CFG SSA Value Search Route Forward and Reverse Functions Φ a 3 State saving edges {T,F b {T 1 Φ Φ SS Φ a 1 a 2 b 2 a 3 {F {F b 2 == + b 1 b 1 a 1 a 2 {T,F - b 1 {F + 1 {F a Target nodes {T a 1 SSA Available nodes Value Search 12

18 Example: Building Route Original Function SSA form CFG SSA Value Search Route Forward and Reverse Functions F {T,F b T {T {F b {T Φ SS Φ SS Φ a 3 {F F {F b 2 {F b 2 1 a 1 a 2 {T,F - b 1 {F + - b 1 F {F {F T {T a 1 {T a 1 Route 13

19 Example: Generating The Forward Program Original Function SSA form CFG SSA Value Search Route Forward and Reverse Functions {T SS a {F {T b {F b 1 - {F Route Φ b 2 1 void foo_forward() { int trace = ; if (a == ) { trace = 1; a = 1; else { store(b); b = a + 1; a = ; store(trace); Red: Path recording. Blue: State saving. 14

20 Example: Generating The Reverse Program Original Function SSA form CFG SSA Value Search Route Forward and Reverse Functions {T SS a {F - {F b b 1 {T {F Φ b 2 1 void foo_reverse() { int trace; restore(trace); if ((trace & 1) == 1) a = ; else { a = b - 1; restore(b); Route 15

21 Example: Generated Forward And Reverse Programs void foo() { if (a == ) a = 1; else { b = a + 1; a = ; void foo_forward() { int trace = ; if (a == ) { trace = 1; a = 1; else { store(b); b = a + 1; a = ; store(trace); Red: Path recording. Blue: State saving. 16 void foo_reverse() { int trace; restore(trace); if ((trace & 1) == 1) a = ; else { a = b - 1; restore(b);

22 Handling Loops What problems do loops bring? Cyclic control flow paths. Solution: In the CFG, we collapse the loop into a single node and remove cycles. Also, we record the control flows in the loop body separately, where the loop body is treated as another loop-free program. 17

23 Handling Loops Recording CFG paths for Programs with Loops Entry Entry Exit Exit 18

24 Handling Loops What problems do loops bring? Cyclic control flow paths. Solution: In the CFG, we collapse the loop into a single node and remove cycles. Also, we record the control flows in the loop body separately, where the loop body is treated as another loop-free program. If we want to build loops in the reverse program, cycles may be formed in the Route. Solution: we build special constructs in VSG for loops and also develop special searching rules. 19

25 Handling While Loops While loop: a special single-entry single-exit loop. A F For each variable modified in a while loop, we define four special definitions of it. v in B T v in : The input of the loop. v out : The output of the loop. v I in = μ(v in, vi out ); while(...) T v I out =...; v I in : The input of the iteration. v I out : The output of the iteration. F v out = η(v I in ); 2

26 Handling While Loops Those four definitions in the VSG: Forward edges represent data flows in the original (forward) programs. Reverse edges represent data flows in the reverse programs. μ v I in η v in μ' v out v I out forward edge reverse edge 21

27 Handling While Loops Those four definitions in the VSG: Forward edges represent data flows in the original (forward) programs. Reverse edges represent data flows in the reverse programs. Initialization on the first iteration μ v I in η v in μ' v out v I out forward edge reverse edge 21

28 Handling While Loops Those four definitions in the VSG: Forward edges represent data flows in the original (forward) programs. Reverse edges represent data flows in the reverse programs. Initialization on the first iteration μ v I in η After each iteration, the output becomes the input v in μ' v I out v out forward edge reverse edge 21

29 Handling While Loops Those four definitions in the VSG: Forward edges represent data flows in the original (forward) programs. Reverse edges represent data flows in the reverse programs. Initialization on the first iteration After each iteration, the output becomes the input v in μ μ' v I out v I in η v out forward edge reverse edge The output value of the loop is the last definition of the mu node. 21

30 Handling While Loops Special search rules on the VSG: Allows cycles to be formed. But each cycle must contain a forward/reverse edge between the input and output of the iteration. μ v I in η v in μ' v out v I out During the search for a given value, the forward and reverse edges cannot coexist in the search result. 22

31 Handling While Loops Building the loop body. Using the same method we build the reverse code for loop-free programs. Building the loop predicate. Approach 1: Building the same loop predicate as in the original loop. Approach 2: If there is a monotonic variable in a loop, build the loop predicate from it. Approach 3: Insert a counter counting the number of iterations of the loop in the forward program, and use this counter to build the loop predicate in the reverse program. 23

32 Handling While Loops Building the loop predicate. Approach 1: Building the same loop predicate as in the original loop. i = ; while (A[i] > ) { /*... */ i = i + 2; Original loop i = ; while (A[i] > ) { /* generated loop body */ i = i + 2; Generated loop 24

33 Handling While Loops Building the loop predicate. Approach 2: If there is a monotonic variable in a loop, build the loop predicate from it. i = ; while (A[i] > ) { /*... */ i = i + 2; /* i == i1 */ Original loop i = ; while (i!= i1) { /* generated loop body */ i = i + 2; Generated loop 25

34 Handling While Loops Building the loop predicate. Approach 3: Insert a counter counting the number of iterations of the loop in the forward program, and use this counter to build the loop predicate in the reverse program. i = ; count = ; while (A[i] > ) { /*... */ i = i + 2; count = count + 1; store(count); Original loop restore(count); while (count > ) { /* generated loop body */ count = count - 1; Generated loop 26

35 An Example Our example: Given an integer n (n > ), get n. // input: n (n > ) s = ; while (n > ) { s = s + n; n = n - 1; // output: s s = ; s 1 = μ(s, s 2 ); n 1 = μ(n, n 2 ); while(n 1 > ) F s 3 = η(s 1 ); n 3 = η(n 1 ); T s 2 = s 1 + n 1 ; n 2 = n 1-1; The loop example CFG in SSA form 27

36 An Example The search result of our example. μ' μ' μ' n 2 n η n 3 n n 2 η n 3 n n 2 η n 3 μ μ μ n 1 n 1 n 1 μ μ μ s 1 s 1 s 1 η η η s s 3 s s 3 s s 3 μ' s 2 μ' s 2 μ' s 2 Available node Target node Forward edge Reverse edge 28

37 An Example The original and generated loop: s = ; while (n > ) { s = s + n; n = n - 1; n = ; while (s!= ) { n = n + 1; s = s - n; The original loop The generated loop 29

38 Handling Other Loops We only consider natural loops (loops with single-entry). A non-while loops may be: A loop with several exits. The entry and exit are at different nodes. 1 F T 2 1 F 2 T 1' 2' ' 4' 5'

39 Current And Future Work We are working on reversing programs with arrays. Specifically, we are interested in automatically reverse some injective programs like compression/decompression programs. We will research on how to rebuild the control flows in the reverse program without path recording. Questions? 31

Studying Optimal Spilling in the light of SSA

Studying Optimal Spilling in the light of SSA Studying Optimal Spilling in the light of SSA Quentin Colombet, Florian Brandner and Alain Darte Compsys, LIP, UMR 5668 CNRS, INRIA, ENS-Lyon, UCB-Lyon Journées compilation, Rennes, France, June 18-20

More information

Data Flow Analysis. Daqing Hou

Data Flow Analysis. Daqing Hou Data Flow Analysis Daqing Hou Outline Basic blocks and control flow graph An example: reaching definitions Characteristics of DFA (Data Flow Analysis) Daqing Hou, Spring 2008 2 Example 100 unsigned int

More information

SSA Construction. Daniel Grund & Sebastian Hack. CC Winter Term 09/10. Saarland University

SSA Construction. Daniel Grund & Sebastian Hack. CC Winter Term 09/10. Saarland University SSA Construction Daniel Grund & Sebastian Hack Saarland University CC Winter Term 09/10 Outline Overview Intermediate Representations Why? How? IR Concepts Static Single Assignment Form Introduction Theory

More information

CS510 Assignment #2 (Due March 7th in class)

CS510 Assignment #2 (Due March 7th in class) CS510 Assignment #2 (Due March 7th in class) March 7, 2017 1 Dynamic Control Dependence (20p) 1. if (p1) 2. return; 3. while (p2) { 4. if (p3) 5. break; 6. if (p4) { 7. s1; 8. } else { 9. s2; 10. continue;

More information

Alias Analysis for Intermediate Code

Alias Analysis for Intermediate Code Alias Analysis for Intermediate Code Sanjiv K. Gupta Naveen Sharma System Software Group HCL Technologies, Noida, India 201 301 {sanjivg,naveens@noida.hcltech.com Abstract Most existing alias analysis

More information

Alias Analysis for Intermediate Code

Alias Analysis for Intermediate Code Alias Analysis for Intermediate Code Sanjiv K. Gupta Naveen Sharma System Software Group HCL Technologies, Noida, India 201 301 {sanjivg,naveens}@noida.hcltech.com Abstract Most existing alias analysis

More information

CS553 Lecture Dynamic Optimizations 2

CS553 Lecture Dynamic Optimizations 2 Dynamic Optimizations Last time Predication and speculation Today Dynamic compilation CS553 Lecture Dynamic Optimizations 2 Motivation Limitations of static analysis Programs can have values and invariants

More information

Theory of control structures

Theory of control structures Theory of control structures Paper written by Bohm and Jacopini in 1966 proposed that all programs can be written using 3 types of control structures. Theory of control structures sequential structures

More information

CFG (Control flow graph)

CFG (Control flow graph) CFG (Control flow graph) Class B T12 오지은 200814189 신승우 201011340 이종선 200811448 Introduction to CFG Algorithm to construct Control Flow Graph Statement of Purpose Q & A Introduction to CFG Algorithm to

More information

Compiler Construction 2009/2010 SSA Static Single Assignment Form

Compiler Construction 2009/2010 SSA Static Single Assignment Form Compiler Construction 2009/2010 SSA Static Single Assignment Form Peter Thiemann March 15, 2010 Outline 1 Static Single-Assignment Form 2 Converting to SSA Form 3 Optimization Algorithms Using SSA 4 Dependencies

More information

Computer Science Department Carlos III University of Madrid Leganés (Spain) David Griol Barres

Computer Science Department Carlos III University of Madrid Leganés (Spain) David Griol Barres Computer Science Department Carlos III University of Madrid Leganés (Spain) David Griol Barres dgriol@inf.uc3m.es Introduction He am a driver might be syntactically correct but semantically wrong. Semantic

More information

Intermediate representation

Intermediate representation Intermediate representation Goals: encode knowledge about the program facilitate analysis facilitate retargeting facilitate optimization scanning parsing HIR semantic analysis HIR intermediate code gen.

More information

What If. Static Single Assignment Form. Phi Functions. What does φ(v i,v j ) Mean?

What If. Static Single Assignment Form. Phi Functions. What does φ(v i,v j ) Mean? Static Single Assignment Form What If Many of the complexities of optimization and code generation arise from the fact that a given variable may be assigned to in many different places. Thus reaching definition

More information

Compiler Design. Fall Data-Flow Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz

Compiler Design. Fall Data-Flow Analysis. Sample Exercises and Solutions. Prof. Pedro C. Diniz Compiler Design Fall 2015 Data-Flow Analysis Sample Exercises and Solutions Prof. Pedro C. Diniz USC / Information Sciences Institute 4676 Admiralty Way, Suite 1001 Marina del Rey, California 90292 pedro@isi.edu

More information

Reuse Optimization. LLVM Compiler Infrastructure. Local Value Numbering. Local Value Numbering (cont)

Reuse Optimization. LLVM Compiler Infrastructure. Local Value Numbering. Local Value Numbering (cont) LLVM Compiler Infrastructure Source: LLVM: A Compilation Framework for Lifelong Program Analysis & Transformation by Lattner and Adve Reuse Optimization Eliminate redundant operations in the dynamic execution

More information

1 Lexical Considerations

1 Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler

More information

CSE P 501 Compilers. SSA Hal Perkins Spring UW CSE P 501 Spring 2018 V-1

CSE P 501 Compilers. SSA Hal Perkins Spring UW CSE P 501 Spring 2018 V-1 CSE P 0 Compilers SSA Hal Perkins Spring 0 UW CSE P 0 Spring 0 V- Agenda Overview of SSA IR Constructing SSA graphs Sample of SSA-based optimizations Converting back from SSA form Sources: Appel ch., also

More information

A Sparse Algorithm for Predicated Global Value Numbering

A Sparse Algorithm for Predicated Global Value Numbering Sparse Predicated Global Value Numbering A Sparse Algorithm for Predicated Global Value Numbering Karthik Gargi Hewlett-Packard India Software Operation PLDI 02 Monday 17 June 2002 1. Introduction 2. Brute

More information

Intermediate Code Generation

Intermediate Code Generation Intermediate Code Generation In the analysis-synthesis model of a compiler, the front end analyzes a source program and creates an intermediate representation, from which the back end generates target

More information

3/18/18. Program Analysis. CYSE 411/AIT 681 Secure Software Engineering. Learning Goal. Program Analysis on Security. Why Program Representations

3/18/18. Program Analysis. CYSE 411/AIT 681 Secure Software Engineering. Learning Goal. Program Analysis on Security. Why Program Representations Program Analysis CYSE 411/AIT 681 Secure Software Engineering Topic #14. Program Analysis Instructor: Dr. Kun Sun The process of automatically analyzing the behavior of computer programs regarding a property

More information

Data Flow Analysis and Computation of SSA

Data Flow Analysis and Computation of SSA Compiler Design 1 Data Flow Analysis and Computation of SSA Compiler Design 2 Definitions A basic block is the longest sequence of three-address codes with the following properties. The control flows to

More information

Example. Example. Constant Propagation in SSA

Example. Example. Constant Propagation in SSA Example x=1 a=x x=2 b=x x=1 x==10 c=x x++ print x Original CFG x 1 =1 a=x 1 x 2 =2 x 3 =φ (x 1,x 2 ) b=x 3 x 4 =1 x 5 = φ(x 4,x 6 ) x 5 ==10 c=x 5 x 6 =x 5 +1 print x 5 CFG in SSA Form In SSA form computing

More information

Lecture Notes on Static Single Assignment Form

Lecture Notes on Static Single Assignment Form Lecture Notes on Static Single Assignment Form 15-411: Compiler Design Frank Pfenning Lecture 6 September 12, 2013 1 Introduction In abstract machine code of the kind we have discussed so far, a variable

More information

Agenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures

Agenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures The main body and cout Agenda 1 Fundamental data types Declarations and definitions Control structures References, pass-by-value vs pass-by-references The main body and cout 2 C++ IS AN OO EXTENSION OF

More information

CS 4120 Lecture 31 Interprocedural analysis, fixed-point algorithms 9 November 2011 Lecturer: Andrew Myers

CS 4120 Lecture 31 Interprocedural analysis, fixed-point algorithms 9 November 2011 Lecturer: Andrew Myers CS 4120 Lecture 31 Interprocedural analysis, fixed-point algorithms 9 November 2011 Lecturer: Andrew Myers These notes are not yet complete. 1 Interprocedural analysis Some analyses are not sufficiently

More information

Problem Score Max Score 1 Syntax directed translation & type

Problem Score Max Score 1 Syntax directed translation & type CMSC430 Spring 2014 Midterm 2 Name Instructions You have 75 minutes for to take this exam. This exam has a total of 100 points. An average of 45 seconds per point. This is a closed book exam. No notes

More information

Single-Path Code Generation and Input-Data Dependence Analysis

Single-Path Code Generation and Input-Data Dependence Analysis Single-Path Code Generation and Input-Data Dependence Analysis Daniel Prokesch daniel@vmars.tuwien.ac.at July 10 th, 2014 Project Workshop Madrid D. Prokesch TUV T-CREST Workshop, Madrid July 10 th, 2014

More information

Expressing Compiler Optimisations Using TRANS. by Robert Quill

Expressing Compiler Optimisations Using TRANS. by Robert Quill Expressing Compiler Optimisations Using TRANS by Robert Quill An Example How can the following loop be optimised?: for(i = 0; i < 10; i++) { a[i] = b[i] + n; if(k > 10) c[2m+n] = a[i] * b[i]; else c[2m+n]

More information

Sorting Algorithms part 1

Sorting Algorithms part 1 Sorting Algorithms part 1 1. Bubble sort Description Bubble sort is a simple sorting algorithm. It works by repeatedly stepping through the array to be sorted, comparing two items at a time, swapping these

More information

Spring Prof. Hyesoon Kim

Spring Prof. Hyesoon Kim Spring 2011 Prof. Hyesoon Kim 2 Warp is the basic unit of execution A group of threads (e.g. 32 threads for the Tesla GPU architecture) Warp Execution Inst 1 Inst 2 Inst 3 Sources ready T T T T One warp

More information

CYSE 411/AIT 681 Secure Software Engineering Topic #14. Program Analysis

CYSE 411/AIT 681 Secure Software Engineering Topic #14. Program Analysis CYSE 411/AIT 681 Secure Software Engineering Topic #14. Program Analysis Instructor: Dr. Kun Sun Program Analysis The process of automatically analyzing the behavior of computer programs regarding a property

More information

CS 510/12. Xiangyu Zhang

CS 510/12. Xiangyu Zhang CS 510/12 Program Representation Xiangyu Zhang Why Program Representations Original representations Source code (cross languages). Binaries (cross machines and platforms). Source code / binaries + test

More information

Instruction Scheduling. Software Pipelining - 3

Instruction Scheduling. Software Pipelining - 3 Instruction Scheduling and Software Pipelining - 3 Department of Computer Science and Automation Indian Institute of Science Bangalore 560 012 NPTEL Course on Principles of Compiler Design Instruction

More information

Conditioned Slicing. David Jong-hoon An. May 23, Abstract

Conditioned Slicing. David Jong-hoon An. May 23, Abstract Conditioned Slicing David Jong-hoon An May 23, 2007 Abstract Program debugging is often a tedious and difficult process that requires programmers to inspect complicated code to understand and analyze the

More information

C Language Part 2 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee

C Language Part 2 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee C Language Part 2 (Minor modifications by the instructor) 1 Scope Rules A variable declared inside a function is a local variable Each local variable in a function comes into existence when the function

More information

Seminar in Software Engineering Presented by Dima Pavlov, November 2010

Seminar in Software Engineering Presented by Dima Pavlov, November 2010 Seminar in Software Engineering-236800 Presented by Dima Pavlov, November 2010 1. Introduction 2. Overview CBMC and SAT 3. CBMC Loop Unwinding 4. Running CBMC 5. Lets Compare 6. How does it work? 7. Conclusions

More information

CSCI Compiler Design

CSCI Compiler Design University of Southern California CSCI565 Compiler Design Midterm Exam - Spring 26 CSCI 565 - Compiler Design Spring 26 Midterm Exam March, 26 at : PM in class (KAP 47) Duration: 2h 3 min. Please label

More information

a data type is Types

a data type is Types Pointers Class 2 a data type is Types Types a data type is a set of values a set of operations defined on those values in C++ (and most languages) there are two flavors of types primitive or fundamental

More information

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #29 Arrays in C

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #29 Arrays in C Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #29 Arrays in C (Refer Slide Time: 00:08) This session will learn about arrays in C. Now, what is the word array

More information

Flow- Context- Sensitive Pointer Analysis

Flow- Context- Sensitive Pointer Analysis Flow- Context- Sensitive Pointer Analysis Yulei Sui Supervisor: Prof. Jingling CORG UNSW December 24, 2010 1 / 38 Pointer Analysis Why Pointer Analysis? Why Pointer Analysis is difficult? Outline Flow-

More information

/ / / Net Speedup. Percentage of Vectorization

/ / / Net Speedup. Percentage of Vectorization Question (Amdahl Law): In this exercise, we are considering enhancing a machine by adding vector hardware to it. When a computation is run in vector mode on the vector hardware, it is 2 times faster than

More information

THE BACKSTROKE FRAMEWORK FOR SOURCE LEVEL REVERSE COMPUTATION APPLIED TO PARALLEL DISCRETE EVENT SIMULATION

THE BACKSTROKE FRAMEWORK FOR SOURCE LEVEL REVERSE COMPUTATION APPLIED TO PARALLEL DISCRETE EVENT SIMULATION Proceedings of the 2011 Winter Simulation Conference S. Jain, R.R. Creasey, J. Himmelspach, K.P. White, and M. Fu, eds. THE BACKSTROKE FRAMEWORK FOR SOURCE LEVEL REVERSE COMPUTATION APPLIED TO PARALLEL

More information

An Architectural Overview of GCC

An Architectural Overview of GCC An Architectural Overview of GCC Diego Novillo dnovillo@redhat.com Red Hat Canada Linux Symposium Ottawa, Canada, July 2006 Topics 1. Overview 2. Development model 3. Compiler infrastructure 4. Intermediate

More information

ECE 552 / CPS 550 Advanced Computer Architecture I. Lecture 15 Very Long Instruction Word Machines

ECE 552 / CPS 550 Advanced Computer Architecture I. Lecture 15 Very Long Instruction Word Machines ECE 552 / CPS 550 Advanced Computer Architecture I Lecture 15 Very Long Instruction Word Machines Benjamin Lee Electrical and Computer Engineering Duke University www.duke.edu/~bcl15 www.duke.edu/~bcl15/class/class_ece252fall11.html

More information

What Compilers Can and Cannot Do. Saman Amarasinghe Fall 2009

What Compilers Can and Cannot Do. Saman Amarasinghe Fall 2009 What Compilers Can and Cannot Do Saman Amarasinghe Fall 009 Optimization Continuum Many examples across the compilation pipeline Static Dynamic Program Compiler Linker Loader Runtime System Optimization

More information

printf("this program adds the value 10 to a given integer number.\n\n");

printf(this program adds the value 10 to a given integer number.\n\n); PA1 Sample Solution Program 1 void add10(int *n); //Prototype int n; printf("this program adds the value 10 to a given integer number.\n\n"); printf("please enter an integer number: "); scanf("%d", &n);

More information

CIS 341 Final Examination 4 May 2017

CIS 341 Final Examination 4 May 2017 CIS 341 Final Examination 4 May 2017 1 /14 2 /15 3 /12 4 /14 5 /34 6 /21 7 /10 Total /120 Do not begin the exam until you are told to do so. You have 120 minutes to complete the exam. There are 14 pages

More information

CSE Lecture In Class Example Handout

CSE Lecture In Class Example Handout CSE 30321 Lecture 07-09 In Class Example Handout Part A: A Simple, MIPS-based Procedure: Swap Procedure Example: Let s write the MIPS code for the following statement (and function call): if (A[i] > A

More information

Compiler Design. Fall Control-Flow Analysis. Prof. Pedro C. Diniz

Compiler Design. Fall Control-Flow Analysis. Prof. Pedro C. Diniz Compiler Design Fall 2015 Control-Flow Analysis Sample Exercises and Solutions Prof. Pedro C. Diniz USC / Information Sciences Institute 4676 Admiralty Way, Suite 1001 Marina del Rey, California 90292

More information

Machine Language Instructions Introduction. Instructions Words of a language understood by machine. Instruction set Vocabulary of the machine

Machine Language Instructions Introduction. Instructions Words of a language understood by machine. Instruction set Vocabulary of the machine Machine Language Instructions Introduction Instructions Words of a language understood by machine Instruction set Vocabulary of the machine Current goal: to relate a high level language to instruction

More information

Lecture 8 Dynamic Branch Prediction, Superscalar and VLIW. Computer Architectures S

Lecture 8 Dynamic Branch Prediction, Superscalar and VLIW. Computer Architectures S Lecture 8 Dynamic Branch Prediction, Superscalar and VLIW Computer Architectures 521480S Dynamic Branch Prediction Performance = ƒ(accuracy, cost of misprediction) Branch History Table (BHT) is simplest

More information

ECE 5775 High-Level Digital Design Automation Fall More CFG Static Single Assignment

ECE 5775 High-Level Digital Design Automation Fall More CFG Static Single Assignment ECE 5775 High-Level Digital Design Automation Fall 2018 More CFG Static Single Assignment Announcements HW 1 due next Monday (9/17) Lab 2 will be released tonight (due 9/24) Instructor OH cancelled this

More information

Loops. CSE 114, Computer Science 1 Stony Brook University

Loops. CSE 114, Computer Science 1 Stony Brook University Loops CSE 114, Computer Science 1 Stony Brook University http://www.cs.stonybrook.edu/~cse114 1 Motivation Suppose that you need to print a string (e.g., "Welcome to Java!") a user-defined times N: N?

More information

6. Intermediate Representation

6. Intermediate Representation 6. Intermediate Representation Oscar Nierstrasz Thanks to Jens Palsberg and Tony Hosking for their kind permission to reuse and adapt the CS132 and CS502 lecture notes. http://www.cs.ucla.edu/~palsberg/

More information

Introduction to Software Testing Chapter 2.3 Graph Coverage for Source Code. Paul Ammann & Jeff Offutt

Introduction to Software Testing Chapter 2.3 Graph Coverage for Source Code. Paul Ammann & Jeff Offutt Introduction to Software Testing Chapter 2.3 Graph Coverage for Source Code Paul Ammann & Jeff Offutt Overview The most common application of graph criteria is to program source Graph : Usually the control

More information

Compiler Construction 2010/2011 Loop Optimizations

Compiler Construction 2010/2011 Loop Optimizations Compiler Construction 2010/2011 Loop Optimizations Peter Thiemann January 25, 2011 Outline 1 Loop Optimizations 2 Dominators 3 Loop-Invariant Computations 4 Induction Variables 5 Array-Bounds Checks 6

More information

Occupancy-based compilation

Occupancy-based compilation Occupancy-based compilation Advanced Course on Compilers Spring 2015 (III-V): Lecture 10 Vesa Hirvisalo ESG/CSE/Aalto Today Threads and occupancy GPUs as the example SIMT execution warp (thread-group)

More information

l Determine if a number is odd or even l Determine if a number/character is in a range - 1 to 10 (inclusive) - between a and z (inclusive)

l Determine if a number is odd or even l Determine if a number/character is in a range - 1 to 10 (inclusive) - between a and z (inclusive) Final Exam Exercises Chapters 1-7 + 11 Write C++ code to: l Determine if a number is odd or even CS 2308 Fall 2016 Jill Seaman l Determine if a number/character is in a range - 1 to 10 (inclusive) - between

More information

CSCI Compiler Design

CSCI Compiler Design University of Southern California CSCI565 Compiler Design Midterm Exam - Fall 26 CSCI 565 - Compiler Design Fall 26 Midterm Exam Solution Problem : Context-Free-Grammars and Parsing Algorithms [4 points]

More information

Appendix 1. Description Logic Terminology

Appendix 1. Description Logic Terminology Appendix 1 Description Logic Terminology Franz Baader Abstract The purpose of this appendix is to introduce (in a compact manner) the syntax and semantics of the most prominent DLs occurring in this handbook.

More information

Lecture 3 Local Optimizations, Intro to SSA

Lecture 3 Local Optimizations, Intro to SSA Lecture 3 Local Optimizations, Intro to SSA I. Basic blocks & Flow graphs II. Abstraction 1: DAG III. Abstraction 2: Value numbering IV. Intro to SSA ALSU 8.4-8.5, 6.2.4 Phillip B. Gibbons 15-745: Local

More information

Appendix 1. Description Logic Terminology

Appendix 1. Description Logic Terminology Appendix 1 Description Logic Terminology Franz Baader Abstract The purpose of this appendix is to introduce (in a compact manner) the syntax and semantics of the most prominent DLs occurring in this handbook.

More information

Class object initialization block destructor Class object

Class object initialization block destructor Class object In this segment, I will review the Java statements and primitives that relate explicitly to Object Oriented Programming. I need to re-enforce Java s commitment to OOP. Unlike C++, there is no way to build

More information

Bounded Model Checking Of C Programs: CBMC Tool Overview

Bounded Model Checking Of C Programs: CBMC Tool Overview Workshop on Formal Verification and Analysis Tools, CFDVS, IIT-Bombay - Feb 21,2017 Bounded Model Checking Of C Programs: CBMC Tool Overview Prateek Saxena CBMC Developed and Maintained by Dr Daniel Kröning

More information

Towards an SSA based compiler back-end: some interesting properties of SSA and its extensions

Towards an SSA based compiler back-end: some interesting properties of SSA and its extensions Towards an SSA based compiler back-end: some interesting properties of SSA and its extensions Benoit Boissinot Équipe Compsys Laboratoire de l Informatique du Parallélisme (LIP) École normale supérieure

More information

Compiler Construction 2016/2017 Loop Optimizations

Compiler Construction 2016/2017 Loop Optimizations Compiler Construction 2016/2017 Loop Optimizations Peter Thiemann January 16, 2017 Outline 1 Loops 2 Dominators 3 Loop-Invariant Computations 4 Induction Variables 5 Array-Bounds Checks 6 Loop Unrolling

More information

CMSC430 Spring 2014 Midterm 2 Solutions

CMSC430 Spring 2014 Midterm 2 Solutions CMSC430 Spring 2014 Midterm 2 Solutions 1. (12 pts) Syntax directed translation & type checking Consider the following grammar fragment for an expression for C--: exp CONST IDENT 1 IDENT 2 [ exp 1 ] Assume

More information

Advanced C Programming

Advanced C Programming Advanced C Programming Compilers Sebastian Hack hack@cs.uni-sb.de Christoph Weidenbach weidenbach@mpi-inf.mpg.de 20.01.2009 saarland university computer science 1 Contents Overview Optimizations Program

More information

Introduction to Software Testing Chapter 3, Sec# 3.3 Logic Coverage for Source Code

Introduction to Software Testing Chapter 3, Sec# 3.3 Logic Coverage for Source Code Introduction to Software Testing Chapter 3, Sec# 3.3 Logic Coverage for Source Code Paul Ammann & Jeff Offutt http://www.cs.gmu.edu/~offutt/soft waretest/ Logic Expressions from Source Predicates are derived

More information

C-Programming. CSC209: Software Tools and Systems Programming. Paul Vrbik. University of Toronto Mississauga

C-Programming. CSC209: Software Tools and Systems Programming. Paul Vrbik. University of Toronto Mississauga C-Programming CSC209: Software Tools and Systems Programming Paul Vrbik University of Toronto Mississauga https://mcs.utm.utoronto.ca/~209/ Adapted from Dan Zingaro s 2015 slides. Week 2.0 1 / 19 What

More information

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade;

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade; Control Statements Control Statements All programs could be written in terms of only one of three control structures: Sequence Structure Selection Structure Repetition Structure Sequence structure The

More information

Using GCC as a Research Compiler

Using GCC as a Research Compiler Using GCC as a Research Compiler Diego Novillo dnovillo@redhat.com Computer Engineering Seminar Series North Carolina State University October 25, 2004 Introduction GCC is a popular compiler, freely available

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

Fundamentals of Programming Session 12

Fundamentals of Programming Session 12 Fundamentals of Programming Session 12 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2014 These slides have been created using Deitel s slides Sharif University of Technology Outlines

More information

6O03 project report. Main points for the solution. Build a combination possibility tableau. Problem: Page 5, the prime number problem

6O03 project report. Main points for the solution. Build a combination possibility tableau. Problem: Page 5, the prime number problem 1 6O03 project report Problem: Page 5, the prime number problem Main points for the solution The problem is asking a minimum value of k with given a number of the possibility of its prime combination multinomial.

More information

Lecture 10 Design by Contract

Lecture 10 Design by Contract CS 5959 Writing Solid Code Fall 2015 Nov-23 Lecture 10 Design by Contract Zvonimir Rakamarić University of Utah Design by Contract Also called assume-guarantee reasoning Developers annotate software components

More information

Homework I - Solution

Homework I - Solution CS 426 Fall 2017 1 Homework I - Solution Homework I - Solution CS 426 Compiler Construction Fall Semester 2017 1. (50 points) Intermediate representations: (a) (25 points) Construct a Control-Flow Graph

More information

QDP++ Primer. Robert Edwards David Richards

QDP++ Primer. Robert Edwards David Richards QDP++ Primer Robert Edwards David Richards Introduction Including QDP++ QDP++ Basics Simple example QDP++ -1- Feb. 2003 Introduction Implementation of Level-2 QCD-API in C++ QDP++ codes will be portable,

More information

CSCE 110 Notes on Recursive Algorithms (Part 12) Prof. Amr Goneid

CSCE 110 Notes on Recursive Algorithms (Part 12) Prof. Amr Goneid CSCE 110 Notes on Recursive Algorithms (Part 12) Prof. Amr Goneid 1. Definition: The expression Recursion is derived from Latin: Re- = back and currere = to run, or to happen again, especially at repeated

More information

Fundamentals of Programming Session 15

Fundamentals of Programming Session 15 Fundamentals of Programming Session 15 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2013 These slides have been created using Deitel s slides Sharif University of Technology Outlines

More information

Combining Analyses, Combining Optimizations - Summary

Combining Analyses, Combining Optimizations - Summary Combining Analyses, Combining Optimizations - Summary 1. INTRODUCTION Cliff Click s thesis Combining Analysis, Combining Optimizations [Click and Cooper 1995] uses a structurally different intermediate

More information

CS313D: ADVANCED PROGRAMMING LANGUAGE

CS313D: ADVANCED PROGRAMMING LANGUAGE CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science Department Lecture 3: C# language basics Lecture Contents 2 C# basics Conditions Loops Methods Arrays Dr. Amal Khalifa, Spr 2015 3 Conditions and

More information

Logic Coverage from Source Code

Logic Coverage from Source Code Logic Coverage from Source Code Moonzoo Kim School of Computing KAIST The original slides are taken from Chap. 8 of Intro. to SW Testing 2 nd ed by Ammann and Offutt Logic Expressions from Source Predicates

More information

CSE443 Compilers. Dr. Carl Alphonce 343 Davis Hall

CSE443 Compilers. Dr. Carl Alphonce 343 Davis Hall CSE443 Compilers Dr. Carl Alphonce alphonce@buffalo.edu 343 Davis Hall http://www.cse.buffalo.edu/faculty/alphonce/sp17/cse443/index.php https://piazza.com/class/iybn4ndqa1s3ei Announcements Be sure to

More information

Syntax Analysis. Amitabha Sanyal. (www.cse.iitb.ac.in/ as) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay

Syntax Analysis. Amitabha Sanyal. (www.cse.iitb.ac.in/ as) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay Syntax Analysis (www.cse.iitb.ac.in/ as) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay September 2007 College of Engineering, Pune Syntax Analysis: 2/124 Syntax

More information

Topic 9: Control Flow

Topic 9: Control Flow Topic 9: Control Flow COS 320 Compiling Techniques Princeton University Spring 2016 Lennart Beringer 1 The Front End The Back End (Intel-HP codename for Itanium ; uses compiler to identify parallelism)

More information

LECTURE 11 TEST DESIGN TECHNIQUES IV

LECTURE 11 TEST DESIGN TECHNIQUES IV Code Coverage Testing 1. Statement coverage testing 2. Branch coverage testing 3. Conditional coverage testing LECTURE 11 TEST DESIGN TECHNIQUES IV Code Complexity Testing 1. Cyclomatic Complexity s V

More information

RANDOM NUMBER GAME PROJECT

RANDOM NUMBER GAME PROJECT Random Number Game RANDOM NUMBER GAME - Now it is time to put all your new knowledge to the test. You are going to build a random number game. - The game needs to generate a random number between 1 and

More information

CSCI Compiler Design

CSCI Compiler Design University of Southern California CSCI565 Compiler Design Mterm Exam Solution - Spring 2014 CSCI 565 - Compiler Design Spring 2014 Mterm Exam - Solution Problem 1: Context-Free-Grammars and Parsing Algorithms

More information

CPSC 213. Introduction to Computer Systems. Static Control Flow. Unit 1d

CPSC 213. Introduction to Computer Systems. Static Control Flow. Unit 1d CPSC 213 Introduction to Computer Systems Unit 1d Static Control Flow 1 Reading Companion 2.7.1-2.7.3, 2.7.5-2.7.6 Textbook 3.6.1-3.6.5 2 Control Flow The flow of control is the sequence of instruction

More information

CS4961 Parallel Programming. Lecture 2: Introduction to Parallel Algorithms 8/31/10. Mary Hall August 26, Homework 1, cont.

CS4961 Parallel Programming. Lecture 2: Introduction to Parallel Algorithms 8/31/10. Mary Hall August 26, Homework 1, cont. Parallel Programming Lecture 2: Introduction to Parallel Algorithms Mary Hall August 26, 2010 1 Homework 1 Due 10:00 PM, Wed., Sept. 1 To submit your homework: - Submit a PDF file - Use the handin program

More information

ANSWERS. Birkbeck (University of London) Software and Programming 1 In-class Test Feb Student Name Student Number. Answer all questions

ANSWERS. Birkbeck (University of London) Software and Programming 1 In-class Test Feb Student Name Student Number. Answer all questions Birkbeck (University of London) Software and Programming 1 In-class Test 1.1 8 Feb 2018 Student Name Student Number Answer all questions 1. Consider the following sequence of Java statements: int i = 3;

More information

CSCE 548 Building Secure Software Software Analysis Basics

CSCE 548 Building Secure Software Software Analysis Basics CSCE 548 Building Secure Software Software Analysis Basics Professor Lisa Luo Spring 2018 Previous Class Ø Android Background Ø Two Android Security Problems: 1. Android App Repackaging o Very easy to

More information

Register Allocation in Just-in-Time Compilers: 15 Years of Linear Scan

Register Allocation in Just-in-Time Compilers: 15 Years of Linear Scan Register Allocation in Just-in-Time Compilers: 15 Years of Linear Scan Kevin Millikin Google 13 December 2013 Register Allocation Overview Register allocation Intermediate representation (IR): arbitrarily

More information

Using Static Single Assignment Form

Using Static Single Assignment Form Using Static Single Assignment Form Announcements Project 2 schedule due today HW1 due Friday Last Time SSA Technicalities Today Constant propagation Loop invariant code motion Induction variables CS553

More information

Chapter 3. Syntax - the form or structure of the expressions, statements, and program units

Chapter 3. Syntax - the form or structure of the expressions, statements, and program units Syntax - the form or structure of the expressions, statements, and program units Semantics - the meaning of the expressions, statements, and program units Who must use language definitions? 1. Other language

More information

Information Science. No. For each question, choose one correct answer and write its symbol (A E) in the box.

Information Science. No. For each question, choose one correct answer and write its symbol (A E) in the box. For each question, choose one correct answer and write its symbol (A E) in the box. (A E) Q16. When compiling the program below, the name of which is prog.c, the following error is reported. Which program

More information

Computer Science 146. Computer Architecture

Computer Science 146. Computer Architecture Computer rchitecture Spring 2004 Harvard University Instructor: Prof. dbrooks@eecs.harvard.edu Lecture 11: Software Pipelining and Global Scheduling Lecture Outline Review of Loop Unrolling Software Pipelining

More information

Exam 1 Format, Concepts, What you should be able to do, and Sample Problems

Exam 1 Format, Concepts, What you should be able to do, and Sample Problems CSSE 120 Introduction to Software Development Exam 1 Format, Concepts, What you should be able to do, and Sample Problems Page 1 of 6 Format: The exam will have two sections: Part 1: Paper-and-Pencil o

More information

ANSWERS. Birkbeck (University of London) Software and Programming 1 In-class Test Feb Student Name Student Number. Answer all questions

ANSWERS. Birkbeck (University of London) Software and Programming 1 In-class Test Feb Student Name Student Number. Answer all questions Birkbeck (University of London) Software and Programming 1 In-class Test 1.2 8 Feb 2018 Student Name Student Number Answer all questions 1. Consider the following sequence of Java statements: int i = 4;

More information