egcs-1.1: i386 stdcall function codegen bug

Mumit Khan khan@xraylith.wisc.edu
Wed Oct 28 00:40:00 GMT 1998


egcs version : release and mainline
binutils     : 2.9.1 and 980830 snapshots

There seems to be a i386 codegen bug that affects "stdcall" functions
returning anything larger than an integer.

For the following function,

  double __attribute__((stdcall))
  foo_local1 (double f) {
    return f;
  }

The assembly created (using -O2 -fomit-frame-pointer to cut noise), we
get the following. This causes the return value to be garbage unless
I comment out the "fstp" instruction. 

  .globl _foo_local1@8
  _foo_local1@8:
	  fldl 4(%esp)
	  fstp %st(0)		## <<<< offending instruction
	  ret $8

Interestingly, for a "cdecl" function, the fstp instruction is missing
and everything works as expected.

  double 
  foo_local2 (double f) {
    return f;
  }

  .globl _foo_local2
  _foo_local2:
	  fldl 4(%esp)		## <<<< no fstp instruction
	  ret

I'm attaching a trivial, but complete, test program that shows the 
problem.

Regards,
Mumit



More information about the Cygwin mailing list