dataflowAnalysis - Dataflow Analysis Iterative Data-flow...

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

View Full Document Right Arrow Icon
cs5363 1 Dataflow Analysis Iterative Data-flow Analysis and Static-Single-Assignment
Background image of page 1

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

View Full DocumentRight Arrow Icon
cs5363 2 Optimization And Analysis Improving efficiency of generated code Correctness: optimized code must preserve meaning of the original program Profitability: optimized code must improve code quality Program analysis Ensure safety and profitability of optimizations Compile-time reasoning of runtime program behavior Undecidable in general due to unknown program input Conservative approximation of program runtime behavior May miss opportunities, but ensure all optimizations are safe Data-flow analysis Reason about flow of values between statements Can be used for program optimization or understanding
Background image of page 2
cs5363 3 Control-Flow Graph Graphical representation of runtime control-flow paths Nodes of graph: basic blocks (straight-line computations) Edges of graph: flows of control Useful for collecting information about computation Detect loops, remove redundant computations, register allocation, instruction scheduling… Alternative CFG: Each node contains a single statement if I < 50 …… t1 := b * 2; a := a + t1; i = i + 1; i =0;
Background image of page 3

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

View Full DocumentRight Arrow Icon
cs5363 4 Building Control-Flow Graphs Identifying Basic Blocks Input: a sequence of three-address statements Output: a list of basic blocks Method: Determine each statement that starts a new basic block, including The first statement of the input sequence Any statement that is the target of a goto statement Any statement that immediately follows a goto statement Each basic block consists of A starting statement S0 (leader of the basic block) All statements following S0 up to but not including the next starting statement (or the end of input) …… i := 0 s0: if i < 50 goto s1 goto s2 s1: t1 := b * 2 a := a + t1 goto s0 S2: … Starting statements: i := 0 S0, goto S2 S1, S2
Background image of page 4
cs5363 5 Building Control-Flow Graphs Identify all the basic blocks Create a flow graph node for each basic block For each basic block B1 If B1 ends with a jump to a statement that starts basic block B2, create an edge from B1 to B2 If B1 does not end with an unconditional jump, create an edge from B1 to the basic block that immediately follows B1 in the original evaluation order …… i := 0 s0: if i < 50 goto s1 goto s2 s1: t1 := b * 2 a := a + t1 goto s0 S2: … S0: if i < 50 goto s1 goto s2 s1: t1 := b * 2 a := a + t1 goto s0 S2: …… i :=0
Background image of page 5

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

View Full DocumentRight Arrow Icon
cs5363 6 Exercise: Building Control-flow Graph …… i = 0; z = x while (i < 100) { i = i + 1; if (y < x) z=y; A[i]=i; } ….
Background image of page 6
cs5363 7 Live Variable Analysis A data-flow analysis problem A variable v is live at CFG point p iff there is a path from p to a use of v along which v is not redefined At any CFG point p, what variables are alive? Live variable analysis can be used in
Background image of page 7

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

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

This note was uploaded on 01/29/2012 for the course CS 5363 taught by Professor Staff during the Spring '08 term at The University of Texas at San Antonio- San Antonio.

Page1 / 31

dataflowAnalysis - Dataflow Analysis Iterative Data-flow...

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

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