This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[lto][patch] Clear DECL_CONTEXT if it is a NAMESPACE_DECL
- 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: Wed, 7 Jan 2009 14:23:30 +0000
- Subject: [lto][patch] Clear DECL_CONTEXT if it is a NAMESPACE_DECL
We don't use DECL_CONTEXT that are NAMESPACE_DECL in lto1. In fact, I
am not sure if we use namespaces at all. This patch clears
DECL_CONTEXT to save some memory and disk.
Did a bootstrap and a regression test on linux x86-64.
2009-01-07 Rafael Avila de Espindola <espindola@google.com>
* tree.c (reset_decl_lang_specific): Clear DECL_CONTEXT if it is a
NAMESPACE_DECL.
Cheers,
--
Rafael Avila de Espindola
Google | Gordon House | Barrow Street | Dublin 4 | Ireland
Registered in Dublin, Ireland | Registration Number: 368047
diff --git a/gcc/tree.c b/gcc/tree.c
index 42a99f1..c85825c 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -4051,13 +4051,15 @@ static int
reset_decl_lang_specific (void **slot, void *unused ATTRIBUTE_UNUSED)
{
tree decl = *(tree *) slot;
+ tree context = DECL_CONTEXT (decl);
lang_hooks.reset_lang_specifics (decl);
+ if (context && TREE_CODE (context) == NAMESPACE_DECL)
+ DECL_CONTEXT (decl) = context = NULL_TREE;
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);
@@ -4079,7 +4081,6 @@ reset_decl_lang_specific (void **slot, void *unused ATTRIBUTE_UNUSED)
}
else if (TREE_CODE (decl) == FUNCTION_DECL)
{
- tree context = DECL_CONTEXT (decl);
if (context && TREE_CODE (context) == FUNCTION_DECL)
DECL_CONTEXT (decl) = NULL_TREE;
}