05 Sparse Analysis

05 Sparse Analysis - Course Outline Introduction...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Course Outline Introduction Control-flow analysis Dataflow analysis and abstract interpretation Sparse analysis Adding indirection (pointers) Adding functions Type- and constraint-based analysis Ben Hardekopf () CS 290C Program Analysis Fall 2011 1 / 41 Section Outline Sparse Analysis Def-Use 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 Def-Use 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 def-use 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 Def-Use Chains To compute this def-use info: Compute reaching definitions For each node n d defining a variable x and node n u using x , create a def-use edge n d → n u if the definition at n d reaches n u The def-use 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 def-use chains and redo the analysis using those def-use 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 Def-Use Chains This sounds great, but there’s a major problem. The fly in the ointment: The number of def-use 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 Def-Use Chains This sounds great, but there’s a major problem. The fly in the ointment: The number of def-use 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 def-use 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.

Page1 / 48

05 Sparse Analysis - Course Outline Introduction...

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

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