This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Problem with hard-coded register variables
- To: bug-gcc at gnu dot org
- Subject: Problem with hard-coded register variables
- From: Bonzini <bonzini at gnu dot org>
- Date: Sun, 12 Dec 1999 14:19:40 +0100
When inlining a function which uses hard-coded register variables,
inside another function which hard-codes another variable in the same
register, code that saves and restores the outer variable is not
generated.
The test program (which uses x86 registers):
#include <stdio.h>
inline void test ()
{
register int b asm("%edi");
b = 5;
printf("inside %d\n", b);
}
int main ()
{
register int a asm("%edi");
a = 1;
printf("outside %d\n", a);
test ();
printf("outside %d\n", a);
exit (a != 1);
}
produces
outside 1
inside 5
outside 1
(correct) with inlining disabled, and
outside 1
inside 5
outside 5
(wrong) with inlining enabled.
gcc -v shows:
Reading specs from
/cygnus/b19/H-i386-cygwin32/lib/gcc-lib/i386-cygwin32\2.7-B19\specs
gcc driver version 2.7-B19 executing gcc version 2.7-97r2aBeta
gcc --version shows:
2.7-B19
I don't know if the results apply to EGCS or GCC 2.95 compilers.
Paolo Bonzini
bonzini@gnu.org