This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix -fcompare-debug bugs during updating into loop closed ssa form (PR debug/80436)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Biener <rguenther at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 19 Apr 2017 15:55:19 +0200
- Subject: [PATCH] Fix -fcompare-debug bugs during updating into loop closed ssa form (PR debug/80436)
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9DA584E4CA
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9DA584E4CA
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
-fcompare-debug fails on the following testcase, because during loop
splitting we attempt to switch into loop closed SSA form and use
also debug stmt uses in those decisions, which is wrong.
Looking at the rest of tree-ssa-loop-manip.c, both find_uses_to_rename_stmt
and check_loop_closed_ssa_stmt ignore debug stmts, this patch just adds
that to another spot. Without it a new SSA_NAME is created (only with -g)
and then soon (in the next pass) removed again because DCE sees it as
dead (it has no non-debug uses) and is replaced by the definition from the
loop again.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2017-04-19 Jakub Jelinek <jakub@redhat.com>
PR debug/80436
* tree-ssa-loop-manip.c (find_uses_to_rename_def): Ignore debug uses.
* g++.dg/opt/pr80436.C: New test.
--- gcc/tree-ssa-loop-manip.c.jj 2017-02-27 15:19:12.000000000 +0100
+++ gcc/tree-ssa-loop-manip.c 2017-04-19 09:47:30.768610273 +0200
@@ -494,6 +494,9 @@ find_uses_to_rename_def (tree def, bitma
FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, def)
{
+ if (is_gimple_debug (use_stmt))
+ continue;
+
basic_block use_bb = gimple_bb (use_stmt);
use_operand_p use_p;
--- gcc/testsuite/g++.dg/opt/pr80436.C.jj 2017-04-19 09:54:59.370714079 +0200
+++ gcc/testsuite/g++.dg/opt/pr80436.C 2017-04-19 09:56:28.003549930 +0200
@@ -0,0 +1,42 @@
+// PR debug/80436
+// { dg-do compile { target c++11 } }
+// { dg-options "-O3 -fcompare-debug" }
+
+void fn (...);
+void foo (int, int, int);
+struct { int elt1; int bits; } *a;
+int b, d;
+
+int
+bar (unsigned *x)
+{
+ if (0)
+ next_bit:
+ return 1;
+ while (1)
+ {
+ if (b)
+ if (a->bits)
+ goto next_bit;
+ *x = b;
+ if (a->elt1)
+ return 0;
+ a = 0;
+ }
+}
+
+enum { C0, C1 } *c;
+
+void
+baz ()
+{
+ int e, m = d;
+ for (; e < m; e++)
+ {
+ if (e < 0)
+ foo (0, 0, c[e]);
+ unsigned f;
+ for (; bar (&f);)
+ fn (f);
+ }
+}
Jakub