Fix invalid reads in valgrind during unused basic block collections
When clearing cross-references to unused basic blocks blocks, don't
delete the block right afterwards because another block might also
still reference it. Instead keep track of the ones to be deleted
and delete them afterwards in one shot.
Also replaces the existance check for the blocks from a linear
vector search to a hash set lookup which we already have around.
Change-Id: I3bd72359259065ba26bf2116bf849575e4601f32
Reviewed-by: Lars Knoll <lars.knoll@digia.com>