* [PATCH] Fix -fcompare-debug issue in purge_dead_edges [PR95080]
@ 2020-05-13 8:27 Jakub Jelinek
2020-05-13 8:34 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2020-05-13 8:27 UTC (permalink / raw)
To: Richard Biener, Jeff Law; +Cc: gcc-patches, Alexandre Oliva
Hi!
The following testcase fails with -fcompare-debug, the bug used to be latent
since introduction of -fcompare-debug.
The loop at the start of purge_dead_edges behaves differently between -g0
and -g - if the last insn is a DEBUG_INSN, then it skips not just
DEBUG_INSNs but also NOTEs until it finds some other real insn (or bb head),
while with -g0 it will not skip any NOTEs, so if we have
real_insn
note
debug_insn // not present with -g0
then with -g it might remove useless REG_EH_REGION from real_insn, while
with -g0 it will not.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?
Yet another option would be not skipping NOTE_P in the loop; I couldn't find
in history rationale for why it is done.
2020-05-13 Jakub Jelinek <jakub@redhat.com>
PR debug/95080
* cfgrtl.c (purge_dead_edges): Skip over debug and note insns even
if the last insn is a note.
* g++.dg/opt/pr95080.C: New test.
--- gcc/cfgrtl.c.jj 2020-04-17 10:32:58.589780140 +0200
+++ gcc/cfgrtl.c 2020-05-12 21:02:09.808395583 +0200
@@ -3100,7 +3100,7 @@ purge_dead_edges (basic_block bb)
bool found;
edge_iterator ei;
- if (DEBUG_INSN_P (insn) && insn != BB_HEAD (bb))
+ if ((DEBUG_INSN_P (insn) || NOTE_P (insn)) && insn != BB_HEAD (bb))
do
insn = PREV_INSN (insn);
while ((DEBUG_INSN_P (insn) || NOTE_P (insn)) && insn != BB_HEAD (bb));
--- gcc/testsuite/g++.dg/opt/pr95080.C.jj 2020-05-12 21:01:09.804295824 +0200
+++ gcc/testsuite/g++.dg/opt/pr95080.C 2020-05-12 21:00:52.738551862 +0200
@@ -0,0 +1,41 @@
+// PR debug/95080
+// { dg-do compile }
+// { dg-options "-Og -fcse-follow-jumps -fnon-call-exceptions -fcompare-debug" }
+
+char *a;
+
+void baz ();
+
+static inline bool
+bar ()
+{
+ int j = a[0] - 1;
+ switch (j)
+ {
+ case 0:
+ case 2:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static inline bool
+foo ()
+{
+ if (bar ())
+ baz ();
+ return 0;
+}
+
+struct S
+{
+ int h;
+ ~S ();
+};
+
+S::~S ()
+{
+ if (a[0] == 0)
+ foo () != h;
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix -fcompare-debug issue in purge_dead_edges [PR95080]
2020-05-13 8:27 [PATCH] Fix -fcompare-debug issue in purge_dead_edges [PR95080] Jakub Jelinek
@ 2020-05-13 8:34 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2020-05-13 8:34 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Jeff Law, gcc-patches, Alexandre Oliva
On Wed, 13 May 2020, Jakub Jelinek wrote:
> Hi!
>
> The following testcase fails with -fcompare-debug, the bug used to be latent
> since introduction of -fcompare-debug.
> The loop at the start of purge_dead_edges behaves differently between -g0
> and -g - if the last insn is a DEBUG_INSN, then it skips not just
> DEBUG_INSNs but also NOTEs until it finds some other real insn (or bb head),
> while with -g0 it will not skip any NOTEs, so if we have
> real_insn
> note
> debug_insn // not present with -g0
> then with -g it might remove useless REG_EH_REGION from real_insn, while
> with -g0 it will not.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?
OK.
Thanks,
Richard.
> Yet another option would be not skipping NOTE_P in the loop; I couldn't find
> in history rationale for why it is done.
>
> 2020-05-13 Jakub Jelinek <jakub@redhat.com>
>
> PR debug/95080
> * cfgrtl.c (purge_dead_edges): Skip over debug and note insns even
> if the last insn is a note.
>
> * g++.dg/opt/pr95080.C: New test.
>
> --- gcc/cfgrtl.c.jj 2020-04-17 10:32:58.589780140 +0200
> +++ gcc/cfgrtl.c 2020-05-12 21:02:09.808395583 +0200
> @@ -3100,7 +3100,7 @@ purge_dead_edges (basic_block bb)
> bool found;
> edge_iterator ei;
>
> - if (DEBUG_INSN_P (insn) && insn != BB_HEAD (bb))
> + if ((DEBUG_INSN_P (insn) || NOTE_P (insn)) && insn != BB_HEAD (bb))
> do
> insn = PREV_INSN (insn);
> while ((DEBUG_INSN_P (insn) || NOTE_P (insn)) && insn != BB_HEAD (bb));
> --- gcc/testsuite/g++.dg/opt/pr95080.C.jj 2020-05-12 21:01:09.804295824 +0200
> +++ gcc/testsuite/g++.dg/opt/pr95080.C 2020-05-12 21:00:52.738551862 +0200
> @@ -0,0 +1,41 @@
> +// PR debug/95080
> +// { dg-do compile }
> +// { dg-options "-Og -fcse-follow-jumps -fnon-call-exceptions -fcompare-debug" }
> +
> +char *a;
> +
> +void baz ();
> +
> +static inline bool
> +bar ()
> +{
> + int j = a[0] - 1;
> + switch (j)
> + {
> + case 0:
> + case 2:
> + return true;
> + default:
> + return false;
> + }
> +}
> +
> +static inline bool
> +foo ()
> +{
> + if (bar ())
> + baz ();
> + return 0;
> +}
> +
> +struct S
> +{
> + int h;
> + ~S ();
> +};
> +
> +S::~S ()
> +{
> + if (a[0] == 0)
> + foo () != h;
> +}
>
> Jakub
>
>
--
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-13 8:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-13 8:27 [PATCH] Fix -fcompare-debug issue in purge_dead_edges [PR95080] Jakub Jelinek
2020-05-13 8:34 ` Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).