This preview shows pages 1–9. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Course Outline Introduction Controlflow analysis Dataflow analysis and abstract interpretation Sparse analysis Adding indirection (pointers) Adding functions Type and constraintbased analysis Ben Hardekopf () CS 290C Program Analysis Fall 2011 1 / 41 Section Outline Sparse Analysis DefUse Chains Static Single Assignment Ben Hardekopf () CS 290C Program Analysis Fall 2011 2 / 41 DFA Efficiency DFA is not always very efficient—there’s a lot of redundant/unnecessary information being propagated through the CFG. Example (Constant Propagation) 1 x := 4 ; 2 y := 1 ; 3 if (_) then { 4 y := 3 ; 5 z := x } else { 6 z := 3 } ; 7 a := y+z Notice that information is propagated to many nodes that don’t need that information. Ben Hardekopf () CS 290C Program Analysis Fall 2011 3 / 41 DefUse Chains How can we improve DFA efficiency? Directly connect definitions (assignments that produce information) with uses (statements that consume information). Then run the DFA on these defuse edges instead of on the CFG. Example (Constant Propagation Redux) 1 x := 4 ; 2 y := 1 ; 3 if (_) then { 4 y := 3 ; 5 z := x } else { 6 z := 3 } ; 7 a := y+z Ben Hardekopf () CS 290C Program Analysis Fall 2011 4 / 41 Computing DefUse Chains To compute this defuse info: Compute reaching definitions For each node n d defining a variable x and node n u using x , create a defuse edge n d → n u if the definition at n d reaches n u The defuse edges embody the reaching definition analysis solution at the points where that information matters (i.e., where the definition is actually used). Ben Hardekopf () CS 290C Program Analysis Fall 2011 5 / 41 Exercise This is the same program we used as an exercise for Constant Propagation. Review the standard DFA solution, then compute defuse chains and redo the analysis using those defuse edges. Program 1 x := 2 ; 2 y := x+3 3 if (_) then { 4 while (_) do { 5 x := y ; 6 y := x+3 ; 7 z := x+y } } else { 8 y := x ; 9 z := x+y } ; 10 a := x+y ; 11 b := x+3 Ben Hardekopf () CS 290C Program Analysis Fall 2011 6 / 41 Problem with DefUse Chains This sounds great, but there’s a major problem. The fly in the ointment: The number of defuse edges can be quadratic in the number of program statements (whereas the CFG is linear). Ben Hardekopf () CS 290C Program Analysis Fall 2011 7 / 41 Problem with DefUse Chains This sounds great, but there’s a major problem. The fly in the ointment: The number of defuse edges can be quadratic in the number of program statements (whereas the CFG is linear). Example if (_) then { x := _ } else if (_) then { x := _ } else { x := _ } ; if (_) then { _ := x } else if (_) then { _ := x } else { _ := x } The solution to this problem is to factor the defuse edges—which leads us to SSA form....
View
Full
Document
This note was uploaded on 12/27/2011 for the course CMPSC 290a taught by Professor Vandam during the Fall '09 term at UCSB.
 Fall '09
 Vandam

Click to edit the document details