04 Practice Designing Analyses

# 04 Practice Designing Analyses - Designing Analyses...

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

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

View Full Document

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Designing Analyses Practicing analysis design: Deﬁnitely-Initialized Variables Live Variables Program Slicing Ben Hardekopf () CS 290C Program Analysis Fall 2011 1/4 Designing Analyses Practicing analysis design: Deﬁnitely-Initialized Variables Live Variables Program Slicing For each analysis: Deﬁne the abstract lattice and give its properties Deﬁne the transfer functions and give their properties Give a rough estimate of the analysis complexity Argue that the analysis: Terminates Does/does not compute the MOP solution Is sound (using the Galois connection) Ben Hardekopf () CS 290C Program Analysis Fall 2011 1/4 Deﬁnitely-Initialized Variables Which variables are guaranteed to have been assigned a value before being used? (Lingo assumes uninitialized values are 0, but this analysis is useful for catching programmer mistakes and for languages like C.) Example 1x := 1 ; (y < x) then { 3 y := 2 } else { 4 y := 3 ; 5 z := 4 } ; 6 a := x ; 7 b := y ; 8 c := z 2 if At 2 y may not be initialized and at 8 z may not be initialized. Ben Hardekopf () CS 290C Program Analysis Fall 2011 2/4 Live Variables Which variables may be used before being redeﬁned (or reaching the end of the program)? Note that this is a backwards analysis. Example 1x := 1 ; 2 y := 2 ; 3 z := 3 ; (_) then { 5 while (_) do { 6 y := y+1 }} else { 7 y := x } ; 8 z := 4 4 if Right after 1, x is live and y, z are dead. Ben Hardekopf () CS 290C Program Analysis Fall 2011 3/4 Program Slicing Given a program statement, what other statements contribute to the result of executing that statement? (Assume you’ve already computed control dependencies and reaching deﬁnitions.) Example 1n := 5 ; 2 i := 1 ; 3 sum := 0 ; 4 product := 1 ; (i <= n) do { 6 sum := sum+i ; 7 product := product*i ; 8 i := i+1 } }; 9 x := sum ; 10 y := product 5 while The slice for statement 10 = { 1, 2, 4, 5, 7, 8, 10 }. Ben Hardekopf () CS 290C Program Analysis Fall 2011 4/4 ...
View Full Document

{[ snackBarMessage ]}

### Page1 / 5

04 Practice Designing Analyses - Designing Analyses...

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

View Full Document
Ask a homework question - tutors are online