Problem with hard-coded register variables

Bonzini bonzini@gnu.org
Sun Dec 12 05:25:00 GMT 1999


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


More information about the Gcc-bugs mailing list