Code that used to compile

Laurent.Kersten@alcatel.be Laurent.Kersten@alcatel.be
Tue Nov 14 03:03:00 GMT 2000


1
Dear sirs,

I wrote a small C function that read the TSC counter of my Pentium processor. And this function worked well until a do a compiler  upgrade. The new compiler refuses to compile my code and give me a error message which, I think,  is inappropriate.

Output of gcc -v with the old working compiler :

Reading specs from /usr/lib/gcc-lib/i486-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)

Output of gcc -v with the new compiler:

Reading specs from /usr/lib/gcc-lib/i486-suse-linux/2.95.2/specs
gcc version 2.95.2 19991024 (release)

Error message from  the new compiler (gcc -c rdtsc.c)

rdtsc.c: In function `user_rdtsc':
rdtsc.c:13: Invalid `asm' statement:
rdtsc.c:13: fixed or forbidden register 0 (ax) was spilled for class AREG.

Source Code :

unsigned long long
user_rdtsc (void)
{
  union
  {
    unsigned long long time;
    unsigned long time_lh[2];
  }
  tsc;
  __asm__ __volatile__ ("rdtsc"
               :"=a" (tsc.time_lh[0]), "=d" (tsc.time_lh[1])
               :
               :"ax", "dx");
  return tsc.time;
}


Code generated by the old  compiler (objdump --disassemble rdtsc.o) The code was compiled with -O2 switch.


rdtsc.o:     file format elf32-i386

Disassembly of section .text:

00000000 <user_rdtsc>:
   0:     55                  pushl  %ebp
   1:     89 e5               movl   %esp,%ebp
   3:     56                  pushl  %esi
   4:     53                  pushl  %ebx
   5:     0f 31               rdtsc
   7:     89 c1               movl   %eax,%ecx
   9:     89 d6               movl   %edx,%esi
   b:     89 f3               movl   %esi,%ebx
   d:     8d 65 f8            leal   0xfffffff8(%ebp),%esp
  10:     89 c8               movl   %ecx,%eax
  12:     89 da               movl   %ebx,%edx
  14:     5b                  popl   %ebx
  15:     5e                  popl   %esi
  16:     89 ec               movl   %ebp,%esp
  18:     5d                  popl   %ebp
  19:     c3                  ret



Thanks for a bug-fix / explanation.

Regards

Laurent Kersten

Alcatel Bell Space N.V.
Berkenrodelei 33
B-2660 Hoboken.
Tel :     00-32-3-829.54.09
Fax :     00-32-3-829.57.63








More information about the Gcc-bugs mailing list