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]

egcs 1.1.1 miscompiles linux 2.1.127


egcs 1.1.1 prerelease miscompiles linux 2.1.127 when -O3 is used. Here
is a simple testcase.

# gcc -O2 bug.c
# a.out
# gcc -O3 bug.c
# a.out
zsh: 657 abort      ./a.out

The problem is when egcs inlines calibrate_tsc, it puts RET in eax
for
       __asm__(  
	       "movl $100, %%eax\n\t"  
               "movl %1, %%edx\n\t"
	       "movl %%edx, %%eax\n\t"  
               "movl %%eax, %0\n\t"
               : "=r" (retval)
               : "r" (RET)
               :   "ax", "bx", "cx", "dx", "cc", "memory");


although it clearly says eax will be clobbered. If the asm statement
is correct, I hope it won't be hard to fix in egcs 1.1.1.


Thanks.


-- 
H.J. Lu (hjl@gnu.org)
---
#define RET	1000

static unsigned long calibrate_tsc(void)  
{
       unsigned long retval;
       __asm__(  
	       "movl $100, %%eax\n\t"  
               "movl %1, %%edx\n\t"
	       "movl %%edx, %%eax\n\t"  
               "movl %%eax, %0\n\t"
               : "=r" (retval)
               : "r" (RET)
               :   "ax", "bx", "cx", "dx", "cc", "memory");
       return retval;
}
static unsigned long fast_gettimeoffset_quotient=0;
unsigned long cpu_hz;	 
void time_init(void)  
{
	fast_gettimeoffset_quotient = calibrate_tsc();
	{	unsigned long eax=0, edx=1000000;
		__asm__("nop"
	       	:"=a" (cpu_hz), "=d" (edx)
               	:"r" (fast_gettimeoffset_quotient),
               	"0" (eax), "1" (edx));
	}
}

main ()
{
  time_init ();
  if (fast_gettimeoffset_quotient != RET)
    abort ();

  return 0;
}


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