static3

# static3 - Dataflow Analysis Widening and Narrowing Path...

This preview shows pages 1–13. Sign up to view the full content.

1 Dataflow Analysis Dataflow Analysis Widening and Narrowing Widening and Narrowing Path Sensitivity Path Sensitivity Interprocedural Analysis Interprocedural Analysis Static Analysis 2009 Static Analysis 2009 Michael I. Schwartzbach Computer Science, University of Aarhus

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

View Full Document
2 2 Static Analysis Sign Analysis Sign Analysis ± Determine the sign ( + , - , 0 ) of all expressions ± The Sign lattice: ± The full lattice is the map lattice: Vars Sign •w h e r e Vars is the set of variables in the program ? + -0
3 3 Static Analysis Sign Constraints Sign Constraints ± The variable [[v]] denotes a map that gives the sign value for all variables at the program point after v ± For variable declarations: [[v]] = [i d 1 ? , . .., id n ? ] ± For assignments: [[v]] = JOIN (v)[ id eval ( JOIN (v), E ) ± For all other nodes: [[v]] = JOIN (v) = [[w]] w pred (v)

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

View Full Document
4 4 Static Analysis Evaluating Signs Evaluating Signs ± The eval function is an abstract evaluation : eval ( σ , id ) = σ ( id ) eval ( σ , intconst ) = sign ( intconst ) eval ( σ , E 1 op E 2 ) = op ( eval ( σ , E 1 ), eval ( σ , E 2 )) ± The sign function gives the sign of an integer ± The op function is an abstract evaluation of the given operator
5 5 Static Analysis Abstract Operators Abstract Operators ? ? ? ? ? ? + ? + + ? ? - - - ? + - 0 0 ? + - 0 + ? ? ? ? ? ? ? + + + ? - ? - - ? - + 0 0 ? + - 0 - ? ? ? 0 ? ? + - 0 + ? - + 0 - 0 0 0 0 0 0 0 ? + - 0 * ? ? ? ? ? ? ? ? ? + ? ? ? ? - ? 0 0 ? 0 ? + - 0 / ? ? ? ? ? ? ? + + + ? 0 ? 0 - ? 0 + 0 0 ? + - 0 > ? ? ? ? ? ? ? 0 0 + ? 0 ? 0 - ? 0 0 + 0 ? + - 0 ==

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

View Full Document
6 6 Static Analysis Monotonicity Monotonicity ± The operator and map updates are monotone ± Compositions preserve monotonicity ± Are the abstract operators monotone? ± This is verified by a tedious manual inspection ± Or better, run an O( n 3 ) algorithm for an n × n table: x , y , x’ L: xx x op yx op y x , y , y’ L: yy x op op y’
7 7 Static Analysis Increasing Precision Increasing Precision ± Some loss of information: • (2>0)==1 is analyzed as ? •+/+ is analyzed as ? , since e.g. ½ is rounded down ± Use a richer lattice for better precision: ± Abstract operators are now 8 × 8 tables ? + 0- 1 +0 -0

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

View Full Document
8 8 Static Analysis Constant Propagation Constant Propagation ± Determine variables with a constant value ± Similar to sign analysis, with basic lattice: ± Abstract operator for addition: + (n,m) = if (n ? m ? ) { n + m } else { ? } ? -1 01 23 -2 -3
9 9 Static Analysis Constant Folding Constant Folding ± Exploiting constant propagation: var x,y,z; x = 27; y = input, z = 2*x+y; if (x<0) { y=z-3; } else { y=12 } output y; var x,y,z; var y; x = 27; y = input; y = input; output 12; z = 54+y; if (0) { y=z-3; } else { y=12 } output y;

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

View Full Document
10 10 Static Analysis Interval Analysis Interval Analysis ± Compute upper and lower bounds for integers ± Lattice of intervals: Interval = lift ({ [ l , h ] | l,h N l h }) where: N = { - , . .., -2 , -1 , 0 , 1 , 2 , . .., } and intervals are ordered by inclusion: [ l 1 , h 1 ] [ l 2 , h 2 ] iff l 2 l 1 h 1 h 2
11 11 Static Analysis The Interval Lattice The Interval Lattice [- , ] [0,0] [1,1] [2,2] [-1,-1] [-2,-2] [0,1] [1,2] [-1,0] [-2,-1] [2, ] [1, ] [0, ] [- ,-2] [- ,-1] [- ,0] [-2,0] [-1,1] [0,2] [-2,1] [-1,2] [-2,2]

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

View Full Document
12 12 Static Analysis Interval Analysis Lattice
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 04/18/2011 for the course COMPUTER 091 taught by Professor Rajivsir during the Spring '11 term at MIT.

### Page1 / 59

static3 - Dataflow Analysis Widening and Narrowing Path...

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

View Full Document
Ask a homework question - tutors are online