> On Mar 14, 2022, at 11:04 AM, Richard Sandiford <richard.sandif...@arm.com> 
> wrote:
> 
> Sorry for the slow response, was out for a few days.
> 
> Xi Ruoyao <xry...@mengyan1223.wang> writes:
>> On Sat, 2022-03-12 at 18:48 +0800, Xi Ruoyao via Gcc-patches wrote:
>>> On Fri, 2022-03-11 at 21:26 +0000, Qing Zhao wrote:
>>>> Hi, Ruoyao,
>>>> 
>>>> (I might not be able to reply to this thread till next Wed due to a
>>>> short vacation).
>>>> 
>>>> First, some comments on opening bugs against Gcc:
>>>> 
>>>> I took a look at the bug reports PR104817 and PR104820:
>>>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104820
>>>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104817
>>>> 
>>>> I didn’t see a testing case and a script to repeat the error, so I
>>>> cannot repeat the error at my side.
>>> 
>>> I've put the test case, but maybe you didn't see it because it is too
>>> simple:
>>> 
>>> echo 'int t() {}' | /home/xry111/git-repos/gcc-test-mips/gcc/cc1 -
>>> nostdinc -fzero-call-used-regs=all
>>> 
>>> An empty function is enough to break -fzero-call-used-regs=all.  And
>>> if
>>> you append -mips64r2 to the cc1 command line you'll get 104820.  I
>>> enabled 4 existing tests for MIPS (reported "not work" on MIPS) in the
>>> patch so I think it's unnecessary to add new test cases.
>>> 
>>> Richard: can we use MIPS_EPILOGUE_TEMP as a scratch register in the
>>> sequence for zeroing the call-used registers, and then zero itself
>>> (despite it's not in need_zeroed_hardregs)?
>> 
>> No, it leads to an ICE at stage 3 bootstrapping :(.
>> 
>> Now I think the only rational ways are:
>> 
>> (1) allow zeroing more registers than need_zeroed_hardregs.
> 
> I think this is the way to go.  I agree it's a bit hacky, but it seems
> like the least worst option.
> 
> A less hacky alternative would be to pass an extra argument to the hook
> that contains the set of registers that the hook is *allowed* to clobber.
> For -fzero-call-used-regs=X, this new argument would be the set that
> would have been chosen for -fzero-call-used-regs=all, regardless of
> what X actually is.  We could then assert that the extra registers we
> want to clobber are in that set (which will be true for all values of X).

If we have to go this way, I think it’s better to make the change you suggested 
above, 
and then also update the documentation, both internal documentation on how to 
define
 the hook and the user level documentation on what the user might expect when 
using 
this option (i.e, it’s possible that the compiler might clear more registers 
than the user 
requests on some targets due to the implementation limitation). 

I can make this change if we decide to do this.

Thanks.

Qing

> 
>> Or
>> 
>> (2) allow zeroing less registers than need_zeroed_hardregs (then I'll
>> skip ST_REGS, after all they are just 8 bits in total).
> 
> Yeah, this is explicitly OK, provided that the target maintainers
> feel that the contents of the registers in question are not a significant
> security concern.  I don't feel I can make that call though.  It's really
> a question for the userbase.
> 
> Thanks,
> Richard
> 
>> If all these are unacceptable, then
>> 
>> (3) I'll just call sorry in MIPS target hook to tell not to use this
>> feature on MIPS.

Reply via email to