register variable is clobbered by passing parameter to a function
Dave Korn
dk@artimi.com
Tue Mar 16 13:21:00 GMT 2004
> -----Original Message-----
> From: gcc-owner On Behalf Of Ian Lance Taylor
> "Dave Korn" <dk@artimi.com> writes:
>
> > Wolfgang, your best bet is probably to just add
> -fixed-r16 to your
> > compile-time flags. And don't call any library functions that were
> > compiled without it.
>
> This is AVR, and he is trying to use r16. According to
> function_arg_regno_p() in avr.c, that register can be used to
> pass parameters to functions. gcc can't handle declaring a
> register used for parameter passing as fixed.
Ah. Then my advice should have been "Change r16 to some safer register."
Hopefully that should then suffice to make his global-register-var work
correctly and there isn't actually a bug in gcc.
> Trying to do that is an implicit ABI change anyhow. Maybe
> gcc should warn about this, but it doesn't.
>
> Ian
Fair enough. It would be simple enough for the code that implements
-fixed-rXX to clear the corresponding entries from the CALL_USED_REGISTERS
and REG_ALLOC_ORDER arrays at the same time as it sets the entry in
FIXED_REGISTERS; but I guess there's no general way to allow for what
backends might do with registers in prolog/epilog or varargs codegeneration.
As to the implicit ABI change, well, we're a long way into the realms of
"don't do this unless you know exactly what you're doing" anyway. Issuing a
warning seems tricky, without having some knowledge of what goes on inside
functions in the backend. The best bet might be to add a bit more
documentation to the register-vars pages, indicating that registers chosen
should not be call-used or fixed-for-other-purposes-by-the-abi.
cheers,
DaveK
--
Can't think of a witty .sigline today....
More information about the Gcc
mailing list