> gcc/c-family/:
> 
> 2014-09-15  Andi Kleen  <a...@linux.intel.com>
> 
>       * c-common.c (handle_no_reorder_attribute): New function.
>       (c_common_attribute_table): Add no_reorder attribute.
> 
> gcc/:
> 
> 2014-09-14  Andi Kleen  <a...@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.
>       * doc/extend.texi (no_reorder): Document no_reorder attribute.
>       * ipa-visibility.c (function_and_variable_visibility): Set
>       no_reorder flag in symtab_node from declaration.
>       * 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-13  Andi Kleen  <a...@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.
> ---
>  gcc/c-family/c-common.c |  28 ++++++++++++
>  gcc/cgraph.h            |   5 +--
>  gcc/cgraphclones.c      |   2 +
>  gcc/cgraphunit.c        |  38 +++++++---------
>  gcc/doc/extend.texi     |  12 +++++-
>  gcc/ipa-visibility.c    |   6 +++
>  gcc/lto-cgraph.c        |   4 ++
>  gcc/lto/lto-partition.c | 112 
> ++++++++++++++++++++++++++++++------------------
>  gcc/symtab.c            |   2 +
>  gcc/trans-mem.c         |   1 +
>  gcc/varpool.c           |  21 +++++++--
>  11 files changed, 159 insertions(+), 72 deletions(-)
> 
> diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
> index 39be956..d0845d1 100644
> --- a/gcc/c-family/c-common.c
> +++ b/gcc/c-family/c-common.c
> @@ -328,6 +328,8 @@ static tree handle_used_attribute (tree *, tree, tree, 
> int, bool *);
>  static tree handle_unused_attribute (tree *, tree, tree, int, bool *);
>  static tree handle_externally_visible_attribute (tree *, tree, tree, int,
>                                                bool *);
> +static tree handle_no_reorder_attribute (tree *, tree, tree, int,
> +                                              bool *);
>  static tree handle_const_attribute (tree *, tree, tree, int, bool *);
>  static tree handle_transparent_union_attribute (tree *, tree, tree,
>                                               int, bool *);
> @@ -652,6 +654,8 @@ const struct attribute_spec c_common_attribute_table[] =
>                             handle_unused_attribute, false },
>    { "externally_visible",     0, 0, true,  false, false,
>                             handle_externally_visible_attribute, false },
> +  { "no_reorder",          0, 0, true, false, false,
> +                              handle_no_reorder_attribute, false },
>    /* The same comments as for noreturn attributes apply to const ones.  */
>    { "const",                  0, 0, true,  false, false,
>                             handle_const_attribute, false },
> @@ -6953,6 +6957,30 @@ handle_externally_visible_attribute (tree *pnode, tree 
> name,
>    return NULL_TREE;
>  }
>  
> +/* Handle the "no_reorder" attribute. Arguments as in
> +   struct attribute_spec.handler. */
> +
> +static tree
> +handle_no_reorder_attribute (tree *pnode,
> +                          tree name,
> +                          tree,
> +                          int,
> +                          bool *no_add_attrs)
> +{
> +  tree node = *pnode;
> +
> +  if ((TREE_CODE (node) != FUNCTION_DECL && TREE_CODE (node) != VAR_DECL)
> +     && !(TREE_STATIC (node) || (DECL_P (node) && DECL_EXTERNAL (node))))
> +    {
> +      warning (OPT_Wattributes,
> +             "%qE attribute only affects top level objects",
> +             name);
> +      *no_add_attrs = true;
> +    }

You explicitly check that NODE is FUNCTION_DECL or VAR_DECL 
(use VAR_OR_FUNCTION_DECL_P) so you can also remove DECL_P.
TREE_STACK || DECL_EXTERNAL should be enough.
> diff --git a/gcc/ipa-visibility.c b/gcc/ipa-visibility.c
> index 32199af..541d568 100644
> --- a/gcc/ipa-visibility.c
> +++ b/gcc/ipa-visibility.c
> @@ -492,6 +492,9 @@ function_and_variable_visibility (bool whole_program)
>         node->externally_visible = false;
>         node->forced_by_abi = false;
>       }
> +      if (lookup_attribute ("no_reorder",
> +                         DECL_ATTRIBUTES (node->decl)))
> +     node->no_reorder = 1;
>        if (!node->externally_visible
>         && node->definition && !node->weakref
>         && !DECL_EXTERNAL (node->decl))
> @@ -633,6 +636,9 @@ function_and_variable_visibility (bool whole_program)
>            vnode->externally_visible = false;
>         vnode->forced_by_abi = false;
>       }
> +      if (lookup_attribute ("no_reorder",
> +                         DECL_ATTRIBUTES (vnode->decl)))
> +     vnode->no_reorder = 1;
>        if (!vnode->externally_visible
>         && !vnode->weakref)
>       {

I would still move this into process_common_attributes in cgraphunit.c
so we do not introduce more places where attributes are converted to flags...

OK,
thanks!
Honza

Reply via email to