On 09-01-14 16:31, Richard Sandiford wrote:
Tom de Vries <tom_devr...@mentor.com> writes:
On 25/12/13 14:02, Tom de Vries wrote:
On 07-12-13 16:07, Tom de Vries wrote:
Richard,
This patch implements the target hook TARGET_FN_OTHER_HARD_REG_USAGE (posted
here: http://gcc.gnu.org/ml/gcc-patches/2013-03/msg01318.html) for MIPS, to
address the issue that $6 is sometimes used in split calls.
Build and reg-tested on MIPS.
OK for stage1?
Richard,
Ping.
This patch is the only part of -fuse-caller-save that still needs approval.
Richard,
thanks for the review.
Hmm, where were parts 4 and 6 approved?
In http://gcc.gnu.org/ml/gcc-patches/2013-03/msg00508.html, Vladimir wrote:
...
The patch is ok for me for trunk at stage1. But I think you need a formal
approval for df-scan.c, arm.c, mips.c, GCC testsuite expect files
(lib/target-supports.exp and gcc.target/mips/mips.exp) as I am not a maintainer
of these parts although these changes look ok for me.
...
In reaction to that, I split up the patch into a patches series, and replied in
http://gcc.gnu.org/ml/gcc-patches/2013-03/msg01255.html:
...
I'm assuming you've ok'ed patch 1, 2, 3, 4, 6, 8, 9 and the non-df-scan part of
7.
I'll ask other maintainers about the other parts (5, 10 and the df-scan part of
7).
...
Was looking for the discussion
in the hope that it would answer the question I don't really understand,
which is: this hook is only used during final, is that right?
Yes.
And the
clobber that you're adding is exposed at the rtl level.
Yes, after the calls are split, but not before.
So why do we
need the hook at all?
In general we need the hook for registers that are clobbered during a call to a
function, while the registers are not present in the final rtl representation of
that function.
For MIPS, we don't need the hook for that purpose.
But, for MIPS there's the following issue: the unsplit call clobbers r6, but the
clobber is not explicit in the rtl. Only after splitting, the clobber becomes
explicit in the rtl.
In general, that's not a problem because r6 is a member of the set of register
clobbered by a call (CALL_REALLY_USED_REGISTERS), so it's implicitly clobbered.
But for -fuse-caller-save, when we find a call, we ignore
CALL_REALLY_USED_REGISTERS and use a potentially smaller set of implicit
clobbers: the union of:
- the registers usage analysis of the final rtl representation of the called
function
- the registers marked by the hook.
So before splitting the unsplit call, there's nothing to tell us that r6 is
clobbered by that call. Resulting in register allocation using r6 as if it was
not clobbered, which causes errors.
Why not just collect the usage information at
the end of final rather than at the beginning, so that all splits during
final have been done?
If we have a call to a leaf function, the final rtl representation does not
contain calls. The problem does not lie in the final pass where the callee is
analyzed, but in the caller, where information is used, and where the unsplit
call is missing the clobber of r6.
For other cases (where the usage isn't explicit
at the rtl level), why not record the usage in CALL_INSN_FUNCTION_USAGE
instead?
Right, we could add the r6 clobber that way. But to keep things simple, I've
used the hook instead.
Thanks,
- Tom
Thanks,
Richard