lecture-11 Interprocedural Analysis (continnued)

lecture-11 Interprocedural Analysis (continnued) - Inlining...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Inlining pros and cons (discussion) Inlining pros and cons • Pros – eliminate overhead of call/return sequence – can optimize callee in context of caller and vice versa • Cons – can increase compiled code space requirements – can slow down compilation – recursion? • Virtual inlining: simulate inlining during analysis of caller, but don’t actually perform the inlining Which calls to inline (discussion) • What affects the decision as to which calls to inline? Which calls to inline • What affects the decision as to which calls to inline? – size of caller and callee (easy to compute size before inlining, but what about size after inlining?) – frequency of call (static estimates or dynamic profiles) – call sites where callee benefits most from optimization (not clear how to quantify) – programmer annotations (if so, annotate procedure or call site? Also, should the compiler really listen to the programmer?) Which calls to inline • The above metrics vary in how easy/hard they are to quantify • Even if one were able to quantify all of them accurately, how does one put them together to make a decision? • Inlining heuristics Inlining heuristics • Strategy 1: superficial analysis – examine source code of callee to estimate space costs, use this to determine when to inline – doesn’t account for post-inlining optimizations • How can we do better?
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Inlining heuristics • Strategy 2: deep analysis – perform inlining – perform post-inlining analysis/optimizations – estimate benefits from opts, and measure code space after opts – undo inlining if costs exceed benefits – better accounts for post-inlining effects – much more expensive in compile-time • How can we do better? Inlining heuristics • Strategy 3: amortized version of 2 – perform strategy 2: an inlining “trial” – record cost/benefit trade-offs in persistent database – reuse previous cost/benefit results for “similar” call sites Inlining heuristics • Strategy 4: use machine learning techniques • For example, use genetic algorithms to evolve heuristics for inlining – fitness is evaluated on how well the heuristics do on a set of benchmarks – cross-populate and mutate heuristics • Can work surprisingly well to derive various heuristics for compilres Another way to remove procedure calls inf f(. ..) { if (. ..) return g(. ..); ... return h(i(. ...), j(. ..)); } Tail call eliminiation • Tail call: last thing before return is a call – callee returns, then caller immediately returns • Can splice out one stack frame creation and destruction by jumping to callee rather than calling
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

lecture-11 Interprocedural Analysis (continnued) - Inlining...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online