aboutsummaryrefslogtreecommitdiff
path: root/gcc/varpool.c
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2014-09-24 03:29:24 +0000
committerAndi Kleen <ak@gcc.gnu.org>2014-09-24 03:29:24 +0000
commit7861b6489dd7777b1b8829fd8726079f133eb34c (patch)
tree73e70259b9d2f956939310c8f0e194397eda7e4b /gcc/varpool.c
parent2f4a54f2d91538336797b9a5401c83e6f9831f0b (diff)
downloadgcc-7861b6489dd7777b1b8829fd8726079f133eb34c.zip
gcc-7861b6489dd7777b1b8829fd8726079f133eb34c.tar.gz
gcc-7861b6489dd7777b1b8829fd8726079f133eb34c.tar.bz2
Add an no_reorder attribute for LTO
Some projects need to prevent reordering of specific top level declarations with LTO, in particular declarations defining init calls. The only way to do that with LTO was to use -fno-toplevel-reorder, which stops reordering for all declarations and makes LTO partitioning less efficient. This patch adds a new no_reorder attribute that stops reordering only for the marked declaration. The program can then only mark e.g. the initcalls and leave all the other declarations alone. The patch does: - Adds the new no_reorder attribute for the C family. - Initializes a new no_reorder flag in the symtab_nodes in the function visibility flag. - Maintains the no_reorder flag when creating new nodes. - Changes the partition code to always keep a separate sorted queue of ordered nodes and flush them in order with the other nodes. This is used by all nodes with -fno-toplevel-reorder, and only the marked ones without it. Parts of the old -fno-toplevel-reorder code paths are reused. - Adds various checks throughout the tree to make no_reorder marked functions behave the same as with -fno-toplevel-reorder - Changes the LTO streamer to serialize the no_reorder attribute. gcc/c-family/: 2014-09-23 Andi Kleen <ak@linux.intel.com> * c-common.c (handle_no_reorder_attribute): New function. (c_common_attribute_table): Add no_reorder attribute. gcc/: 2014-09-23 Andi Kleen <ak@linux.intel.com> * cgraph.h (symtab_node): Add no_reorder attribute. (symbol_table::output_asm_statements): Remove. * cgraphclones.c (cgraph_node::create_clone): Copy no_reorder. (cgraph_node::create_version_clone): Dito. (symbol_table::output_asm_statements): Remove. * trans-mem.c (ipa_tm_create_version_alias): Dito. * cgraphunit.c (varpool_node::finalize_decl): Check no_reorder. (output_in_order): Add no_reorder flag. Only handle no_reorder nodes when set. (symbol_table::compile): Add separate pass for no_reorder nodes. (process_common_attributes): Set no_reorder flag in symtab node. Add node argument. (process_function_and_variable_attributes): Pass symtab nodes to process_common_attributes. * doc/extend.texi (no_reorder): Document no_reorder attribute. * lto-cgraph.c (lto_output_node): Serialize no_reorder. (lto_output_varpool_node): Dito. (input_overwrite_node): Dito. (input_varpool_node): Dito. * varpool.c (varpool_node::add): Set no_reorder attribute. (symbol_table::remove_unreferenced_decls): Handle no_reorder. (symbol_table::output_variables): Dito. * symtab.c (symtab_node::dump_base): Print no_reorder. gcc/lto/: 2014-09-23 Andi Kleen <ak@linux.intel.com> * lto-partition.c (node_cmp): Update comment. (varpool_node_cmp): Use symtab_node for comparison. (add_sorted_nodes): New function. (lto_balanced_map): Change to keep ordered queue of ordered node. Handle no_reorder attribute. From-SVN: r215537
Diffstat (limited to 'gcc/varpool.c')
-rw-r--r--gcc/varpool.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/gcc/varpool.c b/gcc/varpool.c
index 14ef089..8001c93 100644
--- a/gcc/varpool.c
+++ b/gcc/varpool.c
@@ -449,6 +449,8 @@ varpool_node::add (tree decl)
symtab->call_varpool_insertion_hooks (node);
if (node->externally_visible_p ())
node->externally_visible = true;
+ if (lookup_attribute ("no_reorder", decl))
+ node->no_reorder = 1;
}
/* Return variable availability. See cgraph.h for description of individual
@@ -640,7 +642,7 @@ symbol_table::remove_unreferenced_decls (void)
for (node = first_defined_variable (); node; node = next)
{
next = next_defined_variable (node);
- if (!node->aux)
+ if (!node->aux && !node->no_reorder)
{
if (dump_file)
fprintf (dump_file, " %s", node->asm_name ());
@@ -687,11 +689,22 @@ symbol_table::output_variables (void)
timevar_push (TV_VAROUT);
FOR_EACH_DEFINED_VARIABLE (node)
- node->finalize_named_section_flags ();
+ {
+ /* Handled in output_in_order. */
+ if (node->no_reorder)
+ continue;
+
+ node->finalize_named_section_flags ();
+ }
FOR_EACH_DEFINED_VARIABLE (node)
- if (node->assemble_decl ())
- changed = true;
+ {
+ /* Handled in output_in_order. */
+ if (node->no_reorder)
+ continue;
+ if (node->assemble_decl ())
+ changed = true;
+ }
timevar_pop (TV_VAROUT);
return changed;
}