INTERPROCEDURAL ANALYSIS

Size: px
Start display at page:

Download "INTERPROCEDURAL ANALYSIS"

Transcription

1 INTERPROCEDURAL ANALYSIS Interprocedural Analysis gathering information about the entire program rather than single Alias Analysis Call Graph Construction Interprocedural Level Optimizations make changes that involve s Constant Propagation Inlining 1

2 MOTIVATION Why consider analysis & optimization of whole programs? 1. To produce better code around call sites Avoid saves & restores Understand cross-call data flow 2. To produce tailored copies of s Often, full generality is unneeded Constant-valued parameters & globals, aliases 3. To provide sharper global analysis Improve on conservative assumptions Particularly true for global variables 4. To present the optimizer with more context Languages (& programs) with short s Assumes that context improves code quality FACT VERSUS FOLKLORE Folklore : Create a single large graph & optimize it all Get all the benefits of analyzing the whole program See all the opportunities This should show the upper bound on improvement Fact: The details get in the way Single methods get overwhelmed with details Imagine a data-flow analysis with all the names Two choices summarization or slow compilation And most of the detail is local Not clear that this approach leads to better code It does lead (inexorably ) to slower compilation 2

3 FACT VERSUS FOLKLORE Folklore : Overhead of calls is significant For small s, linkage can dominate useful work Should eliminate calls whenever possible (avoid the cost ) Lead scientific programmers to nonmodular style Fact : Calls have costs, but they also have benefits Actual costs are a function of size and call frequency Calls provide a much needed separation of concerns Imagine nesting all those register lifetimes Eliminating calls can slow the code down FACT VERSUS FOLKLORE : Modular codes need interprocedural optimization : Folklore Higher ratio of calls to real work Less straight-line code for optimizer Fact Opportunities are limited Smaller s have smaller name spaces Fewer interactions to improve Fewer common overheads, like address expressions Procedure call optimization is more important Calls take a larger fraction of the time Inline calls to eliminate linkages & create context Avoid copying & dereferencing parameters 3

4 WHAT MAKES THIS DIFFICULT? Different calls to p have different properties Frequency of the call Environment that p inherits Mapping from parameters to value (& locations) Constant values & known values Size of task Surrounding execution context Is call in a parallel loop? Which registers are unused? Procedure-valued parameters (OOP) m 1, p n May want to optimize distinct calls differently WHAT MAKES THIS DIFFICULT? joe(i,j,k) l 2 * k if (j = 100) then m 10 * j else m i call ralph(l,m,k) o m * 2 q 2 call ralph(o,q,k) write q, m, o, l What happens at a call? main call joe( 10, 100, 1000) ralph(a,b,c) b a * c / 2000 Use worst case assumptions about side effects Leads to imprecise intraprocedural information Leads to explosion in intraprocedural def-use chains Since j = 100 this always executes the then clause and always m has the value 1000 What value is printed for q? Did ralph() change it? 4

5 EXAMPLE INTERPROCEDURAL PROBLEMS Modification and Side Effects The modification side effect set of a call at s, MOD(s), is the set of all variables that may be modified as a side effect of the call at s. The reference side effect set REF(s) is the set of variables that may be referenced as a side effect of the call at s. Alias Analysis For a p and a formal parameter x passed to p, the alias set ALIAS(s,x) is the set of variables that may refer to the same location as x on entry to s. EXAMPLE INTERPROCEDURAL PROBLEMS Kill Analysis For a given call site s, the kill side effect set KILL(p) is the set of variables that are assigned on every path through p invoked at s and s invoked from within p. Constant Propagation Given a program and a p within that program, the set of interprocedural constants CONST(p) contains the variables that have known constant values on every invocation of p. For a variable v in CONST(p), valin(x,p) is a function returning the value of x on entry to p 5

6 EXAMPLE INTERPROCEDURAL PROBLEMS Live Analysis For a given call site s, which invokes p, the use side effect set USE(s) is the set of variables that have an upwards-exposed use in p A variable is live at a call site s if x in USE(s) or if there is a path through the called at s that does not assign a new value to x and x is live at some control flow successor of s WHAT MAKES THIS DIFFICULT? joe(i,j,k) l 2 * k if (j = 100) then m 10 * j else m i With perfect call ralph(l,m,k) knowledge, the compiler o could m * 2 replace this with write q 1000, , 2000, 2000 call ralph(o,q,k) and the rest is dead! write q, m, o, l What happens at a call? main call joe( 10, 100, 1000) ralph(a,b,c) b a * c / 2000 Use worst case assumptions about side effects Leads to imprecise intraprocedural information Leads to explosion in intraprocedural def-use chains Since j = 100 this always executes the then clause and always m has the value 1000 What value is printed for q? Did ralph() change it? 6

7 INTERPROCEDURAL ANALYSIS: CLASSIFICATION Definitions May problems describe events that might happen in a call MOD() sets include any name the call might define REF() sets include any name the call might use USE() sets Must problems describe events that always happen in a call KILL() INTERPROCEDURAL ANALYSIS: CLASSIFICATION Definitions Computation can consider or ignore control-flow in Flow-insensitive analysis ignores intraprocedural control-flow Flow-sensitive analysis tracks intraprocedural control-flow 7

8 INTERPROCEDURAL ANALYSIS: CLASSIFICATION A R1 R2 A B B MOD(R1) = MOD(A) + MOD(B) KILL(R1) = KILL(A) + KILL(B) USE(R1) = USE(A) + ( KILL(A) USE(B)) MOD(R2) = MOD(A) + MOD(B) KILL(R2) = KILL(A) KILL(B) USE(R2) = USE(A) + USE(B) An interprocedural dataflow problem is flow insensitive iff the value of the solution on both sequentially and alternatively composed regions is determined by taking the union of the solutions for the sub regions. INTERPROCEDURAL ANALYSIS: CLASSIFICATION Definitions Side effect problems ask about what might (or must) happen as a side effect of a call MOD() sets include any name the call might define REF() sets include any name the call might use USE() sets Propagation problems ask about what conditions may or must hold upon entry ALIAS() CONST() 8

9 INTERPROCEDURAL ANALYSIS Classical Problems have appeared in the literature Constructing the call graph May summary problems MOD & REF Alias tracking ALIAS Constant propagation CONST Kill information KILL New-fangled problems appear all the time Alignment propagation for caches Propagating data distributions for FORTRAN D Placing instrumentation & picking checkpoints INTERPROCEDURAL ANALYSIS The modification side effect set of a call at s, MOD(s), is the set of all variables that may be modified as a side effect of the call at s. MOD(s) = DMOD(s) x DMOD(s) Alias(p,x) DMOD(s) - the set of variables visible at s that may be modified by executing p without taking aliasing into account. Alias(p,x) = set of variables that may be aliased to x on entry to p Flow-insensitive approach Assume FORTRAN semantics no pointers, no nesting (local/global only), parameters passed by reference 9

10 INTERPROCEDURAL ANALYSIS DMOD(s) = {v p invoked at s, v s w and w GMOD(p)} v s w actual parameter v is bound to formal parameter w at call site s GMOD(p) set of global variables and formal parameters of p that are modified, either directly or indirectly, as a result of the invocation of p CALL P(A,B,C) SUBROUTINE P(X,Y,Z) INTEGER X,Y,Z X = X * Z Y = Y * Z END DMOD = {A,B} GMOD(P) = {X,Y} INTERPROCEDURAL ANALYSIS GMOD(p) = IMOD(p) s=(p,q) {z z s w and w GMOD(q)} IMOD(p) immediate modification side effect set variables explicitly modified in p 10

11 EXAMPLE S 0 S 1 SUBROUTINE P INTEGER A CALL S(A,A) END SUBROUTINE S(X,Y) INTEGER X,Y CALL Q(X) END SUBROUTINE Q(Z) INTEGER Z Z = 0 END GMOD(P) = IMOD(P) A, since A S 0 X and X GMOD(Q) GMOD(S) = IMOD(S) X, since X S 1 Z and Z GMOD(Q) P {} S {} IMOD(p) Q {Z} EXAMPLE S 0 S 1 SUBROUTINE P INTEGER A CALL S(A,A) END SUBROUTINE S(X,Y) INTEGER X,Y CALL Q(X) END SUBROUTINE Q(Z) INTEGER Z Z = 0 END A X Y Binding Graph captures the parameter relationships 1. Construct a vertex for each formal parameter f of every 2. Construct a directed edge from formal parameter f1 to formal parameter f2 if a call ties the two Z 11

12 SYSTEM DEPENDENCE GRAPHS Data structure representing the relationships between a system of s rather than a monolithic program Built on program dependence graphs (PDG) PDGs connected by additional dependence edge types EXAMPLE PDG main() sum := 0 i := 1 while i < 11 do sum := sum + i i := i + 1 od end(sum,i) T ENTRY T T T T sum := 0 i := 1 while i < 11 final(i) final(sum) T T sum := sum + i i := i + 1 Control Loop carried flow Loop independent flow Output 12

13 SYSTEM DEPENDENCE GRAPHS Should be possible to build dependence graphs with minimal knowledge of other systems components Should be possible to link these together with additional nodes and edges to represent the call sites. Should be useful for precise slicing SYSTEM DEPENDENCE GRAPH Assumptions: main with auxiliary s s end with return statement parameters are value/result no calls of form P(x,x) or P(g) where g is a global (no aliasing). 13

14 EXAMPLE program Main sum := 0; i := 1; while i < 11 do call A(sum,i); return Add(a,b) a := a + b; return A(x,y) call Add(x,y); call Inc(y); return Inc(z) call Add(z,1); return CALL GRAPH Main A Add Inc 14

15 ENTRY main sum := 0 i := 1 while i < 11 final(sum) final(i) program Main sum := 0; i := 1; while i < 11 do call A(sum,i); return ENTRY A call Add call Inc call A A(x,y) call Add(x,y); call Increment(y); return ENTRY Inc ENTRY Add a := a + b Add(a,b) a := a + b; return Call Add Inc(z) call Add(z,1); return PROCEDURE CALLS AND PARAMETER PASSING Call by value/result parameter passing represented using 4 different types of parameter vertices: actual-in, actual-out formal-in and formal-out Actuals control dependent on call. Formals control dependent on entry node Use of temporary variables for passing in and out information. 15

16 ENTRY main sum := 0 i := 1 while i < 11 final(sum) final(i) program Main sum := 0; i := 1; while i < 11 do call A(sum,i); return call A x_in := sum y_in := i sum:= x_out i := y_out Inc(z) call Add(z,1); return z:=z_in ENTRY Inc Call Add z_out:=z a_in := z b_in := 1 z:=a_out x:=x_in y:=y_in call Add ENTRY A call Inc a_in := x b_in := y x:=a_out y:=b_out z_in := y y:= z_out x_out:=x y_out:=y A(x,y) call Add(x,y); call Increment(y); return ENTRY Add a:=a_in b:=b_in a := a + b a.out:=a b_out:=b Add(a,b) a := a + b; return 16

17 PROCEDURE CALLS AND PARAMETER PASSING Caller - The value of the actual parameters get ``copied'' to the temporary sites (actual-in) one per parameter. The return value is copied from a different temporary site (actual-out). Callee - similar operation from formal-in and formal-out. Dependencies between actual-in and formal-in as well as formal-out and actual-out. CALL GRAPH CONSTRUCTION Graphical representation of the calling structure of a program. Important in this kind of analysis. Nodes: s and functions of a program Edges: represent potential calls between the nodes Cycles in the graph represent recursion May be a multi-graph multiple calls between two s result in multiple edges between them. 17

18 BUILDING CALL GRAPHS main() call g() call h() call g() end f g() call h() call i() end g j() end j i() call g() call j() end i h() end h h main i g j CONSTRUCTING THE CALL GRAPH PROCEDURE/FUNCTION PARAMETERS main call confuse(a,c) call confuse(b,d) confuse(x,y) call x(y) main confuse a(z) call z() b(z) call z() a b c() d()... c Imprecise Precise call graph d 18

19 CALL GRAPHS PROCEDURE/FUNCTION PARAMETERS a c(w,x) call b(d,c) end a b(u,v) call v(u,u) end b call w(b,c) end c d(y,z) call y(c,c) end d a c b d CALL GRAPHS PROCEDURE/FUNCTION PARAMETERS a c(w,x) call b(d,c) end a b(u,v) d(y,z) call v(u,u) end b checked: b(d,c) call w(b,c) end c call y(c,c) end d a c b d 19

20 CALL GRAPHS PROCEDURE/FUNCTION PARAMETERS a c(w,x) call b(d,c) end a b(u,v) d(y,z) call v(u,u) c(d,d) end b checked: b(d,c),c(d,d) call w(b,c) end c call y(c,c) end d a c b d CALL GRAPHS PROCEDURE/FUNCTION PARAMETERS a c(w,x) call b(d,c) end a b(u,v) d(y,z) call v(u,u) end b checked: b(d,c),c(d,d),d(b,c) call w(b,c) end c call y(c,c) end d d(b,c) a c b d 20

21 CALL GRAPHS PROCEDURE/FUNCTION PARAMETERS a c(w,x) call b(d,c) call w(b,c) b c end a end c b(u,v) d(y,z) call v(u,u) end b call y(c,c) end d checked: b(d,c),c(d,d),d(b,c),b(c,c) b(c,c) a c b d CALL GRAPHS PROCEDURE/FUNCTION PARAMETERS a c(w,x) call b(d,c) end a b(u,v) d(y,z) call v(u,u) end b c c c(c,c) call w(b,c) end c call y(c,c) end d checked: b(d,c),c(d,d),d(b,c),b(c,c),c(c,c) a c b d 21

22 CALL GRAPHS PROCEDURE/FUNCTION PARAMETERS a c(w,x) call b(d,c) end a call w(b,c) end c b(u,v) d(y,z) call v(u,u) call y(c,c) end b end d c c c(b,c) checked: b(d,c),c(d,d),d(b,c),b(c,c),c(c,c),c(b,c) a c b d CALL GRAPHS PROCEDURE/FUNCTION PARAMETERS a c(w,x) call b(d,c) end a call w(b,c) end c b(u,v) d(y,z) call v(u,u) call y(c,c) end b end d b c b(b,c) checked: b(d,c),c(d,d),d(b,c),b(c,c),c(c,c),c(b,c),b(b,c) a c b d 22

23 CALL GRAPHS PROCEDURE/FUNCTION PARAMETERS a c(w,x) call b(d,c) end a b(u,v) d(y,z) call v(u,u) end b c(b,b) b c call w(b,c) end c call y(c,c) end d checked: b(d,c),c(d,d),d(b,c),b(c,c),c(c,c),c(b,c),b(b,c),c(b,b) a c b d CALL GRAPHS PROCEDURE/FUNCTION PARAMETERS a c(w,x) call b(d,c) end a b(u,v) d(y,z) call v(u,u) end b call w(b,c) end c b b call y(c,c) end d b(b,c) repeat a c b d checked: b(d,c),c(d,d),d(b,c),b(c,c),c(c,c),c(b,c),b(b,c),c(b,b) 23

24 ALIAS ANALYSIS Determination of storage locations that may be accessed in more than one way Pointers Formal/Global Formal/Formal p = &a int p int x q = p p, int q) one(int q) two(int * * body of one * body of two one(p) two(x,x) In all 3 examples, p and q are aliases at the point marked with * ALIASES Influences all of the analysis we have talked about Finding full range of aliases essential to correctness Smallest possible set of aliases essential to aggressive optimization 24

25 INTERPROCEDURAL ANALYSIS VS. INTERPROCEDURAL OPTIMIZATION Interprocedural analysis Gather information across multiple s (typically across the entire program) Can use this information to improve intraprocedural analyses and optimization Interprocedural optimizations Optimizations that involve multiple s e.g., Inlining, cloning, interprocedural register allocation Optimizations that use interprocedural analysis DIMENSIONS OF INTERPROCEDURAL ANALYSIS Flow-sensitive vs. flow-insensitive Context-sensitive vs. context-insensitive Path-sensitive vs. path-insensitive 25

26 FLOW (IN)SENSITIVE ANALYSIS Flow-sensitive analysis Computes one answer for every program point Requires iterative data-flow analysis or similar technique Flow-insensitive analysis Ignores control flow Computes one answer for every Can compute in linear time Less accurate than flow-sensitive FLOW SENSITIVITY EXAMPLE Flow-sensitive analysis Computes an answer at every program point: x is 4 after the first assignment x is 5 after the second assignment Flow-insensitive analysis Computes one answer for the entire : x is not constant int f(int x) { return x*x} 26

27 CONTEXT SENSITIVITY Context-sensitive analysis Re-analyzes callee for each caller Also known as polyvariant analysis Context-insensitive analysis Perform one analysis independent of callers Also known as monovariant analysis Context-sensitive analysis Computes an answer for every callsite: x is 4 in the first call x is 5 in the second call Context-insensitive analysis Computes one answer for all callsites: x is not constant Suffers from unrealizable paths: Can mistakenly conclude that id(4) can return 5 because wemerge information from all callsites 27

28 PATH SENSITIVITY Path-sensitive analysis Computes one answer for every execution path Subsumes flow-sensitivity Extremely expensive Used in software verification via model checking Path-insensitive Assumes current program point can be reached by all possible incoming points PATH SENSITIVITY EXAMPLE Is x constant? Path-sensitive analysis Computes an answer for every path: x is 4 at the end of the left path x is 5 at the end of the right path Path-insensitive analysis Computes one answer for all path: x is not constant 28

29 { } int x, y, a; int *p; p = &a; x = 5; foo(&x); y = x + 1; foo (int *p) { return p; } Is x constant? With a supergraph, run our same IDFA algorithm Determine that x = 5 29

30 BRUTE FORCE: FULL CONTEXT-SENSITIVE INTERPROCEDURAL ANALYSIS Invocation Graph [Emami94] Use an invocation graph, which distinguishes all calling chains Re-analyze callee for all distinct calling paths Pro: precise Cons: exponentially expensive, recursion is tricky void foo(int b) { hoo(b); } void goo(int c) { hoo(c); } main() { int x, y; foo(x); goo(y); } 30

31 void f() { g() g() h() } Void g() { h() i() } Void h() { } Void i(){ g() j() } Void j() { } INTERPROCEDURAL ANALYSIS: SUMMARIES Compute summary information for each Summarize effect of called for callers Summarize effect of callers for called Store summaries in database Use later when optimizing s Pros Concise Can be fast to compute and use Separate compilation practical Cons Imprecise if only have one summary per 31

32 TWO TYPE OF INFORMATION Track information that flows into a Sometimes known as propagation problems e.g., What formals are constant? e.g., Which formals are aliased to globals? Track information that flows out of a Sometimes known as side effect problems e.g., Which globals are def d/used by a? e.g., Which locals are def d/used by a? e.g., Which actual parameters are def d by a? EXAMPLES Propagation Summaries MAY-ALIAS: The set of formals that may be aliased to globals and each other MUST-ALIAS: The set of formals that are definitely aliased to globals and each other CONSTANT: The set of formals that must be constant Side-effect Summaries MOD: The set of variables possibly modified (defined) by a call to a REF: The set of variables possibly read (used) by a call to a DEF: The set of variables that are definitely defined by a (e.g., killed in the liveness sense) 32

33 COMPUTING INTERPROCEDURAL SUMMARIES Top-down Summarize information about the caller (MAY-ALIAS, MUST-ALIAS) Use this information inside the body int a; void foo(int &b, &c){... } foo(a,a); Bottom-up Summarize the effects of a call (MOD, REF, DEF) Use this information around calls x = 7; foo(x); y = x + 3; CONTEXT-SENSITIVITY OF SUMMARIES None ( zero levels of the call path ) Top-down: Meet (or smear) information from all callers to particular callee Bottom-up: Use side-effect information for callee at all callsites Callsite ( one level of the call path ) Top-down: Label data-flow information with callsite Bottom-up: Affects alias analysis, which in turn affects side-effects 33

34 CONTEXT-SENSITIVITY OF SUMMARIES k levels of call path (k-limiting) Forward propagation: Label data-flow information with k levels of the call path Side-effects: label side-effects with k levels of call path INTERPROCEDURAL CONSTANT PROPAGATION (ICP) Information flows from caller to callee and back int a,b,c,d; void foo(e){ a = b + c; d = e + 2; } foo(3); Interprocedural Alias Analysis The calling context tells us that the formal e is bound to the constant 3, which enables constant propagation within foo() After calling foo() we know that the constant 5 (3+2) propagates to the global d Top-down: aliasing due to reference parameters Bottom-up: points-to relationships due to multilevel pointers 34

35 INTERPROCEDURAL CONSTANT PROPAGATION [CALLAHAN, ET AL 86] Basic Idea Extend the global constant propagation by using an extension of the CFG, the interprocedural value graph, which represents the movement of values across calls Can be either context-sensitive or context-insensitive Jump Functions For a call of q at site s, Js x determines the value of the formal parameter x based on the inputs to the p that calls q The support of Js x is the set of inputs to p actually used to compute Js x Interprocedural Value Graph Create one node for each jump function Js x If x support(jt y ) for some call site t in the, then construct an edge from Js x to Jt y (Connect Js x with nodes that use the value of x) JUMP FUNCTION 35

36 MORE ABOUT JUMP FUNCTION How do we handle return values? Create return jump functions that pass values from callees to callers R s x determines the value of x upon return from p Add nodes and edges for R s x to the interprocedural value graph Types of jump functions Jump functions determine the value of a parameter How should they determine these values? Symbolic interpretation Conditional constants Simple constants Simple constants seem to do well 36

37 ALTERNATIVE TO INTERPROCEDURAL ANALYSIS: INLINING Idea Replace call with body Pros Reduces call overhead Exposes calling context to body Exposes side effects of to caller Simple Cons Code bloat (decrease efficacy of caches, branch predictor, etc) Can t always statically determine callee (e.g., in OO languages) Library source is usually unavailable Can t always inline (recursion) INLINING POLICIES The hard question How do we decide which calls to inline? Many possible heuristics Only inline small functions Let the programmer decide using an inline directive Use a code expansion budget [Ayers, et al 97] Use profiling or instrumentation to identify hot paths inline along the hot paths [Chang, et al 92] JIT compilers do this Use inlining trials for object oriented languages [Dean & Chambers 94] Keep a database of functions, their parameter types, and the benefit of inlining Keeps track of indirect benefit of inlining Effective in an incrementally compiled language 37

38 ALTERNATIVE TO INTERPROCEDURAL ANALYSIS: CLONING Procedure Cloning/Specialization Create a customized version of for particular call sites Compromise between inlining and interprocedural optimization Pros Less code bloat than inlining Recursion is not an issue (as compared to inlining) Better caller/callee optimization potential (versus interprocedural analysis) Cons Still some code bloat (versus interprocedural analysis) May have to do interprocedural analysis anyway e.g. Interprocedural constant propagation can guide cloning EVALUATION Many compilers avoid interprocedural analysis It s expensive and complex Not beneficial for most classical optimizations Separate compilation + interprocedural analysis requires recompilation analysis [Burke and Torczon 93] Can t analyze library code When is it useful? Pointer analysis Constant propagation Object oriented class analysis Security and error checking Program understanding and re-factoring Code compaction Parallelization 38

39 OTHER TRENDS Cost of s is growing More of them and they re smaller (OO languages) Modern machines demand precise information (memory op aliasing) Cost of inlining is growing Code bloat degrades efficacy of many modern structures Procedures are being used more extensively Programs are becoming larger Cost of interprocedural analysis is shrinking Faster machines Better methods 39

Calvin Lin The University of Texas at Austin

Calvin Lin The University of Texas at Austin Interprocedural Analysis Last time Introduction to alias analysis Today Interprocedural analysis March 4, 2015 Interprocedural Analysis 1 Motivation Procedural abstraction Cornerstone of programming Introduces

More information

Interprocedural Analysis. Motivation. Interprocedural Analysis. Function Calls and Pointers

Interprocedural Analysis. Motivation. Interprocedural Analysis. Function Calls and Pointers Interprocedural Analysis Motivation Last time Introduction to alias analysis Today Interprocedural analysis Procedural abstraction Cornerstone of programming Introduces barriers to analysis Example x =

More information

COMP 515: Advanced Compilation for Vector and Parallel Processors. Vivek Sarkar Department of Computer Science Rice University

COMP 515: Advanced Compilation for Vector and Parallel Processors. Vivek Sarkar Department of Computer Science Rice University COMP 515: Advanced Compilation for Vector and Parallel Processors Vivek Sarkar Department of Computer Science Rice University vsarkar@rice.edu COMP 515, Lecture 22 14 April 2009 Announcements Schedule

More information

Advanced Compiler Construction

Advanced Compiler Construction CS 526 Advanced Compiler Construction http://misailo.cs.illinois.edu/courses/cs526 INTERPROCEDURAL ANALYSIS The slides adapted from Vikram Adve So Far Control Flow Analysis Data Flow Analysis Dependence

More information

Interprocedural Analysis. Dealing with Procedures. Course so far: Terminology

Interprocedural Analysis. Dealing with Procedures. Course so far: Terminology Interprocedural Analysis Course so far: Control Flow Representation Dataflow Representation SSA form Classic DefUse and UseDef Chains Optimizations Scheduling Register Allocation Just-In-Time Compilation

More information

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

CSE 501 Midterm Exam: Sketch of Some Plausible Solutions Winter 1997 1) [10 pts] On homework 1, I asked about dead assignment elimination and gave the following sample solution: 8. Give an algorithm for dead assignment elimination that exploits def/use chains to work faster

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 4 Thomas Wies New York University Review Last week Control Structures Selection Loops Adding Invariants Outline Subprograms Calling Sequences Parameter

More information

CS558 Programming Languages Winter 2018 Lecture 4a. Andrew Tolmach Portland State University

CS558 Programming Languages Winter 2018 Lecture 4a. Andrew Tolmach Portland State University CS558 Programming Languages Winter 2018 Lecture 4a Andrew Tolmach Portland State University 1994-2018 Pragmatics of Large Values Real machines are very efficient at handling word-size chunks of data (e.g.

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Fall 2016 Lecture 4a Andrew Tolmach Portland State University 1994-2016 Pragmatics of Large Values Real machines are very efficient at handling word-size chunks of data (e.g.

More information

G Programming Languages Spring 2010 Lecture 4. Robert Grimm, New York University

G Programming Languages Spring 2010 Lecture 4. Robert Grimm, New York University G22.2110-001 Programming Languages Spring 2010 Lecture 4 Robert Grimm, New York University 1 Review Last week Control Structures Selection Loops 2 Outline Subprograms Calling Sequences Parameter Passing

More information

Interprocedural Analysis with Data-Dependent Calls. Circularity dilemma. A solution: optimistic iterative analysis. Example

Interprocedural Analysis with Data-Dependent Calls. Circularity dilemma. A solution: optimistic iterative analysis. Example Interprocedural Analysis with Data-Dependent Calls Circularity dilemma In languages with function pointers, first-class functions, or dynamically dispatched messages, callee(s) at call site depend on data

More information

The Procedure Abstraction Part I Basics

The Procedure Abstraction Part I Basics The Procedure Abstraction Part I Basics Procedure Abstraction The compiler must deal with interface between compile time and run time Most of the tricky issues arise in implementing procedures Procedures

More information

Interprocedural Analysis with Data-Dependent Calls. Circularity dilemma. A solution: optimistic iterative analysis. Example

Interprocedural Analysis with Data-Dependent Calls. Circularity dilemma. A solution: optimistic iterative analysis. Example Interprocedural Analysis with Data-Dependent Calls Circularity dilemma In languages with function pointers, first-class functions, or dynamically dispatched messages, callee(s) at call site depend on data

More information

More Dataflow Analysis

More Dataflow Analysis More Dataflow Analysis Steps to building analysis Step 1: Choose lattice Step 2: Choose direction of dataflow (forward or backward) Step 3: Create transfer function Step 4: Choose confluence operator (i.e.,

More information

Outline. Register Allocation. Issues. Storing values between defs and uses. Issues. Issues P3 / 2006

Outline. Register Allocation. Issues. Storing values between defs and uses. Issues. Issues P3 / 2006 P3 / 2006 Register Allocation What is register allocation Spilling More Variations and Optimizations Kostis Sagonas 2 Spring 2006 Storing values between defs and uses Program computes with values value

More information

CS415 Compilers. Procedure Abstractions. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

CS415 Compilers. Procedure Abstractions. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University CS415 Compilers Procedure Abstractions These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University Where are we? Well understood Engineering Source Code

More information

The Procedure Abstraction

The Procedure Abstraction The Procedure Abstraction Procedure Abstraction Begins Chapter 6 in EAC The compiler must deal with interface between compile time and run time Most of the tricky issues arise in implementing procedures

More information

register allocation saves energy register allocation reduces memory accesses.

register allocation saves energy register allocation reduces memory accesses. Lesson 10 Register Allocation Full Compiler Structure Embedded systems need highly optimized code. This part of the course will focus on Back end code generation. Back end: generation of assembly instructions

More information

Flow-sensitive rewritings and Inliner improvements for the Graal JIT compiler

Flow-sensitive rewritings and Inliner improvements for the Graal JIT compiler 1 / 25 Flow-sensitive rewritings and for the Graal JIT compiler Miguel Garcia http://lampwww.epfl.ch/~magarcia/ 2014-07-07 2 / 25 Outline Flow-sensitive rewritings during HighTier Example Rewritings in

More information

Weeks 6&7: Procedures and Parameter Passing

Weeks 6&7: Procedures and Parameter Passing CS320 Principles of Programming Languages Weeks 6&7: Procedures and Parameter Passing Jingke Li Portland State University Fall 2017 PSU CS320 Fall 17 Weeks 6&7: Procedures and Parameter Passing 1 / 45

More information

12/4/18. Outline. Implementing Subprograms. Semantics of a subroutine call. Storage of Information. Semantics of a subroutine return

12/4/18. Outline. Implementing Subprograms. Semantics of a subroutine call. Storage of Information. Semantics of a subroutine return Outline Implementing Subprograms In Text: Chapter 10 General semantics of calls and returns Implementing simple subroutines Call Stack Implementing subroutines with stackdynamic local variables Nested

More information

Run Time Environment. Activation Records Procedure Linkage Name Translation and Variable Access

Run Time Environment. Activation Records Procedure Linkage Name Translation and Variable Access Run Time Environment Activation Records Procedure Linkage Name Translation and Variable Access Copyright 2015, Pedro C. Diniz, all rights reserved. Students enrolled in the Compilers class at the University

More information

Separate compilation. Topic 6: Runtime Environments p.1/21. CS 526 Topic 6: Runtime Environments The linkage convention

Separate compilation. Topic 6: Runtime Environments p.1/21. CS 526 Topic 6: Runtime Environments The linkage convention Runtime Environment The Procedure Abstraction and Separate Compilation Topics we will cover The procedure abstraction and linkage conventions Runtime storage convention Non-local data access (brief) These

More information

Register Allocation. CS 502 Lecture 14 11/25/08

Register Allocation. CS 502 Lecture 14 11/25/08 Register Allocation CS 502 Lecture 14 11/25/08 Where we are... Reasonably low-level intermediate representation: sequence of simple instructions followed by a transfer of control. a representation of static

More information

Chapter 9 Subprograms

Chapter 9 Subprograms Chapter 9 Subprograms We now explore the design of subprograms, including parameter-passing methods, local referencing environment, overloaded subprograms, generic subprograms, and the aliasing and problematic

More information

CSE 504. Expression evaluation. Expression Evaluation, Runtime Environments. One possible semantics: Problem:

CSE 504. Expression evaluation. Expression Evaluation, Runtime Environments. One possible semantics: Problem: Expression evaluation CSE 504 Order of evaluation For the abstract syntax tree + + 5 Expression Evaluation, Runtime Environments + + x 3 2 4 the equivalent expression is (x + 3) + (2 + 4) + 5 1 2 (. Contd

More information

ELEC 876: Software Reengineering

ELEC 876: Software Reengineering ELEC 876: Software Reengineering () Dr. Ying Zou Department of Electrical & Computer Engineering Queen s University Compiler and Interpreter Compiler Source Code Object Compile Execute Code Results data

More information

Programming Languages Third Edition. Chapter 10 Control II Procedures and Environments

Programming Languages Third Edition. Chapter 10 Control II Procedures and Environments Programming Languages Third Edition Chapter 10 Control II Procedures and Environments Objectives Understand the nature of procedure definition and activation Understand procedure semantics Learn parameter-passing

More information

Procedure and Function Calls, Part II. Comp 412 COMP 412 FALL Chapter 6 in EaC2e. target code. source code Front End Optimizer Back End

Procedure and Function Calls, Part II. Comp 412 COMP 412 FALL Chapter 6 in EaC2e. target code. source code Front End Optimizer Back End COMP 412 FALL 2017 Procedure and Function Calls, Part II Comp 412 source code IR Front End Optimizer Back End IR target code Copyright 2017, Keith D. Cooper & Linda Torczon, all rights reserved. Students

More information

Lecture 9: Parameter Passing, Generics and Polymorphism, Exceptions

Lecture 9: Parameter Passing, Generics and Polymorphism, Exceptions Lecture 9: Parameter Passing, Generics and Polymorphism, Exceptions COMP 524 Programming Language Concepts Stephen Olivier February 12, 2008 Based on notes by A. Block, N. Fisher, F. Hernandez-Campos,

More information

Implementing Subroutines. Outline [1]

Implementing Subroutines. Outline [1] Implementing Subroutines In Text: Chapter 9 Outline [1] General semantics of calls and returns Implementing simple subroutines Call Stack Implementing subroutines with stackdynamic local variables Nested

More information

Lecture 14 Pointer Analysis

Lecture 14 Pointer Analysis Lecture 14 Pointer Analysis Basics Design Options Pointer Analysis Algorithms Pointer Analysis Using BDDs Probabilistic Pointer Analysis [ALSU 12.4, 12.6-12.7] Phillip B. Gibbons 15-745: Pointer Analysis

More information

Alias Analysis. Advanced Topics. What is pointer analysis? Last Time

Alias Analysis. Advanced Topics. What is pointer analysis? Last Time Advanced Topics Last Time Experimental Methodology Today What s a managed language? Alias Analysis - dealing with pointers Focus on statically typed managed languages Method invocation resolution Alias

More information

CSE 504: Compiler Design. Runtime Environments

CSE 504: Compiler Design. Runtime Environments Runtime Environments Pradipta De pradipta.de@sunykorea.ac.kr Current Topic Procedure Abstractions Mechanisms to manage procedures and procedure calls from compiler s perspective Runtime Environment Choices

More information

Compiler Passes. Optimization. The Role of the Optimizer. Optimizations. The Optimizer (or Middle End) Traditional Three-pass Compiler

Compiler Passes. Optimization. The Role of the Optimizer. Optimizations. The Optimizer (or Middle End) Traditional Three-pass Compiler Compiler Passes Analysis of input program (front-end) character stream Lexical Analysis Synthesis of output program (back-end) Intermediate Code Generation Optimization Before and after generating machine

More information

Lecture 27. Pros and Cons of Pointers. Basics Design Options Pointer Analysis Algorithms Pointer Analysis Using BDDs Probabilistic Pointer Analysis

Lecture 27. Pros and Cons of Pointers. Basics Design Options Pointer Analysis Algorithms Pointer Analysis Using BDDs Probabilistic Pointer Analysis Pros and Cons of Pointers Lecture 27 Pointer Analysis Basics Design Options Pointer Analysis Algorithms Pointer Analysis Using BDDs Probabilistic Pointer Analysis Many procedural languages have pointers

More information

Lecture 20 Pointer Analysis

Lecture 20 Pointer Analysis Lecture 20 Pointer Analysis Basics Design Options Pointer Analysis Algorithms Pointer Analysis Using BDDs Probabilistic Pointer Analysis (Slide content courtesy of Greg Steffan, U. of Toronto) 15-745:

More information

Run-time Environments

Run-time Environments Run-time Environments Status We have so far covered the front-end phases Lexical analysis Parsing Semantic analysis Next come the back-end phases Code generation Optimization Register allocation Instruction

More information

Run-time Environments

Run-time Environments Run-time Environments Status We have so far covered the front-end phases Lexical analysis Parsing Semantic analysis Next come the back-end phases Code generation Optimization Register allocation Instruction

More information

Lecture 16 Pointer Analysis

Lecture 16 Pointer Analysis Pros and Cons of Pointers Lecture 16 Pointer Analysis Basics Design Options Pointer Analysis Algorithms Pointer Analysis Using BDDs Probabilistic Pointer Analysis Many procedural languages have pointers

More information

Run-time Environments - 2

Run-time Environments - 2 Run-time Environments - 2 Y.N. Srikant Computer Science and Automation Indian Institute of Science Bangalore 560 012 NPTEL Course on Principles of Compiler Design Outline of the Lecture n What is run-time

More information

Compiler Optimizations. Chapter 8, Section 8.5 Chapter 9, Section 9.1.7

Compiler Optimizations. Chapter 8, Section 8.5 Chapter 9, Section 9.1.7 Compiler Optimizations Chapter 8, Section 8.5 Chapter 9, Section 9.1.7 2 Local vs. Global Optimizations Local: inside a single basic block Simple forms of common subexpression elimination, dead code elimination,

More information

Context-Sensitive Pointer Analysis. Recall Context Sensitivity. Partial Transfer Functions [Wilson et. al. 95] Emami 1994

Context-Sensitive Pointer Analysis. Recall Context Sensitivity. Partial Transfer Functions [Wilson et. al. 95] Emami 1994 Context-Sensitive Pointer Analysis Last time Flow-insensitive pointer analysis Today Context-sensitive pointer analysis Emami invocation graphs Partial Transfer Functions The big picture Recall Context

More information

Data-flow Analysis. Y.N. Srikant. Department of Computer Science and Automation Indian Institute of Science Bangalore

Data-flow Analysis. Y.N. Srikant. Department of Computer Science and Automation Indian Institute of Science Bangalore Department of Computer Science and Automation Indian Institute of Science Bangalore 560 012 NPTEL Course on Compiler Design Data-flow analysis These are techniques that derive information about the flow

More information

Compiler Optimizations. Chapter 8, Section 8.5 Chapter 9, Section 9.1.7

Compiler Optimizations. Chapter 8, Section 8.5 Chapter 9, Section 9.1.7 Compiler Optimizations Chapter 8, Section 8.5 Chapter 9, Section 9.1.7 2 Local vs. Global Optimizations Local: inside a single basic block Simple forms of common subexpression elimination, dead code elimination,

More information

Run-time Environments. Lecture 13. Prof. Alex Aiken Original Slides (Modified by Prof. Vijay Ganesh) Lecture 13

Run-time Environments. Lecture 13. Prof. Alex Aiken Original Slides (Modified by Prof. Vijay Ganesh) Lecture 13 Run-time Environments Lecture 13 by Prof. Vijay Ganesh) Lecture 13 1 What have we covered so far? We have covered the front-end phases Lexical analysis (Lexer, regular expressions,...) Parsing (CFG, Top-down,

More information

Statement Basics. Assignment Statements

Statement Basics. Assignment Statements Statement Basics The meaning of a single statement executed in a state s is a new state s, which reflects the effects of the statement M stmt ( stmt, s) = s N. Meng, S. Arthur 1 Assignment Statements M

More information

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

CSE 501: Compiler Construction. Course outline. Goals for language implementation. Why study compilers? Models of compilation CSE 501: Compiler Construction Course outline Main focus: program analysis and transformation how to represent programs? how to analyze programs? what to analyze? how to transform programs? what transformations

More information

do such opportunities arise? (i) calling library code (ii) Where programs. object-oriented Propagating information across procedure boundaries is usef

do such opportunities arise? (i) calling library code (ii) Where programs. object-oriented Propagating information across procedure boundaries is usef Interprocedural Dataow Analysis 1 do such opportunities arise? (i) calling library code (ii) Where programs. object-oriented Propagating information across procedure boundaries is useful. Optimize caller

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

Run Time Environment. Procedure Abstraction. The Procedure as a Control Abstraction. The Procedure as a Control Abstraction

Run Time Environment. Procedure Abstraction. The Procedure as a Control Abstraction. The Procedure as a Control Abstraction Procedure Abstraction Run Time Environment Records Procedure Linkage Name Translation and Variable Access Copyright 2010, Pedro C. Diniz, all rights reserved. Students enrolled in the Compilers class at

More information

Siloed Reference Analysis

Siloed Reference Analysis Siloed Reference Analysis Xing Zhou 1. Objectives: Traditional compiler optimizations must be conservative for multithreaded programs in order to ensure correctness, since the global variables or memory

More information

CS 406/534 Compiler Construction Putting It All Together

CS 406/534 Compiler Construction Putting It All Together CS 406/534 Compiler Construction Putting It All Together Prof. Li Xu Dept. of Computer Science UMass Lowell Fall 2004 Part of the course lecture notes are based on Prof. Keith Cooper, Prof. Ken Kennedy

More information

Interprocedural Slicing Using Dependence Graphs

Interprocedural Slicing Using Dependence Graphs - 1 - Interprocedural Slicing Using Dependence Graphs SUSAN HORWITZ, THOMAS REPS, and DAVID BINKLEY University of Wisconsin-Madison The notion of a program slice, originally introduced by Mark Weiser,

More information

Announcements. My office hours are today in Gates 160 from 1PM-3PM. Programming Project 3 checkpoint due tomorrow night at 11:59PM.

Announcements. My office hours are today in Gates 160 from 1PM-3PM. Programming Project 3 checkpoint due tomorrow night at 11:59PM. IR Generation Announcements My office hours are today in Gates 160 from 1PM-3PM. Programming Project 3 checkpoint due tomorrow night at 11:59PM. This is a hard deadline and no late submissions will be

More information

Compiler Optimization and Code Generation

Compiler Optimization and Code Generation Compiler Optimization and Code Generation Professor: Sc.D., Professor Vazgen Melikyan 1 Course Overview Introduction: Overview of Optimizations 1 lecture Intermediate-Code Generation 2 lectures Machine-Independent

More information

COP4020 Programming Languages. Subroutines and Parameter Passing Prof. Robert van Engelen

COP4020 Programming Languages. Subroutines and Parameter Passing Prof. Robert van Engelen COP4020 Programming Languages Subroutines and Parameter Passing Prof. Robert van Engelen Overview Parameter passing modes Subroutine closures as parameters Special-purpose parameters Function returns COP4020

More information

Static Program Analysis Part 7 interprocedural analysis

Static Program Analysis Part 7 interprocedural analysis Static Program Analysis Part 7 interprocedural analysis http://cs.au.dk/~amoeller/spa/ Anders Møller & Michael I. Schwartzbach Computer Science, Aarhus University Interprocedural analysis Analyzing the

More information

9/5/17. The Design and Implementation of Programming Languages. Compilation. Interpretation. Compilation vs. Interpretation. Hybrid Implementation

9/5/17. The Design and Implementation of Programming Languages. Compilation. Interpretation. Compilation vs. Interpretation. Hybrid Implementation Language Implementation Methods The Design and Implementation of Programming Languages Compilation Interpretation Hybrid In Text: Chapter 1 2 Compilation Interpretation Translate high-level programs to

More information

Procedure and Object- Oriented Abstraction

Procedure and Object- Oriented Abstraction Procedure and Object- Oriented Abstraction Scope and storage management cs5363 1 Procedure abstractions Procedures are fundamental programming abstractions They are used to support dynamically nested blocks

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

Intermediate Representation (IR)

Intermediate Representation (IR) Intermediate Representation (IR) Components and Design Goals for an IR IR encodes all knowledge the compiler has derived about source program. Simple compiler structure source code More typical compiler

More information

Data-flow Analysis - Part 2

Data-flow Analysis - Part 2 - Part 2 Department of Computer Science Indian Institute of Science Bangalore 560 012 NPTEL Course on Compiler Design Data-flow analysis These are techniques that derive information about the flow of data

More information

Introduction to Optimization Local Value Numbering

Introduction to Optimization Local Value Numbering COMP 506 Rice University Spring 2018 Introduction to Optimization Local Value Numbering source IR IR target code Front End Optimizer Back End code Copyright 2018, Keith D. Cooper & Linda Torczon, all rights

More information

Obfuscating Transformations. What is Obfuscator? Obfuscation Library. Obfuscation vs. Deobfuscation. Summary

Obfuscating Transformations. What is Obfuscator? Obfuscation Library. Obfuscation vs. Deobfuscation. Summary ? Obfuscating Outline? 1? 2 of Obfuscating 3 Motivation: Java Virtual Machine? difference between Java and others? Most programming languages: Java: Source Code Machine Code Predefined Architecture Java

More information

CS 314 Principles of Programming Languages. Lecture 13

CS 314 Principles of Programming Languages. Lecture 13 CS 314 Principles of Programming Languages Lecture 13 Zheng Zhang Department of Computer Science Rutgers University Wednesday 19 th October, 2016 Zheng Zhang 1 CS@Rutgers University Class Information Reminder:

More information

Static Program Analysis Part 9 pointer analysis. Anders Møller & Michael I. Schwartzbach Computer Science, Aarhus University

Static Program Analysis Part 9 pointer analysis. Anders Møller & Michael I. Schwartzbach Computer Science, Aarhus University Static Program Analysis Part 9 pointer analysis Anders Møller & Michael I. Schwartzbach Computer Science, Aarhus University Agenda Introduction to points-to analysis Andersen s analysis Steensgaards s

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

Interprocedural Dataflow Analysis. Galeotti/Gorla/Rau Saarland University

Interprocedural Dataflow Analysis. Galeotti/Gorla/Rau Saarland University Interprocedural Dataflow Analysis Galeotti/Gorla/Rau Saarland University int divbyx(int x) { [result := 10/x] 1 ; void caller1() { [x := 5] 1 ; [y := divbyx(x)] 2 ; [y := divbyx(5)] 3 ; [y := divbyx(1)]

More information

OOPLs - call graph construction. Example executed calls

OOPLs - call graph construction. Example executed calls OOPLs - call graph construction Compile-time analysis of reference variables and fields Problem: how to resolve virtual function calls? Need to determine to which objects (or types of objects) a reference

More information

Program Static Analysis. Overview

Program Static Analysis. Overview Program Static Analysis Overview Program static analysis Abstract interpretation Data flow analysis Intra-procedural Inter-procedural 2 1 What is static analysis? The analysis to understand computer software

More information

Why Global Dataflow Analysis?

Why Global Dataflow Analysis? Why Global Dataflow Analysis? Answer key questions at compile-time about the flow of values and other program properties over control-flow paths Compiler fundamentals What defs. of x reach a given use

More information

Compilers and Code Optimization EDOARDO FUSELLA

Compilers and Code Optimization EDOARDO FUSELLA Compilers and Code Optimization EDOARDO FUSELLA Contents Data memory layout Instruction selection Register allocation Data memory layout Memory Hierarchy Capacity vs access speed Main memory Classes of

More information

Compiler Structure. Data Flow Analysis. Control-Flow Graph. Available Expressions. Data Flow Facts

Compiler Structure. Data Flow Analysis. Control-Flow Graph. Available Expressions. Data Flow Facts Compiler Structure Source Code Abstract Syntax Tree Control Flow Graph Object Code CMSC 631 Program Analysis and Understanding Fall 2003 Data Flow Analysis Source code parsed to produce AST AST transformed

More information

Design Issues. Subroutines and Control Abstraction. Subroutines and Control Abstraction. CSC 4101: Programming Languages 1. Textbook, Chapter 8

Design Issues. Subroutines and Control Abstraction. Subroutines and Control Abstraction. CSC 4101: Programming Languages 1. Textbook, Chapter 8 Subroutines and Control Abstraction Textbook, Chapter 8 1 Subroutines and Control Abstraction Mechanisms for process abstraction Single entry (except FORTRAN, PL/I) Caller is suspended Control returns

More information

Redundant Computation Elimination Optimizations. Redundancy Elimination. Value Numbering CS2210

Redundant Computation Elimination Optimizations. Redundancy Elimination. Value Numbering CS2210 Redundant Computation Elimination Optimizations CS2210 Lecture 20 Redundancy Elimination Several categories: Value Numbering local & global Common subexpression elimination (CSE) local & global Loop-invariant

More information

Chapter 5 Names, Binding, Type Checking and Scopes

Chapter 5 Names, Binding, Type Checking and Scopes Chapter 5 Names, Binding, Type Checking and Scopes Names - We discuss all user-defined names here - Design issues for names: -Maximum length? - Are connector characters allowed? - Are names case sensitive?

More information

CS 536 Introduction to Programming Languages and Compilers Charles N. Fischer Lecture 11

CS 536 Introduction to Programming Languages and Compilers Charles N. Fischer Lecture 11 CS 536 Introduction to Programming Languages and Compilers Charles N. Fischer Lecture 11 CS 536 Spring 2015 1 Handling Overloaded Declarations Two approaches are popular: 1. Create a single symbol table

More information

The Procedure Abstraction Part I: Basics

The Procedure Abstraction Part I: Basics The Procedure Abstraction Part I: Basics Procedure Abstraction Begins Chapter 6 in EAC The compiler must deal with interface between compile time and run time Most of the tricky issues arise in implementing

More information

Programming Languages: Lecture 12

Programming Languages: Lecture 12 1 Programming Languages: Lecture 12 Chapter 10: Implementing Subprograms Jinwoo Kim jwkim@jjay.cuny.edu Chapter 10 Topics 2 The General Semantics of Calls and Returns Implementing Simple Subprograms Implementing

More information

Optimizer. Defining and preserving the meaning of the program

Optimizer. Defining and preserving the meaning of the program Where are we? Well understood Engineering Source Code Front End IR Optimizer IR Back End Machine code Errors The latter half of a compiler contains more open problems, more challenges, and more gray areas

More information

Wednesday, October 15, 14. Functions

Wednesday, October 15, 14. Functions Functions Terms void foo() { int a, b;... bar(a, b); void bar(int x, int y) {... foo is the caller bar is the callee a, b are the actual parameters to bar x, y are the formal parameters of bar Shorthand:

More information

Interprocedural Type Specialization of JavaScript Programs Without Type Analysis

Interprocedural Type Specialization of JavaScript Programs Without Type Analysis Interprocedural Type Specialization of JavaScript Programs Without Type Analysis Maxime Chevalier-Boisvert joint work with Marc Feeley ECOOP - July 20th, 2016 Overview Previous work: Lazy Basic Block Versioning

More information

11/29/17. Outline. Subprograms. Subroutine. Subroutine. Parameters. Characteristics of Subroutines/ Subprograms

11/29/17. Outline. Subprograms. Subroutine. Subroutine. Parameters. Characteristics of Subroutines/ Subprograms Outline Subprograms In Text: Chapter 9 Definitions Design issues for subroutines Parameter passing modes and mechanisms Advanced subroutine issues N. Meng, S. Arthur 2 Subroutine A sequence of program

More information

Chapter 10. Implementing Subprograms ISBN

Chapter 10. Implementing Subprograms ISBN Chapter 10 Implementing Subprograms ISBN 0-321-33025-0 Chapter 10 Topics The General Semantics of Calls and Returns Implementing Simple Subprograms Implementing Subprograms with Stack-Dynamic Local Variables

More information

Static Analysis and Dataflow Analysis

Static Analysis and Dataflow Analysis Static Analysis and Dataflow Analysis Static Analysis Static analyses consider all possible behaviors of a program without running it. 2 Static Analysis Static analyses consider all possible behaviors

More information

Why Data Flow Models? Dependence and Data Flow Models. Learning objectives. Def-Use Pairs (1) Models from Chapter 5 emphasized control

Why Data Flow Models? Dependence and Data Flow Models. Learning objectives. Def-Use Pairs (1) Models from Chapter 5 emphasized control Why Data Flow Models? Dependence and Data Flow Models Models from Chapter 5 emphasized control Control flow graph, call graph, finite state machines We also need to reason about dependence Where does this

More information

Chapter 9 :: Subroutines and Control Abstraction

Chapter 9 :: Subroutines and Control Abstraction Chapter 9 :: Subroutines and Control Abstraction Programming Language Pragmatics, Fourth Edition Michael L. Scott Copyright 2016 Elsevier 1 Chapter09_Subroutines_and_Control_Abstraction_4e - Tue November

More information

A Context-Sensitive Memory Model for Verification of C/C++ Programs

A Context-Sensitive Memory Model for Verification of C/C++ Programs A Context-Sensitive Memory Model for Verification of C/C++ Programs Arie Gurfinkel and Jorge A. Navas University of Waterloo and SRI International SAS 17, August 30th, 2017 Gurfinkel and Navas (UWaterloo/SRI)

More information

Alias Analysis. Last time Interprocedural analysis. Today Intro to alias analysis (pointer analysis) CS553 Lecture Alias Analysis I 1

Alias Analysis. Last time Interprocedural analysis. Today Intro to alias analysis (pointer analysis) CS553 Lecture Alias Analysis I 1 Alias Analysis Last time Interprocedural analysis Today Intro to alias analysis (pointer analysis) CS553 Lecture Alias Analysis I 1 Aliasing What is aliasing? When two expressions denote the same mutable

More information

Compilers. 8. Run-time Support. Laszlo Böszörmenyi Compilers Run-time - 1

Compilers. 8. Run-time Support. Laszlo Böszörmenyi Compilers Run-time - 1 Compilers 8. Run-time Support Laszlo Böszörmenyi Compilers Run-time - 1 Run-Time Environment A compiler needs an abstract model of the runtime environment of the compiled code It must generate code for

More information

Data Flow Testing. CSCE Lecture 10-02/09/2017

Data Flow Testing. CSCE Lecture 10-02/09/2017 Data Flow Testing CSCE 747 - Lecture 10-02/09/2017 Control Flow Capture dependencies in terms of how control passes between parts of a program. We care about the effect of a statement when it affects the

More information

Dependence and Data Flow Models. (c) 2007 Mauro Pezzè & Michal Young Ch 6, slide 1

Dependence and Data Flow Models. (c) 2007 Mauro Pezzè & Michal Young Ch 6, slide 1 Dependence and Data Flow Models (c) 2007 Mauro Pezzè & Michal Young Ch 6, slide 1 Why Data Flow Models? Models from Chapter 5 emphasized control Control flow graph, call graph, finite state machines We

More information

! Those values must be stored somewhere! Therefore, variables must somehow be bound. ! How?

! Those values must be stored somewhere! Therefore, variables must somehow be bound. ! How? A Binding Question! Variables are bound (dynamically) to values Subprogram Activation! Those values must be stored somewhere! Therefore, variables must somehow be bound to memory locations! How? Function

More information

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology exam Compiler Construction in4020 July 5, 2007 14.00-15.30 This exam (8 pages) consists of 60 True/False

More information

Names, Bindings, Scopes

Names, Bindings, Scopes Names, Bindings, Scopes Variables In imperative l Language: abstractions of von Neumann machine Variables: abstraction of memory cell or cells Sometimes close to machine (e.g., integers), sometimes not

More information

Dependence and Data Flow Models. (c) 2007 Mauro Pezzè & Michal Young Ch 6, slide 1

Dependence and Data Flow Models. (c) 2007 Mauro Pezzè & Michal Young Ch 6, slide 1 Dependence and Data Flow Models (c) 2007 Mauro Pezzè & Michal Young Ch 6, slide 1 Why Data Flow Models? Models from Chapter 5 emphasized control Control flow graph, call graph, finite state machines We

More information

Programming Languages

Programming Languages Programming Languages Tevfik Koşar Lecture - XX April 4 th, 2006 1 Roadmap Subroutines Allocation Strategies Calling Sequences Parameter Passing Generic Subroutines Exception Handling Co-routines 2 1 Review

More information

Field Analysis. Last time Exploit encapsulation to improve memory system performance

Field Analysis. Last time Exploit encapsulation to improve memory system performance Field Analysis Last time Exploit encapsulation to improve memory system performance This time Exploit encapsulation to simplify analysis Two uses of field analysis Escape analysis Object inlining April

More information

Run-Time Environments/Garbage Collection

Run-Time Environments/Garbage Collection Run-Time Environments/Garbage Collection Department of Computer Science, Faculty of ICT January 5, 2014 Introduction Compilers need to be aware of the run-time environment in which their compiled programs

More information