This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][MIPS] Fix register renaming in the interrupt handlers
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: Mike Stump <mikestump at comcast dot net>
- Cc: Robert Suchanek <Robert dot Suchanek at imgtec dot com>, "Catherine_Moore\ at mentor dot com" <Catherine_Moore at mentor dot com>, Matthew Fortune <Matthew dot Fortune at imgtec dot com>, "gcc-patches\ at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 15 Aug 2015 17:19:43 +0100
- Subject: Re: [PATCH][MIPS] Fix register renaming in the interrupt handlers
- Authentication-results: sourceware.org; auth=none
- References: <B5E67142681B53468FAF6B7C31356562441B01AD at hhmail02 dot hh dot imgtec dot org> <87k2szc6b9 dot fsf at googlemail dot com> <4438A5B8-6266-4E4F-A43C-8BA503A08900 at comcast dot net> <B5E67142681B53468FAF6B7C31356562441B05D2 at hhmail02 dot hh dot imgtec dot org> <878u9ckfkh dot fsf at googlemail dot com> <25005AA9-2F88-48E3-9776-2257FC513ED4 at comcast dot net>
Mike Stump <mikestump@comcast.net> writes:
> On Aug 15, 2015, at 3:32 AM, Richard Sandiford
> <rdsandiford@googlemail.com> wrote:
>>
>> The port is only buggy if they have define_peephole2s with match_scratches
>> and those match_scratches require a register that would be saved by
>> an interrupt function. In other cases defining T_H_R_S_O would have
>> no effect (but still be a good idea for future proofing -- obviously
>> someone who adds a new define_peephole2 is unlikely to be thinking
>> about inerrupt functions).
>
> Yeah, that was my reading of the code after I posted as well. My port
> was buggy. :-( I think all the other ports like likely buggy or
> suboptimal.
Suboptimal how?
>> The main problem is that we then have three sets of registers:
>> - the ABI call-clobbered set
>> - the call-clobbered set for the current function
>> - the set of registers that are clobbered by an already-compiled function
>> (for -fipa-ra)
>>
>> I think that's valid, but you obviously have to be very careful to use
>> the right one. Especially when it comes to cached derived information.
>
> No. Being very careful isnât the right solution. It should be
> impossible to use the wrong one.
>
> Something like static inline call_used (regno, call_abi = 0) { return
> call_used[call_abi][regno]; } where callers that want the call_used for
> a given function would call call_used (regno, fndecl) and fndecl can
> convert over to a call_abi or possibly something like
> fndecl->call_used[regno] where most callers can just use
> cfun->call_used[regnp] is the right one. It is fine for ports without
> interrupt functions (because call_abi defaults to 0), and it is the
> right one to use on ports with interrupt functions. In the later, the
> interrupt function will have its call_abi set appropriately. Ports that
> already have and manage call_abi today will notice they even like the
> new scheme. And the TARGET_CALL_FUSAGE_CONTAINS_NON_CALLEE_CLOBBERS
> code I think could benefit from this as well.
I don't see how that helps. The default argument creates exactly the
same difference as thw first two in my list. There are many times when
you don't know which function is being called and so can't pass a decl.
The third in my list is still there unless you disable -fipa-ra.
Richard