]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fix -fcompare-debug issue in delete_insn_and_edges [PR94618]
authorJakub Jelinek <jakub@redhat.com>
Fri, 17 Apr 2020 08:33:27 +0000 (10:33 +0200)
committerJakub Jelinek <jakub@redhat.com>
Fri, 17 Apr 2020 08:33:27 +0000 (10:33 +0200)
commitc41884a09206be0e21cad7eea71b9754daa969d4
tree9a197fc01c6e4fa97c82c78963dc71548fbe50e0
parentc58cb6ac6891886b7aa01c440ac71a5e7cbcba97
Fix -fcompare-debug issue in delete_insn_and_edges [PR94618]

delete_insn_and_edges calls purge_dead_edges whenever deleting the last insn
in a bb, whatever it is.  If it called it only for mandatory last insns
in the basic block (that may not be followed by DEBUG_INSNs, dunno if that
is control_flow_insn_p or something more complex), that wouldn't be a
problem, but as it calls it on any last insn and can actually do something
in the bb, if such an insn is followed by one more more DEBUG_INSNs and
nothing else in the same bb, we don't call purge_dead_edges with -g and do
call it with -g0.

On the testcase, there are two reg-to-reg moves with REG_EH_REGION notes
(previously memory accesses but simplified and yet not optimized), and the
second is followed by DEBUG_INSNs; the second move is delete_insn_and_edges
and after removing it, for -g0 purge_dead_edges removes the REG_EH_REGION
from the now last insn in the bb (the first reg-to-reg move), while
for -g it isn't called and things diverge from that quickly on.

Fixed by calling purdge_dead_edges even if we remove the last real insn
followed only by DEBUG_INSNs in the same bb.

2020-04-17  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/94618
* cfgrtl.c (delete_insn_and_edges): Set purge not just when
insn is the BB_END of its block, but also when it is only followed
by DEBUG_INSNs in its block.

* g++.dg/opt/pr94618.C: New test.
gcc/ChangeLog
gcc/cfgrtl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr94618.C [new file with mode: 0644]