FlattenCFG may erase unnecessary blocks, which also invalidates iterators to those erased blocks.
Before this patch, iterativelyFlattenCFG could try to increment a BB iterator after that BB has been removed and crash.
This patch makes FlattenCFGPass use WeakVH to skip over erased blocks.