public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-4531] Fix PR middle-end/102764
@ 2021-10-20  8:47 Eric Botcazou
  0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2021-10-20  8:47 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:972ee845f54839e9bd2e4611bb268d75440f3845

commit r12-4531-g972ee845f54839e9bd2e4611bb268d75440f3845
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Wed Oct 20 10:42:56 2021 +0200

    Fix PR middle-end/102764
    
    This is a regression present on the mainline in the form of -fcompare-debug
    failure at -O3 on a compiler-generated testcase.  Fixed by disregarding a
    debug statement in the last position of a basic block to reset the current
    location for the outgoing edges.
    
    gcc/
            PR middle-end/102764
            * cfgexpand.c (expand_gimple_basic_block): Disregard a final debug
            statement to reset the current location for the outgoing edges.
    
    gcc/testsuite/
            * gcc.dg/pr102764.c: New test.

Diff:
---
 gcc/cfgexpand.c                 |  2 +-
 gcc/testsuite/gcc.dg/pr102764.c | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 03260b019e5..8b067f9d848 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -6090,7 +6090,7 @@ expand_gimple_basic_block (basic_block bb, bool disable_tail_calls)
   /* Expand implicit goto and convert goto_locus.  */
   FOR_EACH_EDGE (e, ei, bb->succs)
     {
-      if (e->goto_locus != UNKNOWN_LOCATION || !stmt)
+      if (e->goto_locus != UNKNOWN_LOCATION || !stmt || is_gimple_debug (stmt))
 	set_curr_insn_location (e->goto_locus);
       if ((e->flags & EDGE_FALLTHRU) && e->dest != bb->next_bb)
 	{
diff --git a/gcc/testsuite/gcc.dg/pr102764.c b/gcc/testsuite/gcc.dg/pr102764.c
new file mode 100644
index 00000000000..ea1c634c73c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr102764.c
@@ -0,0 +1,14 @@
+/* PR middle-end/102764 */
+/* Reported by Chengnian Sun <cnsun@uwaterloo.ca> */
+
+/* { dg-do compile } */
+/* { dg-options "-O3 -fcompare-debug" } */
+
+volatile int a;
+
+void main (void)
+{
+  for (int i = 0; i < 1000; i++)
+    if (i % 17)
+      a++;
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-20  8:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-20  8:47 [gcc r12-4531] Fix PR middle-end/102764 Eric Botcazou

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).