public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/redhat/heads/gcc-8-branch)] Fix -fcompare-debug issue in purge_dead_edges [PR95080]
@ 2020-09-17 17:23 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2020-09-17 17:23 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:3863112b91d354f0a028e806cfe2678c8552b051
commit 3863112b91d354f0a028e806cfe2678c8552b051
Author: Jakub Jelinek <jakub@redhat.com>
Date: Wed May 13 11:22:37 2020 +0200
Fix -fcompare-debug issue in purge_dead_edges [PR95080]
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.
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.
(cherry picked from commit 18edc195442291525e04f0fa4d5ef972155117da)
Diff:
---
gcc/cfgrtl.c | 2 +-
gcc/testsuite/g++.dg/opt/pr95080.C | 41 ++++++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index d15f94ec6dc..261aa5078e7 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -3051,7 +3051,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));
diff --git a/gcc/testsuite/g++.dg/opt/pr95080.C b/gcc/testsuite/g++.dg/opt/pr95080.C
new file mode 100644
index 00000000000..2da7df73b72
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr95080.C
@@ -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;
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-17 17:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 17:23 [gcc(refs/vendors/redhat/heads/gcc-8-branch)] Fix -fcompare-debug issue in purge_dead_edges [PR95080] Jakub Jelinek
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).