{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

dataflowAnalysis - Dataflow Analysis Iterative Data-flow...

Info icon This 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
Image of page 1

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

View Full Document Right 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
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;
Image of page 3

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

View Full Document Right 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
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
Image of page 5

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

View Full Document Right 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; } ….
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 Global register allocation Dead variables no longer need to be in registers SSA (static single assignment) construction Dead variables don’t need -functions at CFG merge points Useless-store elimination
Image of page 7

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

View Full Document Right Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.
  • Spring '08
  • STAFF
  • basic block, Reaching definition, Dead code elimination, IDOM, Static single assignment form, Optimization And Analysis

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern