From: Alexandre Oliva Date: Sat, 15 Dec 2007 20:16:03 +0000 (+0000) Subject: dwarf2out.c (reference_to_unused): Don't emit strings in initializers just because... X-Git-Tag: releases/gcc-4.3.0~970 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2f08d98796279fe8886918e7746eb276420545c;p=thirdparty%2Fgcc.git dwarf2out.c (reference_to_unused): Don't emit strings in initializers just because of debug information. gcc/ChangeLog: * dwarf2out.c (reference_to_unused): Don't emit strings in initializers just because of debug information. * tree.h (TREE_ASM_WRITTEN): Document use for STRING_CSTs. gcc/testsuite/ChangeLog: * gcc.dg/debug/const-3.c: New. From-SVN: r130959 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3921ab3601f9..0bebee04a791 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2007-12-15 Alexandre Oliva + + * dwarf2out.c (reference_to_unused): Don't emit strings in + initializers just because of debug information. + * tree.h (TREE_ASM_WRITTEN): Document use for STRING_CSTs. + 2007-12-15 Sebastian Pop * tree-scalar-evolution.c (number_of_iterations_for_all_loops): Replace diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 785d0fa96913..a0df24c44619 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -10365,6 +10365,8 @@ reference_to_unused (tree * tp, int * walk_subtrees, if (!node->output) return *tp; } + else if (TREE_CODE (*tp) == STRING_CST && !TREE_ASM_WRITTEN (*tp)) + return *tp; return NULL_TREE; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ee443e372715..a80b86a14780 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2007-12-15 Alexandre Oliva + + * gcc.dg/debug/const-3.c: New. + 2007-12-15 John David Anglin * g++.dg/other/datasec1.C: Require named section support. diff --git a/gcc/testsuite/gcc.dg/debug/const-3.c b/gcc/testsuite/gcc.dg/debug/const-3.c new file mode 100644 index 000000000000..2e9db490cb7a --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/const-3.c @@ -0,0 +1,7 @@ +/* Make sure we don't emit strings just because of debug information + for string initializers. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -g" } */ +/* { dg-final { scan-assembler-not "dontgenerate" } } */ +static const char *p = "dontgenerate1"; +static const char *q[2] = { 0, "dontgenerate2" }; diff --git a/gcc/tree.h b/gcc/tree.h index c98a921fec6a..331bdfab16ef 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -546,7 +546,7 @@ struct gimple_stmt GTY(()) TREE_ASM_WRITTEN in VAR_DECL, FUNCTION_DECL, RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE - BLOCK, SSA_NAME + BLOCK, SSA_NAME, STRING_CST used_flag: @@ -1300,7 +1300,7 @@ extern void omp_clause_range_check_failed (const_tree, const char *, int, /* In integral and pointer types, means an unsigned type. */ #define TYPE_UNSIGNED(NODE) (TYPE_CHECK (NODE)->base.unsigned_flag) -/* Nonzero in a VAR_DECL means assembler code has been written. +/* Nonzero in a VAR_DECL or STRING_CST means assembler code has been written. Nonzero in a FUNCTION_DECL means that the function has been compiled. This is interesting in an inline function, since it might not need to be compiled separately.