Commit 0d6e14fd by Jan Hubicka Committed by Jan Hubicka

builtin-attrs.def (ATTR_LEAF): New attribute.

	* builtin-attrs.def (ATTR_LEAF): New attribute.
	(ATTR_NOVOPS_LEAF_LIST, ATTR_LEAF_LIST, ATTR_NOTHROW_LEAF_LIST,
	ATTR_CONST_NOTHROW_LEAF_LIST, ATTR_PURE_NOTHROW_LEAF_LIST,
	ATTR_PURE_NOTHROW_NOVOPS_LEAF_LIST, ATTR_NORETURN_NOTHROW_LEAF_LIST,
	ATTR_MALLOC_NOTHROW_LEAF_LIST, ATTR_SENTINEL_NOTHROW_LEAF_LIST,
	ATTR_NOTHROW_NONNULL_LEAF, ATTR_CONST_NOTHROW_NONNULL_LEAF,
	ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF, ATTR_PURE_NOTHROW_NONNULL_LEAF,
	ATTR_MALLOC_NOTHROW_NONNULL_LEAF): New attribute lists.
	* sync-builtins.def: Annotate all builtins by leaf.
	* omp-builtins.def: Annotate all builtins by leaf.
	* builtins.def: Annotate relevant builtins with leaf attribute.
	(ATTR_MATHFN_ERRNO, ATTR_MATHFN_FPROUNDING,
	ATTR_MATHFN_FPROUNDING_ERRNO, ATTR_MATHFN_FPROUNDING_STORE): Make
	leaf.
        * gcc-interface/utils.c (handle_leaf_attribute): New function.
        (gnat_internal_attribute_tables): Add leaf.

        * lto-lang.c (handle_leaf_attribute): New function.
        (lto_attribute_tables): Add leaf.

        * f95-lang.c (gfc_define_builtin): Make leaf.
        (gfc_init_builtin_functions): Handle only ATTR_CONST_NOTHROW_LEAF_LIST
        and ATTR_NOTHROW_LEAF_LIST.
        (DEF_SYNC_BUILTIN): Check ATTR_CONST_NOTHROW_LEAF_LIST.
        (DEF_GOMP_BUILTIN): Likewise.

From-SVN: r164689
parent 697c3575
2010-09-28 Jan Hubicka <jh@suse.cz>
* builtin-attrs.def (ATTR_LEAF): New attribute.
(ATTR_NOVOPS_LEAF_LIST, ATTR_LEAF_LIST, ATTR_NOTHROW_LEAF_LIST,
ATTR_CONST_NOTHROW_LEAF_LIST, ATTR_PURE_NOTHROW_LEAF_LIST,
ATTR_PURE_NOTHROW_NOVOPS_LEAF_LIST, ATTR_NORETURN_NOTHROW_LEAF_LIST,
ATTR_MALLOC_NOTHROW_LEAF_LIST, ATTR_SENTINEL_NOTHROW_LEAF_LIST,
ATTR_NOTHROW_NONNULL_LEAF, ATTR_CONST_NOTHROW_NONNULL_LEAF,
ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF, ATTR_PURE_NOTHROW_NONNULL_LEAF,
ATTR_MALLOC_NOTHROW_NONNULL_LEAF): New attribute lists.
* sync-builtins.def: Annotate all builtins by leaf.
* omp-builtins.def: Annotate all builtins by leaf.
* builtins.def: Annotate relevant builtins with leaf attribute.
(ATTR_MATHFN_ERRNO, ATTR_MATHFN_FPROUNDING,
ATTR_MATHFN_FPROUNDING_ERRNO, ATTR_MATHFN_FPROUNDING_STORE): Make
leaf.
2010-09-28 Jan Hubicka <jh@suse.cz>
* tree-ssa-ccp.c (fold_ctor_reference): New function.
(fold_const_aggregate_ref): Use it.
* fold-const.c (canonicalize_constructor_val): Check that we don't fold
2010-09-28 Jan Hubicka <jh@suse.cz>
* gcc-interface/utils.c (handle_leaf_attribute): New function.
(gnat_internal_attribute_tables): Add leaf.
2010-09-22 Joseph Myers <joseph@codesourcery.com>
* gcc-interface/lang.opt (-all-warnings, -include-barrier,
......
......@@ -87,6 +87,7 @@ static tree handle_novops_attribute (tree *, tree, tree, int, bool *);
static tree handle_nonnull_attribute (tree *, tree, tree, int, bool *);
static tree handle_sentinel_attribute (tree *, tree, tree, int, bool *);
static tree handle_noreturn_attribute (tree *, tree, tree, int, bool *);
static tree handle_leaf_attribute (tree *, tree, tree, int, bool *);
static tree handle_malloc_attribute (tree *, tree, tree, int, bool *);
static tree handle_type_generic_attribute (tree *, tree, tree, int, bool *);
static tree handle_vector_size_attribute (tree *, tree, tree, int, bool *);
......@@ -108,6 +109,7 @@ const struct attribute_spec gnat_internal_attribute_table[] =
{ "nonnull", 0, -1, false, true, true, handle_nonnull_attribute },
{ "sentinel", 0, 1, false, true, true, handle_sentinel_attribute },
{ "noreturn", 0, 0, true, false, false, handle_noreturn_attribute },
{ "leaf", 0, 0, true, false, false, handle_leaf_attribute },
{ "malloc", 0, 0, true, false, false, handle_malloc_attribute },
{ "type generic", 0, 0, false, true, true, handle_type_generic_attribute },
......@@ -5184,6 +5186,28 @@ handle_noreturn_attribute (tree *node, tree name, tree ARG_UNUSED (args),
return NULL_TREE;
}
/* Handle a "leaf" attribute; arguments as in
struct attribute_spec.handler. */
static tree
handle_leaf_attribute (tree *node, tree name,
tree ARG_UNUSED (args),
int ARG_UNUSED (flags), bool *no_add_attrs)
{
if (TREE_CODE (*node) != FUNCTION_DECL)
{
warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
if (!TREE_PUBLIC (*node))
{
warning (OPT_Wattributes, "%qE attribute has no effect on unit local functions", name);
*no_add_attrs = true;
}
return NULL_TREE;
}
/* Handle a "malloc" attribute; arguments as in
struct attribute_spec.handler. */
......
......@@ -82,6 +82,7 @@ DEF_ATTR_IDENT (ATTR_MALLOC, "malloc")
DEF_ATTR_IDENT (ATTR_NONNULL, "nonnull")
DEF_ATTR_IDENT (ATTR_NORETURN, "noreturn")
DEF_ATTR_IDENT (ATTR_NOTHROW, "nothrow")
DEF_ATTR_IDENT (ATTR_LEAF, "leaf")
DEF_ATTR_IDENT (ATTR_PRINTF, "printf")
DEF_ATTR_IDENT (ATTR_ASM_FPRINTF, "asm_fprintf")
DEF_ATTR_IDENT (ATTR_GCC_DIAG, "gcc_diag")
......@@ -97,20 +98,38 @@ DEF_ATTR_IDENT (ATTR_TYPEGENERIC, "type generic")
DEF_ATTR_TREE_LIST (ATTR_NOVOPS_LIST, ATTR_NOVOPS, ATTR_NULL, ATTR_NULL)
DEF_ATTR_TREE_LIST (ATTR_NOVOPS_LEAF_LIST, ATTR_LEAF, ATTR_NULL, ATTR_NOVOPS_LIST)
DEF_ATTR_TREE_LIST (ATTR_LEAF_LIST, ATTR_LEAF, ATTR_NULL, ATTR_NULL)
DEF_ATTR_TREE_LIST (ATTR_NOTHROW_LIST, ATTR_NOTHROW, ATTR_NULL, ATTR_NULL)
DEF_ATTR_TREE_LIST (ATTR_NOTHROW_LEAF_LIST, ATTR_LEAF, ATTR_NULL, ATTR_NOTHROW_LIST)
DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_LIST, ATTR_CONST, \
ATTR_NULL, ATTR_NOTHROW_LIST)
DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_LEAF_LIST, ATTR_CONST, \
ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_LIST, ATTR_PURE, \
ATTR_NULL, ATTR_NOTHROW_LIST)
DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_LEAF_LIST, ATTR_PURE, \
ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_NOVOPS_LIST, ATTR_NOVOPS, \
ATTR_NULL, ATTR_PURE_NOTHROW_LIST)
DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_NOVOPS_LEAF_LIST, ATTR_NOVOPS,\
ATTR_NULL, ATTR_PURE_NOTHROW_LEAF_LIST)
DEF_ATTR_TREE_LIST (ATTR_NORETURN_NOTHROW_LIST, ATTR_NORETURN, \
ATTR_NULL, ATTR_NOTHROW_LIST)
DEF_ATTR_TREE_LIST (ATTR_NORETURN_NOTHROW_LEAF_LIST, ATTR_NORETURN,\
ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_LIST, ATTR_MALLOC, \
ATTR_NULL, ATTR_NOTHROW_LIST)
DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_LEAF_LIST, ATTR_MALLOC, \
ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
DEF_ATTR_TREE_LIST (ATTR_SENTINEL_NOTHROW_LIST, ATTR_SENTINEL, \
ATTR_NULL, ATTR_NOTHROW_LIST)
DEF_ATTR_TREE_LIST (ATTR_SENTINEL_NOTHROW_LEAF_LIST, ATTR_SENTINEL, \
ATTR_NULL, ATTR_NOTHROW_LEAF_LIST)
/* Functions whose pointer parameter(s) are all nonnull. */
DEF_ATTR_TREE_LIST (ATTR_NONNULL_LIST, ATTR_NONNULL, ATTR_NULL, ATTR_NULL)
......@@ -126,6 +145,9 @@ DEF_ATTR_TREE_LIST (ATTR_NOTHROW_SENTINEL_1, ATTR_SENTINEL, ATTR_LIST_1, \
/* Nothrow functions whose pointer parameter(s) are all nonnull. */
DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL, ATTR_NONNULL, ATTR_NULL, \
ATTR_NOTHROW_LIST)
/* Nothrow leaf functions whose pointer parameter(s) are all nonnull. */
DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_LEAF, ATTR_NONNULL, ATTR_NULL, \
ATTR_NOTHROW_LEAF_LIST)
/* Nothrow functions whose first parameter is a nonnull pointer. */
DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_1, ATTR_NONNULL, ATTR_LIST_1, \
ATTR_NOTHROW_LIST)
......@@ -144,15 +166,27 @@ DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_5, ATTR_NONNULL, ATTR_LIST_5, \
/* Nothrow const functions whose pointer parameter(s) are all nonnull. */
DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_NONNULL, ATTR_CONST, ATTR_NULL, \
ATTR_NOTHROW_NONNULL)
/* Nothrow const leaf functions whose pointer parameter(s) are all nonnull. */
DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_NONNULL_LEAF, ATTR_CONST, ATTR_NULL, \
ATTR_NOTHROW_NONNULL_LEAF)
/* Nothrow const functions which are type-generic. */
DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_TYPEGENERIC, ATTR_TYPEGENERIC, ATTR_NULL, \
ATTR_CONST_NOTHROW_LIST)
/* Nothrow const leaf functions which are type-generic. */
DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_TYPEGENERIC_LEAF, ATTR_TYPEGENERIC, ATTR_NULL, \
ATTR_CONST_NOTHROW_LEAF_LIST)
/* Nothrow pure functions whose pointer parameter(s) are all nonnull. */
DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_NONNULL, ATTR_PURE, ATTR_NULL, \
ATTR_NOTHROW_NONNULL)
/* Nothrow pure leaf functions whose pointer parameter(s) are all nonnull. */
DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_NONNULL_LEAF, ATTR_PURE, ATTR_NULL, \
ATTR_NOTHROW_NONNULL_LEAF)
/* Nothrow malloc functions whose pointer parameter(s) are all nonnull. */
DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_NONNULL, ATTR_MALLOC, ATTR_NULL, \
ATTR_NOTHROW_NONNULL)
/* Nothrow malloc leaf functions whose pointer parameter(s) are all nonnull. */
DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_NONNULL_LEAF, ATTR_MALLOC, ATTR_NULL, \
ATTR_NOTHROW_NONNULL_LEAF)
/* Construct a tree for a format attribute. */
#define DEF_FORMAT_ATTRIBUTE(TYPE, FA, VALUES) \
......
2010-09-28 Jan Hubicka <jh@suse.cz>
* f95-lang.c (gfc_define_builtin): Make leaf.
(gfc_init_builtin_functions): Handle only ATTR_CONST_NOTHROW_LEAF_LIST
and ATTR_NOTHROW_LEAF_LIST.
(DEF_SYNC_BUILTIN): Check ATTR_CONST_NOTHROW_LEAF_LIST.
(DEF_GOMP_BUILTIN): Likewise.
2010-09-28 Tobias Burnus <burnus@net-b.de>
PR fortran/45756
......
......@@ -638,6 +638,8 @@ gfc_define_builtin (const char *name,
if (const_p)
TREE_READONLY (decl) = 1;
TREE_NOTHROW (decl) = 1;
DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("leaf"),
NULL, DECL_ATTRIBUTES (decl));
built_in_decls[code] = decl;
implicit_built_in_decls[code] = decl;
......@@ -728,8 +730,8 @@ gfc_init_builtin_functions (void)
enum
{
/* So far we need just these 2 attribute types. */
ATTR_NOTHROW_LIST,
ATTR_CONST_NOTHROW_LIST
ATTR_NOTHROW_LEAF_LIST,
ATTR_CONST_NOTHROW_LEAF_LIST
};
tree mfunc_float[6];
......@@ -1083,7 +1085,7 @@ gfc_init_builtin_functions (void)
#undef DEF_SYNC_BUILTIN
#define DEF_SYNC_BUILTIN(code, name, type, attr) \
gfc_define_builtin (name, builtin_types[type], code, name, \
attr == ATTR_CONST_NOTHROW_LIST);
attr == ATTR_CONST_NOTHROW_LEAF_LIST);
#include "../sync-builtins.def"
#undef DEF_SYNC_BUILTIN
......@@ -1092,7 +1094,7 @@ gfc_init_builtin_functions (void)
#undef DEF_GOMP_BUILTIN
#define DEF_GOMP_BUILTIN(code, name, type, attr) \
gfc_define_builtin ("__builtin_" name, builtin_types[type], \
code, name, attr == ATTR_CONST_NOTHROW_LIST);
code, name, attr == ATTR_CONST_NOTHROW_LEAF_LIST);
#include "../omp-builtins.def"
#undef DEF_GOMP_BUILTIN
}
......
2010-09-28 Jan Hubicka <jh@suse.cz>
* lto-lang.c (handle_leaf_attribute): New function.
(lto_attribute_tables): Add leaf.
2010-09-25 Jie Zhang <jie@codesourcery.com>
* lto.c (lto_read_all_file_options): Start a new line after
......
......@@ -36,6 +36,7 @@ along with GCC; see the file COPYING3. If not see
#include "toplev.h"
static tree handle_noreturn_attribute (tree *, tree, tree, int, bool *);
static tree handle_leaf_attribute (tree *, tree, tree, int, bool *);
static tree handle_const_attribute (tree *, tree, tree, int, bool *);
static tree handle_malloc_attribute (tree *, tree, tree, int, bool *);
static tree handle_pure_attribute (tree *, tree, tree, int, bool *);
......@@ -53,6 +54,8 @@ const struct attribute_spec lto_attribute_table[] =
/* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
{ "noreturn", 0, 0, true, false, false,
handle_noreturn_attribute },
{ "leaf", 0, 0, true, false, false,
handle_leaf_attribute },
/* The same comments as for noreturn attributes apply to const ones. */
{ "const", 0, 0, true, false, false,
handle_const_attribute },
......@@ -184,6 +187,27 @@ handle_noreturn_attribute (tree *node, tree ARG_UNUSED (name),
return NULL_TREE;
}
/* Handle a "leaf" attribute; arguments as in
struct attribute_spec.handler. */
static tree
handle_leaf_attribute (tree *node, tree name,
tree ARG_UNUSED (args),
int ARG_UNUSED (flags), bool *no_add_attrs)
{
if (TREE_CODE (*node) != FUNCTION_DECL)
{
warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
if (!TREE_PUBLIC (*node))
{
warning (OPT_Wattributes, "%qE attribute has no effect on unit local functions", name);
*no_add_attrs = true;
}
return NULL_TREE;
}
/* Handle a "const" attribute; arguments as in
struct attribute_spec.handler. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment