static5 - Pointer Analysis Static Analysis 2009 Michael I....

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

View Full Document Right Arrow Icon
1 Pointer Analysis Pointer Analysis Static Analysis 2009 Static Analysis 2009 Michael I. Schwartzbach Computer Science, University of Aarhus
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 2 Static Analysis Heap Pointers Heap Pointers ± Pointers in the TIP language are limited: • malloc only allocates a single cell • only linear structures can be built in the heap ± But we still have all relevant analysis challenges. .. x y z
Background image of page 2
3 3 Static Analysis Pointer Targets Pointer Targets ± The fundamental question about pointers: What are their possible targets? ± We need a suitable abstraction: •& id for a program variable named id • malloc- i for an allocation site with index i ± The set of all these is denoted Targets ± Each target may correspond to many actual memory cells at runtime
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 4 Static Analysis Points Points - - To Analysis To Analysis ± Determine for each pointer variable p the set, pt ( p ), of its possible targets ± A conservative analysis: • the set may be too large • the trivial answer is pt ( p ) = Targets • can e.g. eliminate aliases: pt ( p ) pt ( q ) = ± A flow-insensitive analysis: • takes place on the AST • before or together with the control-flow analysis
Background image of page 4
5 5 Static Analysis Obtaining Points Obtaining Points - - To Information To Information ± The simplest non-trivial analysis: • include all malloc- i targets • include & id if that expression occurs in the program • this is called address-taken ± Improvement for a typed language: • eliminate those targets whose types do not match ± Amazingly, this is sometimes good enough • and clearly very fast to compute
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 6 Static Analysis Pointer Normalization Pointer Normalization ± Assume that all pointer usage is normalized: id = malloc id 1 =& id 2 id 1 = id 2 id 1 =* id 2 •* id 1 = id 2 id =null ± Simply introduce lots of temporary variables ± All subexpressions are now named
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 26

static5 - Pointer Analysis Static Analysis 2009 Michael I....

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

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