This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [lto][patch] Provide fake resolution for non public 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: Wed, 8 Oct 2008 11:10:56 +0100
- Subject: Re: [lto][patch] Provide fake resolution for non public decls
- References: <38a0d8450810080300u212edbc3p95194e1b31614f16@mail.gmail.com>
Forgot the patch. Attached.
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-tree-in.h b/gcc/lto-tree-in.h
index 27bf738..2ca7c35 100644
--- a/gcc/lto-tree-in.h
+++ b/gcc/lto-tree-in.h
@@ -118,5 +118,6 @@ extern void lto_symtab_merge_fn (tree new_fn,
enum ld_plugin_symbol_resolution resolution);
extern tree lto_symtab_prevailing_decl (tree decl);
+extern enum ld_plugin_symbol_resolution lto_symtab_get_resolution (tree decl);
#endif /* GCC_LTO_TREE_IN_H */
diff --git a/gcc/lto/lto-symtab.c b/gcc/lto/lto-symtab.c
index c62fa45..2feff72 100644
--- a/gcc/lto/lto-symtab.c
+++ b/gcc/lto/lto-symtab.c
@@ -432,6 +432,21 @@ lto_symtab_compatible (tree old_decl, tree new_decl)
return true;
}
+/* Marks decl DECL as having resolution RESOLUTION. */
+
+static void
+lto_symtab_set_resolution (tree decl, ld_plugin_symbol_resolution_t resolution)
+{
+ gcc_assert (decl);
+
+ gcc_assert (TREE_PUBLIC (decl));
+ gcc_assert (TREE_CODE (decl) != FUNCTION_DECL || !DECL_ABSTRACT (decl));
+
+ gcc_assert (!DECL_LANG_SPECIFIC (decl));
+ DECL_LANG_SPECIFIC (decl) = GGC_NEW (struct lang_decl);
+ LTO_DECL_RESOLUTION (decl) = resolution;
+}
+
/* Common helper function for merging variable and function declarations.
NEW_DECL is the newly found decl. RESOLUTION is the decl's resolution
provided by the linker. */
@@ -466,9 +481,7 @@ lto_symtab_merge_decl (tree new_decl,
}
/* Remember the resolution of this symbol. */
- gcc_assert (!DECL_LANG_SPECIFIC (new_decl));
- DECL_LANG_SPECIFIC (new_decl) = GGC_NEW (struct lang_decl);
- LTO_DECL_RESOLUTION (new_decl) = resolution;
+ lto_symtab_set_resolution (new_decl, resolution);
/* Retrieve the previous declaration. */
name = DECL_ASSEMBLER_NAME (new_decl);
@@ -486,7 +499,7 @@ lto_symtab_merge_decl (tree new_decl,
if (!lto_symtab_compatible (old_decl, new_decl))
return;
- old_resolution = LTO_DECL_RESOLUTION (old_decl);
+ old_resolution = lto_symtab_get_resolution (old_decl);
gcc_assert (resolution != LDPR_UNKNOWN
&& resolution != LDPR_UNDEF
&& old_resolution != LDPR_UNKNOWN
@@ -547,5 +560,32 @@ lto_symtab_merge_fn (tree new_fn, enum ld_plugin_symbol_resolution resolution)
tree
lto_symtab_prevailing_decl (tree decl)
{
- return LTO_IDENTIFIER_DECL (DECL_ASSEMBLER_NAME (decl));
+ tree ret;
+ gcc_assert (decl);
+
+ if (!TREE_PUBLIC (decl))
+ return decl;
+
+ /* LTO FIXME: There should be no DECL_ABSTRACT in the middle end. */
+ if (TREE_CODE (decl) == FUNCTION_DECL && DECL_ABSTRACT (decl))
+ return decl;
+
+ ret = LTO_IDENTIFIER_DECL (DECL_ASSEMBLER_NAME (decl));
+ gcc_assert (ret);
+ return ret;
+}
+
+enum ld_plugin_symbol_resolution
+lto_symtab_get_resolution (tree decl)
+{
+ gcc_assert (decl);
+
+ if (!TREE_PUBLIC (decl))
+ return LDPR_PREVAILING_DEF_IRONLY;
+
+ /* LTO FIXME: There should be no DECL_ABSTRACT in the middle end. */
+ if (TREE_CODE (decl) == FUNCTION_DECL && DECL_ABSTRACT (decl))
+ return LDPR_PREVAILING_DEF_IRONLY;
+
+ return LTO_DECL_RESOLUTION (decl);
}
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index 6e2a611..f8a5375 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -800,18 +800,13 @@ lto_fixup_tree (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != FUNCTION_DECL)
return NULL;
- if (!TREE_PUBLIC (t))
- return NULL;
-
- /* FIXME lto. There should be no DECL_ABSTRACT in the middle end. */
- if (TREE_CODE (t) == FUNCTION_DECL && DECL_ABSTRACT (t))
- return NULL;
-
prevailing = lto_symtab_prevailing_decl (t);
- gcc_assert (prevailing);
- *tp = prevailing;
- *walk_subtrees = 0;
+ if (prevailing != t)
+ {
+ *tp = prevailing;
+ *walk_subtrees = 0;
+ }
return NULL;
}
@@ -835,12 +830,7 @@ lto_fixup_state (struct lto_in_decl_state *state,
gcc_assert (decl);
gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
- /* FIXME lto. There should be no DECL_ABSTRACT in the middle end. */
- if (!TREE_PUBLIC (decl) || DECL_ABSTRACT (decl))
- continue;
-
prevailing = lto_symtab_prevailing_decl (decl);
- gcc_assert (prevailing);
if (TREE_NOTHROW (prevailing) != TREE_NOTHROW (decl))
{
@@ -869,11 +859,7 @@ lto_fixup_state (struct lto_in_decl_state *state,
gcc_assert (TREE_CODE (decl) == VAR_DECL);
- if (!TREE_PUBLIC (decl))
- continue;
-
prevailing = lto_symtab_prevailing_decl (decl);
- gcc_assert (prevailing);
initial = DECL_INITIAL (decl);