Bug 20952 - -finstrument-functions breaks on functions returning doubles
Summary: -finstrument-functions breaks on functions returning doubles
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 7.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2000-11-16 14:30 UTC by Alexander Larsson
Modified: 2007-04-18 16:29 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2004-03-08 13:33:38 UTC
Embargoed:


Attachments (Terms of Use)

Description Alexander Larsson 2000-11-16 14:30:09 UTC
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);
}

outputs:

res: nan

Here is the generated code:
function:
	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)
	ret

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 16:20:44 UTC
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 17:08:54 UTC
Oops, forgot to close this. It was really fixed in 2.96-79 and above.

Comment 3 Miloslav Trmac 2004-03-08 13:33:38 UTC
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.