Transfer Functions - Advanced Compiler - Lecture Slides , Slides of Computer Science

These are the Lecture Slides of Advanced Compiler which includes Partial Transfer Functions, Input Information, Output Information, Data-Based Context Sensitivity, Bottom-Up Example, Infinite Domains, Interprocedural Analysis etc. Key important points are: Transfer Functions, Partial Transfer Functions, Input Information, Output Information, Data-Based Context Sensitivity, Bottom-Up Example, Infinite Domains, Interprocedural Analysis

Typology: Slides

2012/2013

Uploaded on 03/19/2013

dharmaa
dharmaa 🇮🇳

4.4

(19)

149 documents

1 / 20

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Transfer functions
Our pairs of summaries look like functions
from input information to output information
We call these transfer functions
Complete transfer functions
contain entries for all possible incoming dataflow
information
Partial transfer functions
contain only some entries, and continually refine
during analysis
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14

Partial preview of the text

Download Transfer Functions - Advanced Compiler - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

Transfer functions

• Our pairs of summaries look like functions

from input information to output information

• We call these transfer functions

• Complete transfer functions

– contain entries for all possible incoming dataflow

information

• Partial transfer functions

– contain only some entries, and continually refine

during analysis

Top-down vs. bottom-up

• We’ve always run our interproc analysis top

down: from main, down into procs

• For data-based context sensitivity, can also

run the analysis bottom-up

– analyze a proc in all possibly contexts

– if domain is distributive, only need to analyze

singleton sets

Top-down vs. bottom-up

• What are the tradeoffs?

Top-down vs. bottom-up

• What are the tradeoffs?

– In top-down, only analyze procs in the context that

occur during analysis, whereas in bottom-up, may do

useless work analyzing proc in a data context never

used during analysis

– However, top-down requires analyzing a given

function at several points in time that are far away

from each other. If the entire program can’t fit in

RAM, this will lead to unnecessary swapping. On the

other hand, can do bottom-up as one pass over the

call-graph, one SCC at a time. Once a proc is analyzed,

it never needs to be reloaded in memory.

– top-down better suited for infinite domains

Reps Horwitz and Sagiv 95 (RHS)

g() {

if(isLocked()) {

unlock;

} else {

lock;

} } f() { g(); if (...) { main(); } }

main() {

g();

f();

lock;

unlock;

}

Reps Horwitz and Sagiv 95 (RHS)

g() {

if(isLocked()) {

unlock;

} else {

lock;

} } f() { g(); if (...) { main(); } }

main() {

g();

f();

lock;

unlock;

}

Procedure specialization

• Interprocedural analysis is great for callers

• But for the callee, information is still merged

main() {

x := new A(...);

y := x.g();

y.f();

x := new A(...);

y := x.g();

y.f();

x := new B(...);

y:= x.g();

y.f();

// g too large to inline

g(x) {

x.f();

// lots of code

return x;

// but want to inline f

f(x@A) { ... }

f(x@B) { ... }

Procedure specialization

  • Specialize g for each dataflow information
  • “In between” inlining and context-sensitve interproc

main() {

x := new A(...);

y := x.g 1 ();

y.f();

x := new A(...);

y := x.g 1 ();

y.f();

x := new B(...);

y:= x.g 2 ();

y.f();

g 1 (x) {

x.f(); // can now inline

// lots of code

return x;

g 2 (x) {

x.f(); // can now inline

// lots of code

return x;

// but want to inline f

f(x@A) { ... }

f(x@B) { ... } Docsity.com

A() {

}

D

B() {

}

D ’’

C() {

}

D ’’’

Inlining

A() {

call D

}

B() {

call D

}

C() {

call D

}

D() { ... }

A() {

call D

}

B() {

call D

}

C() {

call D

}

D() { ... }

caller summary callee summary

Context-insensitive summary

A() {

call D

}

B() {

call D

}

C() {

call D

}

D() { ... }

A() {

call D

}

B() {

call D

}

C() {

call D

}

D() { ... }

D’() { ... }

Procedure Specialization

A() {

call D

}

B() {

call D

}

C() {

call D

}

D() { ... }

Comparison

Caller precision Callee precision Code bloat

Inlining

context-insensitive interproc

Context sensitive interproc

Specialization

Summary on how to optimize function calls

  • Inlining
  • Tail call optimizations
  • Interprocedural analysis using summaries
    • context sensitive
    • context insensitive
  • Specialization

Cutting edge research

• Making interprocedural analysis run fast

– Many of the approaches as we have seen them do

not scale to large programs (eg millions of lines of

code)

– Trade off precision for analysis speed

• Optimizing first order function calls

• Making inlining effective in the presence of

dynamic dispatching and class loading