register variable is clobbered by passing parameter to a function

Dave Korn dk@artimi.com
Tue Mar 16 12:43:00 GMT 2004


> -----Original Message-----
> From: gcc-owner On Behalf Of Michael Matz
> Sent: 16 March 2004 12:30

> > a.. Global register variables reserve registers throughout the 
> > program. This may be useful in programs such as programming 
> language 
> > interpreters which have a couple of global variables that 
> are accessed very often.
> 
> This says nothing about local register variables, like you used.

  Actually, taking a closer look at his sample code, the variable is defined
at file scope.  So if that's an accurate extract of what he's been
compiling, it should have been a global register variable.

---quote---
Example-code:

register  char often_used_variable asm ("r16"); char foo;
void function1 (char p1, char p2, char p3, char p4, char p5) {   };

int main (void)
{
often_used_variable = 5;
function1 (6,7,8,9,10);
foo = often_used_variable;
}
---quote---

  So there may be a genuine bug here.

  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.


    cheers, 
      DaveK
-- 
Can't think of a witty .sigline today....



More information about the Gcc mailing list