This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 12/25] Make default_static_chain return NULL in non-static functions
- From: <ams at codesourcery dot com>
- To: <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 5 Sep 2018 12:50:27 +0100
- Subject: [PATCH 12/25] Make default_static_chain return NULL in non-static functions
- References: <cover.1536144068.git.ams@codesourcery.com>
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