public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix dead_debug_insert_before ICE (PR debug/49522)
@ 2011-07-04 17:29 Jakub Jelinek
  2011-07-05  8:51 ` Eric Botcazou
  0 siblings, 1 reply; 8+ messages in thread
From: Jakub Jelinek @ 2011-07-04 17:29 UTC (permalink / raw)
  To: gcc-patches

Hi!

In dead_debug_* we don't immediately rescan insns, because that kills all
the df links we need to use, only queue their rescanning.

There are two kinds of changes we do on the debug insns without immediate
rescanning:
1) reset the debug insn
2) replace a reg use with DEBUG_EXPR of the same mode or
   subreg of a larger DEBUG_EXPR with the same outer mode as the reg

In the attached testcase on arm a debug insn is reset, because a multi-reg
register has been used there and as the debug insn location was that
multi-reg register before, it is now VOIDmode after the reset - (clobber
(const_int 0)).  Fixed by disregarding the reset debug insns.  Changes
of kind 2) that needed rescanning don't need this, as the mode doesn't
change in that case.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.6?

2011-07-04  Jakub Jelinek  <jakub@redhat.com>

	PR debug/49522
	* df-problems.c (dead_debug_insert_before): Ignore uses
	where the use debug insn has been reset.

	* gcc.dg/debug/pr49522.c: New test.

--- gcc/df-problems.c.jj	2011-06-17 11:02:19.000000000 +0200
+++ gcc/df-problems.c	2011-07-04 10:46:42.000000000 +0200
@@ -3148,6 +3148,7 @@ dead_debug_insert_before (struct dead_de
   struct dead_debug_use *cur;
   struct dead_debug_use *uses = NULL;
   struct dead_debug_use **usesp = &uses;
+  bool no_reg_ok = false;
   rtx reg = NULL;
   rtx dval;
   rtx bind;
@@ -3161,6 +3162,21 @@ dead_debug_insert_before (struct dead_de
     {
       if (DF_REF_REGNO (cur->use) == uregno)
 	{
+	  /* If cur->use insn has been meanwhile reset, but hasn't been
+	     rescanned, just ignore that use.  */
+	  if (DF_REF_REAL_LOC (cur->use)
+	      == &INSN_VAR_LOCATION_LOC (DF_REF_INSN (cur->use))
+	      && VAR_LOC_UNKNOWN_P (*DF_REF_REAL_LOC (cur->use)))
+	    {
+	      gcc_assert (debug->to_rescan != NULL
+			  && bitmap_bit_p (debug->to_rescan,
+					   INSN_UID (DF_REF_INSN (cur->use))));
+	      *tailp = cur->next;
+	      XDELETE (cur);
+	      if (!reg)
+		no_reg_ok = true;
+	      continue;
+	    }
 	  *usesp = cur;
 	  usesp = &cur->next;
 	  *tailp = cur->next;
@@ -3174,6 +3190,9 @@ dead_debug_insert_before (struct dead_de
 	tailp = &(*tailp)->next;
     }
 
+  if (no_reg_ok && !reg)
+    return;
+
   gcc_assert (reg);
 
   /* Create DEBUG_EXPR (and DEBUG_EXPR_DECL).  */
--- gcc/testsuite/gcc.dg/debug/pr49522.c.jj	2011-07-04 10:54:23.000000000 +0200
+++ gcc/testsuite/gcc.dg/debug/pr49522.c	2011-07-04 10:54:02.000000000 +0200
@@ -0,0 +1,41 @@
+/* PR debug/49522 */
+/* { dg-do compile } */
+/* { dg-options "-fcompare-debug" } */
+
+int val1 = 0L;
+volatile int val2 = 7L;
+long long val3;
+int *ptr = &val1;
+
+static int
+func1 ()
+{
+  return 0;
+}
+
+static short int
+func2 (short int a, unsigned int b)
+{
+  return !b ? a : a >> b;
+}
+
+static unsigned long long
+func3 (unsigned long long a, unsigned long long b)
+{
+  return !b ? a : a % b;
+}
+
+void
+func4 (unsigned short arg1, int arg2)
+{
+  for (arg2 = 0; arg2 < 2; arg2++)
+    {
+      *ptr = func3 (func3 (10, func2 (val3, val2)), val3);
+      for (arg1 = -14; arg1 > 14; arg1 = func1 ())
+	{
+	  *ptr = -1;
+	  if (foo ())
+	    ;
+	}
+    }
+}

	Jakub

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-07-07 15:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-04 17:29 [PATCH] Fix dead_debug_insert_before ICE (PR debug/49522) Jakub Jelinek
2011-07-05  8:51 ` Eric Botcazou
2011-07-05 20:12   ` Jakub Jelinek
2011-07-06 19:48     ` [PATCH] Fix dead_debug_insert_before ICE (PR debug/49522, take 2) Jakub Jelinek
2011-07-06 20:55       ` Eric Botcazou
2011-07-07 10:27         ` [PATCH] Fix dead_debug_insert_before ICE (PR debug/49522, take 3) Jakub Jelinek
2011-07-07 15:53           ` Eric Botcazou
2011-07-06 20:36     ` [PATCH] Fix dead_debug_insert_before ICE (PR debug/49522) 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).