This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [vta,vta4.3,trunk?] defer creation of DECLs for dwarf indirect constants
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 01 Jun 2009 05:02:53 -0300
- Subject: Re: [vta,vta4.3,trunk?] defer creation of DECLs for dwarf indirect constants
- References: <ord4jc4aho.fsf@oliva.athome.lsd.ic.unicamp.br>
On Sep 10, 2008, Alexandre Oliva <aoliva@redhat.com> wrote:
> This is another difference detected by -fcompare-debug, that *may*
> cause codegen differences with or without -g. At the end of
> compilation of a function that requires constants to be placed in
> memory for debug info, we create new decls. These new decls cause
> decls in subsequent functions to vary depending on whether debug
> information is generated. Varying decl uids are known to cause
> codegen differences in some cases, although I don't have any such
> testcase. They were enough to change anonymous temporary D.<number>
> names in dumps generated for -fcompare-debug, though, which was enough
> of a reason for me to fix it.
> The fix, which should also reduce total memory use during compilation,
> was to delay the creation of DECLs for the constants to the end of
> compilation, when we actually need them to emit debug info. Until
> then, we hold on to the identifier we'd have used for the DECL.
> Ok for trunk?
Ping?
for gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* dwarf2asm.c (dw2_force_const_mem): Defer creation of
declarations for constants until...
(dw2_output_indirect_constant_1): ... this point.
Index: gcc/dwarf2asm.c
===================================================================
--- gcc/dwarf2asm.c.orig 2009-03-01 02:16:17.000000000 -0300
+++ gcc/dwarf2asm.c 2009-05-28 04:35:19.000000000 -0300
@@ -809,7 +809,7 @@ dw2_force_const_mem (rtx x, bool is_publ
{
splay_tree_node node;
const char *key;
- tree decl;
+ tree decl_id;
if (! indirect_pool)
/* We use strcmp, rather than just comparing pointers, so that the
@@ -821,7 +821,7 @@ dw2_force_const_mem (rtx x, bool is_publ
key = XSTR (x, 0);
node = splay_tree_lookup (indirect_pool, (splay_tree_key) key);
if (node)
- decl = (tree) node->value;
+ decl_id = (tree) node->value;
else
{
tree id;
@@ -832,13 +832,9 @@ dw2_force_const_mem (rtx x, bool is_publ
char *ref_name = XALLOCAVEC (char, strlen (str) + sizeof "DW.ref.");
sprintf (ref_name, "DW.ref.%s", str);
- id = get_identifier (ref_name);
- decl = build_decl (VAR_DECL, id, ptr_type_node);
- DECL_ARTIFICIAL (decl) = 1;
- DECL_IGNORED_P (decl) = 1;
- TREE_PUBLIC (decl) = 1;
- DECL_INITIAL (decl) = decl;
- make_decl_one_only (decl);
+ gcc_assert (!maybe_get_identifier (ref_name));
+ decl_id = get_identifier (ref_name);
+ TREE_PUBLIC (decl_id) = 1;
}
else
{
@@ -846,12 +842,8 @@ dw2_force_const_mem (rtx x, bool is_publ
ASM_GENERATE_INTERNAL_LABEL (label, "LDFCM", dw2_const_labelno);
++dw2_const_labelno;
- id = get_identifier (label);
- decl = build_decl (VAR_DECL, id, ptr_type_node);
- DECL_ARTIFICIAL (decl) = 1;
- DECL_IGNORED_P (decl) = 1;
- TREE_STATIC (decl) = 1;
- DECL_INITIAL (decl) = decl;
+ gcc_assert (!maybe_get_identifier (label));
+ decl_id = get_identifier (label);
}
id = maybe_get_identifier (str);
@@ -859,10 +851,10 @@ dw2_force_const_mem (rtx x, bool is_publ
TREE_SYMBOL_REFERENCED (id) = 1;
splay_tree_insert (indirect_pool, (splay_tree_key) key,
- (splay_tree_value) decl);
+ (splay_tree_value) decl_id);
}
- return XEXP (DECL_RTL (decl), 0);
+ return gen_rtx_SYMBOL_REF (Pmode, IDENTIFIER_POINTER (decl_id));
}
/* A helper function for dw2_output_indirect_constants called through
@@ -874,10 +866,24 @@ dw2_output_indirect_constant_1 (splay_tr
{
const char *sym;
rtx sym_ref;
- tree decl;
+ tree id, decl;
sym = (const char *) node->key;
- decl = (tree) node->value;
+ id = (tree) node->value;
+
+ decl = build_decl (VAR_DECL, id, ptr_type_node);
+ DECL_ARTIFICIAL (decl) = 1;
+ DECL_IGNORED_P (decl) = 1;
+ DECL_INITIAL (decl) = decl;
+
+ if (TREE_PUBLIC (id))
+ {
+ TREE_PUBLIC (decl) = 1;
+ make_decl_one_only (decl);
+ }
+ else
+ TREE_STATIC (decl) = 1;
+
sym_ref = gen_rtx_SYMBOL_REF (Pmode, sym);
sym = targetm.strip_name_encoding (sym);
if (TREE_PUBLIC (decl) && USE_LINKONCE_INDIRECT)
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist Red Hat Brazil Compiler Engineer