aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorGeoffrey Keating <geoffk@apple.com>2006-03-27 06:09:48 +0000
committerGeoffrey Keating <geoffk@gcc.gnu.org>2006-03-27 06:09:48 +0000
commit0d06ead596132ef29fc5c3e2e7a32b9506675946 (patch)
treee2aaa33a44365850573ec0e40ea48caf0b331efd /gcc
parentef6fa01d3af63506555c932629c9d870af559aca (diff)
downloadgcc-0d06ead596132ef29fc5c3e2e7a32b9506675946.zip
gcc-0d06ead596132ef29fc5c3e2e7a32b9506675946.tar.gz
gcc-0d06ead596132ef29fc5c3e2e7a32b9506675946.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/dwarf2out.c37
2 files changed, 37 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0f50ac3..dac49f6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+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>
PR target/26459
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 6255c40..5b1894c 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -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,
for use in a later add_const_value_attribute call. */
@@ -9955,15 +9972,16 @@ rtl_for_decl_init (tree init, tree type)
rtl = gen_rtx_CONST_STRING (VOIDmode,
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
- immediate RTL constant, expand it now. Expanding anything else
- tends to produce unresolved symbols; see debug/5770 and c++/6381. */
- /* Aggregate, vector, and complex types may contain constructors that may
- result in code being generated when expand_expr is called, so we can't
- 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)
+ immediate RTL constant, expand it now. We must be careful not to
+ reference variables which won't be output. */
+ else if (initializer_constant_valid_p (init, type)
+ && ! walk_tree (&init, reference_to_unused, NULL, NULL))
{
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,
add_AT_location_description (die, attr, descr);
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