Definitioncore
Meet-over-all-paths solution
Also called MOP solution, merge over all paths.
The meet, over all paths from the entry to a point, of the composed transfer functions of the path, which is the ideal dataflow answer.
The meet-over-all-paths (MOP) solution of a dataflow analysis gives each program point the meet, over every path in the control flow graph from the start to that point, of the fact that the path produces. It treats each path on its own and merges only at the end, so it is the most precise answer that an analysis can give when it assumes that every CFG path can run. It is the yardstick for the computed answer, the maximal fixed-point solution: in every monotone dataflow framework MFP MOP, and in a distributive dataflow framework the two are equal. A loop gives infinitely many paths, and Kam and Ullman (1977) proved that no algorithm computes MOP for every monotone framework.
Definition
The dataflow pages use the meet convention: is a meet semilattice, means , is the identity of meet, and the height is finite. Lower facts are weaker, safer claims.
The instance. A control flow graph with an entry block, a transfer function for each block, and a boundary value that holds at the start of the entry.
Paths and path functions. A path to is a sequence of blocks with the entry, , and an edge from each block to the next. Its function applies the blocks before in order:
and is the identity for the path of length zero. The fact that produces at the start of is .
Definition. For each block ,
where is the set of paths to . The value at the end of uses the paths that go through itself: . For a backward problem, the paths run from the end of a block to the end of a ret block, on the reverse CFG, and holds after each ret block.
The meet exists. A loop makes infinite, so the meet needs care. In a semilattice of finite height with a top, every set has a greatest lower bound, and when is not empty it is the meet of at most members of . Proof. Start with any . While some has , replace with ; each replacement goes strictly down, so there are at most . At the end for all , and every lower bound of is below the members used and hence below . The empty set has meet . So is well defined, and it is exactly when no path reaches or all paths give .
MOP is the ideal answer for CFG paths. Assume each is safe: if a fact describes the state at the start of , then describes the state at the end, and a lower fact describes every state that a higher one describes. A run that reaches follows some path , so by induction along the fact describes its state at , and so does the lower fact . This is soundness. Conversely, any answer at that is safe for every path taken on its own must be below each , so below their meet. MOP is the greatest such answer. It can still be below the truth, because some CFG paths are never run.
Precision with an example. For constant propagation on the diamond below, the two paths to join give and , and the function of join gives on each, so has . The maximal fixed point merges and at the start of join first and gets "not a constant" for .
entry:
br c left right
left:
x = 2
y = 3
jump join
right:
x = 3
y = 2
jump join
join:
z = x + y
ret z
Relation to the fixed point. In every monotone framework, every solution of the dataflow equations is below MOP at every block, and in particular MFP MOP; the proof is on the maximal fixed-point solution page. If the functions are distributive and every block is reachable, MOP itself solves the equations, so MFP = MOP; the proof is on the distributive dataflow framework page, and the MOP-MFP coincidence theorem states it.
Cost and computability.
- Acyclic CFG. The paths are finite in number, so MOP is computable by enumeration. Their number can be exponential: a chain of diamonds has paths from the first block to the last.
- Distributive frameworks. MOP = MFP, and a worklist solver finds it with transfer functions and meets on blocks and edges.
- Finite lattices. If has finitely many elements, MOP is computable for any monotone framework. Solve the problem on sets of facts instead: the fact at a point is the set of values over paths to , with , union as the merge, and applied to each element. This lifted problem is distributive over union and has height at most , so iteration finds the exact sets, and . The cost grows with , which is usually huge.
- Infinite lattices of finite height. Kam and Ullman (1977) showed that no algorithm computes MOP for every instance of every monotone framework. Constant propagation is of this kind: its lattice is infinite, so the method for finite lattices does not apply. This is why analyses compute MFP.
Examples and non-examples
Live variables on the running example. The loop of the running example of dataflow analysis gives infinitely many paths from each block to done. Live variables is distributive, so MOP equals the MFP shown on the live variable analysis page; for instance . By the lemma above, a finite number of these paths already gives the whole meet.
An unreachable block. If no path reaches , then , the empty meet: every claim holds vacuously, since no run gets there. MFP need not agree: in a may problem an unreachable block that generates a fact still sends it to its successors in every solution of the equations, while MOP does not count it.
Non-example: the meet over runs. The meet over the paths that some input actually follows is more precise than MOP, as in the example of two branches on the same condition. But deciding which paths can run is undecidable in general, by Rice's theorem, so this is not a definition that any analysis can compute; MOP is the ideal relative to the CFG.
Non-example: the meet over valid paths. Across procedures, a CFG path that enters a callee from one call site and returns to another call site is not a real path. The interprocedural ideal is the meet over valid paths only, with matched calls and returns. The IFDS framework computes it exactly for distributive problems over finite sets.
Related definitions
- Maximal fixed-point solution: the greatest solution of the equations, what iterative solvers compute.
- MOP-MFP coincidence theorem: MFP = MOP for distributive frameworks.
- Distributive dataflow framework and monotone dataflow framework: the classes of problems.
- Collecting semantics: the set of all states at each point, of which MOP is an abstraction that treats paths separately.
- Undecidability: why neither the meet over runs nor, for some monotone frameworks, the meet over CFG paths can be computed.
References
- Gary A. Kildall, A unified approach to global program optimization, Proceedings of the 1st ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL 1973), 194-206, the whole paper (the meet over all paths to a node as the meaning of a solution, and the proof that the iterative algorithm reaches it for distributive functions)
- John B. Kam and Jeffrey D. Ullman, Monotone data flow analysis frameworks, Acta Informatica 7(3), 1977, 305-317, the whole paper (the MOP solution of a monotone framework, MFP below MOP, and the proof that no algorithm computes the MOP solution of every instance of every monotone framework)
- Alfred V. Aho, Monica S. Lam, Ravi Sethi and Jeffrey D. Ullman, Compilers, Principles, Techniques, and Tools, second edition, Pearson Addison-Wesley, 2007, Section 9.3.4 (Meaning of a Data-Flow Solution, the ideal solution, the meet-over-paths solution and the maximum fixed point)
- Flemming Nielson, Hanne Riis Nielson and Chris Hankin, Principles of Program Analysis, Springer, 1999, Section 2.4 (Equation Solving, the MOP solution and its relation to the MFP solution), stated with a join
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag Y54EPM Edit this page History Report an error Markdown