compiler/cmm/Hoopl/Dataflow.hs¶
Note [Unreachable blocks]¶
A block that is not in the domain of tfb_fbase is “currently unreachable”. A currently-unreachable block is not even analyzed. Reason: consider constant prop and this graph, with entry point L1:
L1: x:=3; goto L4 L2: x:=4; goto L4 L4: if x>3 goto L2 else goto L5
Here L2 is actually unreachable, but if we process it with bottom input fact, we’ll propagate (x=4) to L4, and nuke the otherwise-good rewriting of L4.
If a currently-unreachable block is not analyzed, then its rewritten graph will not be accumulated in tfb_rg. And that is good: unreachable blocks simply do not appear in the output.
Note that clients must be careful to provide a fact (even if bottom) for each entry point. Otherwise useful blocks may be garbage collected.
Note that updateFact must set the change-flag if a label goes from not-in-fbase to in-fbase, even if its fact is bottom. In effect the real fact lattice is
UNR bottom the points above bottom
Even if the fact is going from UNR to bottom, we still call the client’s fact_join function because it might give the client some useful debugging information.
All of this only applies for forward ixpoints. For the backward case we must treat every block as reachable; it might finish with a ‘return’, and therefore have no successors, for example.