This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[lto][patch] Remove some DECL_ABSTRACT decls
- From: Rafael Espindola <espindola at google dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Cc: Diego Novillo <dnovillo at google dot com>
- Date: Tue, 9 Dec 2008 14:35:54 +0000
- Subject: [lto][patch] Remove some DECL_ABSTRACT decls
The attached patch remove some DECL_ABSTRACT decls. They were
reachable via DECL_CONTEXT and not used. They were incorrectly added
to the symbol table, and this confused the linker plugin.
Tested on linux x86-64.
2008-12-09 Rafael Avila de Espindola <espindola@google.com>
* lto-function-in.c (input_local_var_decl): Handle the case DECL_CONTEXT
is NULL.
* lto-section-out.c (write_symbol_vec): Assert that we don't see a
DECL_ABSTRACT.
* tree.c (reset_decl_lang_specific): Clea DECL_CONTEXT of VAR_DECLs
and PARM_DECLs if the context is an abstract function.
Cheers,
--
Rafael Avila de Espindola
Google | Gordon House | Barrow Street | Dublin 4 | Ireland
Registered in Dublin, Ireland | Registration Number: 368047
diff --git a/gcc/lto-function-in.c b/gcc/lto-function-in.c
index bfba332..5c62247 100644
--- a/gcc/lto-function-in.c
+++ b/gcc/lto-function-in.c
@@ -1229,6 +1229,7 @@ input_local_var_decl (struct lto_input_block *ib, struct data_in *data_in,
lto_flags_type flags;
tree result;
tree context;
+ enum LTO_tags context_tag;
variant = tag & 0xF;
is_var = ((tag & 0xFFF0) == LTO_local_var_decl_body0);
@@ -1295,8 +1296,12 @@ input_local_var_decl (struct lto_input_block *ib, struct data_in *data_in,
set_line_info (data_in, result);
LTO_DEBUG_TOKEN ("context");
- context = input_expr_operand (ib, data_in, fn, input_record_start (ib));
- if (TYPE_P (context))
+ context_tag = input_record_start (ib);
+ if (context_tag)
+ context = input_expr_operand (ib, data_in, fn, context_tag);
+ else
+ context = NULL_TREE;
+ if (context && TYPE_P (context))
DECL_CONTEXT (result) = TYPE_NAME (context);
else
DECL_CONTEXT (result) = context;
diff --git a/gcc/lto-section-out.c b/gcc/lto-section-out.c
index 7ed26eb..5f06392 100644
--- a/gcc/lto-section-out.c
+++ b/gcc/lto-section-out.c
@@ -1078,6 +1078,8 @@ write_symbol_vec (htab_t hash, struct lto_output_stream *stream,
if (!TREE_PUBLIC (t))
continue;
+ gcc_assert (!DECL_ABSTRACT (t));
+
if (TREE_CODE (t) == RESULT_DECL)
continue;
diff --git a/gcc/tree.c b/gcc/tree.c
index 534429e..39348a7 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -4012,6 +4012,18 @@ reset_decl_lang_specific (void **slot, void *unused ATTRIBUTE_UNUSED)
lang_hooks.reset_lang_specifics (decl);
+
+ if (TREE_CODE (decl) == PARM_DECL || TREE_CODE (decl) == VAR_DECL)
+ {
+ tree context = DECL_CONTEXT (decl);
+ if (context)
+ {
+ enum tree_code code = TREE_CODE (context);
+ if (code == FUNCTION_DECL && DECL_ABSTRACT (context))
+ DECL_CONTEXT (decl) = NULL_TREE;
+ }
+ }
+
if (TREE_CODE (decl) == PARM_DECL || TREE_CODE (decl) == FIELD_DECL)
{
tree unit_size = DECL_SIZE_UNIT (decl);