This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 12/25] Make default_static_chain return NULL in non-static functions
<ams@codesourcery.com> writes:
> This patch allows default_static_chain to be called from the back-end without
> it knowing if the function is static or not. Or, to put it another way,
> without duplicating the check everywhere it's used.
>
> 2018-09-05 Tom de Vries <tom@codesourcery.com>
>
> gcc/
> * targhooks.c (default_static_chain): Return NULL in non-static
> functions.
> ---
> gcc/targhooks.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/targhooks.c b/gcc/targhooks.c
> index afd56f3..742cfbf 100644
> --- a/gcc/targhooks.c
> +++ b/gcc/targhooks.c
> @@ -1021,8 +1021,14 @@ default_internal_arg_pointer (void)
> }
>
> rtx
> -default_static_chain (const_tree ARG_UNUSED (fndecl_or_type), bool incoming_p)
> +default_static_chain (const_tree fndecl_or_type, bool incoming_p)
> {
> + /* While this function won't be called by the middle-end when a static
> + chain isn't needed, it's also used throughout the backend so it's
> + easiest to keep this check centralized. */
> + if (DECL_P (fndecl_or_type) && !DECL_STATIC_CHAIN (fndecl_or_type))
> + return NULL;
> +
> if (incoming_p)
> {
> #ifdef STATIC_CHAIN_INCOMING_REGNUM
Not sure about this. The caller has to make sure the query's sensible
for types, since types don't indicate whether they need a static chain.
Allowing it to be more sloppy for decls seems a bit dangerous.
Which part of the backend needs this? I couldn't tell from a quick
grep where the call came from.
Thanks,
Richard