]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-cfg: Fix up gimple_merge_blocks FORCED_LABEL handling [PR99034]
authorJakub Jelinek <jakub@redhat.com>
Fri, 19 Feb 2021 11:14:39 +0000 (12:14 +0100)
committerJakub Jelinek <jakub@redhat.com>
Fri, 19 Mar 2021 23:27:50 +0000 (00:27 +0100)
commit33be24d77d3d8f0c992eb344ce63f78e14cf753d
treec6cbc3e61a8179a9052ae6c64569454da0a1f67c
parent3d7ce7ce6c03165ca1041b38e02428c925254968
tree-cfg: Fix up gimple_merge_blocks FORCED_LABEL handling [PR99034]

The verifiers require that DECL_NONLOCAL or EH_LANDING_PAD_NR
labels are always the first label if there is more than one label.

When merging blocks, we don't honor that though.
On the following testcase, we try to merge blocks:
<bb 13> [count: 0]:
<L2>:
S::~S (&s);

and
<bb 15> [count: 0]:
<L0>:
resx 1

where <L2> is landing pad and <L0> is FORCED_LABEL.  And the code puts
the FORCED_LABEL before the landing pad label, violating the verification
requirements.

The following patch fixes it by moving the FORCED_LABEL after the
DECL_NONLOCAL or EH_LANDING_PAD_NR label if it is the first label.

2021-02-19  Jakub Jelinek  <jakub@redhat.com>

PR ipa/99034
* tree-cfg.c (gimple_merge_blocks): If bb a starts with eh landing
pad or non-local label, put FORCED_LABELs from bb b after that label
rather than before it.

* g++.dg/opt/pr99034.C: New test.

(cherry picked from commit 37bde2f87267908a93c07856317a28827f8284f7)
gcc/testsuite/g++.dg/opt/pr99034.C [new file with mode: 0644]
gcc/tree-cfg.c