From bbc7bce1c47bab845c0b7e35395958f7ec852660 Mon Sep 17 00:00:00 2001 From: dberlin Date: Fri, 24 Dec 2004 05:23:10 +0000 Subject: [PATCH] 2004-12-24 Daniel Berlin 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@92585 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 13 +++++++++++++ gcc/dwarf2out.c | 7 +++++-- gcc/tree-outof-ssa.c | 5 +++++ gcc/tree.h | 4 ++++ gcc/var-tracking.c | 19 ++++++++++++++----- 5 files changed, 41 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e499e8c..0bd56df 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2004-12-24 Daniel Berlin + + 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 PR target/19142 diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index beed56b..26174ec 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -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 diff --git a/gcc/tree-outof-ssa.c b/gcc/tree-outof-ssa.c index d61acbd..a5fc993 100644 --- a/gcc/tree-outof-ssa.c +++ b/gcc/tree-outof-ssa.c @@ -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); diff --git a/gcc/tree.h b/gcc/tree.h index 1411d71..0858670 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -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) diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c index 72cb81d..ef9f9dc 100644 --- a/gcc/var-tracking.c +++ b/gcc/var-tracking.c @@ -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) -- 2.7.4