public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/redhat/heads/gcc-8-branch)] tree-inline: Fix a -fcompare-debug issue in the inliner [PR94167]
@ 2020-09-17 17:20 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2020-09-17 17:20 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d40d927eb0eb6b98b3a97b245e3e9c48c8f46bb8

commit d40d927eb0eb6b98b3a97b245e3e9c48c8f46bb8
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Mon Mar 16 09:03:59 2020 +0100

    tree-inline: Fix a -fcompare-debug issue in the inliner [PR94167]
    
    The following testcase fails with -fcompare-debug.  The problem is that
    bar is marked as address_taken only with -g and not without.
    I've tracked it down to insert_init_stmt calling gimple_regimplify_operands
    even on DEBUG_STMTs.  That function will just insert normal stmts before
    the DEBUG_STMT if the DEBUG_STMT operand isn't gimple val or invariant.
    While DCE will turn those statements into debug temporaries, it can cause
    differences in SSA_NAMEs and more importantly, the ipa references are
    generated from those before the DCE happens.
    On the testcase, the DEBUG_STMT value is (int)bar.
    
    We could generate DEBUG_STMTs with debug temporaries instead, but I fail to
    see the reason to do that, DEBUG_STMTs allow other expressions and all we
    want to ensure is that the expressions aren't too large (arbitrarily
    complex), but during inlining/function versioning I don't see why something
    would queue a DEBUG_STMT with arbitrarily complex expressions in there.
    
    2020-03-16  Jakub Jelinek  <jakub@redhat.com>
    
            PR debug/94167
            * tree-inline.c (insert_init_stmt): Don't gimple_regimplify_operands
            DEBUG_STMTs.
    
            * gcc.dg/pr94167.c: New test.
    
    (cherry picked from commit 378e830538afd4a02e41674cc9161fa59b5e09a9)

Diff:
---
 gcc/testsuite/gcc.dg/pr94167.c | 33 +++++++++++++++++++++++++++++++++
 gcc/tree-inline.c              |  4 ++--
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/pr94167.c b/gcc/testsuite/gcc.dg/pr94167.c
new file mode 100644
index 00000000000..4b819d3a869
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr94167.c
@@ -0,0 +1,33 @@
+/* PR debug/94167 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fcompare-debug" } */
+
+struct S { int g, h; signed char i; int j; signed char k; int l[4]; } a, c;
+struct T { signed char g; } e;
+int *b, d;
+static void foo ();
+
+void
+bar (void)
+{
+  while (d)
+    {
+      int k;
+      struct T f[3];
+      foo (bar, a);
+      for (k = 0;; k++)
+	f[k] = e;
+    }
+}
+
+static inline void
+foo (int x, struct S y, struct T z)
+{
+  for (z.g = 2; z.g; z.g--)
+    {
+      c = a = y;
+      *b |= 6;
+      if (y.g)
+	break;
+    }
+}
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index cd7e477337a..715b1a18f8d 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -3177,10 +3177,10 @@ insert_init_stmt (copy_body_data *id, basic_block bb, gimple *init_stmt)
 	  gimple_assign_set_rhs1 (init_stmt, rhs);
 	}
       gsi_insert_after (&si, init_stmt, GSI_NEW_STMT);
-      gimple_regimplify_operands (init_stmt, &si);
-
       if (!is_gimple_debug (init_stmt))
 	{
+	  gimple_regimplify_operands (init_stmt, &si);
+
 	  tree def = gimple_assign_lhs (init_stmt);
 	  insert_init_debug_bind (id, bb, def, def, init_stmt);
 	}


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

only message in thread, other threads:[~2020-09-17 17:20 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:20 [gcc(refs/vendors/redhat/heads/gcc-8-branch)] tree-inline: Fix a -fcompare-debug issue in the inliner [PR94167] 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).