diff mbox

[committed] Fix promote_debug_loc (PR debug/49544)

Message ID 20110627164946.GD16443@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek June 27, 2011, 4:49 p.m. UTC
Hi!

When I've added adding subregs of wider value to cselib_lookup_1
in http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174508, I've mistakenly
only adjusted the assertion, while we need in that case to adjust
the second location's setting_insn as well.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
committed to trunk as obvious.

2011-06-27  Jakub Jelinek  <jakub@redhat.com>

	PR debug/49544
	* cselib.c (promote_debug_loc): If cselib_preserve_constants
	and l has two DEBUG_INSN owned locs instead of just one, adjust
	the second location's setting_insn too.

	* gcc.dg/pr49544.c: New test.


	Jakub
diff mbox

Patch

--- gcc/cselib.c.jj	2011-06-27 11:21:17.000000000 +0200
+++ gcc/cselib.c	2011-06-27 13:34:11.000000000 +0200
@@ -257,7 +257,15 @@  promote_debug_loc (struct elt_loc_list *
     {
       n_debug_values--;
       l->setting_insn = cselib_current_insn;
-      gcc_assert (!l->next || cselib_preserve_constants);
+      if (cselib_preserve_constants && l->next)
+	{
+	  gcc_assert (l->next->setting_insn
+		      && DEBUG_INSN_P (l->next->setting_insn)
+		      && !l->next->next);
+	  l->next->setting_insn = cselib_current_insn;
+	}
+      else
+	gcc_assert (!l->next);
     }
 }
 
--- gcc/testsuite/gcc.dg/pr49544.c.jj	2011-06-27 15:00:33.000000000 +0200
+++ gcc/testsuite/gcc.dg/pr49544.c	2011-06-27 15:00:13.000000000 +0200
@@ -0,0 +1,19 @@ 
+/* PR debug/49544 */
+/* { dg-do compile } */
+/* { dg-options "-g -O2" } */
+
+int baz (int, int, void *);
+
+static inline __attribute__ ((always_inline)) long
+foo (int x, int y, void *z)
+{
+  if (y < 0)
+    return baz (x, y, z);
+  return 0;
+}
+
+long
+bar (long x, long y, long z)
+{
+  return foo (x, y, (void *) z);
+}