This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[varmap] Emit precise start-of-life
- From: Michael Matz <matz at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 29 May 2008 22:07:12 +0200 (CEST)
- Subject: [varmap] Emit precise start-of-life
Hi,
when a decl has only one location dwarf2out.c doesn't generate a location
list but simply a location description. A debugger would interpret this
as that decl having the location in all instructions of the function. We
can do better as we at least know at which instruction this is the case.
We now emit a location list from the single label up to the function end,
like we already do for the last node when a decl has a multi-node
location list.
Ciao,
Michael.
--
* dwarf2out.c (add_location_or_const_value_attribute): When a
decl only has one location nevertheless note it's start of live.
Index: dwarf2out.c
===================================================================
--- dwarf2out.c (revision 130292)
+++ dwarf2out.c (working copy)
@@ -10808,7 +10808,29 @@ add_location_or_const_value_attribute (d
descr = loc_descriptor (NOTE_VAR_LOCATION (node->var_loc_note), status);
if (descr)
{
- add_AT_location_description (die, attr, descr);
+ /* If we have a label the life of DECL starts there, so make
+ a location list. */
+ if (node->label)
+ {
+ dw_loc_list_ref list;
+ const char *endname;
+ char label_id[MAX_ARTIFICIAL_LABEL_BYTES];
+ if (!current_function_decl)
+ endname = text_end_label;
+ else
+ {
+ ASM_GENERATE_INTERNAL_LABEL (label_id, FUNC_END_LABEL,
+ current_function_funcdef_no);
+ endname = ggc_strdup (label_id);
+ }
+ list = new_loc_list (descr, node->label, endname,
+ secname_for_decl (decl), 1);
+ add_AT_loc_list (die, attr, list);
+ }
+ else
+ /* Otherwise at least note the location, as if it was valid
+ for the whole function. */
+ add_AT_location_description (die, attr, descr);
return;
}
}