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: Eric Botcazou <ebotcazou at adacore dot com>
- To: Tom de Vries <Tom_deVries at mentor dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Mike Stump <mikestump at comcast dot net>, Vladimir Makarov <vmakarov at redhat dot com>
- Date: Fri, 17 Oct 2014 21:24:59 +0200
- Subject: Re: -fuse-caller-save - Collect register usage information
- Authentication-results: sourceware.org; auth=none
- References: <534ED7BC dot 50300 at mentor dot com> <4449487 dot ggfnoZPqHa at polaris> <5440F3D1 dot 6090309 at mentor dot com>
> Let's look at the effect of the option (after the recent fix for PR61605) on
> gcc.target/i386/fuse-calller-save.c:
> ...
> foo:
> .LFB1:
> .cfi_startproc
> - pushq %rbx
> - .cfi_def_cfa_offset 16
> - .cfi_offset 3, -16
> - movl %edi, %ebx
> call bar
> - addl %ebx, %eax
> - popq %rbx
> - .cfi_def_cfa_offset 8
> + addl %edi, %eax
> ret
> .cfi_endproc
> .LFE1:
> ...
> So, the effect is: instead of using a callee-save register, we use a
> caller-save register to store a value that's live over a call, without
> needing to add a caller-save, as would be normally the case.
>
> If I see an option -foptimize-caller-saves, I'd expect the effect to be that
> without, there are some caller-saves and with, there are less. This is not
> the case in the diff above.
To me it is, "movl %edi, %ebx"/"addl %ebx, %eax" is a caller-save/restore.
> I'm starting to lean towards -foptimize-call-clobbers or similar.
Yes, that's also a good name and was my initial preference. But you pointed
out the existing -fcaller-saves:
`-fcaller-saves'
Enable allocation of values to registers that are clobbered by
function calls, by emitting extra instructions to save and restore
the registers around such calls. Such allocation is done only
when it seems to result in better code.
so -foptimize-caller-saves can be understood as optimizing out the "extra
instructions to save and restore the registers around such calls" and, thus,
as having a direct relationship with -fcaller-saves.
--
Eric Botcazou