This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] register CALL_INSN_FUNCTION_USAGE in find_all_hard_reg_sets
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Tom de Vries <Tom_deVries at mentor dot com>, Eric Botcazou <ebotcazou at adacore dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 16 Apr 2014 12:41:06 +0100
- Subject: Re: [PATCH] register CALL_INSN_FUNCTION_USAGE in find_all_hard_reg_sets
- Authentication-results: sourceware.org; auth=none
- References: <52D6BCFC dot 6000408 at mentor dot com> <87fvopnl67 dot fsf at talisman dot default> <52D72860 dot 8060200 at mentor dot com> <8761pkny3h dot fsf at talisman dot default> <534E5166 dot 6020709 at mentor dot com> <20140416111228 dot GF1817 at tucnak dot redhat dot com>
Jakub Jelinek <jakub@redhat.com> writes:
> On Wed, Apr 16, 2014 at 11:46:14AM +0200, Tom de Vries wrote:
>> >...why do we need two different mechanisms to deal with these two?
>> >IMO the set recorded for the callee should contain what the callee
>> >instructions clobber and nothing else. CALL_INSN_FUNCTION_USAGE
>> >should contain everything clobbered by a call outside the callee,
>> >whether that's in the calling function itself, in a PLT, in a MIPS16
>> >stub, or whatever.
>
> Always putting all call clobbered registers to C_I_F_U explicitly
> can be a serious memory hog on some architectures, e.g. doesn't
> ia64 have ~ 160 call clobbered hard registers, times number of calls in a
> function (sometimes tens of thousands)?
That isn't what we're doing though. The problem Tom's trying to solve
is that call sequences themselves can sometimes use call-clobbered
registers internally, on the assumption that they cannot possibly hold
a live value. These uses aren't always exposed in the rtl, at least not
until after reload (which is later than Tom needs the information).
So it isn't always correct to assume that a call only clobbers the
registers that are clobbered by the call target.
E.g. $gp is call-clobbered on MIPS o32, so we need to restore it after
a call if the GOT base is still needed. This is doing using post-reload
split of the call insn. And on MIPS16 we need a temporary register to
do that, since it isn't possible to load directly into $gp. The temporary
register we use is the call-clobbered $6.
Tom's original approach was to have a hook that told the target-independent
code that $6 might be clobbered in this way. My argument was that we
should reuse CALL_INSN_FUNCTION_USAGE instead, since it already holds
other such special uses and clobbers. The difference is that the special
registers we need to know about here are call-clobbered, whereas until now
it has only been necessary to mention call-saved ones (or, in the case of
USEs, registers set up before the call and not otherwise used by the call).
Thanks,
Richard