adjust landing pads when changing main label
authorAlexandre Oliva <oliva@adacore.com>
Wed, 14 Jul 2021 01:25:54 +0000 (22:25 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Wed, 14 Jul 2021 01:25:54 +0000 (22:25 -0300)
commit66907e739959ff85490f1711cfd06fdf1e946945
tree079ba47d7560f6e184eba683e26294234e60043f
parent0e7754560f694b4e702baebdc481f6b0e82f7b14
adjust landing pads when changing main label

If an artificial label created for a landing pad ends up being
dropped in favor of a user-supplied label, the user-supplied label
inherits the landing pad index, but the post_landing_pad field is not
adjusted to point to the new label.

This patch fixes the problem, and adds verification that we don't
remove a label that's still used as a landing pad.

The circumstance in which this problem can be hit was unusual: removal
of a block with an unreachable label moves the label to some other
unrelated block, in case its address is taken.  In the case at hand
(pr42739.C, complicated by wrappers and cleanups), the chosen block
happened to be an EH landing pad.  (A followup patch will change that.)

for  gcc/ChangeLog

* tree-cfg.c (cleanup_dead_labels_eh): Update
post_landing_pad label upon change of landing pad block's
primary label.
(cleanup_dead_labels): Check that a removed label is not that
of a landing pad.
gcc/tree-cfg.c