mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-23 06:20:25 +08:00
cgraph.h (struct varpool_node): new used_from_object_file flag.
2010-06-28 Bingfeng Mei <bmei@broadcom.com> * cgraph.h (struct varpool_node): new used_from_object_file flag. (struct cgraph_local_info): new used_from_object_file flag. * cgraph.c (dump_cgraph_node): dump used_from_object_file flag. (cgraph_clone_node): initialize used_from_object_file. (cgraph_create_virtual_clone): initialize used_from_object_file. * lto-symbtab.c (lto_symtab_merge_decls_1): Set used_from_object_file flags for symbols of LDPR_PREVAILING_DEF when compiling with -fwhole-program. (lto_symtab_resolve_symbols) Use LDPR_PREVAILING_DEF_IRONLY for internal resolver. * ipa.c (function_and_variable_visibility): Set externally_visible flag of varpool_node if used_from_object_file flag is set. (cgraph_externally_visible_p): check used_from_object_file flag. * doc/invoke.texi (-fwhole-program option): Change description of externally_visible attribute accordingly. * doc/extend.texi (externally_visible): Ditto. From-SVN: r161483
This commit is contained in:
parent
7802ca7cfd
commit
6d41cd0238
@ -1,3 +1,22 @@
|
||||
2010-06-28 Bingfeng Mei <bmei@broadcom.com>
|
||||
|
||||
* cgraph.h (struct varpool_node): new used_from_object_file flag.
|
||||
(struct cgraph_local_info): new used_from_object_file flag.
|
||||
* cgraph.c (dump_cgraph_node): dump used_from_object_file flag.
|
||||
(cgraph_clone_node): initialize used_from_object_file.
|
||||
(cgraph_create_virtual_clone): initialize used_from_object_file.
|
||||
* lto-symbtab.c (lto_symtab_merge_decls_1): Set
|
||||
used_from_object_file flags for symbols of LDPR_PREVAILING_DEF
|
||||
when compiling with -fwhole-program.
|
||||
(lto_symtab_resolve_symbols) Use LDPR_PREVAILING_DEF_IRONLY for
|
||||
internal resolver.
|
||||
* ipa.c (function_and_variable_visibility): Set externally_visible
|
||||
flag of varpool_node if used_from_object_file flag is set.
|
||||
(cgraph_externally_visible_p): check used_from_object_file flag.
|
||||
* doc/invoke.texi (-fwhole-program option): Change description of
|
||||
externally_visible attribute accordingly.
|
||||
* doc/extend.texi (externally_visible): Ditto.
|
||||
|
||||
2010-06-27 Jan Hubicka <jh@suse.cz>
|
||||
|
||||
* params.def (max-inline-insns-auto): Default to 40.
|
||||
|
@ -1825,6 +1825,8 @@ dump_cgraph_node (FILE *f, struct cgraph_node *node)
|
||||
fprintf (f, " local");
|
||||
if (node->local.externally_visible)
|
||||
fprintf (f, " externally_visible");
|
||||
if (node->local.used_from_object_file)
|
||||
fprintf (f, " used_from_object_file");
|
||||
if (node->local.finalized)
|
||||
fprintf (f, " finalized");
|
||||
if (node->local.disregard_inline_limits)
|
||||
@ -2075,6 +2077,7 @@ cgraph_clone_node (struct cgraph_node *n, tree decl, gcov_type count, int freq,
|
||||
new_node->analyzed = n->analyzed;
|
||||
new_node->local = n->local;
|
||||
new_node->local.externally_visible = false;
|
||||
new_node->local.used_from_object_file = false;
|
||||
new_node->local.local = true;
|
||||
new_node->local.vtable_method = false;
|
||||
new_node->global = n->global;
|
||||
@ -2266,6 +2269,7 @@ cgraph_create_virtual_clone (struct cgraph_node *old_node,
|
||||
else
|
||||
new_node->clone.combined_args_to_skip = args_to_skip;
|
||||
new_node->local.externally_visible = 0;
|
||||
new_node->local.used_from_object_file = 0;
|
||||
new_node->local.local = 1;
|
||||
new_node->lowered = true;
|
||||
new_node->reachable = true;
|
||||
|
@ -102,6 +102,9 @@ struct GTY(()) cgraph_local_info {
|
||||
/* Set when function is visible by other units. */
|
||||
unsigned externally_visible : 1;
|
||||
|
||||
/* Set when resolver determines that function is visible by other units. */
|
||||
unsigned used_from_object_file : 1;
|
||||
|
||||
/* Set once it has been finalized so we consider it to be output. */
|
||||
unsigned finalized : 1;
|
||||
|
||||
@ -487,6 +490,8 @@ struct GTY((chain_next ("%h.next"), chain_prev ("%h.prev"))) varpool_node {
|
||||
unsigned output : 1;
|
||||
/* Set when function is visible by other units. */
|
||||
unsigned externally_visible : 1;
|
||||
/* Set when resolver determines that variable is visible by other units. */
|
||||
unsigned used_from_object_file : 1;
|
||||
/* Set for aliases once they got through assemble_alias. Also set for
|
||||
extra name aliases in varpool_extra_name_alias. */
|
||||
unsigned alias : 1;
|
||||
|
@ -2296,7 +2296,7 @@ attribute is present.
|
||||
@cindex @code{externally_visible} attribute.
|
||||
This attribute, attached to a global variable or function, nullifies
|
||||
the effect of the @option{-fwhole-program} command-line option, so the
|
||||
object remains visible outside the current compilation unit.
|
||||
object remains visible outside the current compilation unit. If @option{-fwhole-program} is used together with @option{-flto} and @command{gold} is used as the linker plugin, @code{externally_visible} attributes are automatically added to functions (not variable yet due to a current @command{gold} issue) that are accessed outside of LTO objects according to resolution file produced by @command{gold}. For other linkers that cannot generate resolution file, explicit @code{externally_visible} attributes are still necessary.
|
||||
|
||||
@item far
|
||||
@cindex functions which handle memory bank switching
|
||||
|
@ -7310,7 +7310,7 @@ Enabled by default with @option{-funroll-loops}.
|
||||
Assume that the current compilation unit represents the whole program being
|
||||
compiled. All public functions and variables with the exception of @code{main}
|
||||
and those merged by attribute @code{externally_visible} become static functions
|
||||
and in effect are optimized more aggressively by interprocedural optimizers.
|
||||
and in effect are optimized more aggressively by interprocedural optimizers. If @command{gold} is used as the linker plugin, @code{externally_visible} attributes are automatically added to functions (not variable yet due to a current @command{gold} issue) that are accessed outside of LTO objects according to resolution file produced by @command{gold}. For other linkers that cannot generate resolution file, explicit @code{externally_visible} attributes are still necessary.
|
||||
While this option is equivalent to proper use of the @code{static} keyword for
|
||||
programs consisting of a single file, in combination with option
|
||||
@option{-combine}, @option{-flto} or @option{-fwhopr} this flag can be used to
|
||||
|
@ -576,6 +576,8 @@ cgraph_externally_visible_p (struct cgraph_node *node, bool whole_program)
|
||||
return false;
|
||||
if (!whole_program)
|
||||
return true;
|
||||
if (node->local.used_from_object_file)
|
||||
return true;
|
||||
if (DECL_PRESERVE_P (node->decl))
|
||||
return true;
|
||||
/* COMDAT functions must be shared only if they have address taken,
|
||||
@ -729,6 +731,7 @@ function_and_variable_visibility (bool whole_program)
|
||||
we start reordering datastructures. */
|
||||
|| DECL_COMDAT (vnode->decl)
|
||||
|| DECL_WEAK (vnode->decl)
|
||||
|| vnode->used_from_object_file
|
||||
|| lookup_attribute ("externally_visible",
|
||||
DECL_ATTRIBUTES (vnode->decl))))
|
||||
vnode->externally_visible = true;
|
||||
|
@ -530,11 +530,20 @@ lto_symtab_resolve_symbols (void **slot)
|
||||
return;
|
||||
|
||||
found:
|
||||
if (TREE_CODE (prevailing->decl) == VAR_DECL
|
||||
&& TREE_READONLY (prevailing->decl))
|
||||
/* If current lto files represent the whole program,
|
||||
it is correct to use LDPR_PREVALING_DEF_IRONLY.
|
||||
If current lto files are part of whole program, internal
|
||||
resolver doesn't know if it is LDPR_PREVAILING_DEF
|
||||
or LDPR_PREVAILING_DEF_IRONLY. Use IRONLY conforms to
|
||||
using -fwhole-program. Otherwise, it doesn't
|
||||
matter using either LDPR_PREVAILING_DEF or
|
||||
LDPR_PREVAILING_DEF_IRONLY
|
||||
|
||||
FIXME: above workaround due to gold plugin makes some
|
||||
variables IRONLY, which are indeed PREVAILING_DEF in
|
||||
resolution file. These variables still need manual
|
||||
externally_visible attribute. */
|
||||
prevailing->resolution = LDPR_PREVAILING_DEF_IRONLY;
|
||||
else
|
||||
prevailing->resolution = LDPR_PREVAILING_DEF;
|
||||
}
|
||||
|
||||
/* Merge all decls in the symbol table chain to the prevailing decl and
|
||||
@ -698,6 +707,24 @@ lto_symtab_merge_decls_1 (void **slot, void *data ATTRIBUTE_UNUSED)
|
||||
&& TREE_CODE (prevailing->decl) != VAR_DECL)
|
||||
prevailing->next = NULL;
|
||||
|
||||
/* Set externally_visible flags for declaration of LDPR_PREVAILING_DEF */
|
||||
if (flag_whole_program)
|
||||
{
|
||||
if (prevailing->resolution == LDPR_PREVAILING_DEF)
|
||||
{
|
||||
if (TREE_CODE (prevailing->decl) == FUNCTION_DECL)
|
||||
prevailing->node->local.used_from_object_file = true;
|
||||
else
|
||||
prevailing->vnode->used_from_object_file = true;
|
||||
}
|
||||
else if (prevailing->resolution == LDPR_PREVAILING_DEF_IRONLY)
|
||||
{
|
||||
if (TREE_CODE (prevailing->decl) == FUNCTION_DECL)
|
||||
prevailing->node->local.used_from_object_file = false;
|
||||
else
|
||||
prevailing->vnode->used_from_object_file = false;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user