Message ID | 52026D4D.8020604@acm.org |
---|---|
State | New |
Headers | show |
> The usual x86 ports avoid this, because their must_return_in_mem hooks DTRT > already and we never fall into the default case. So why not do the same for i686-elf? > I am very surprised this hasn't bitten someone before -- I presume this > never worked with i686-elf. It is possible this'll change some other ABI > where a fixed reg was permitted to be used in the manner that this now > prohibits, but I have a hard time thinking that happens. Shout if you > know of one. IMO that's not sufficient, you ought to go through all the back-ends and check that you aren't breaking anything with such a bold change. This code is more than 2 decades old and can affect every single port in a major way.
Having poked further, I find this in the testsuite: pr11001-strlen-2.c --begin register int regvar asm("%eax"); char * do_copy (char *str) { return malloc (strlen (str) + 1); } --end Is that even meaningful? The doc's for a global reg var say: 'Choose a register that is normally saved and restored by function calls on your machine, so that library routines will not clobber it.' If one never made calls to a library unaware of the reg's global use, things would be ok. Except if one chose a register that is used by the ABI to return things, or by the pro/epilogue code as a scratch register. Should attempts to use a call_used reg as a global reg var generate an error? Should it stop it being marked as a fixed_reg? nathan
On Wed, Aug 7, 2013 at 10:34 AM, Nathan Sidwell <nathan@acm.org> wrote: > Having poked further, I find this in the testsuite: > > pr11001-strlen-2.c > --begin > register int regvar asm("%eax"); > > char * > do_copy (char *str) > { > return malloc (strlen (str) + 1); > } > --end > > Is that even meaningful? The doc's for a global reg var say: > 'Choose a register that is normally saved and restored by function calls on > your > machine, so that library routines will not clobber it.' This is risky but meaningful, and potentially useful with asm instructions. > If one never made calls to a library unaware of the reg's global use, things > would be ok. Except if one chose a register that is used by the ABI to > return things, or by the pro/epilogue code as a scratch register. > > Should attempts to use a call_used reg as a global reg var generate an > error? No. Perhaps a warning. > Should it stop it being marked as a fixed_reg? Definitely not. Ian
Index: gcc/function.c =================================================================== --- gcc/function.c (revision 417583) +++ gcc/function.c (working copy) @@ -2031,7 +2031,7 @@ aggregate_value_p (const_tree exp, const regno = REGNO (reg); nregs = hard_regno_nregs[regno][TYPE_MODE (type)]; for (i = 0; i < nregs; i++) - if (! call_used_regs[regno + i]) + if (! call_used_regs[regno + i] || fixed_regs[regno + i]) return 1; return 0;