In the jumpthreading main loop, we handle unreachable blocks generated in the middle of transformation by checking pred_empty(&BB), and delete this block. But this mechanism cannot handle all unreachable blocks: when a BB is made unreachable, it may still have a predecessor. This is true when the bb is part of a connected component and the edge from entry block to the component is removed.
This patch adds a full clean-up of unreachable blocks after the transformation.
This code is only used by the legacy pass manager, so your test case cannot be using it. You'd have to do this in runImpl() for it to apply to both the legacy and new pass manager.