diff mbox

Improve debug info for partial inlining (PR debug/54519, take 2)

Message ID 20121004073137.GX1787@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Oct. 4, 2012, 7:31 a.m. UTC
On Thu, Oct 04, 2012 at 01:31:08AM -0300, Alexandre Oliva wrote:
> On Oct  3, 2012, Jakub Jelinek <jakub@redhat.com> wrote:
> 
> > basically there is a non-addressable parameter in stack slot, and
> > vt_canon_true_dep -> canon_true_dependence thinks an argument push
> > insn might alias with it, because it doesn't have a MEM_EXPR and
> > ao_ref_from_mem fails.
> 
> I have a pending (still unreviewed) patch that might address :-), so to
> speak, this problem.

This is PR54796 now btw.

> for  gcc/ChangeLog
> from  Alexandre Oliva  <aoliva@redhat.com>
> 
> 	PR debug/53671
> 	PR debug/49888
> 	* var-tracking.c (attrs_list_by_loc_eq): New.
> 	(track_stack_pointer): New.
> 	(dataflow_set_merge): Use it.
> 	(vt_initialize): Record the initial stack pointer in the
> 	dataflow set.

Unfortunately this patch makes this significantly worse, not better.
The change from stock gcc for pr54796.c testcase (or for pr54519-3.c
testcase with the two PR54519 patches) to one with this patch applied
additionally is (with -m32 -Os -g) that argp based var_locations are
gone, replaced by sp based locations, which change on every sp change.
That results in bigger debug info, as for argp we use the compact
DW_OP_fbreg, while otherwise we end up with longish location lists.
And the clobber_overlapping_mems resets are the same as before on
the testcases.

What I meant in the PR54796 comments is something like this untested patch.
Unfortunately it needs work, on the two testcases it seems to unfortunately
results in more clobber_overlapping_mems resets in the prologues (before hfp
is set), then fewer resets in the rest of the function (so, in pr54796.c the
net effect is partial improvement (previously none of a, b, c vars at line
17 could be printed, now a and c can, b was reset in the prologue and
can't), on pr54519-3.c y and z in the second case are still unavailable, but
newly also unavailable in the first case where they were previously
available).



	Jakub
diff mbox

Patch

--- gcc/cselib.h.jj	2012-03-06 17:02:12.000000000 +0100
+++ gcc/cselib.h	2012-10-04 08:42:04.879335722 +0200
@@ -99,6 +99,8 @@  extern void cselib_preserve_only_values
 extern void cselib_preserve_cfa_base_value (cselib_val *, unsigned int);
 extern void cselib_add_permanent_equiv (cselib_val *, rtx, rtx);
 extern bool cselib_have_permanent_equivalences (void);
+extern void cselib_set_value_sp_based (cselib_val *);
+extern bool cselib_sp_based_value_p (cselib_val *);
 
 extern void dump_cselib_table (FILE *);
 
--- gcc/alias.c.jj	2012-09-12 10:57:03.000000000 +0200
+++ gcc/alias.c	2012-10-04 08:45:22.893221350 +0200
@@ -1641,6 +1641,9 @@  find_base_term (rtx x)
       if (!val)
 	return ret;
 
+      if (cselib_sp_based_value_p (val))
+	return static_reg_base_value[STACK_POINTER_REGNUM];
+
       f = val->locs;
       /* Temporarily reset val->locs to avoid infinite recursion.  */
       val->locs = NULL;
--- gcc/cselib.c.jj	2012-08-24 23:44:03.000000000 +0200
+++ gcc/cselib.c	2012-10-04 08:45:12.722278664 +0200
@@ -210,6 +210,9 @@  void (*cselib_record_sets_hook) (rtx ins
 #define PRESERVED_VALUE_P(RTX) \
   (RTL_FLAG_CHECK1("PRESERVED_VALUE_P", (RTX), VALUE)->unchanging)
 
+#define SP_BASED_VALUE_P(RTX) \
+  (RTL_FLAG_CHECK1("SP_BASED_VALUE_P", (RTX), VALUE)->jump)
+
 
 
 /* Allocate a struct elt_list and fill in its two elements with the
@@ -739,6 +742,23 @@  cselib_preserve_only_values (void)
   gcc_assert (first_containing_mem == &dummy_val);
 }
 
+/* Arrange for a value to be marked as based on stack pointer
+   for find_base_term purposes.  */
+
+void
+cselib_set_value_sp_based (cselib_val *v)
+{
+  SP_BASED_VALUE_P (v->val_rtx) = 1;
+}
+
+/* Test whether a value is preserved.  */
+
+bool
+cselib_sp_based_value_p (cselib_val *v)
+{
+  return SP_BASED_VALUE_P (v->val_rtx);
+}
+
 /* Return the mode in which a register was last set.  If X is not a
    register, return its mode.  If the mode in which the register was
    set is not known, or the value was already clobbered, return
--- gcc/var-tracking.c.jj	2012-10-03 09:01:36.297902370 +0200
+++ gcc/var-tracking.c	2012-10-04 09:05:58.294277166 +0200
@@ -5769,6 +5769,11 @@  add_stores (rtx loc, const_rtx expr, voi
 
   resolve = preserve = !cselib_preserved_value_p (v);
 
+  if (loc == stack_pointer_rtx
+      && hard_frame_pointer_adjustment != -1
+      && preserve)
+    cselib_set_value_sp_based (v);
+
   nloc = replace_expr_with_values (oloc);
   if (nloc)
     oloc = nloc;
--- gcc/rtl.h.jj	2012-09-28 14:16:57.000000000 +0200
+++ gcc/rtl.h	2012-09-28 14:16:57.000000000 +0200
@@ -267,7 +267,8 @@  struct GTY((chain_next ("RTX_NEXT (&%h)"
      1 in a CALL_INSN if it is a sibling call.
      1 in a SET that is for a return.
      In a CODE_LABEL, part of the two-bit alternate entry field.
-     1 in a CONCAT is VAL_EXPR_IS_COPIED in var-tracking.c.  */
+     1 in a CONCAT is VAL_EXPR_IS_COPIED in var-tracking.c.
+     1 in a VALUE is SP_BASED_VALUE_P in cselib.c.  */
   unsigned int jump : 1;
   /* In a CODE_LABEL, part of the two-bit alternate entry field.
      1 in a MEM if it cannot trap.