CSCE 434 Lecture 39
« previous | Wednesday, November 27, 2013 | next »
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 Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle p} .
- 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 , Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle e} has already been computed and has name Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle x} , we can replace the evaluation of Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle e} with a reference to Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle x} .
Requires global expression naming scheme.
Available Expressions
- AVAIL(Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle b} ) is set of expressions available on entry to .
- KILL(Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle b} ) is set of expressions that are killed in Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle b} .
- GEN(Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle b} ) is set of expressions defined in Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle b} and not subsequently killed in Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle b} .
The Data Flow Equation:
Algorithm
- Build control flow graph
- Initial (local) data gathering
- propagate information around the graph
- 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