re PR tree-optimization/14638 (Variables disappear from debug info at -O1)
authorDaniel Berlin <dberlin@dberlin.org>
Fri, 24 Dec 2004 05:23:10 +0000 (05:23 +0000)
committerDaniel Berlin <dberlin@gcc.gnu.org>
Fri, 24 Dec 2004 05:23:10 +0000 (05:23 +0000)
2004-12-24  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.
(VARIABLE_HASH_VAL): Use DECL_UID, so that this is deterministic.
  * 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.

From-SVN: r92585

gcc/ChangeLog
gcc/dwarf2out.c
gcc/tree-outof-ssa.c
gcc/tree.h
gcc/var-tracking.c

index e499e8c7226e05013ee3f087b6d2b83158497555..0bd56df349661398c63896e13a24b2012b060b15 100644 (file)
@@ -1,3 +1,16 @@
+2004-12-24  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.
+       (VARIABLE_HASH_VAL): Use DECL_UID, so that this is deterministic.
+       * 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.
+
 2004-12-24  Alan Modra  <amodra@bigpond.net.au>
 
        PR target/19142
index beed56b49810e73252c7f7f45cddeae5f01eab66..26174ec1c51bd8a2174d77d5077062dd8170bd7a 100644 (file)
@@ -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))
+    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 d61acbd0b1d408f8f87d7722944af5c2b3d12eab..a5fc99309a5aad14e30e39ac6422229729f1e237 100644 (file)
@@ -156,6 +156,11 @@ 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_IGNORED_P (t))
+    DECL_DEBUG_ALIAS_OF (tmp) = t;
   DECL_ARTIFICIAL (tmp) = DECL_ARTIFICIAL (t);
   add_referenced_tmp_var (tmp);
 
index 1411d71ad527da8707c99e305b0b3de9cdebfadf..0858670609c7ac2e02f20edfe077f944cf6d319d 100644 (file)
@@ -2014,6 +2014,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 72cb81d927e9cfa43fdf80e8f511b7959bc8b244..ef9f9dcc5d6bf79ca867bf0f93cd75b1afe6d43f 100644 (file)
@@ -244,7 +244,7 @@ typedef struct variable_def
 } *variable;
 
 /* Hash function for DECL for VARIABLE_HTAB.  */
-#define VARIABLE_HASH_VAL(decl) ((size_t) (decl))
+#define VARIABLE_HASH_VAL(decl) (DECL_UID (decl))
 
 /* Pointer to the BB's information specific to variable tracking pass.  */
 #define VTI(BB) ((variable_tracking_info) (BB)->aux)
@@ -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)