https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123110
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The first way is adding:
```
/* If the destination block consists of a nonlocal label or is a
EH landing pad, do not merge it. */
if (glabel *label_stmt = safe_dyn_cast <glabel *> (first_stmt (dest)))
if (DECL_NONLOCAL (gimple_label_label (label_stmt))
|| EH_LANDING_PAD_NR (gimple_label_label (label_stmt)))
return false;
```
The second way is just:
gsi_to = gsi_start_bb (dest);
is replaced with:
gsi_to = gsi_after_labels (dest);
Note the reason why the second works is because we check to make sure the block
which we are going to remove does not have non-local labels or an eh landing
pad associated with it already. So we don't end up with 2 non-local labels nor
2 landing pads (or a mix).
Both are safe in terms of the IR. The second one has the advantage of removing
a forwarder block (which might even improve compile time speed and I have not
checked out that jump threading ignores forwarder blocks correctly but I think
they do which means either way is fine there).