]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-inline: Fix a -fcompare-debug issue in the inliner [PR94167]
authorJakub Jelinek <jakub@redhat.com>
Mon, 16 Mar 2020 08:03:59 +0000 (09:03 +0100)
committerJakub Jelinek <jakub@redhat.com>
Tue, 17 Mar 2020 17:24:28 +0000 (18:24 +0100)
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.

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr94167.c [new file with mode: 0644]
gcc/tree-inline.c

index dfb83c5adf6bc4d8bb0793ea906abdad02f6ee76..6e05c9699938a45394d3d3e9cb9c533a48f38bc1 100644 (file)
@@ -1,6 +1,12 @@
 2020-03-17  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2020-03-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/94167
+       * tree-inline.c (insert_init_stmt): Don't gimple_regimplify_operands
+       DEBUG_STMTs.
+
        2020-03-14  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/93566
index 10026d55a584706f6001c9c480c2a985bf26b53c..522a7608203d4363462042a26a0e858609dc77fd 100644 (file)
@@ -1,6 +1,11 @@
 2020-03-17  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2020-03-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/94167
+       * gcc.dg/pr94167.c: New test.
+
        2020-03-12  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/94130
diff --git a/gcc/testsuite/gcc.dg/pr94167.c b/gcc/testsuite/gcc.dg/pr94167.c
new file mode 100644 (file)
index 0000000..4b819d3
--- /dev/null
@@ -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;
+    }
+}
index 7ba2ebf3695153d32f64b2717b0d302e573b7188..7a41f64bcc34a1c12cfc76ef7238d0471533bd93 100644 (file)
@@ -3213,10 +3213,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);
        }