From last class. The above is Click’s solution (PLDI 95)

Slides:



Advertisements
Similar presentations
SSA and CPS CS153: Compilers Greg Morrisett. Monadic Form vs CFGs Consider CFG available exp. analysis: statement gen's kill's x:=v 1 p v 2 x:=v 1 p v.
Advertisements

1 SSA review Each definition has a unique name Each use refers to a single definition The compiler inserts  -functions at points where different control.
Data-Flow Analysis II CS 671 March 13, CS 671 – Spring Data-Flow Analysis Gather conservative, approximate information about what a program.
School of EECS, Peking University “Advanced Compiler Techniques” (Fall 2011) SSA Guo, Yao.
1 Authors: Vugranam C. Sreedhar, Roy Dz-Ching Ju, David M. Gilles and Vatsa Santhanam Reader: Pushpinder Kaur Chouhan Translating Out of Static Single.
Data Flow Analysis. Goal: make assertions about the data usage in a program Use these assertions to determine if and when optimizations are legal Local:
Context-Sensitive Interprocedural Points-to Analysis in the Presence of Function Pointers Presentation by Patrick Kaleem Justin.
Control-Flow Graphs & Dataflow Analysis CS153: Compilers Greg Morrisett.
SSA.
1 CS 201 Compiler Construction Lecture Interprocedural Data Flow Analysis.
Components of representation Control dependencies: sequencing of operations –evaluation of if & then –side-effects of statements occur in right order Data.
Program Representations. Representing programs Goals.
1 Constant Propagation for Loops with Factored Use-Def Chains Reporter : Lai, Yen-Chang.
Example in SSA X := Y op Z in out F X := Y op Z (in) = in [ { X ! Y op Z } X :=  (Y,Z) in 0 out F X :=   (in 0, in 1 ) = (in 0 Å in 1 ) [ { X ! E |
Program Representations Xiangyu Zhang. CS590F Software Reliability Why Program Representations  Initial representations Source code (across languages).
Common Sub-expression Elim Want to compute when an expression is available in a var Domain:
Recap from last time We were trying to do Common Subexpression Elimination Compute expressions that are available at each program point.
Course project presentations No midterm project presentation Instead of classes, next week I’ll meet with each group individually, 30 mins each Two time.
Feedback: Keep, Quit, Start
Recap from last time Saw several examples of optimizations –Constant folding –Constant Prop –Copy Prop –Common Sub-expression Elim –Partial Redundancy.
Next Section: Pointer Analysis Outline: –What is pointer analysis –Intraprocedural pointer analysis –Interprocedural pointer analysis (Wilson & Lam) –Unification.
Cpeg421-08S/final-review1 Course Review Tom St. John.
Interprocedural analyses and optimizations. Costs of procedure calls Up until now, we treated calls conservatively: –make the flow function for call nodes.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Advanced Compilers CMPSCI 710.
1 Intermediate representation Goals: –encode knowledge about the program –facilitate analysis –facilitate retargeting –facilitate optimization scanning.
Administrative info Subscribe to the class mailing list –instructions are on the class web page, which is accessible from my home page, which is accessible.
1 CS 201 Compiler Construction Lecture 1 Introduction.
Previous finals up on the web page use them as practice problems look at them early.
Another example p := &x; *p := 5 y := x + 1;. Another example p := &x; *p := 5 y := x + 1; x := 5; *p := 3 y := x + 1; ???
From last class: CSE Want to compute when an expression is available in a var Domain:
Loop invariant detection using SSA An expression is invariant in a loop L iff: (base cases) –it’s a constant –it’s a variable use, all of whose single.
From last lecture x := y op z in out F x := y op z (in) = in [ x ! in(y) op in(z) ] where a op b =
Intermediate Code. Local Optimizations
From last time: Inlining pros and cons Pros –eliminate overhead of call/return sequence –eliminate overhead of passing args & returning results –can optimize.
Projects. Dataflow analysis Dataflow analysis: what is it? A common framework for expressing algorithms that compute information about a program Why.
Recap from last time: live variables x := 5 y := x + 2 x := x + 1 y := x y...
Course project presentations Midterm project presentation Originally scheduled for Tuesday Nov 4 th Can move to Th Nov 6 th or Th Nov 13 th.
Schedule Midterm out tomorrow, due by next Monday Final during finals week Project updates next week.
Direction of analysis Although constraints are not directional, flow functions are All flow functions we have seen so far are in the forward direction.
Recap from last time We saw various different issues related to program analysis and program transformations You were not expected to know all of these.
Precision Going back to constant prop, in what cases would we lose precision?
Code Optimization, Part III Global Methods Comp 412 Copyright 2010, Keith D. Cooper & Linda Torczon, all rights reserved. Students enrolled in Comp 412.
Chapter 7 Runtime Environments. Relationships between names and data objects As execution proceeds, the same name can denote different data objects Procedures,
1 CS 201 Compiler Construction Introduction. 2 Instructor Information Rajiv Gupta Office: WCH Room Tel: (951) Office.
Compiler Principles Fall Compiler Principles Lecture 0: Local Optimizations Roman Manevich Ben-Gurion University.
12/5/2002© 2002 Hal Perkins & UW CSER-1 CSE 582 – Compilers Data-flow Analysis Hal Perkins Autumn 2002.
1 The System Dependence Graph and its use in Program Slicing.
1 Control Flow Analysis Topic today Representation and Analysis Paper (Sections 1, 2) For next class: Read Representation and Analysis Paper (Section 3)
Program Representations. Representing programs Goals.
CS412/413 Introduction to Compilers Radu Rugina Lecture 18: Control Flow Graphs 29 Feb 02.
1 Control Flow Graphs. 2 Optimizations Code transformations to improve program –Mainly: improve execution time –Also: reduce program size Can be done.
RUNTIME ENVIRONMENT AND VARIABLE BINDINGS How to manage local variables.
Interprocedural analyses and optimizations. Costs of procedure calls Up until now, we treated calls conservatively: –make the flow function for call nodes.
Interprocedural analyses and optimizations. Costs of procedure calls Up until now, we treated calls conservatively: –make the flow function for call nodes.
LECTURE 19 Subroutines and Parameter Passing. ABSTRACTION Recall: Abstraction is the process by which we can hide larger or more complex code fragments.
Optimization Simone Campanoni
Run-Time Environments Presented By: Seema Gupta 09MCA102.
Code Optimization Overview and Examples
Dataflow analysis.
Static Single Assignment
Program Representations
For Example: User level quicksort program Three address code.
Fall Compiler Principles Lecture 8: Loop Optimizations
Topic 10: Dataflow Analysis
CS 201 Compiler Construction
Code Optimization Overview and Examples Control Flow Graph
UNIT V Run Time Environments.
Interprocedural analyses and optimizations
SSA-based Optimizations
Presentation transcript:

From last class

The above is Click’s solution (PLDI 95)

Control Dependences A node (basic block) Y is control-dependent on another X iff X determines whether Y executes –there exists a path from X to Y s.t. every node in the path other than X and Y is post-dominated by Y –X is not post-dominated by Y

Control Dependences A node (basic block) Y is control-dependent on another X iff X determines whether Y executes –there exists a path from X to Y s.t. every node in the path other than X and Y is post-dominated by Y –X is not post-dominated by Y

Example

Control Dependence Graph Control dependence graph: Y decsendent of X iff Y is control dependent on Y –label each child edge with required condition –group all children with same condition under region node Program dependence graph: super-impose dataflow graph (in SSA form or not) on top of the control dependence graph

Example

Another example

Summary so far Dataflow analysis –flow functions, lattice theoretic framework, optimistic iterative analysis, MOP Rhodium/Collider –declarative specifications of flow functions Advanced Program Representations –SSA, CDG, PDG, code motion Next: dealing with procedures

After that Pointer analysis Program analysis for verification Correctness Analyzing object-oriented languages Advanced topics (set constraints, ordering analyses and transformations, gc)

Interprocedural analyses and optimizations

Costs of procedure calls Up until now, we treated calls conservatively: –make the flow function for call nodes return top –start iterative analysis with incoming edge of the CFG set to top –This leads to less precise results: “lost-precision” cost Calls also incur a direct runtime cost –cost of call, return, argument & result passing, stack frame maintainance –“direct runtime” cost

Addressing costs of procedure calls Technique 1: try to get rid of calls, using inlining and other techniques Technique 2: interprocedural analysis, for calls that are left

Inlining Replace call with body of callee Turn parameter- and result-passing into assignments –do copy prop to eliminate copies Manage variable scoping correctly –rename variables where appropriate

Program representation for inlining Call graph –nodes are procedures –edges are calls, labelled by invocation counts/frequency Hard cases for builing call graph –calls to/from external routines –calls through pointers, function values, messages Where in the compiler should inlining be performed?