Hi!

To avoid -fcompare-debug failures, we promote_debug_loc VALUEs looked
up from DEBUG_INSNs when they are looked from some other insns.
Unfortunately, the scheduler after cselib_lookup_from_insn from
DEBUG_INSN calls cselib_subst_to_values, which may e.g. cselib_lookup_mem
(with create=0).  As that is with cselib_current_insn == NULL,
promote_debug_loc considers it being a non-DEBUG_INSN lookup and promotes
it to non-debug, which on the testcase in the PR (too large and too hard
to further reduce) results in different n_useless_values and
remove_useless_values being triggered at different times between
-g and -g0 compilations.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
tested on the testcase with ia64-linux cross.  Ok for trunk?

2012-02-13  Jakub Jelinek  <ja...@redhat.com>

        PR bootstrap/52172
        * cselib.h (cselib_subst_to_values_from_insn): New prototype.
        * cselib.c (cselib_subst_to_values_from_insn): New function.
        * sched-deps.c (add_insn_mem_dependence,
        sched_analyze_1, sched_analyze_2): Use it.

--- gcc/cselib.h.jj     2012-01-01 19:54:46.000000000 +0100
+++ gcc/cselib.h        2012-02-13 21:29:21.792483236 +0100
@@ -88,6 +88,7 @@ extern rtx cselib_expand_value_rtx_cb (r
 extern bool cselib_dummy_expand_value_rtx_cb (rtx, bitmap, int,
                                              cselib_expand_callback, void *);
 extern rtx cselib_subst_to_values (rtx, enum machine_mode);
+extern rtx cselib_subst_to_values_from_insn (rtx, enum machine_mode, rtx);
 extern void cselib_invalidate_rtx (rtx);
 
 extern void cselib_reset_table (unsigned int);
--- gcc/cselib.c.jj     2012-02-13 18:15:17.000000000 +0100
+++ gcc/cselib.c        2012-02-13 21:33:37.019088486 +0100
@@ -1905,6 +1905,19 @@ cselib_subst_to_values (rtx x, enum mach
   return copy;
 }
 
+/* Wrapper for cselib_subst_to_values, that indicates X is in INSN.  */
+
+rtx
+cselib_subst_to_values_from_insn (rtx x, enum machine_mode memmode, rtx insn)
+{
+  rtx ret;
+  gcc_assert (!cselib_current_insn);
+  cselib_current_insn = insn;
+  ret = cselib_subst_to_values (x, memmode);
+  cselib_current_insn = NULL;
+  return ret;
+}
+
 /* Look up the rtl expression X in our tables and return the value it
    has.  If CREATE is zero, we return NULL if we don't know the value.
    Otherwise, we create a new one if possible, using mode MODE if X
--- gcc/sched-deps.c.jj 2012-01-26 09:22:21.000000000 +0100
+++ gcc/sched-deps.c    2012-02-13 21:30:40.235054596 +0100
@@ -1728,7 +1728,8 @@ add_insn_mem_dependence (struct deps_des
   if (sched_deps_info->use_cselib)
     {
       mem = shallow_copy_rtx (mem);
-      XEXP (mem, 0) = cselib_subst_to_values (XEXP (mem, 0), GET_MODE (mem));
+      XEXP (mem, 0) = cselib_subst_to_values_from_insn (XEXP (mem, 0),
+                                                       GET_MODE (mem), insn);
     }
   link = alloc_EXPR_LIST (VOIDmode, canon_rtx (mem), *mem_list);
   *mem_list = link;
@@ -2449,7 +2450,9 @@ sched_analyze_1 (struct deps_desc *deps,
          t = shallow_copy_rtx (dest);
          cselib_lookup_from_insn (XEXP (t, 0), address_mode, 1,
                                   GET_MODE (t), insn);
-         XEXP (t, 0) = cselib_subst_to_values (XEXP (t, 0), GET_MODE (t));
+         XEXP (t, 0)
+           = cselib_subst_to_values_from_insn (XEXP (t, 0), GET_MODE (t),
+                                               insn);
        }
       t = canon_rtx (t);
 
@@ -2609,7 +2612,9 @@ sched_analyze_2 (struct deps_desc *deps,
            t = shallow_copy_rtx (t);
            cselib_lookup_from_insn (XEXP (t, 0), address_mode, 1,
                                     GET_MODE (t), insn);
-           XEXP (t, 0) = cselib_subst_to_values (XEXP (t, 0), GET_MODE (t));
+           XEXP (t, 0)
+             = cselib_subst_to_values_from_insn (XEXP (t, 0), GET_MODE (t),
+                                                 insn);
          }
 
        if (!DEBUG_INSN_P (insn))

        Jakub

Reply via email to