This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH]: Fix PR/14638


On Wed, 2004-12-22 at 11:36 -0800, Richard Henderson wrote:
> On Tue, Dec 21, 2004 at 11:53:55PM -0500, Daniel Berlin wrote:
> > +  while (DECL_DEBUG_ALIAS_OF (realdecl))
> > +    realdecl = DECL_DEBUG_ALIAS_OF  (realdecl);
> 
> This is the only thing I don't like.  Can't we manage to point to
> the ultimate decl with one extra comparison in tree-outof-ssa.c?

Yes.
Steven Bosccher suggested this to me on IRC this morning, as well as the
improvement that we don't need to set the alias if the original is not
an alias, and artifical.

so now in tree-outof-ssa.c, we have

  if (DECL_DEBUG_ALIAS_OF (t))
    DECL_DEBUG_ALIAS_OF (tmp) = DECL_DEBUG_ALIAS_OF (t);
  else if (!DECL_ARTIFICIAL (t))
    DECL_DEBUG_ALIAS_OF (tmp) = t;


and the other parts don't use while loops to access this.

I've attached the updated patch.

> Otherwise, I've been thinking that something like this was going
> to be needed for a long time.

> 
> 
> 
> r~
2004-12-22  Daniel Berlin  <dberlin@dberlin.org>
	
	Fix PR debug/14638

	* tree.h (DECL_DEBUG_ALIAS_OF): New macro.
	* var-tracking.c (track_expr_p): Don't disqualify tracking of variables
	that are aliases of variables we want to track, unless the
	original variable is also ignored for debugging purposes.
 	* tree-outof-ssa.c (create_temp): Note who we are a debug alias of.
	* dwarf2out.c (dwarf2out_var_location): Add us to the location of
	the decl we are an alias of.

Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.669
diff -u -p -r1.669 tree.h
--- tree.h	21 Dec 2004 17:43:11 -0000	1.669
+++ tree.h	22 Dec 2004 21:44:16 -0000
@@ -2009,6 +2009,10 @@ struct tree_binfo GTY (())
    writing debugging information about vfield and vbase decls for C++.  */
 #define DECL_FCONTEXT(NODE) (FIELD_DECL_CHECK (NODE)->decl.vindex)
 
+/* For VAR_DECL, this is set to the variable we were split from, due to
+   optimization. */
+#define DECL_DEBUG_ALIAS_OF(NODE) (DECL_CHECK (NODE)->decl.vindex)
+
 /* Every ..._DECL node gets a unique number.  */
 #define DECL_UID(NODE) (DECL_CHECK (NODE)->decl.uid)
 
Index: tree-outof-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-outof-ssa.c,v
retrieving revision 2.36
diff -u -p -r2.36 tree-outof-ssa.c
--- tree-outof-ssa.c	14 Dec 2004 20:05:48 -0000	2.36
+++ tree-outof-ssa.c	22 Dec 2004 21:44:17 -0000
@@ -156,6 +156,10 @@ create_temp (tree t)
   if (name == NULL)
     name = "temp";
   tmp = create_tmp_var (type, name);
+  if (DECL_DEBUG_ALIAS_OF (t))
+    DECL_DEBUG_ALIAS_OF (tmp) = DECL_DEBUG_ALIAS_OF (t);  
+  else if (!DECL_ARTIFICIAL (t))
+    DECL_DEBUG_ALIAS_OF (tmp) = t;
   DECL_ARTIFICIAL (tmp) = DECL_ARTIFICIAL (t);
   add_referenced_tmp_var (tmp);
 
Index: dwarf2out.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dwarf2out.c,v
retrieving revision 1.562
diff -u -p -r1.562 dwarf2out.c
--- dwarf2out.c	9 Dec 2004 10:54:33 -0000	1.562
+++ dwarf2out.c	22 Dec 2004 21:44:19 -0000
@@ -13037,6 +13037,7 @@ dwarf2out_var_location (rtx loc_note)
   rtx prev_insn;
   static rtx last_insn;
   static const char *last_label;
+  tree decl;
 
   if (!DECL_P (NOTE_VAR_LOCATION_DECL (loc_note)))
     return;
@@ -13065,8 +13066,10 @@ dwarf2out_var_location (rtx loc_note)
 
   last_insn = loc_note;
   last_label = newloc->label;
-
-  add_var_loc_to_decl (NOTE_VAR_LOCATION_DECL (loc_note), newloc);
+  decl = NOTE_VAR_LOCATION_DECL (loc_note);
+  if (DECL_DEBUG_ALIAS_OF (decl) != NULL)
+    decl = DECL_DEBUG_ALIAS_OF (decl);
+  add_var_loc_to_decl (decl, newloc);
 }
 
 /* We need to reset the locations at the beginning of each
Index: var-tracking.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/var-tracking.c,v
retrieving revision 2.22
diff -u -p -r2.22 var-tracking.c
--- var-tracking.c	28 Sep 2004 07:59:52 -0000	2.22
+++ var-tracking.c	22 Dec 2004 21:48:43 -0000
@@ -1441,6 +1441,7 @@ static bool
 track_expr_p (tree expr)
 {
   rtx decl_rtl;
+  tree realdecl;
 
   /* If EXPR is not a parameter or a variable do not track it.  */
   if (TREE_CODE (expr) != VAR_DECL && TREE_CODE (expr) != PARM_DECL)
@@ -1454,14 +1455,22 @@ track_expr_p (tree expr)
   decl_rtl = DECL_RTL_IF_SET (expr);
   if (!decl_rtl)
     return 0;
-
-  /* Do not track EXPR if it should be ignored for debugging purposes.  */
-  if (DECL_IGNORED_P (expr))
+  
+  /* If this expression is really a debug alias of some other declaration, we 
+     don't need to track this expression if the ultimate declaration is
+     ignored.  */
+  realdecl = expr;
+  if (DECL_DEBUG_ALIAS_OF (realdecl))
+    realdecl = DECL_DEBUG_ALIAS_OF  (realdecl);
+
+  /* Do not track EXPR if REALDECL it should be ignored for debugging
+     purposes.  */ 
+  if (DECL_IGNORED_P (realdecl))
     return 0;
 
   /* Do not track global variables until we are able to emit correct location
      list for them.  */
-  if (TREE_STATIC (expr))
+  if (TREE_STATIC (realdecl))
     return 0;
 
   /* When the EXPR is a DECL for alias of some variable (see example)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]