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 <t...@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