CSCE 434 Lecture 39

From Notes
Jump to navigation Jump to search

« previous | Wednesday, November 27, 2013 | next »

Lecture Slides

Data Flow Analysis

Compile-time analysis of run-time flow of values in the program

  • When running a program, instructions come in lexicographic order. When execution splits, only one branch will be taken.
  • However, at compile-time We generally don't know which will be taken
  • Therefore, we look at both paths "simultaneously"

Data Flow overview:

  • Attach sets to nodes and edges of graphs
  • Use Lattice to describe relation between values
  • Start with initial guess of facts at each node
  • Propagate until node sets stabilize at maximal fixed point
  • meet over all paths solution (MOP) is desired, but not affordable.


Pointers and arrays are difficult to analyze:

  • when writing to array, assume all elements are touched
  • when writing to pointers, assume all pointers are modified

Definitions

define
expression is defined at if value is computed at .
kill
expression is killed at if one of its argument variables is defined at .
suppose . Executing kills .
available
expression is available at in a procedure if all paths leading to contains a prior definition of that is not killed between its definition and .

Global Common Subexpression Elimination

If at some point for , has already been computed and has name , we can replace the evaluation of with a reference to .

Requires global expression naming scheme.

Available Expressions

  • AVAIL() is set of expressions available on entry to .
  • KILL() is set of expressions that are killed in .
  • GEN() is set of expressions defined in and not subsequently killed in .

The Data Flow Equation:


Algorithm

  1. Build control flow graph
  2. Initial (local) data gathering
  3. propagate information around the graph
  4. post-processing


Worklist Iterative Algorithm

queue<Node> worklist(cfg.nodes);

while(!worklist.empty()) {
    Node n = worklist.dequeue();
    recompute AVAIL(n);
    if (AVAIL(n).changed())
        worklist.enqueue(n.successors);
}

Representation

Facts usually represented on bit vectors

union is bitwise OR, intersection is bitwise AND