diff mbox

Patch to fix PR68691

Message ID 5669BE98.10801@redhat.com
State New
Headers show

Commit Message

Vladimir Makarov Dec. 10, 2015, 6:04 p.m. UTC
The following patch fixes

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68691

   The patch was bootstrapped and tested on x86/x86-64.

   Committed as rev. 231538.
diff mbox

Patch

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 231537)
+++ ChangeLog	(working copy)
@@ -1,3 +1,9 @@ 
+2015-12-10  Vladimir Makarov  <vmakarov@redhat.com>
+
+	PR rtl-optimization/68691
+	* lra-spills.c (lra_final_code_change): Check pseudo occurrence
+	number in non-debug insns and remove debug insns if necessary.
+
 2015-12-10  Martin Sebor  <msebor@redhat.com>
 
 	* invoke.texi (Warning Options): Update -Wall options.  Clarify
Index: lra-spills.c
===================================================================
--- lra-spills.c	(revision 231423)
+++ lra-spills.c	(working copy)
@@ -708,6 +708,30 @@  lra_final_code_change (void)
 	    }
 	
 	  lra_insn_recog_data_t id = lra_get_insn_recog_data (insn);
+	  struct lra_insn_reg *reg;
+
+	  for (reg = id->regs; reg != NULL; reg = reg->next)
+	    if (reg->regno >= FIRST_PSEUDO_REGISTER
+		&& lra_reg_info [reg->regno].nrefs == 0)
+	      break;
+	  
+	  if (reg != NULL)
+	    {
+	      /* Pseudos still can be in debug insns in some very rare
+		 and complicated cases, e.g. the pseudo was removed by
+		 inheritance and the debug insn is not EBBs where the
+		 inheritance happened.  It is difficult and time
+		 consuming to find what hard register corresponds the
+		 pseudo -- so just remove the debug insn.  Another
+		 solution could be assigning hard reg/memory but it
+		 would be a misleading info.  It is better not to have
+		 info than have it wrong.  */
+	      lra_assert (DEBUG_INSN_P (insn));
+	      lra_invalidate_insn_data (insn);
+	      delete_insn (insn);
+	      continue;
+	    }
+	  
 	  struct lra_static_insn_data *static_id = id->insn_static_data;
 	  bool insn_change_p = false;
 	  
Index: testsuite/ChangeLog
===================================================================
--- testsuite/ChangeLog	(revision 231537)
+++ testsuite/ChangeLog	(working copy)
@@ -1,3 +1,8 @@ 
+2015-12-10  Vladimir Makarov  <vmakarov@redhat.com>
+
+	PR rtl-optimization/68691
+	* gcc.target/i386/pr68691.c: New.
+
 2015-12-10  David Malcolm  <dmalcolm@redhat.com>
 
 	* lib/multiline.exp (_multiline_expected_outputs): Update comment.
Index: testsuite/gcc.target/i386/pr68691.c
===================================================================
--- testsuite/gcc.target/i386/pr68691.c	(revision 0)
+++ testsuite/gcc.target/i386/pr68691.c	(working copy)
@@ -0,0 +1,42 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O3 -g" } */
+
+char a, b, i, j;
+int c, d, e, f, g, h, n;
+
+char
+fn1 ()
+{
+  char k, l, m;
+  int p;
+  e = g > f;
+  for (b = 0; b < 2; b++)
+    {
+      for (p = 0; p < 3; p++)
+	{
+	  for (; h < 1; h++)
+	    {
+	      for (; m;)
+		goto lbl;
+	      e = g;
+	    }
+	  l = a < 0 || a < d;
+	}
+      d++;
+      for (;;)
+	{
+	  k = g;
+	  n = -k;
+	  j = n;
+	  c = j;
+	  e = 2;
+	  if (l)
+	    break;
+	  return 2;
+	}
+    }
+  for (;;)
+    ;
+ lbl:
+  return i;
+}