Backport CFG simplification pass from XLA backend
Right now we don't do too much CFG simplification (esp since
we turned off doing so for constant folded branches). This
isn't too much of a problem, because LLVM is very good at
cutting down any excess basic block we happen to emit.
However, for non-SSA backends, excess CFG can be a
significant problem that the backend may not be able
to optimize away (even if it's trivial at the Julia
IR level). Plus it's annoying for humans to read.
The XLA backend had a simple CFG simplification pass.
Backport this pass to Base, so it can live alongside
the code it depends on (it has a fairly close dependency
on the details of the CFG and IncrementalCompact).
As it stands, I don't think it's useful to have this
pass in the default compiler pipeline (both because
LLVM can handle it easily and because our round-trip
to statement based representations cleans up some
of this), but I do think it's useful interactively
and for non-standard compiler backends. We should
re-evaluate whether to put this in the standard
compiler pipeline once we re-enable the CFG
transformations of constant folded conditions. If
that ends up leaving a lot of basic block chains
around, it might yet be worth putting this in.