diff options
author | Jan Hubicka <jh@suse.cz> | 2020-10-26 20:19:33 +0100 |
---|---|---|
committer | Jan Hubicka <jh@suse.cz> | 2020-10-26 20:22:16 +0100 |
commit | 4f8cfb42883cc247f11096a3703e379d1f24ab3f (patch) | |
tree | 427a28a3f52d39bc54bd04eda144d76ae53e7765 /gcc/gimple.c | |
parent | 2118438f49f0c193abe3fa3def350a8129045746 (diff) | |
download | gcc-4f8cfb42883cc247f11096a3703e379d1f24ab3f.zip gcc-4f8cfb42883cc247f11096a3703e379d1f24ab3f.tar.gz gcc-4f8cfb42883cc247f11096a3703e379d1f24ab3f.tar.bz2 |
Extend builtin fnspecs
* attr-fnspec.h: Update toplevel comment.
(attr_fnspec::attr_fnspec): New constructor.
(attr_fnspec::arg_read_p,
attr_fnspec::arg_written_p,
attr_fnspec::arg_access_size_given_by_arg_p,
attr_fnspec::arg_single_access_p
attr_fnspec::loads_known_p
attr_fnspec::stores_known_p,
attr_fnspec::clobbers_errno_p): New member functions.
(gimple_call_fnspec): Declare.
(builtin_fnspec): Declare.
* builtins.c: Include attr-fnspec.h
(builtin_fnspec): New function.
* builtins.def (BUILT_IN_MEMCPY): Do not specify RET1 fnspec.
(BUILT_IN_MEMMOVE): Do not specify RET1 fnspec.
(BUILT_IN_MEMSET): Do not specify RET1 fnspec.
(BUILT_IN_STRCAT): Do not specify RET1 fnspec.
(BUILT_IN_STRCPY): Do not specify RET1 fnspec.
(BUILT_IN_STRNCAT): Do not specify RET1 fnspec.
(BUILT_IN_STRNCPY): Do not specify RET1 fnspec.
(BUILT_IN_MEMCPY_CHK): Do not specify RET1 fnspec.
(BUILT_IN_MEMMOVE_CHK): Do not specify RET1 fnspec.
(BUILT_IN_MEMSET_CHK): Do not specify RET1 fnspec.
(BUILT_IN_STRCAT_CHK): Do not specify RET1 fnspec.
(BUILT_IN_STRCPY_CHK): Do not specify RET1 fnspec.
(BUILT_IN_STRNCAT_CHK): Do not specify RET1 fnspec.
(BUILT_IN_STRNCPY_CHK): Do not specify RET1 fnspec.
* gimple.c (gimple_call_fnspec): Return attr_fnspec.
(gimple_call_arg_flags): Update.
(gimple_call_return_flags): Update.
* tree-ssa-alias.c (check_fnspec): New function.
(ref_maybe_used_by_call_p_1): Use fnspec for builtin handling.
(call_may_clobber_ref_p_1): Likewise.
(attr_fnspec::verify): Update verifier.
* calls.c (decl_fnspec): New function.
(decl_return_flags): Use it.
Diffstat (limited to 'gcc/gimple.c')
-rw-r--r-- | gcc/gimple.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/gcc/gimple.c b/gcc/gimple.c index f19e24d..469e6f3 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -1487,23 +1487,30 @@ gimple_call_flags (const gimple *stmt) /* Return the "fn spec" string for call STMT. */ -static const_tree +attr_fnspec gimple_call_fnspec (const gcall *stmt) { tree type, attr; if (gimple_call_internal_p (stmt)) - return internal_fn_fnspec (gimple_call_internal_fn (stmt)); + { + const_tree spec = internal_fn_fnspec (gimple_call_internal_fn (stmt)); + if (spec) + return spec; + else + return ""; + } type = gimple_call_fntype (stmt); - if (!type) - return NULL_TREE; - - attr = lookup_attribute ("fn spec", TYPE_ATTRIBUTES (type)); - if (!attr) - return NULL_TREE; - - return TREE_VALUE (TREE_VALUE (attr)); + if (type) + { + attr = lookup_attribute ("fn spec", TYPE_ATTRIBUTES (type)); + if (attr) + return TREE_VALUE (TREE_VALUE (attr)); + } + if (gimple_call_builtin_p (stmt, BUILT_IN_NORMAL)) + return builtin_fnspec (gimple_call_fndecl (stmt)); + return ""; } /* Detects argument flags for argument number ARG on call STMT. */ @@ -1511,13 +1518,12 @@ gimple_call_fnspec (const gcall *stmt) int gimple_call_arg_flags (const gcall *stmt, unsigned arg) { - const_tree attr = gimple_call_fnspec (stmt); + attr_fnspec fnspec = gimple_call_fnspec (stmt); - if (!attr) + if (!fnspec.known_p ()) return 0; int flags = 0; - attr_fnspec fnspec (attr); if (!fnspec.arg_specified_p (arg)) ; @@ -1540,15 +1546,10 @@ gimple_call_arg_flags (const gcall *stmt, unsigned arg) int gimple_call_return_flags (const gcall *stmt) { - const_tree attr; - if (gimple_call_flags (stmt) & ECF_MALLOC) return ERF_NOALIAS; - attr = gimple_call_fnspec (stmt); - if (!attr) - return 0; - attr_fnspec fnspec (attr); + attr_fnspec fnspec = gimple_call_fnspec (stmt); unsigned int arg_no; if (fnspec.returns_arg (&arg_no)) |