This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: -fuse-caller-save - Collect register usage information
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: Tom de Vries <Tom_deVries at mentor dot com>
- Cc: Eric Botcazou <ebotcazou at adacore dot com>, gcc-patches at gcc dot gnu dot org, Jan Hubicka <hubicka at ucw dot cz>, rdsandiford at googlemail dot com
- Date: Sun, 25 May 2014 02:42:56 +0200
- Subject: Re: -fuse-caller-save - Collect register usage information
- Authentication-results: sourceware.org; auth=none
- References: <534ED7BC dot 50300 at mentor dot com> <878uqwgjoe dot fsf at talisman dot default> <535BABD1 dot 8050208 at mentor dot com> <1426417 dot RtLpSRnsYv at polaris> <537A1583 dot 7020702 at mentor dot com>
> +/* Get the declaration of the function called by INSN. */
> +
> +static tree
> +get_call_fndecl (rtx insn)
> +{
> + rtx note, datum;
> +
> + note = find_reg_note (insn, REG_CALL_DECL, NULL_RTX);
> + if (note == NULL_RTX)
> + return NULL_TREE;
> +
> + datum = XEXP (note, 0);
> + if (datum != NULL_RTX)
> + return SYMBOL_REF_DECL (datum);
> +
> + return NULL_TREE;
> +}
> +
> +static struct cgraph_node *
> +get_call_cgraph_node (rtx insn)
> +{
> + tree fndecl;
> +
> + if (insn == NULL_RTX)
> + return NULL;
> +
> + fndecl = get_call_fndecl (insn);
> + if (fndecl == NULL_TREE
> + || !targetm.binds_local_p (fndecl))
> + return NULL;
> +
> + return cgraph_get_node (fndecl);
> +}
So far we do not have any RTL code in cgraph*.c, so lets keep it here until we
get some other uses for it. Then I think it can go to rtlanal.
get_call_cgraph_node is missing description and probably should emhatize the
fact that it returns NULL for call targets that can be overwritten.
You want to test decl_binds_to_current_def_p instead of binds_local_p.
Consider hidden weak symbol - that one binds local, but it can be rewritten by
other implementation at linktime.
With this change and after the data are moved to rtl info, the patch is OK (given that
Eric already approved the RTL bits I can't)
Note that this patch will interfere rather badly with Martin's work to order functions
in execution order, since it wants to have callee before caller. I wonder if we can't
add support for GAS section fragments in this case to order functions in a way we want.
Honza