Com S 641 meeting -*- Outline -*- * Dataflow Analysis (1.3) ** goals To propogate information about data through a program. ** idea Q: What's the basic idea? Represent program as a data flow graph Q: What's a data flow graph? nodes are elementary blocks edges describe how control passes from one elementary block to another Q: How is that used to model the semantics? nodes transform information (differences from entry to exit) edges connect exit from one node to entry of another (equations) ** example ------------------------------------------ EXAMPLE [q := 0]^1; [r := x]^2; while [r >= y]^3 do ([r := r-y]^4; [q := q+1]^5); assert [0<=r and r[r >= y]^3 ----no------->| | | | | | yes | | v | | [r := r-y]^4 | | | | | v | | [q := q+1]^5 | | | | \_____/ | _____________________/ | v [0<=r and r Powerset(Var*) where Lab* = set of labels in program Var* = set of variables in prog block Equation ======================================= [x:=a]^l AVexit(l) = [skip]^l AVexit(l) = [b]^l AVexit(l) = How are edges connected? ------------------------------------------ ... AVentry(l) \cup {x} AVentry(l) AVentry(l) Q: Why are these the right equations? Q: How does this work out for our example? **** algorithm for solving the equations Q: What can we do to solve a set of simultaneous equations? e.g., R(1) = {y} R(2) = R(1) \cup {x} want least solution or greatest, which is better for this case? least, as Var* may have been assigned, so that's safe but not precise what ordering is appropriate for sets? ------------------------------------------ LEAST SOLUTION F: (Powerset(Var*))^12 -> (Powerset(Var*))^12 F is defined by: F(RD_1, ..., RD_{12}) = (F_1(CS_1, ..., RD_{12}), F_2(RD_1, ..., RD_{12}), ..., F_{12}(RD_1, ..., RD_{12})) where F_1(RD_1, ..., RD_{12}) = {(q,?),(r,?),(x,?),(y,?)} F_2(RD_1, ..., RD_{12}) = RD_1 union {x} Solution (AVentry(1), AVexit(1), ..., AVexit(6)) is a solution if (AVentry(1), AVexit(1), ..., AVexit(6)) = F(AVentry(1), AVexit(1), ..., AVexit(6)) ------------------------------------------ Q: Would this still be a 12-tuple if there were seven elementary blocks? Q: How to compare such tuples? pointwise Q: What does the lattice structure of (Powerset(Var* x Lab*))^12 look like? Q: How can one find the fixed point using this information? *** the constraint based approach Q: What are the constraints? subset relationships between AVexit(l) and AVentry(l') Q: How do the elementary blocks work? Q: How do the flows work? Q: What's the connection to the equations?