Bug 20952 - -finstrument-functions breaks on functions returning doubles
-finstrument-functions breaks on functions returning doubles
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
David Lawrence
Depends On:
  Show dependency treegraph
Reported: 2000-11-16 09:30 EST by Alexander Larsson
Modified: 2007-04-18 12:29 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-03-08 08:33:38 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Alexander Larsson 2000-11-16 09:30:09 EST
Compiling code that returns doubles with -finstrument-functions is broken.
This does not depend on -O or -g flags.

This program:
double function (void)
  return 10.0;
int main(void)
  double d = function ();
  printf ("res: %f\n", d);


res: nan

Here is the generated code:
	pushl	%ebp
	movl	%esp, %ebp
	pushl	%esi
	pushl	%ebx
	subl	$16, %esp
	subl	$8, %esp
	pushl	4(%ebp)
	pushl	$function
	call	__cyg_profile_func_enter
	addl	$16, %esp
	movl	$0, %ebx
	movl	$1076101120, %esi
	subl	$8, %esp
	pushl	4(%ebp)
	pushl	$function
	call	__cyg_profile_func_exit
	addl	$16, %esp
	movl	%ebx, -16(%ebp)
	movl	%esi, -12(%ebp)
	fldl	-16(%ebp)
	leal	-8(%ebp), %esp
	popl	%ebx
	popl	%esi
	popl	%ebp
	fstp	%st(0)

Everything seems peachy, except the last "fstp %st(0)" which just throws
away the calculated result.

This is pretty bad. I regulary use -finstrument-functions to profile
Mozilla and other things.
Comment 1 Jakub Jelinek 2001-03-14 11:20:44 EST
I have fixed this in my tree, am just bootstrapping CVS gcc with it before
submitting it to gcc-patches. It will appear later on in gcc-2.96-79.
Comment 2 Jakub Jelinek 2001-09-06 13:08:54 EDT
Oops, forgot to close this. It was really fixed in 2.96-79 and above.
Comment 3 Miloslav Trmac 2004-03-08 08:33:38 EST
Fix confirmed in gcc-3.3.2-1.

Note You need to log in before you can comment on or make changes to this bug.