This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Use resolution file, autoconf help needed
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: gcc-patches at gcc dot gnu dot org, autoconf at gnu dot org
- Date: Tue, 26 Oct 2010 17:25:51 +0200
- Subject: Use resolution file, autoconf help needed
Hi,
this patch makes GCC to use LDPR_PREVAILING_DEF_IRONLY. Plugin specification says that
all symbols resolved as LDPR_PREVAILING_DEF_IRONLY can be removed by the compiler and thus
we can bring them local.
The patch unfortunately breaks libiberty configure since we start to make whole program assumptions
by default when we know that nothing dynamically binds that leads to optimizing:
char pstat_getstatic ();
char (*f) () = pstat_getstatic;
int
main ()
{
return f != pstat_getstatic;
}
Here we first bring F local, then prove it is read only and the nfold f != pstat_getstatic
to false. This makes autoconf to conclude that getstatic is available.
We need to fix the testcase generation by i.e. using volatile var or by using test that just
calls the function. I filled in autoconf bug, but it probably won't be fixed upstream for this
stage 1.
This is pretty important feature, so I spoke with Richard and we concluded that probably we should
work around in our autoconf by providing our definition of AC_CHECK_FUNC. I am not sure how to do that
however, would be there some good soul who can help me?
Otherwise the patch has been bootstrapped/regtested on x86_64-linux and I intend to commit it as soon
as the configure issues are fixed.
* ipa.c (cgraph_externally_visible_p, varpool_externally_visible_p): When availabe,
use linker plugin data to privatize symbols.
Index: ipa.c
===================================================================
--- ipa.c (revision 165965)
+++ ipa.c (working copy)
@@ -593,6 +593,7 @@ ipa_discover_readonly_nonaddressable_var
static bool
cgraph_externally_visible_p (struct cgraph_node *node, bool whole_program, bool aliased)
{
+ struct cgraph_node *alias;
if (!node->local.finalized)
return false;
if (!DECL_COMDAT (node->decl)
@@ -612,6 +613,18 @@ cgraph_externally_visible_p (struct cgra
if (lookup_attribute ("externally_visible", DECL_ATTRIBUTES (node->decl)))
return true;
+ /* See if we have linker information about symbol not being used or
+ if we need to make guess based on the declaration.
+
+ Even if the linker clams the symbol is unused, never bring internal
+ symbols that are declared by user as used or externally visible.
+ This is needed for i.e. references from asm statements. */
+ for (alias = node->same_body; alias; alias = alias->next)
+ if (alias->resolution != LDPR_PREVAILING_DEF_IRONLY)
+ break;
+ if (!alias && node->resolution == LDPR_PREVAILING_DEF_IRONLY)
+ return false;
+
/* When doing link time optimizations, hidden symbols become local. */
if (in_lto_p
&& (DECL_VISIBILITY (node->decl) == VISIBILITY_HIDDEN
@@ -655,6 +668,7 @@ cgraph_externally_visible_p (struct cgra
static bool
varpool_externally_visible_p (struct varpool_node *vnode, bool aliased)
{
+ struct varpool_node *alias;
if (!DECL_COMDAT (vnode->decl) && !TREE_PUBLIC (vnode->decl))
return false;
@@ -681,6 +695,11 @@ varpool_externally_visible_p (struct var
This is needed for i.e. references from asm statements. */
if (varpool_used_from_object_file_p (vnode))
return true;
+ for (alias = vnode->extra_name; alias; alias = alias->next)
+ if (alias->resolution != LDPR_PREVAILING_DEF_IRONLY)
+ break;
+ if (!alias && vnode->resolution == LDPR_PREVAILING_DEF_IRONLY)
+ return false;
/* When doing link time optimizations, hidden symbols become local. */
if (in_lto_p