This is the mail archive of the
mailing list for the GCC project.
Re: -fuse-caller-save - Collect register usage information
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Tom de Vries <Tom_deVries at mentor dot com>
- Cc: Eric Botcazou <ebotcazou at adacore dot com>, GCC Patches <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 13:00:01 +0200
- Subject: Re: -fuse-caller-save - Collect register usage information
- Authentication-results: sourceware.org; auth=none
- References: <534ED7BC dot 50300 at mentor dot com> <1934759 dot KususQOCne at polaris> <5440387C dot 7060202 at mentor dot com> <4449487 dot ggfnoZPqHa at polaris> <5440F3D1 dot 6090309 at mentor dot com>
On Fri, Oct 17, 2014 at 12:47 PM, Tom de Vries <Tom_deVries@mentor.com> wrote:
> On 16-10-14 23:46, Eric Botcazou wrote:
>>> Having said that, in my mind, what is confusing about the name
>>> -fuse-caller-save, is that in fact the caller-save registers are already
>>> used in register allocation. It's just that they're used across calls
>>> without the need to save them, but
>>> -fuse-caller-save-across-calls-without-saving-if-possible is not such a
>>> good option name.
>>> Another thing that - in my mind - is confusing is that there's an option
>>> fcaller-saves which controls behaviour for caller-save registers:
>>> - for -fno-caller-saves, caller-save registers are not used across calls
>>> - for -fcaller-saves, caller-save registers are used across calls
>>> The name is similar to -fuse-caller-save, and it won't be clear from just
>>> the names what the difference is.
>> OK, so the existing -fcaller-saves is in fact -fuse-caller-saves,
> Right, in the sense that a caller-save is the save of caller-save register,
> as opposed to short for a caller-save register, which is how it's used in
>> which means
>> that we should really find a better name for yours. :-)
> Agreed :)
>>> I've pondered the name -fipa-ira, but I rejected that earlier because
>>> might suggest actual register allocation at the interprocedural scope,
>>> while this is only register allocation at the scope of a single
>>> taking some interprocedural information into account. Furthermore, it's
>>> only ira that uses the interprocedural information.
>>> So, let's a generate a list of option names.
>>> Any preferences, alternatives?
>> Given the existing -fcaller-saves, I'd keep "caller-saves" in the name, so
>> something along the lines of -foptimize-caller-saves or
> Let's look at the effect of the option (after the recent fix for PR61605) on
> - 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
> 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. Nevertheless, if we'd have a case where we
> already have caller-saves, that would be indeed the observed effect. I'm
> just trying to point out that the optimization does more than just removing
> The optimization, at it's core, can be regarded as removing superfluous
> clobbers from calls, and everything else is derived from that:
> - if a caller-save register is not clobbered by a call, then there's no need
> for a caller-save before that call, so it's cheaper to use across that
> than a callee-save register.
> (which explains what we see in the diff)
> - if a caller-save register is live across a call, and is not clobbered by a
> call, then there's no need for a caller-save, and it can be removed.
> (which explains what we see in case we have an example where there are
> actual caller-saves without the optimization, and less so with the
> I'm starting to lean towards -foptimize-call-clobbers or similar.
Well, it is really some form of IPA driven register allocation. Whether
you want to call it -fipa-ra or not is another question - but if we had
such option then enabling it with that option would be fine.
Also users may have no idea what call vs callee clobbers are, but
IPA RA may be a term that is more widely known (or at least google
can come up with something for you).
So - I like -fipa-ra more.
I can't see the obvious difference between -foptimize-caller-saves
and -foptimize-call-clobbers (for the latter -fipa-call-clobbers would
be more to the point?)
> - Tom