When we build the walk across these DAG's we need to be able to reach every node
from the roots. Flip and traversal edges (so that use->def becomes def->uses)
that make nodes unreachable. Note that early on we'll just error out on these
flipped edges as def->uses edges are more complicated to match due to their
one->many nature.
Depends on D69077
During an off-list review it was pointed out that this is quadratic in the worst case. I haven't fixed that yet but I don't think it's likely to be an issue in practice. This is partly due to the DAG's tending to be small (1-5 instr nodes) but is mostly due to the common case for the shape of the DAG.
The quadratic case is a 'straight-line' DAG of the form:
which can occasionally occur but is rarely more than 3 nodes long. The best case is a fan-out like:
which is linear but most DAGs will be roughly nlogn. For example:
If it becomes a bottleneck then I can improve this