This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Incorrectly using call-clobbered registers


On 6 Mar 2003, Carlos Sánchez de La Lama wrote:

> I'm working with a port of gcc for the OpenRISC architecture,

Using GCC CVS, I hope?  If not, do that.

> but I've a
> question that I think is better to post here than in OpenRISC forum.

You *bet* it is.

> In that architecture, register r11 is used to hold return value from
> functions,

(Is there a r12 to go with that, for 64-bit values?)

> but I've found that in certain cases the compiler uses it as
> a general register and, before a function call, saves its value on the
> stack, restoring it *just* after function call,

(By the caller, I presume.)

> and therefore losing the
> returned value. The next instructions try to get the value out of r11,
> but it's not longer there, and as it was a pointer it all end in a
> Alignment Error.
>
> I've been able to fix it by defining macro CALLED_SAVE_PROFITABLE to be
> always 0, so no fuction-clobbered register is ever use as a general
> register, but I feel this is not the right way to do it.

That's a kludge.  I've never needed to use that macro for the
two ports I wrote and maintain.

> So, anyone who knows better how all this stuff works, please tell me
> what to do.

You should start the process to submit the port to the FSF and
ask (for you or another) to be maintainer.  Really.  Resistance
is futile.  QED.

> Should I put r11 in FIXED_REGISTERS macro, so it's never
> used?

No.

> Please help me.

I think your machine description has a bug that causes this
behaviour.  Perhaps or perhaps not as trivial as r11 missing
from CALL_USED_REGISTERS or incorrectly described as a parameter
register through the other macros, for example (but not
restricted to) FUNCTION_VALUE and FUNCTION_VALUE_REGNO_P.  Read
the documentation forwards and backwards a few times.

And give us your port! :-)  Then someone *might just* take your
failing code example (which you didn't send) and look at your
port and perhaps say something useful *just because it doesn't
take much time -- the port already at his/her hands in the
checked out CVS*.

brgds, H-P


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]