This is the mail archive of the gcc-bugs@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]

Problem with hard-coded register variables


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


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