1. We get a list of all the blocks B dominates via get_dominated_by
instead of walking all the blocks checking get_immediate_dominator.
This avoids two walks over all the basic blocks and a boatload of
calls to get_immediate_dominator.
2. Immediate dominators are invariant when computing the dominance
frontiers. So we build a little cache of them so that looking up
the immediate dominator for a block is an array index rather than
a full blown function call. This saves some time as well.
If you look, you'll notice i already added a cache inside
get_immediate_dominator.