re PR debug/46387 (ICE in add_stores, at var-tracking.c:5415)
authorJakub Jelinek <jakub@redhat.com>
Mon, 15 Nov 2010 20:07:39 +0000 (21:07 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 15 Nov 2010 20:07:39 +0000 (21:07 +0100)
PR debug/46387
* rtl.h (vt_equate_reg_base_value): New prototype.
* alias.c (vt_equate_reg_base_value): New function.
* var-tracking.c (vt_init_cfa_base): Use it.

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

From-SVN: r166766

gcc/ChangeLog
gcc/alias.c
gcc/rtl.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr46387.c [new file with mode: 0644]
gcc/var-tracking.c

index 26dff01113e0d84146e5bfd4c924901966d2aa1b..fc7c8d10acd3104b965d887566b1ec4c01d656bd 100644 (file)
@@ -1,3 +1,10 @@
+2010-11-15  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/46387
+       * rtl.h (vt_equate_reg_base_value): New prototype.
+       * alias.c (vt_equate_reg_base_value): New function.
+       * var-tracking.c (vt_init_cfa_base): Use it.
+
 2010-11-15  Jan Hubicka  <jh@suse.cz>
            Diego Novillo  <dnovillo@google.com>
 
index 2e0ac06ce44219980785ac408455fd5d84422c24..2a877979417ac89f0491ff1b31added425636eef 100644 (file)
@@ -2906,6 +2906,15 @@ init_alias_analysis (void)
   timevar_pop (TV_ALIAS_ANALYSIS);
 }
 
+/* Equate REG_BASE_VALUE (reg1) to REG_BASE_VALUE (reg2).
+   Special API for var-tracking pass purposes.  */
+
+void
+vt_equate_reg_base_value (const_rtx reg1, const_rtx reg2)
+{
+  VEC_replace (rtx, reg_base_value, REGNO (reg1), REG_BASE_VALUE (reg2));
+}
+
 void
 end_alias_analysis (void)
 {
index 3e1df2c9bd98d5bb1cd0d5fe2a9014e78b410e6c..66751a6785478276fbe15567f1e97503c4a1e8d8 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2503,6 +2503,7 @@ extern int may_alias_p (const_rtx, const_rtx);
 extern void init_alias_target (void);
 extern void init_alias_analysis (void);
 extern void end_alias_analysis (void);
+extern void vt_equate_reg_base_value (const_rtx, const_rtx);
 extern bool memory_modified_in_insn_p (const_rtx, const_rtx);
 extern rtx find_base_term (rtx);
 extern rtx gen_hard_reg_clobber (enum machine_mode, unsigned int);
index c855ae3aa039332b981652d965b9a081da8924c5..5b8a56e08b0b2ad71818785981d59da0cf588da2 100644 (file)
@@ -1,3 +1,8 @@
+2010-11-15  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/46387
+       * gcc.dg/pr46387.c: New test.
+
 2010-11-15  Nicola Pero  <nicola.pero@meta-innovation.com>
 
        * objc.dg/property/dotsyntax-16.m: New.
diff --git a/gcc/testsuite/gcc.dg/pr46387.c b/gcc/testsuite/gcc.dg/pr46387.c
new file mode 100644 (file)
index 0000000..e06bd3b
--- /dev/null
@@ -0,0 +1,32 @@
+/* PR debug/46387 */
+/* { dg-do compile } */
+/* { dg-options "-g -O2" } */
+
+struct S { double x; double y; short z; };
+int a = 0, b = 0, c;
+void bar (int, int, int);
+void baz (int *, int *, int *);
+
+void
+foo (struct S *v)
+{
+  int x, y, z;
+  if (!a && b != 0)
+    return;
+  if (v->z)
+    baz (&x, &y, &z);
+  else
+    {
+      x = v->x;
+      y = v->y;
+    }
+  x = x / (5 + 1);
+  y = y / (5 + 1);
+  if (x < 0)
+    x = 0;
+  if (x > c - 1)
+    x = c - 1;
+  if (b == 0)
+    bar (x, y, 1);
+  return;
+}
index 5967ddfd4e29b3ccc3c07d87e22671091bdf5997..85847f0263f3def4f60cdb5e87919aaf0eb01151 100644 (file)
@@ -8230,6 +8230,11 @@ vt_init_cfa_base (void)
   if (!MAY_HAVE_DEBUG_INSNS)
     return;
 
+  /* Tell alias analysis that cfa_base_rtx should share
+     find_base_term value with stack pointer or hard frame pointer.  */
+  vt_equate_reg_base_value (cfa_base_rtx,
+                           frame_pointer_needed
+                           ? hard_frame_pointer_rtx : stack_pointer_rtx);
   val = cselib_lookup_from_insn (cfa_base_rtx, GET_MODE (cfa_base_rtx), 1,
                                 get_insns ());
   preserve_value (val);