Commit 0d06ead5 by Geoffrey Keating Committed by Geoffrey Keating

dwarf2out.c (add_location_or_const_value_attribute): Call…

dwarf2out.c (add_location_or_const_value_attribute): Call tree_add_const_value_attribute if nothing else works.

	* dwarf2out.c (add_location_or_const_value_attribute): Call
	tree_add_const_value_attribute if nothing else works.
	(reference_to_unused): New.
	(rtl_for_decl_init): Use reference_to_unused to decide whether
	to output an initializer.

From-SVN: r112408
parent ef6fa01d
2006-03-26 Geoffrey Keating <geoffk@apple.com>
* dwarf2out.c (add_location_or_const_value_attribute): Call
tree_add_const_value_attribute if nothing else works.
(reference_to_unused): New.
(rtl_for_decl_init): Use reference_to_unused to decide whether
to output an initializer.
2006-03-27 Alan Modra <amodra@bigpond.net.au> 2006-03-27 Alan Modra <amodra@bigpond.net.au>
PR target/26459 PR target/26459
......
...@@ -9929,6 +9929,23 @@ add_const_value_attribute (dw_die_ref die, rtx rtl) ...@@ -9929,6 +9929,23 @@ add_const_value_attribute (dw_die_ref die, rtx rtl)
} }
/* Determine whether the evaluation of EXPR references any variables
or functions which aren't otherwise used (and therefore may not be
output). */
static tree
reference_to_unused (tree * tp, int * walk_subtrees,
void * data ATTRIBUTE_UNUSED)
{
if (! EXPR_P (*tp) && ! CONSTANT_CLASS_P (*tp))
*walk_subtrees = 0;
if (DECL_P (*tp) && ! TREE_PUBLIC (*tp) && ! TREE_USED (*tp)
&& ! TREE_ASM_WRITTEN (*tp))
return *tp;
else
return NULL_TREE;
}
/* Generate an RTL constant from a decl initializer INIT with decl type TYPE, /* Generate an RTL constant from a decl initializer INIT with decl type TYPE,
for use in a later add_const_value_attribute call. */ for use in a later add_const_value_attribute call. */
...@@ -9955,15 +9972,16 @@ rtl_for_decl_init (tree init, tree type) ...@@ -9955,15 +9972,16 @@ rtl_for_decl_init (tree init, tree type)
rtl = gen_rtx_CONST_STRING (VOIDmode, rtl = gen_rtx_CONST_STRING (VOIDmode,
ggc_strdup (TREE_STRING_POINTER (init))); ggc_strdup (TREE_STRING_POINTER (init)));
} }
/* Although DWARF could easily handle other kinds of aggregates, we
have no way to represent such values as RTL constants, so skip
those. */
else if (AGGREGATE_TYPE_P (type))
;
/* If the initializer is something that we know will expand into an /* If the initializer is something that we know will expand into an
immediate RTL constant, expand it now. Expanding anything else immediate RTL constant, expand it now. We must be careful not to
tends to produce unresolved symbols; see debug/5770 and c++/6381. */ reference variables which won't be output. */
/* Aggregate, vector, and complex types may contain constructors that may else if (initializer_constant_valid_p (init, type)
result in code being generated when expand_expr is called, so we can't && ! walk_tree (&init, reference_to_unused, NULL, NULL))
handle them here. Integer and float are useful and safe types to handle
here. */
else if ((INTEGRAL_TYPE_P (type) || SCALAR_FLOAT_TYPE_P (type))
&& initializer_constant_valid_p (init, type) == null_pointer_node)
{ {
rtl = expand_expr (init, NULL_RTX, VOIDmode, EXPAND_INITIALIZER); rtl = expand_expr (init, NULL_RTX, VOIDmode, EXPAND_INITIALIZER);
...@@ -10327,6 +10345,9 @@ add_location_or_const_value_attribute (dw_die_ref die, tree decl, ...@@ -10327,6 +10345,9 @@ add_location_or_const_value_attribute (dw_die_ref die, tree decl,
add_AT_location_description (die, attr, descr); add_AT_location_description (die, attr, descr);
return; return;
} }
/* None of that worked, so it must not really have a location;
try adding a constant value attribute from the DECL_INITIAL. */
tree_add_const_value_attribute (die, decl);
} }
/* If we don't have a copy of this variable in memory for some reason (such /* If we don't have a copy of this variable in memory for some reason (such
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment