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: Richard Sandiford <rdsandiford at googlemail dot com>
- To: Tom de Vries <Tom_deVries at mentor dot com>
- Cc: Vladimir Makarov <vmakarov at redhat dot com>, "gcc-patches\ at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 23 Apr 2014 16:16:49 +0100
- Subject: Re: -fuse-caller-save - Collect register usage information
- Authentication-results: sourceware.org; auth=none
- References: <534ED7BC dot 50300 at mentor dot com> <534FF0F9 dot 60404 at redhat dot com> <87lhv4ug7f dot fsf at sandifor-thinkpad dot stglab dot manchester dot uk dot ibm dot com> <53500628 dot 2090802 at redhat dot com> <5356853D dot 8050905 at mentor dot com> <535798F0 dot 7070809 at mentor dot com>
Tom de Vries <Tom_deVries@mentor.com> writes:
> +/* Collect hard register usage for the current function. */
> +
> +static void
> +collect_fn_hard_reg_usage (void)
> +{
> + rtx insn;
> + int i;
> + struct cgraph_node *node;
> +
> + if (!flag_use_caller_save)
> + return;
> +
> + node = cgraph_get_node (current_function_decl);
> + gcc_assert (node != NULL);
> +
> + gcc_assert (!node->function_used_regs_initialized);
> + node->function_used_regs_initialized = 1;
> +
> + for (insn = get_insns (); insn != NULL_RTX; insn = next_insn (insn))
> + {
> + HARD_REG_SET insn_used_regs;
> +
> + if (!NONDEBUG_INSN_P (insn))
> + continue;
> +
> + find_all_hard_reg_sets (insn, &insn_used_regs, false);
> +
> + if (CALL_P (insn)
> + && (!targetm.call_fusage_contains_non_callee_clobbers ()
> + || !get_call_reg_set_usage (insn, &insn_used_regs, call_used_reg_set)))
If the uses of flag_use_caller_save also check
call_fusage_contains_non_callee_clobbers, would it be better to test
them both together here too, rather than waiting to see a call?
> + /* Be conservative - mark fixed and global registers as used. */
> + IOR_HARD_REG_SET (node->function_used_regs, fixed_reg_set);
> + for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
> + if (global_regs[i])
> + SET_HARD_REG_BIT (node->function_used_regs, i);
The loop isn't needed; all globals are fixed.
Thanks again for working on this.
Richard